From 13a6f49d5c0b86bd95f7fb370da5b5b8332c0989 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 7 Sep 2020 12:11:42 +0200 Subject: [PATCH 001/421] Update requirements for PyQt5 dependency --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 450494c8..1f4d6235 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ def find_version(*file_paths): long_description_content_type="text/markdown", version=find_version('PyQt5-stubs', '__init__.pyi'), package_data={"PyQt5-stubs": ['*.pyi']}, - install_requires=["PyQt5==5.13.0"], + install_requires=["PyQt5>=5, <6"], packages=["PyQt5-stubs"], classifiers=[ "Development Status :: 4 - Beta", From 323aacfbb6fae1f1184c255806a426a0dc4c897d Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Wed, 23 Dec 2020 16:08:20 -0500 Subject: [PATCH 002/421] Enable testing on macOS, and make them pass Partially addresses #122 --- .github/workflows/ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12a3ab66..a3935298 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,10 +29,9 @@ jobs: # - name: Windows # runs-on: windows-latest # matrix: windows -# https://github.com/stlehmann/PyQt5-stubs/issues/122 -# - name: macOS -# runs-on: macos-latest -# matrix: macos + - name: macOS + runs-on: macos-latest + matrix: macos python: - name: CPython 3.5 tox: py35 From 4f50e5de028b09f4e9941daba2f30deb04675453 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sat, 13 Mar 2021 19:04:07 -0500 Subject: [PATCH 003/421] Build 5.15.4 --- Dockerfile | 16 ++++++++-------- PyQt5-stubs/Qt3DAnimation.pyi | 2 +- PyQt5-stubs/Qt3DCore.pyi | 2 +- PyQt5-stubs/Qt3DExtras.pyi | 2 +- PyQt5-stubs/Qt3DInput.pyi | 2 +- PyQt5-stubs/Qt3DLogic.pyi | 2 +- PyQt5-stubs/Qt3DRender.pyi | 2 +- PyQt5-stubs/QtBluetooth.pyi | 2 +- PyQt5-stubs/QtChart.pyi | 2 +- PyQt5-stubs/QtCore.pyi | 2 +- PyQt5-stubs/QtDBus.pyi | 2 +- PyQt5-stubs/QtDataVisualization.pyi | 2 +- PyQt5-stubs/QtDesigner.pyi | 2 +- PyQt5-stubs/QtGui.pyi | 2 +- PyQt5-stubs/QtHelp.pyi | 2 +- PyQt5-stubs/QtLocation.pyi | 2 +- PyQt5-stubs/QtMultimedia.pyi | 2 +- PyQt5-stubs/QtMultimediaWidgets.pyi | 2 +- PyQt5-stubs/QtNetwork.pyi | 2 +- PyQt5-stubs/QtNfc.pyi | 2 +- PyQt5-stubs/QtOpenGL.pyi | 2 +- PyQt5-stubs/QtPositioning.pyi | 2 +- PyQt5-stubs/QtPrintSupport.pyi | 2 +- PyQt5-stubs/QtPurchasing.pyi | 2 +- PyQt5-stubs/QtQml.pyi | 2 +- PyQt5-stubs/QtQuick.pyi | 2 +- PyQt5-stubs/QtQuickWidgets.pyi | 2 +- PyQt5-stubs/QtRemoteObjects.pyi | 2 +- PyQt5-stubs/QtSensors.pyi | 2 +- PyQt5-stubs/QtSerialPort.pyi | 2 +- PyQt5-stubs/QtSql.pyi | 2 +- PyQt5-stubs/QtSvg.pyi | 2 +- PyQt5-stubs/QtTest.pyi | 2 +- PyQt5-stubs/QtWebChannel.pyi | 2 +- PyQt5-stubs/QtWebEngine.pyi | 2 +- PyQt5-stubs/QtWebEngineCore.pyi | 2 +- PyQt5-stubs/QtWebEngineWidgets.pyi | 2 +- PyQt5-stubs/QtWebKit.pyi | 2 +- PyQt5-stubs/QtWebKitWidgets.pyi | 2 +- PyQt5-stubs/QtWebSockets.pyi | 2 +- PyQt5-stubs/QtWidgets.pyi | 2 +- PyQt5-stubs/QtX11Extras.pyi | 2 +- PyQt5-stubs/QtXml.pyi | 2 +- PyQt5-stubs/QtXmlPatterns.pyi | 2 +- PyQt5-stubs/__init__.pyi | 2 +- 45 files changed, 52 insertions(+), 52 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6d481693..88859565 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,17 +3,17 @@ # BUILD_DATE is a path from: # https://archive.archlinux.org/repos/ ARG ARCH_VERSION="base-20210221.0.15908" -ARG BUILD_DATE="2021/02/25" +ARG BUILD_DATE="2021/03/13" -ARG SIP_VERSION="6.0.2" +ARG SIP_VERSION="6.0.3" # Also the major.minor of PyQt5-sip ARG SIP_ABI_VERSION="12.8" -ARG PYQT_VERSION="5.15.3" -ARG PYQT_3D_VERSION="5.15.3" -ARG PYQT_CHART_VERSION="5.15.3" -ARG PYQT_DATA_VISUALIZATION_VERSION="5.15.3" -ARG PYQT_PURCHASING_VERSION="5.15.3" -ARG PYQT_WEB_ENGINE_VERSION="5.15.3" +ARG PYQT_VERSION="5.15.4" +ARG PYQT_3D_VERSION="5.15.4" +ARG PYQT_CHART_VERSION="5.15.4" +ARG PYQT_DATA_VISUALIZATION_VERSION="5.15.4" +ARG PYQT_PURCHASING_VERSION="5.15.4" +ARG PYQT_WEB_ENGINE_VERSION="5.15.4" ARG MAKEFLAGS="" diff --git a/PyQt5-stubs/Qt3DAnimation.pyi b/PyQt5-stubs/Qt3DAnimation.pyi index 7b7fc93a..14e31f71 100644 --- a/PyQt5-stubs/Qt3DAnimation.pyi +++ b/PyQt5-stubs/Qt3DAnimation.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DAnimation module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/Qt3DCore.pyi b/PyQt5-stubs/Qt3DCore.pyi index 917656e5..cbe8c673 100644 --- a/PyQt5-stubs/Qt3DCore.pyi +++ b/PyQt5-stubs/Qt3DCore.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DCore module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/Qt3DExtras.pyi b/PyQt5-stubs/Qt3DExtras.pyi index f786d732..6e71ae6d 100644 --- a/PyQt5-stubs/Qt3DExtras.pyi +++ b/PyQt5-stubs/Qt3DExtras.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DExtras module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/Qt3DInput.pyi b/PyQt5-stubs/Qt3DInput.pyi index a8011b5c..a64f8bed 100644 --- a/PyQt5-stubs/Qt3DInput.pyi +++ b/PyQt5-stubs/Qt3DInput.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DInput module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/Qt3DLogic.pyi b/PyQt5-stubs/Qt3DLogic.pyi index 5f46294b..8c652545 100644 --- a/PyQt5-stubs/Qt3DLogic.pyi +++ b/PyQt5-stubs/Qt3DLogic.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DLogic module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/Qt3DRender.pyi b/PyQt5-stubs/Qt3DRender.pyi index 2a1fe9df..8b1afa5a 100644 --- a/PyQt5-stubs/Qt3DRender.pyi +++ b/PyQt5-stubs/Qt3DRender.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DRender module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index d7684014..7a59acc3 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtBluetooth module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtChart.pyi b/PyQt5-stubs/QtChart.pyi index abb1920c..788a739b 100644 --- a/PyQt5-stubs/QtChart.pyi +++ b/PyQt5-stubs/QtChart.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtChart module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 9092194e..41c4e6c5 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtCore module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtDBus.pyi b/PyQt5-stubs/QtDBus.pyi index af71e097..1fdebcbf 100644 --- a/PyQt5-stubs/QtDBus.pyi +++ b/PyQt5-stubs/QtDBus.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtDBus module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtDataVisualization.pyi b/PyQt5-stubs/QtDataVisualization.pyi index 1e057ee4..39bbf634 100644 --- a/PyQt5-stubs/QtDataVisualization.pyi +++ b/PyQt5-stubs/QtDataVisualization.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtDataVisualization module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtDesigner.pyi b/PyQt5-stubs/QtDesigner.pyi index 046e393f..90c5ad4d 100644 --- a/PyQt5-stubs/QtDesigner.pyi +++ b/PyQt5-stubs/QtDesigner.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtDesigner module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 3df533e8..153a988c 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtGui module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtHelp.pyi b/PyQt5-stubs/QtHelp.pyi index 089971d0..904e8a8b 100644 --- a/PyQt5-stubs/QtHelp.pyi +++ b/PyQt5-stubs/QtHelp.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtHelp module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index cdde9790..9132ffd8 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtLocation module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index 5637d421..e0fee9cd 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtMultimedia module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtMultimediaWidgets.pyi b/PyQt5-stubs/QtMultimediaWidgets.pyi index 7b9daccd..cf87f5c0 100644 --- a/PyQt5-stubs/QtMultimediaWidgets.pyi +++ b/PyQt5-stubs/QtMultimediaWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtMultimediaWidgets module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 1cdc343a..929210cb 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtNetwork module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtNfc.pyi b/PyQt5-stubs/QtNfc.pyi index bb4a9ec2..f4cab86a 100644 --- a/PyQt5-stubs/QtNfc.pyi +++ b/PyQt5-stubs/QtNfc.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtNfc module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtOpenGL.pyi b/PyQt5-stubs/QtOpenGL.pyi index 0df32472..d9ea2a18 100644 --- a/PyQt5-stubs/QtOpenGL.pyi +++ b/PyQt5-stubs/QtOpenGL.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtOpenGL module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtPositioning.pyi b/PyQt5-stubs/QtPositioning.pyi index a8f8f39e..ff3fed6d 100644 --- a/PyQt5-stubs/QtPositioning.pyi +++ b/PyQt5-stubs/QtPositioning.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtPositioning module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtPrintSupport.pyi b/PyQt5-stubs/QtPrintSupport.pyi index 7def521d..76831d1f 100644 --- a/PyQt5-stubs/QtPrintSupport.pyi +++ b/PyQt5-stubs/QtPrintSupport.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtPrintSupport module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtPurchasing.pyi b/PyQt5-stubs/QtPurchasing.pyi index 04af0476..5bb9d611 100644 --- a/PyQt5-stubs/QtPurchasing.pyi +++ b/PyQt5-stubs/QtPurchasing.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtPurchasing module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtQml.pyi b/PyQt5-stubs/QtQml.pyi index 0dc9e9dc..6fb88182 100644 --- a/PyQt5-stubs/QtQml.pyi +++ b/PyQt5-stubs/QtQml.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtQml module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 53e703b0..744d4ec5 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtQuick module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtQuickWidgets.pyi b/PyQt5-stubs/QtQuickWidgets.pyi index 777789a4..de642e55 100644 --- a/PyQt5-stubs/QtQuickWidgets.pyi +++ b/PyQt5-stubs/QtQuickWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtQuickWidgets module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtRemoteObjects.pyi b/PyQt5-stubs/QtRemoteObjects.pyi index 399846f7..a04756b4 100644 --- a/PyQt5-stubs/QtRemoteObjects.pyi +++ b/PyQt5-stubs/QtRemoteObjects.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtRemoteObjects module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSensors.pyi b/PyQt5-stubs/QtSensors.pyi index 9898de1e..caa5e0e9 100644 --- a/PyQt5-stubs/QtSensors.pyi +++ b/PyQt5-stubs/QtSensors.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSensors module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSerialPort.pyi b/PyQt5-stubs/QtSerialPort.pyi index 62ffc25f..71526b09 100644 --- a/PyQt5-stubs/QtSerialPort.pyi +++ b/PyQt5-stubs/QtSerialPort.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSerialPort module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSql.pyi b/PyQt5-stubs/QtSql.pyi index 3385ee5f..cf9e1eae 100644 --- a/PyQt5-stubs/QtSql.pyi +++ b/PyQt5-stubs/QtSql.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSql module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSvg.pyi b/PyQt5-stubs/QtSvg.pyi index 69789465..a0a4c20e 100644 --- a/PyQt5-stubs/QtSvg.pyi +++ b/PyQt5-stubs/QtSvg.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSvg module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtTest.pyi b/PyQt5-stubs/QtTest.pyi index 696161f6..59873221 100644 --- a/PyQt5-stubs/QtTest.pyi +++ b/PyQt5-stubs/QtTest.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtTest module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebChannel.pyi b/PyQt5-stubs/QtWebChannel.pyi index b318b382..ca33b388 100644 --- a/PyQt5-stubs/QtWebChannel.pyi +++ b/PyQt5-stubs/QtWebChannel.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebChannel module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebEngine.pyi b/PyQt5-stubs/QtWebEngine.pyi index e1e52289..49faeeae 100644 --- a/PyQt5-stubs/QtWebEngine.pyi +++ b/PyQt5-stubs/QtWebEngine.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebEngine module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebEngineCore.pyi b/PyQt5-stubs/QtWebEngineCore.pyi index f1d12ade..ae7e8279 100644 --- a/PyQt5-stubs/QtWebEngineCore.pyi +++ b/PyQt5-stubs/QtWebEngineCore.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebEngineCore module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebEngineWidgets.pyi b/PyQt5-stubs/QtWebEngineWidgets.pyi index da75b2c3..6e3682aa 100644 --- a/PyQt5-stubs/QtWebEngineWidgets.pyi +++ b/PyQt5-stubs/QtWebEngineWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebEngineWidgets module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebKit.pyi b/PyQt5-stubs/QtWebKit.pyi index 746d279b..37150802 100644 --- a/PyQt5-stubs/QtWebKit.pyi +++ b/PyQt5-stubs/QtWebKit.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebKit module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebKitWidgets.pyi b/PyQt5-stubs/QtWebKitWidgets.pyi index 1c8b237b..07390efb 100644 --- a/PyQt5-stubs/QtWebKitWidgets.pyi +++ b/PyQt5-stubs/QtWebKitWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebKitWidgets module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebSockets.pyi b/PyQt5-stubs/QtWebSockets.pyi index edb8a443..bfcce4d0 100644 --- a/PyQt5-stubs/QtWebSockets.pyi +++ b/PyQt5-stubs/QtWebSockets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebSockets module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index df5965f3..a3a03249 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWidgets module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtX11Extras.pyi b/PyQt5-stubs/QtX11Extras.pyi index fecf2891..5450716e 100644 --- a/PyQt5-stubs/QtX11Extras.pyi +++ b/PyQt5-stubs/QtX11Extras.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtX11Extras module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtXml.pyi b/PyQt5-stubs/QtXml.pyi index 2e328857..ca6f875e 100644 --- a/PyQt5-stubs/QtXml.pyi +++ b/PyQt5-stubs/QtXml.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtXml module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtXmlPatterns.pyi b/PyQt5-stubs/QtXmlPatterns.pyi index 840ac47d..dd2fc8af 100644 --- a/PyQt5-stubs/QtXmlPatterns.pyi +++ b/PyQt5-stubs/QtXmlPatterns.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtXmlPatterns module. # -# Generated by SIP 6.0.2 +# Generated by SIP 6.0.3 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/__init__.pyi b/PyQt5-stubs/__init__.pyi index 919d9b67..c2fa8bdc 100644 --- a/PyQt5-stubs/__init__.pyi +++ b/PyQt5-stubs/__init__.pyi @@ -1 +1 @@ -__version__ = "5.15.3.0" +__version__ = "5.15.4.0" From 79a24e40c5541e1d55a78153dd03b73935206b6c Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 26 Mar 2021 15:51:55 +0100 Subject: [PATCH 004/421] Fix WindowType and WindowFlags integer operations Before the fix, the test would report: windowflags.py:10: error: Incompatible types in assignment (expression has type "int", variable has type "WindowType") windowflags.py:18: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:19: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:20: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:21: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:22: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:27: error: Unsupported operand types for + ("WindowFlags" and "WindowType") windowflags.py:27: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:28: error: Unsupported operand types for - ("WindowFlags" and "WindowType") windowflags.py:28: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:29: error: Unsupported operand types for | ("WindowFlags" and "WindowType") windowflags.py:29: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:30: error: Unsupported operand types for & ("WindowFlags" and "WindowType") windowflags.py:30: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:31: error: Unsupported operand types for ^ ("WindowFlags" and "WindowType") windowflags.py:31: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:34: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:34: error: Unsupported operand types for + ("WindowType" and "WindowFlags") windowflags.py:35: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:35: error: Unsupported operand types for - ("WindowType" and "WindowFlags") windowflags.py:36: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:36: error: Unsupported operand types for | ("WindowType" and "WindowFlags") windowflags.py:37: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:37: error: Unsupported operand types for & ("WindowType" and "WindowFlags") windowflags.py:38: error: Incompatible types in assignment (expression has type "int", variable has type "WindowFlags") windowflags.py:38: error: Unsupported operand types for ^ ("WindowType" and "WindowFlags") windowflags.py:41: error: Unsupported left operand type for + ("WindowFlags") windowflags.py:42: error: Unsupported left operand type for - ("WindowFlags") windowflags.py:43: error: Unsupported left operand type for | ("WindowFlags") windowflags.py:44: error: Unsupported left operand type for & ("WindowFlags") windowflags.py:45: error: Unsupported left operand type for ^ ("WindowFlags") --- PyQt5-stubs/QtCore.pyi | 12 +++++++++++ tests/windowflags.py | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/windowflags.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 5a53e997..7d6041f1 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2376,6 +2376,13 @@ class Qt(sip.simplewrapper): WindowActive = ... # type: Qt.WindowState class WindowType(int): + def __invert__(self) -> 'Qt.WindowType': ... + def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... + def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... + def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... + def __add__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... + def __sub__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... + Widget = ... # type: Qt.WindowType Window = ... # type: Qt.WindowType Dialog = ... # type: Qt.WindowType @@ -2770,6 +2777,11 @@ class Qt(sip.simplewrapper): def __invert__(self) -> 'Qt.WindowFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... + def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... + def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... + def __add__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... + def __sub__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... class WindowStates(sip.simplewrapper): diff --git a/tests/windowflags.py b/tests/windowflags.py new file mode 100644 index 00000000..af75f5ca --- /dev/null +++ b/tests/windowflags.py @@ -0,0 +1,47 @@ + +from PyQt5 import QtCore + +# test on WindowType +windowType1 = QtCore.Qt.WindowContextHelpButtonHint +windowType2 = QtCore.Qt.WindowMaximizeButtonHint + +windowTypeTest = windowType1 # type: QtCore.Qt.WindowType +windowTypeTest = windowType2 +windowTypeTest = ~windowType1 + +# test on WindowFlags +windowFlags1 = QtCore.Qt.WindowFlags() +windowFlags2 = QtCore.Qt.WindowFlags() + +windowFlagsTest = windowFlags1 # type: QtCore.Qt.WindowFlags + +windowFlagsTest = windowType1 & windowType2 +windowFlagsTest = windowType1 | windowType2 +windowFlagsTest = windowType1 ^ windowType2 +windowFlagsTest = windowType1 + windowType2 +windowFlagsTest = windowType1 - windowType2 + +windowFlagsTest = ~windowFlags1 + +# right operator +windowFlagsTest = windowFlags1 + windowType1 +windowFlagsTest = windowFlags1 - windowType1 +windowFlagsTest = windowFlags1 | windowType1 +windowFlagsTest = windowFlags1 & windowType1 +windowFlagsTest = windowFlags1 ^ windowType1 + +# left operator +windowFlagsTest = windowType1 + windowFlags1 +windowFlagsTest = windowType1 - windowFlags1 +windowFlagsTest = windowType1 | windowFlags1 +windowFlagsTest = windowType1 & windowFlags1 +windowFlagsTest = windowType1 ^ windowFlags1 + + +windowFlagsTest = windowFlags1 + windowFlags2 +windowFlagsTest = windowFlags1 - windowFlags2 +windowFlagsTest = windowFlags1 | windowFlags2 +windowFlagsTest = windowFlags1 & windowFlags2 +windowFlagsTest = windowFlags1 ^ windowFlags2 + + From 542d5274db65b13d7f6e82630bdad3e3ba8029dc Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 26 Mar 2021 23:03:28 +0100 Subject: [PATCH 005/421] Full testing on WindowType, WindowFlags and int combinations + correct annotaions --- PyQt5-stubs/QtCore.pyi | 34 +++++--- tests/windowflags.py | 176 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 180 insertions(+), 30 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 7d6041f1..94c6932f 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2375,13 +2375,20 @@ class Qt(sip.simplewrapper): WindowFullScreen = ... # type: Qt.WindowState WindowActive = ... # type: Qt.WindowState - class WindowType(int): - def __invert__(self) -> 'Qt.WindowType': ... - def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... - def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... - def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... - def __add__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... - def __sub__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... + class WindowType(object): + def __init__(self, f: typing.Union['Qt.WindowType', int]) -> None: ... + def __int__(self) -> int: ... + def __invert__(self) -> 'Qt.WindowFlags': ... + def __add__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... + def __sub__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... + def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... + def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... + def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... + def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... + def __rand__(self, other: int) -> 'Qt.WindowFlags': ... + def __rxor__(self, other: int) -> 'Qt.WindowFlags': ... + def __radd__ (self, other: int) -> 'Qt.WindowFlags': ... + def __rsub__ (self, other: int) -> 'Qt.WindowFlags': ... Widget = ... # type: Qt.WindowType Window = ... # type: Qt.WindowType @@ -2768,7 +2775,7 @@ class Qt(sip.simplewrapper): @typing.overload def __init__(self) -> None: ... @typing.overload - def __init__(self, f: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> None: ... + def __init__(self, f: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> None: ... @typing.overload def __init__(self, a0: 'Qt.WindowFlags') -> None: ... @@ -2777,11 +2784,12 @@ class Qt(sip.simplewrapper): def __invert__(self) -> 'Qt.WindowFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... - def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... - def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... - def __add__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... - def __sub__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType']) -> 'Qt.WindowFlags': ... + def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... + def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... + def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... + def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... + def __rand__(self, other: int) -> 'Qt.WindowFlags': ... + def __rxor__(self, other: int) -> 'Qt.WindowFlags': ... class WindowStates(sip.simplewrapper): diff --git a/tests/windowflags.py b/tests/windowflags.py index af75f5ca..b5be8846 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -1,47 +1,189 @@ from PyQt5 import QtCore -# test on WindowType +#########################################################3 +# +# tests on WindowType +# +#########################################################3 + windowType1 = QtCore.Qt.WindowContextHelpButtonHint windowType2 = QtCore.Qt.WindowMaximizeButtonHint windowTypeTest = windowType1 # type: QtCore.Qt.WindowType -windowTypeTest = windowType2 -windowTypeTest = ~windowType1 +intValue = 0 # type: int + +# this is rejected by mypy and is ok, we want to force precise typing on such flags and avoid using generic int +intValue = windowType1 # type: ignore + +# if you really need the int value, you can use this. +intValue = int(windowType1) + +# this is not supported for a good reason +windowTypeTest = 33 # type: ignore + +# correct way to do it +windowTypeTest = QtCore.Qt.WindowType(33) + +#########################################################3 +# +# tests on WindowFlags +# +#########################################################3 -# test on WindowFlags windowFlags1 = QtCore.Qt.WindowFlags() windowFlags2 = QtCore.Qt.WindowFlags() windowFlagsTest = windowFlags1 # type: QtCore.Qt.WindowFlags + +# window flags may be created by combining windowFlags together +windowFlagsTest = ~windowFlags1 +windowFlagsTest = windowFlags1 | windowFlags2 +windowFlagsTest = windowFlags1 & windowFlags2 +windowFlagsTest = windowFlags1 ^ windowFlags2 + +# window flags may be created by combining windowType together +windowFlagsTest = ~windowType1 windowFlagsTest = windowType1 & windowType2 windowFlagsTest = windowType1 | windowType2 windowFlagsTest = windowType1 ^ windowType2 windowFlagsTest = windowType1 + windowType2 windowFlagsTest = windowType1 - windowType2 -windowFlagsTest = ~windowFlags1 +# window flags may also be created by combining windowType and int, left or right +windowFlagsTest = windowType1 & 33 +windowFlagsTest = windowType1 | 33 +windowFlagsTest = windowType1 ^ 33 +windowFlagsTest = windowType1 + 33 +windowFlagsTest = windowType1 - 33 +windowFlagsTest = 33 & windowType1 +windowFlagsTest = 33 | windowType1 +windowFlagsTest = 33 ^ windowType1 +windowFlagsTest = 33 + windowType1 +windowFlagsTest = 33 - windowType1 -# right operator -windowFlagsTest = windowFlags1 + windowType1 -windowFlagsTest = windowFlags1 - windowType1 +# window flags may be created by combining windowFlags and windowType, left or right windowFlagsTest = windowFlags1 | windowType1 windowFlagsTest = windowFlags1 & windowType1 windowFlagsTest = windowFlags1 ^ windowType1 - -# left operator -windowFlagsTest = windowType1 + windowFlags1 -windowFlagsTest = windowType1 - windowFlags1 windowFlagsTest = windowType1 | windowFlags1 windowFlagsTest = windowType1 & windowFlags1 windowFlagsTest = windowType1 ^ windowFlags1 -windowFlagsTest = windowFlags1 + windowFlags2 -windowFlagsTest = windowFlags1 - windowFlags2 -windowFlagsTest = windowFlags1 | windowFlags2 -windowFlagsTest = windowFlags1 & windowFlags2 -windowFlagsTest = windowFlags1 ^ windowFlags2 +# window flags may be created by combining windowFlags and int, right only +windowFlagsTest = windowFlags1 | 33 +windowFlagsTest = windowFlags1 & 33 +windowFlagsTest = windowFlags1 ^ 33 + + +# this is rejected and is slightly annoying: you can not pass a WindowType variable to a method expecting a WindowFlags +# explicit typing must be used on those methods to accept both WindowType and WindowFlags +windowFlagsTest = windowType1 # type: ignore + +# correct way to do it +windowFlagsTest = QtCore.Qt.WindowFlags(windowType1) + +# this is rejected for the same reason as for windowType. We want windowFlags to be stay precise typing +intValue = windowFlagsTest # type: ignore + +# correct way to do it +intValue = int(windowFlagsTest) + +# rejected because all other operations on WindowFlags would then fail, because int +# does not support as many operations as WindowFlags +windowFlagsTest = 33 # type: ignore + +# correct way to do it +windowFlagsTest = QtCore.Qt.WindowFlags(33) + + +#########################################################3 +# +# Exploring errors +# +#########################################################3 + +# This checks the following: +# + and - operations are not supported on windowFlags +# combining int with windowFlags does not work + +try: + windowFlagsTest = windowFlags1 + windowFlags2 # type: ignore + assert False +except TypeError: + pass + +try: + windowFlagsTest = windowFlags1 - windowFlags2 # type: ignore + assert False +except TypeError: + pass + +try: + windowFlagsTest = windowFlags1 + windowType1 # type: ignore + assert False +except TypeError: + pass + +try: + windowFlagsTest = windowFlags1 - windowType1 # type: ignore + assert False +except TypeError: + pass + +try: + windowFlagsTest = windowType1 + windowFlags1 # type: ignore + assert False +except TypeError: + pass + +try: + windowFlagsTest = windowType1 - windowFlags1 # type: ignore + assert False +except TypeError: + pass + +try: + windowFlagsTest = windowFlags1 + 33 # type: ignore + assert False +except TypeError: + pass + +try: + windowFlagsTest = windowFlags1 - 33 # type: ignore + assert False +except TypeError: + pass + +try: + windowFlagsTest = 33 + windowFlags1 # type: ignore + assert False +except TypeError: + pass + +try: + windowFlagsTest = 33 - windowFlags1 # type: ignore + assert False +except TypeError: + pass + +try: + windowFlagsTest = 33 | windowFlags1 # type: ignore + assert False +except TypeError: + pass + +try: + windowFlagsTest = 33 & windowFlags1 # type: ignore + assert False +except TypeError: + pass +try: + windowFlagsTest = 33 ^ windowFlags1 # type: ignore + assert False +except TypeError: + pass From ba5b984201f3c60538c6f7502f3f58879d9f38bf Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 27 Mar 2021 10:29:31 +0100 Subject: [PATCH 006/421] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 790fe22b..b851a4d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added * [#138](https://github.com/python-qt-tools/PyQt5-stubs/pull/138) update to PyQt5 5.15.3 +* [#138](https://github.com/python-qt-tools/PyQt5-stubs/pull/145) Support all implemented arithmetic operations between Qt.WindowType and Qt.WindowFlags and int ## 5.15.2.0 From b3283838f4924ffe0a0e64f1acc18eedea7e5964 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 27 Mar 2021 10:53:54 +0100 Subject: [PATCH 007/421] Make WindowType inherit int again (revert a previous change) --- PyQt5-stubs/QtCore.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 94c6932f..13a7a6b5 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2375,7 +2375,7 @@ class Qt(sip.simplewrapper): WindowFullScreen = ... # type: Qt.WindowState WindowActive = ... # type: Qt.WindowState - class WindowType(object): + class WindowType(int): def __init__(self, f: typing.Union['Qt.WindowType', int]) -> None: ... def __int__(self) -> int: ... def __invert__(self) -> 'Qt.WindowFlags': ... From e1c67d4367463207656132d1e80a37fc3d8bde28 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 29 Mar 2021 14:43:01 +0200 Subject: [PATCH 008/421] Ignore the errors reported from breaking Liskov principle --- PyQt5-stubs/QtCore.pyi | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 13a7a6b5..63843fa6 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2378,17 +2378,17 @@ class Qt(sip.simplewrapper): class WindowType(int): def __init__(self, f: typing.Union['Qt.WindowType', int]) -> None: ... def __int__(self) -> int: ... - def __invert__(self) -> 'Qt.WindowFlags': ... - def __add__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... - def __sub__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... - def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... - def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... - def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... - def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... - def __rand__(self, other: int) -> 'Qt.WindowFlags': ... - def __rxor__(self, other: int) -> 'Qt.WindowFlags': ... - def __radd__ (self, other: int) -> 'Qt.WindowFlags': ... - def __rsub__ (self, other: int) -> 'Qt.WindowFlags': ... + def __invert__(self) -> 'Qt.WindowFlags': ... # type: ignore[override] + def __add__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] + def __sub__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] + def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] + def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] + def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] + def __rand__(self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] + def __rxor__(self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] + def __radd__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] + def __rsub__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] Widget = ... # type: Qt.WindowType Window = ... # type: Qt.WindowType From 1ad195a3b5965620da34c701d094a23715dc7c30 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 29 Mar 2021 14:43:16 +0200 Subject: [PATCH 009/421] add one more test for windowFlags usage --- tests/windowflags.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/windowflags.py b/tests/windowflags.py index b5be8846..21df0c21 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -1,5 +1,14 @@ +from PyQt5 import QtCore, QtWidgets -from PyQt5 import QtCore +#########################################################3 +# +# The original problem +# +#########################################################3 +app = QtWidgets.QApplication([]) + +w = QtWidgets.QWidget() +w.setWindowFlags(w.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) #########################################################3 # From 53c1105b9ac3c76f0180b5be6613e3f3b72f6574 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 29 Mar 2021 21:11:04 +0200 Subject: [PATCH 010/421] WindowType as working cross verfication with mypy and py.test --- PyQt5-stubs/QtCore.pyi | 32 ++-- tests/windowflags.py | 419 ++++++++++++++++++++++++++--------------- 2 files changed, 287 insertions(+), 164 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 63843fa6..0229925f 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2378,17 +2378,27 @@ class Qt(sip.simplewrapper): class WindowType(int): def __init__(self, f: typing.Union['Qt.WindowType', int]) -> None: ... def __int__(self) -> int: ... - def __invert__(self) -> 'Qt.WindowFlags': ... # type: ignore[override] - def __add__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] - def __sub__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] - def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] - def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] - def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] - def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] - def __rand__(self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] - def __rxor__(self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] - def __radd__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] - def __rsub__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] + @typing.overload + def __or__ (self, other: 'Qt.WindowType') -> 'Qt.WindowFlags': ... + @typing.overload + def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... + + # def __add__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] + # def __sub__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] + # @typing.overload + # def __or__ (self, other: 'Qt.WindowFlags') -> 'Qt.WindowFlags': ... + # @typing.overload + # def __and__ (self, other: 'Qt.WindowFlags') -> 'Qt.WindowFlags': ... + # @typing.overload + # def __xor__ (self, other: 'Qt.WindowFlags') -> 'Qt.WindowFlags': ... + # def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] + # def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] + # def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] + # def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] + # def __rand__(self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] + # def __rxor__(self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] + # def __radd__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] + # def __rsub__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] Widget = ... # type: Qt.WindowType Window = ... # type: Qt.WindowType diff --git a/tests/windowflags.py b/tests/windowflags.py index 21df0c21..0c9cb8b4 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -1,3 +1,5 @@ +from typing import Union + from PyQt5 import QtCore, QtWidgets #########################################################3 @@ -5,10 +7,13 @@ # The original problem # #########################################################3 -app = QtWidgets.QApplication([]) -w = QtWidgets.QWidget() -w.setWindowFlags(w.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) +def test_original_problem() -> None: + app = QtWidgets.QApplication([]) + + w = QtWidgets.QWidget() + w.setWindowFlags(w.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) + #########################################################3 # @@ -16,183 +21,291 @@ # #########################################################3 -windowType1 = QtCore.Qt.WindowContextHelpButtonHint -windowType2 = QtCore.Qt.WindowMaximizeButtonHint +def assert_type_windowType(value: QtCore.Qt.WindowType) -> None: + '''This validates both with mypy and regular python the actual type of the value''' + assert type(value) == QtCore.Qt.WindowType -windowTypeTest = windowType1 # type: QtCore.Qt.WindowType -intValue = 0 # type: int -# this is rejected by mypy and is ok, we want to force precise typing on such flags and avoid using generic int -intValue = windowType1 # type: ignore +def assert_type_int(value: int) -> None: + assert type(value) == int -# if you really need the int value, you can use this. -intValue = int(windowType1) -# this is not supported for a good reason -windowTypeTest = 33 # type: ignore +def assert_type_windowFlags(value: QtCore.Qt.WindowFlags) -> None: + '''This validates both with mypy and regular python the actual type of the value''' + assert type(value) == QtCore.Qt.WindowFlags -# correct way to do it -windowTypeTest = QtCore.Qt.WindowType(33) -#########################################################3 -# -# tests on WindowFlags -# -#########################################################3 +def test_on_windowtype() -> None: + windowType1 = QtCore.Qt.WindowContextHelpButtonHint + windowType2 = QtCore.Qt.WindowMaximizeButtonHint + + assert_type_windowType(windowType1) + assert_type_windowType(windowType2) -windowFlags1 = QtCore.Qt.WindowFlags() -windowFlags2 = QtCore.Qt.WindowFlags() + windowTypeTest = windowType1 # type: QtCore.Qt.WindowType + intValue = 0 # type: int + windowFlagsTest = QtCore.Qt.WindowFlags() + windowFlagsOrTypeTest = windowType1 # type: Union[QtCore.Qt.WindowType, QtCore.Qt.WindowFlags] + windowTypeOrInt = windowType1 # type: Union[int, QtCore.Qt.WindowType] -windowFlagsTest = windowFlags1 # type: QtCore.Qt.WindowFlags + assert_type_windowType(windowTypeTest) + assert_type_windowFlags(windowFlagsTest) + assert_type_int(intValue) + # upcast from WindowType to int + intValue = windowType1 -# window flags may be created by combining windowFlags together -windowFlagsTest = ~windowFlags1 -windowFlagsTest = windowFlags1 | windowFlags2 -windowFlagsTest = windowFlags1 & windowFlags2 -windowFlagsTest = windowFlags1 ^ windowFlags2 + # conversion also accepted + intValue = int(windowType1) -# window flags may be created by combining windowType together -windowFlagsTest = ~windowType1 -windowFlagsTest = windowType1 & windowType2 -windowFlagsTest = windowType1 | windowType2 -windowFlagsTest = windowType1 ^ windowType2 -windowFlagsTest = windowType1 + windowType2 -windowFlagsTest = windowType1 - windowType2 + # this is not supported for a good reason + windowTypeTest = 33 # type: ignore -# window flags may also be created by combining windowType and int, left or right -windowFlagsTest = windowType1 & 33 -windowFlagsTest = windowType1 | 33 -windowFlagsTest = windowType1 ^ 33 -windowFlagsTest = windowType1 + 33 -windowFlagsTest = windowType1 - 33 -windowFlagsTest = 33 & windowType1 -windowFlagsTest = 33 | windowType1 -windowFlagsTest = 33 ^ windowType1 -windowFlagsTest = 33 + windowType1 -windowFlagsTest = 33 - windowType1 + # correct way to do it + windowTypeTest = QtCore.Qt.WindowType(33) -# window flags may be created by combining windowFlags and windowType, left or right -windowFlagsTest = windowFlags1 | windowType1 -windowFlagsTest = windowFlags1 & windowType1 -windowFlagsTest = windowFlags1 ^ windowType1 -windowFlagsTest = windowType1 | windowFlags1 -windowFlagsTest = windowType1 & windowFlags1 -windowFlagsTest = windowType1 ^ windowFlags1 + # The rules of WindowType conversion defined in PyQt5 are: + # 1. | ~= with WindowType return a WindowFlags (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + assert_type_windowFlags(windowType1 | windowType2) + assert_type_int(~windowType1) + assert_type_int(windowType1 & windowType2) + assert_type_int(windowType1 ^ windowType2) -# window flags may be created by combining windowFlags and int, right only -windowFlagsTest = windowFlags1 | 33 -windowFlagsTest = windowFlags1 & 33 -windowFlagsTest = windowFlags1 ^ 33 + # right operand + assert_type_int(windowType1 | 33) + assert_type_int(windowType1 & 33) + assert_type_int(windowType1 ^ 33) + assert_type_int(windowType1 + 33) + assert_type_int(windowType1 - 33) + # left operand + assert_type_windowFlags(33 | windowType1) + assert_type_int(33 & windowType1) + assert_type_int(33 ^ windowType1) + assert_type_int(33 + windowType1) + assert_type_int(33 - windowType1) -# this is rejected and is slightly annoying: you can not pass a WindowType variable to a method expecting a WindowFlags -# explicit typing must be used on those methods to accept both WindowType and WindowFlags -windowFlagsTest = windowType1 # type: ignore + windowFlagsOrTypeTest = windowType1 # reset type and value + assert_type_windowType(windowFlagsOrTypeTest) + windowFlagsOrTypeTest |= windowType2 + assert_type_windowFlags(windowFlagsOrTypeTest) # nice violation of Liskov here -# correct way to do it -windowFlagsTest = QtCore.Qt.WindowFlags(windowType1) + windowTypeOrInt = windowType1 # reset type and value + assert_type_windowType(windowTypeOrInt) + windowTypeOrInt |= 33 + assert_type_int(windowTypeOrInt) -# this is rejected for the same reason as for windowType. We want windowFlags to be stay precise typing -intValue = windowFlagsTest # type: ignore + windowTypeOrInt = windowType1 # reset type and value + assert_type_windowType(windowTypeOrInt) + windowTypeOrInt &= 33 + assert_type_int(windowTypeOrInt) -# correct way to do it -intValue = int(windowFlagsTest) + windowTypeOrInt = windowType1 # reset type and value + assert_type_windowType(windowTypeOrInt) + windowTypeOrInt &= windowType2 + assert_type_int(windowTypeOrInt) -# rejected because all other operations on WindowFlags would then fail, because int -# does not support as many operations as WindowFlags -windowFlagsTest = 33 # type: ignore + windowTypeOrInt = windowType1 # reset type and value + assert_type_windowType(windowTypeOrInt) + windowTypeOrInt ^= 33 + assert_type_int(windowTypeOrInt) + + windowTypeOrInt = windowType1 # reset type and value + assert_type_windowType(windowTypeOrInt) + windowTypeOrInt ^= windowType2 + assert_type_int(windowTypeOrInt) -# correct way to do it -windowFlagsTest = QtCore.Qt.WindowFlags(33) #########################################################3 # -# Exploring errors +# tests on WindowFlags # #########################################################3 -# This checks the following: -# + and - operations are not supported on windowFlags -# combining int with windowFlags does not work - -try: - windowFlagsTest = windowFlags1 + windowFlags2 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = windowFlags1 - windowFlags2 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = windowFlags1 + windowType1 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = windowFlags1 - windowType1 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = windowType1 + windowFlags1 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = windowType1 - windowFlags1 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = windowFlags1 + 33 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = windowFlags1 - 33 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = 33 + windowFlags1 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = 33 - windowFlags1 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = 33 | windowFlags1 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = 33 & windowFlags1 # type: ignore - assert False -except TypeError: - pass - -try: - windowFlagsTest = 33 ^ windowFlags1 # type: ignore - assert False -except TypeError: - pass +def test_on_window_flags() -> None: + windowType1 = QtCore.Qt.WindowContextHelpButtonHint + windowType2 = QtCore.Qt.WindowMaximizeButtonHint + + windowFlags1 = QtCore.Qt.WindowFlags() + windowFlags2 = QtCore.Qt.WindowFlags() + + windowFlagsTest = windowFlags1 # type: QtCore.Qt.WindowFlags + + + # window flags may be created by combining windowFlags together + windowFlagsTest = ~windowFlags1 + windowFlagsTest = windowFlags1 | windowFlags2 + windowFlagsTest = windowFlags1 & windowFlags2 + windowFlagsTest = windowFlags1 ^ windowFlags2 + + # window flags may be created by combining windowType together + if 0: + windowFlagsTest = ~windowType1 + windowFlagsTest = windowType1 & windowType2 + windowFlagsTest = windowType1 | windowType2 + windowFlagsTest = windowType1 ^ windowType2 + windowFlagsTest = windowType1 + windowType2 + windowFlagsTest = windowType1 - windowType2 + else: + intValue = ~windowType1 + intValue = windowType1 & windowType2 + intValue = windowType1 | windowType2 + intValue = windowType1 ^ windowType2 + intValue = windowType1 + windowType2 + intValue = windowType1 - windowType2 + + + # window flags may also be created by combining windowType and int, left or right + if 0: + windowFlagsTest = windowType1 & 33 + windowFlagsTest = windowType1 | 33 + windowFlagsTest = windowType1 ^ 33 + windowFlagsTest = windowType1 + 33 + windowFlagsTest = windowType1 - 33 + windowFlagsTest = 33 & windowType1 + windowFlagsTest = 33 | windowType1 + windowFlagsTest = 33 ^ windowType1 + windowFlagsTest = 33 + windowType1 + windowFlagsTest = 33 - windowType1 + else: + intValue = windowType1 & 33 + intValue = windowType1 | 33 + intValue = windowType1 ^ 33 + intValue = windowType1 + 33 + intValue = windowType1 - 33 + intValue = 33 & windowType1 + intValue = 33 | windowType1 + intValue = 33 ^ windowType1 + intValue = 33 + windowType1 + intValue = 33 - windowType1 + + + # window flags may be created by combining windowFlags and windowType, left or right + windowFlagsTest = windowFlags1 | windowType1 + windowFlagsTest = windowFlags1 & windowType1 + windowFlagsTest = windowFlags1 ^ windowType1 + windowFlagsTest = windowType1 | windowFlags1 + windowFlagsTest = windowType1 & windowFlags1 + windowFlagsTest = windowType1 ^ windowFlags1 + + + # window flags may be created by combining windowFlags and int, right only + windowFlagsTest = windowFlags1 | 33 + windowFlagsTest = windowFlags1 & 33 + windowFlagsTest = windowFlags1 ^ 33 + + + # this is rejected and is slightly annoying: you can not pass a WindowType variable to a method expecting a WindowFlags + # explicit typing must be used on those methods to accept both WindowType and WindowFlags + windowFlagsTest = windowType1 # type: ignore + + # correct way to do it + windowFlagsTest = QtCore.Qt.WindowFlags(windowType1) + + # this is rejected for the same reason as for windowType. We want windowFlags to be stay precise typing + intValue = windowFlagsTest # type: ignore + + # correct way to do it + intValue = int(windowFlagsTest) + + # rejected because all other operations on WindowFlags would then fail, because int + # does not support as many operations as WindowFlags + windowFlagsTest = 33 # type: ignore + + # correct way to do it + windowFlagsTest = QtCore.Qt.WindowFlags(33) + + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on windowFlags + # combining int with windowFlags does not work + + try: + windowFlagsTest = windowFlags1 + windowFlags2 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = windowFlags1 - windowFlags2 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = windowFlags1 + windowType1 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = windowFlags1 - windowType1 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = windowType1 + windowFlags1 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = windowType1 - windowFlags1 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = windowFlags1 + 33 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = windowFlags1 - 33 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = 33 + windowFlags1 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = 33 - windowFlags1 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = 33 | windowFlags1 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = 33 & windowFlags1 # type: ignore + assert False + except TypeError: + pass + + try: + windowFlagsTest = 33 ^ windowFlags1 # type: ignore + assert False + except TypeError: + pass From eebb2cb02803b277d9d8d3197a9cc7dda75db5e0 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 29 Mar 2021 21:41:16 +0200 Subject: [PATCH 011/421] WindowFlags operations are verified by both mypy and pytest --- PyQt5-stubs/QtCore.pyi | 23 +---- tests/windowflags.py | 186 ++++++++++------------------------------- 2 files changed, 46 insertions(+), 163 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 0229925f..1eda3616 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2383,23 +2383,6 @@ class Qt(sip.simplewrapper): @typing.overload def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... - # def __add__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] - # def __sub__ (self, other: typing.Union['Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] - # @typing.overload - # def __or__ (self, other: 'Qt.WindowFlags') -> 'Qt.WindowFlags': ... - # @typing.overload - # def __and__ (self, other: 'Qt.WindowFlags') -> 'Qt.WindowFlags': ... - # @typing.overload - # def __xor__ (self, other: 'Qt.WindowFlags') -> 'Qt.WindowFlags': ... - # def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] - # def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] - # def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... # type: ignore[override] - # def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] - # def __rand__(self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] - # def __rxor__(self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] - # def __radd__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] - # def __rsub__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[misc, override] - Widget = ... # type: Qt.WindowType Window = ... # type: Qt.WindowType Dialog = ... # type: Qt.WindowType @@ -2797,9 +2780,9 @@ class Qt(sip.simplewrapper): def __or__ (self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... def __and__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... def __xor__(self, other: typing.Union['Qt.WindowFlags', 'Qt.WindowType', int]) -> 'Qt.WindowFlags': ... - def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... - def __rand__(self, other: int) -> 'Qt.WindowFlags': ... - def __rxor__(self, other: int) -> 'Qt.WindowFlags': ... + def __ror__ (self, other: 'Qt.WindowType') -> 'Qt.WindowFlags': ... + def __rand__(self, other: 'Qt.WindowType') -> 'Qt.WindowFlags': ... + def __rxor__(self, other: 'Qt.WindowType') -> 'Qt.WindowFlags': ... class WindowStates(sip.simplewrapper): diff --git a/tests/windowflags.py b/tests/windowflags.py index 0c9cb8b4..d2d902ef 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -1,5 +1,5 @@ from typing import Union - +import pytest # type: ignore[import] from PyQt5 import QtCore, QtWidgets #########################################################3 @@ -38,16 +38,14 @@ def assert_type_windowFlags(value: QtCore.Qt.WindowFlags) -> None: def test_on_windowtype() -> None: windowType1 = QtCore.Qt.WindowContextHelpButtonHint windowType2 = QtCore.Qt.WindowMaximizeButtonHint - - assert_type_windowType(windowType1) - assert_type_windowType(windowType2) - windowTypeTest = windowType1 # type: QtCore.Qt.WindowType intValue = 0 # type: int windowFlagsTest = QtCore.Qt.WindowFlags() windowFlagsOrTypeTest = windowType1 # type: Union[QtCore.Qt.WindowType, QtCore.Qt.WindowFlags] windowTypeOrInt = windowType1 # type: Union[int, QtCore.Qt.WindowType] + assert_type_windowType(windowType1) + assert_type_windowType(windowType2) assert_type_windowType(windowTypeTest) assert_type_windowFlags(windowFlagsTest) assert_type_int(intValue) @@ -129,92 +127,57 @@ def test_on_windowtype() -> None: def test_on_window_flags() -> None: windowType1 = QtCore.Qt.WindowContextHelpButtonHint - windowType2 = QtCore.Qt.WindowMaximizeButtonHint - windowFlags1 = QtCore.Qt.WindowFlags() windowFlags2 = QtCore.Qt.WindowFlags() - windowFlagsTest = windowFlags1 # type: QtCore.Qt.WindowFlags + intValue = 0 + + assert_type_windowType(windowType1) + assert_type_windowFlags(windowFlags1) + assert_type_windowFlags(windowFlags2) + assert_type_windowFlags(windowFlagsTest) + assert_type_int(intValue) # window flags may be created by combining windowFlags together - windowFlagsTest = ~windowFlags1 - windowFlagsTest = windowFlags1 | windowFlags2 - windowFlagsTest = windowFlags1 & windowFlags2 - windowFlagsTest = windowFlags1 ^ windowFlags2 - - # window flags may be created by combining windowType together - if 0: - windowFlagsTest = ~windowType1 - windowFlagsTest = windowType1 & windowType2 - windowFlagsTest = windowType1 | windowType2 - windowFlagsTest = windowType1 ^ windowType2 - windowFlagsTest = windowType1 + windowType2 - windowFlagsTest = windowType1 - windowType2 - else: - intValue = ~windowType1 - intValue = windowType1 & windowType2 - intValue = windowType1 | windowType2 - intValue = windowType1 ^ windowType2 - intValue = windowType1 + windowType2 - intValue = windowType1 - windowType2 - - - # window flags may also be created by combining windowType and int, left or right - if 0: - windowFlagsTest = windowType1 & 33 - windowFlagsTest = windowType1 | 33 - windowFlagsTest = windowType1 ^ 33 - windowFlagsTest = windowType1 + 33 - windowFlagsTest = windowType1 - 33 - windowFlagsTest = 33 & windowType1 - windowFlagsTest = 33 | windowType1 - windowFlagsTest = 33 ^ windowType1 - windowFlagsTest = 33 + windowType1 - windowFlagsTest = 33 - windowType1 - else: - intValue = windowType1 & 33 - intValue = windowType1 | 33 - intValue = windowType1 ^ 33 - intValue = windowType1 + 33 - intValue = windowType1 - 33 - intValue = 33 & windowType1 - intValue = 33 | windowType1 - intValue = 33 ^ windowType1 - intValue = 33 + windowType1 - intValue = 33 - windowType1 + assert_type_windowFlags( ~windowFlags1 ) + assert_type_windowFlags( windowFlags1 | windowFlags2 ) + assert_type_windowFlags( windowFlags1 & windowFlags2 ) + assert_type_windowFlags( windowFlags1 ^ windowFlags2 ) # window flags may be created by combining windowFlags and windowType, left or right - windowFlagsTest = windowFlags1 | windowType1 - windowFlagsTest = windowFlags1 & windowType1 - windowFlagsTest = windowFlags1 ^ windowType1 - windowFlagsTest = windowType1 | windowFlags1 - windowFlagsTest = windowType1 & windowFlags1 - windowFlagsTest = windowType1 ^ windowFlags1 + assert_type_windowFlags( windowFlags1 | windowType1 ) + assert_type_windowFlags( windowFlags1 & windowType1 ) + assert_type_windowFlags( windowFlags1 ^ windowType1 ) + + assert_type_windowFlags( windowType1 | windowFlags1 ) + assert_type_windowFlags( windowType1 & windowFlags1 ) + assert_type_windowFlags( windowType1 ^ windowFlags1 ) # window flags may be created by combining windowFlags and int, right only - windowFlagsTest = windowFlags1 | 33 - windowFlagsTest = windowFlags1 & 33 - windowFlagsTest = windowFlags1 ^ 33 + assert_type_windowFlags(windowFlags1 | 33) + assert_type_windowFlags(windowFlags1 & 33) + assert_type_windowFlags(windowFlags1 ^ 33) - # this is rejected and is slightly annoying: you can not pass a WindowType variable to a method expecting a WindowFlags + # this is rejected by mypy and is slightly annoying: you can not pass a WindowType variable to a method expecting a WindowFlags # explicit typing must be used on those methods to accept both WindowType and WindowFlags windowFlagsTest = windowType1 # type: ignore # correct way to do it windowFlagsTest = QtCore.Qt.WindowFlags(windowType1) + assert_type_windowFlags(windowFlagsTest) - # this is rejected for the same reason as for windowType. We want windowFlags to be stay precise typing + # this is rejected for the same reason as for windowType. intValue = windowFlagsTest # type: ignore # correct way to do it intValue = int(windowFlagsTest) + assert_type_int(intValue) - # rejected because all other operations on WindowFlags would then fail, because int - # does not support as many operations as WindowFlags + # rejected by mypy rightfully windowFlagsTest = 33 # type: ignore # correct way to do it @@ -231,81 +194,18 @@ def test_on_window_flags() -> None: # + and - operations are not supported on windowFlags # combining int with windowFlags does not work - try: - windowFlagsTest = windowFlags1 + windowFlags2 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = windowFlags1 - windowFlags2 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = windowFlags1 + windowType1 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = windowFlags1 - windowType1 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = windowType1 + windowFlags1 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = windowType1 - windowFlags1 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = windowFlags1 + 33 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = windowFlags1 - 33 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = 33 + windowFlags1 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = 33 - windowFlags1 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = 33 | windowFlags1 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = 33 & windowFlags1 # type: ignore - assert False - except TypeError: - pass - - try: - windowFlagsTest = 33 ^ windowFlags1 # type: ignore - assert False - except TypeError: - pass + pytest.raises(TypeError, lambda: 33 | windowFlags1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & windowFlags1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ windowFlags1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: windowFlags1 + windowFlags2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: windowFlags1 - windowFlags2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: windowFlags1 + windowType1) # type: ignore[operator] + pytest.raises(TypeError, lambda: windowFlags1 - windowType1) # type: ignore[operator] + pytest.raises(TypeError, lambda: windowFlags1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: windowFlags1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: windowType1 + windowFlags1) # type: ignore[operator] + pytest.raises(TypeError, lambda: windowType1 - windowFlags1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + windowFlags1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - windowFlags1) # type: ignore[operator] From af26357ccac8d45c6160ab181c57991b8c997814 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 29 Mar 2021 21:49:15 +0200 Subject: [PATCH 012/421] Also test assignment operator --- tests/windowflags.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/windowflags.py b/tests/windowflags.py index d2d902ef..d017e89e 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -183,6 +183,31 @@ def test_on_window_flags() -> None: # correct way to do it windowFlagsTest = QtCore.Qt.WindowFlags(33) + # assignments operations with WindowType + assert_type_windowFlags(windowFlagsTest) + windowFlagsTest |= windowType1 + assert_type_windowFlags(windowFlagsTest) + + assert_type_windowFlags(windowFlagsTest) + windowFlagsTest &= windowType1 + assert_type_windowFlags(windowFlagsTest) + + assert_type_windowFlags(windowFlagsTest) + windowFlagsTest ^= windowType1 + assert_type_windowFlags(windowFlagsTest) + + # assignments operations with int + assert_type_windowFlags(windowFlagsTest) + windowFlagsTest |= 33 + assert_type_windowFlags(windowFlagsTest) + + assert_type_windowFlags(windowFlagsTest) + windowFlagsTest &= 33 + assert_type_windowFlags(windowFlagsTest) + + assert_type_windowFlags(windowFlagsTest) + windowFlagsTest ^= 33 + assert_type_windowFlags(windowFlagsTest) #########################################################3 # @@ -209,3 +234,21 @@ def test_on_window_flags() -> None: pytest.raises(TypeError, lambda: 33 + windowFlags1) # type: ignore[operator] pytest.raises(TypeError, lambda: 33 - windowFlags1) # type: ignore[operator] + def f1() -> None: + windowFlagsTest = QtCore.Qt.WindowFlags() + windowFlagsTest += windowType1 # type: ignore[assignment, operator] + def f2() -> None: + windowFlagsTest = QtCore.Qt.WindowFlags() + windowFlagsTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + windowFlagsTest = QtCore.Qt.WindowFlags() + windowFlagsTest -= windowType1 # type: ignore[assignment, operator] + def f4() -> None: + windowFlagsTest = QtCore.Qt.WindowFlags() + windowFlagsTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From b0bac6d6bb470637772a5432a64f9c47e29b3531 Mon Sep 17 00:00:00 2001 From: Erik Cederberg Date: Tue, 13 Apr 2021 14:59:32 +0200 Subject: [PATCH 013/421] Implement QDialogButtonBox.StandardButton[s].__or__ --- PyQt5-stubs/QtWidgets.pyi | 6 ++++++ tests/qdialogbuttonbox.py | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 tests/qdialogbuttonbox.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 92d28ffb..ce59af4d 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -3530,6 +3530,11 @@ class QDial(QAbstractSlider): class QDialogButtonBox(QWidget): class StandardButton(int): + @typing.overload # type: ignore[override] + def __or__(self, other: typing.Union['QDialogButtonBox.StandardButton', 'QDialogButtonBox.StandardButtons']) -> 'QDialogButtonBox.StandardButtons': ... # type: ignore[misc] + @typing.overload + def __or__(self, other: int) -> int: ... + NoButton = ... # type: QDialogButtonBox.StandardButton Ok = ... # type: QDialogButtonBox.StandardButton Save = ... # type: QDialogButtonBox.StandardButton @@ -3620,6 +3625,7 @@ class QDialogButtonBox(QWidget): def __invert__(self) -> 'QDialogButtonBox.StandardButtons': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__(self, other: typing.Union[int, 'QDialogButtonBox.StandardButtons', 'QDialogButtonBox.StandardButton']) -> 'QDialogButtonBox.StandardButtons': ... @typing.overload def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qdialogbuttonbox.py b/tests/qdialogbuttonbox.py new file mode 100644 index 00000000..2ab3bd7e --- /dev/null +++ b/tests/qdialogbuttonbox.py @@ -0,0 +1,7 @@ +from PyQt5 import QtWidgets + +a = QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Ok # type: QtWidgets.QDialogButtonBox.StandardButtons +b = QtWidgets.QDialogButtonBox.Ok | 0 # type: int +c = a | 0 # type: QtWidgets.QDialogButtonBox.StandardButtons +d = a | QtWidgets.QDialogButtonBox.Ok # type: QtWidgets.QDialogButtonBox.StandardButtons +e = a | a # type: QtWidgets.QDialogButtonBox.StandardButtons From 8f1d77fd59e21c221b69d30bc36696827d82c508 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 19 Apr 2021 14:33:23 +0200 Subject: [PATCH 014/421] Fix CI: overload not needed, breaking Liskov is OK here Breaking Liskov subsitution is OK because that's what PyQt5 does --- PyQt5-stubs/QtCore.pyi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 1eda3616..c97253d6 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2378,10 +2378,8 @@ class Qt(sip.simplewrapper): class WindowType(int): def __init__(self, f: typing.Union['Qt.WindowType', int]) -> None: ... def __int__(self) -> int: ... - @typing.overload - def __or__ (self, other: 'Qt.WindowType') -> 'Qt.WindowFlags': ... - @typing.overload - def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... + def __or__ (self, other: 'Qt.WindowType') -> 'Qt.WindowFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[override] Widget = ... # type: Qt.WindowType Window = ... # type: Qt.WindowType From 64d3934cd674788570da90b306109e3021a57f50 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 19 Apr 2021 21:00:35 +0200 Subject: [PATCH 015/421] Fix CI --- PyQt5-stubs/QtCore.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index c97253d6..ea90cdac 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2379,7 +2379,7 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.WindowType', int]) -> None: ... def __int__(self) -> int: ... def __or__ (self, other: 'Qt.WindowType') -> 'Qt.WindowFlags': ... # type: ignore[override] - def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[override, misc] Widget = ... # type: Qt.WindowType Window = ... # type: Qt.WindowType From 77af90296486ddd8411c1339f608c810fdfc5e1c Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 19 Apr 2021 21:08:13 +0200 Subject: [PATCH 016/421] Make stubtest happy: there is no need for a __init__ method on int subclass --- tests/windowflags.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/windowflags.py b/tests/windowflags.py index d017e89e..558d5e90 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -61,6 +61,7 @@ def test_on_windowtype() -> None: # correct way to do it windowTypeTest = QtCore.Qt.WindowType(33) + windowTypeTest = QtCore.Qt.WindowType(windowType1) # The rules of WindowType conversion defined in PyQt5 are: # 1. | ~= with WindowType return a WindowFlags (which is not compatible to int) From e277af30c4f480fc574be43c9d1bf4f9f55daa68 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 19 Apr 2021 21:54:40 +0200 Subject: [PATCH 017/421] Fix CI: functions are not needed --- PyQt5-stubs/QtCore.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index ea90cdac..c01aabf8 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2376,8 +2376,6 @@ class Qt(sip.simplewrapper): WindowActive = ... # type: Qt.WindowState class WindowType(int): - def __init__(self, f: typing.Union['Qt.WindowType', int]) -> None: ... - def __int__(self) -> int: ... def __or__ (self, other: 'Qt.WindowType') -> 'Qt.WindowFlags': ... # type: ignore[override] def __ror__ (self, other: int) -> 'Qt.WindowFlags': ... # type: ignore[override, misc] From 8a93e155532f5687b719b3a109ba519479ffcb87 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 19 Apr 2021 22:50:33 +0200 Subject: [PATCH 018/421] Make mypy happy --- tests/windowflags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/windowflags.py b/tests/windowflags.py index 558d5e90..a11a282d 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -1,5 +1,5 @@ from typing import Union -import pytest # type: ignore[import] +import pytest from PyQt5 import QtCore, QtWidgets #########################################################3 From 5d76dde1a88f7c1aad26bcfbf3a55c4c6b3be7fd Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 20 Apr 2021 10:57:50 +0200 Subject: [PATCH 019/421] work in progress on making windowFlags test generic --- tests/windowflags.py | 200 +++++++++++++++++++------------------------ 1 file changed, 89 insertions(+), 111 deletions(-) diff --git a/tests/windowflags.py b/tests/windowflags.py index a11a282d..6594f826 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -1,18 +1,17 @@ -from typing import Union -import pytest +from typing import Union, TypeVar, Type +import pytest # type: ignore from PyQt5 import QtCore, QtWidgets -#########################################################3 -# -# The original problem -# -#########################################################3 +OneFlagClass = QtCore.Qt.WindowType +MultiFlagClass = QtCore.Qt.WindowFlags -def test_original_problem() -> None: - app = QtWidgets.QApplication([]) +oneFlagRefValue1 = QtCore.Qt.WindowContextHelpButtonHint +oneFlagRefValue2 = QtCore.Qt.WindowMaximizeButtonHint - w = QtWidgets.QWidget() - w.setWindowFlags(w.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type #########################################################3 @@ -21,34 +20,19 @@ def test_original_problem() -> None: # #########################################################3 -def assert_type_windowType(value: QtCore.Qt.WindowType) -> None: - '''This validates both with mypy and regular python the actual type of the value''' - assert type(value) == QtCore.Qt.WindowType - - -def assert_type_int(value: int) -> None: - assert type(value) == int - - -def assert_type_windowFlags(value: QtCore.Qt.WindowFlags) -> None: - '''This validates both with mypy and regular python the actual type of the value''' - assert type(value) == QtCore.Qt.WindowFlags - - -def test_on_windowtype() -> None: - windowType1 = QtCore.Qt.WindowContextHelpButtonHint - windowType2 = QtCore.Qt.WindowMaximizeButtonHint +def test_on_one_flag_class() -> None: + windowType1 = oneFlagRefValue1 + windowType2 = oneFlagRefValue2 windowTypeTest = windowType1 # type: QtCore.Qt.WindowType intValue = 0 # type: int - windowFlagsTest = QtCore.Qt.WindowFlags() windowFlagsOrTypeTest = windowType1 # type: Union[QtCore.Qt.WindowType, QtCore.Qt.WindowFlags] windowTypeOrInt = windowType1 # type: Union[int, QtCore.Qt.WindowType] - assert_type_windowType(windowType1) - assert_type_windowType(windowType2) - assert_type_windowType(windowTypeTest) - assert_type_windowFlags(windowFlagsTest) - assert_type_int(intValue) + assert_type_of_value(OneFlagClass, windowType1) + assert_type_of_value(OneFlagClass, windowType2) + assert_type_of_value(OneFlagClass, windowTypeTest) + assert_type_of_value(int, intValue) + # upcast from WindowType to int intValue = windowType1 @@ -60,8 +44,8 @@ def test_on_windowtype() -> None: windowTypeTest = 33 # type: ignore # correct way to do it - windowTypeTest = QtCore.Qt.WindowType(33) - windowTypeTest = QtCore.Qt.WindowType(windowType1) + windowTypeTest = OneFlagClass(33) + windowTypeTest = OneFlagClass(windowType1) # The rules of WindowType conversion defined in PyQt5 are: # 1. | ~= with WindowType return a WindowFlags (which is not compatible to int) @@ -69,98 +53,92 @@ def test_on_windowtype() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_windowFlags(windowType1 | windowType2) - assert_type_int(~windowType1) - assert_type_int(windowType1 & windowType2) - assert_type_int(windowType1 ^ windowType2) + assert_type_of_value(MultiFlagClass, windowType1 | windowType2) + assert_type_of_value(int, ~windowType1) + assert_type_of_value(int, windowType1 & windowType2) + assert_type_of_value(int, windowType1 ^ windowType2) # right operand - assert_type_int(windowType1 | 33) - assert_type_int(windowType1 & 33) - assert_type_int(windowType1 ^ 33) - assert_type_int(windowType1 + 33) - assert_type_int(windowType1 - 33) + assert_type_of_value(int, windowType1 | 33) + assert_type_of_value(int, windowType1 & 33) + assert_type_of_value(int, windowType1 ^ 33) + assert_type_of_value(int, windowType1 + 33) + assert_type_of_value(int, windowType1 - 33) # left operand - assert_type_windowFlags(33 | windowType1) - assert_type_int(33 & windowType1) - assert_type_int(33 ^ windowType1) - assert_type_int(33 + windowType1) - assert_type_int(33 - windowType1) + assert_type_of_value(MultiFlagClass, 33 | windowType1) + assert_type_of_value(int, 33 & windowType1) + assert_type_of_value(int, 33 ^ windowType1) + assert_type_of_value(int, 33 + windowType1) + assert_type_of_value(int, 33 - windowType1) windowFlagsOrTypeTest = windowType1 # reset type and value - assert_type_windowType(windowFlagsOrTypeTest) + assert_type_of_value(OneFlagClass, windowFlagsOrTypeTest) windowFlagsOrTypeTest |= windowType2 - assert_type_windowFlags(windowFlagsOrTypeTest) # nice violation of Liskov here + assert_type_of_value(MultiFlagClass, windowFlagsOrTypeTest) # nice violation of Liskov here windowTypeOrInt = windowType1 # reset type and value - assert_type_windowType(windowTypeOrInt) + assert_type_of_value(OneFlagClass, windowTypeOrInt) windowTypeOrInt |= 33 - assert_type_int(windowTypeOrInt) + assert_type_of_value(int, windowTypeOrInt) windowTypeOrInt = windowType1 # reset type and value - assert_type_windowType(windowTypeOrInt) + assert_type_of_value(OneFlagClass, windowTypeOrInt) windowTypeOrInt &= 33 - assert_type_int(windowTypeOrInt) + assert_type_of_value(int, windowTypeOrInt) windowTypeOrInt = windowType1 # reset type and value - assert_type_windowType(windowTypeOrInt) + assert_type_of_value(OneFlagClass, windowTypeOrInt) windowTypeOrInt &= windowType2 - assert_type_int(windowTypeOrInt) + assert_type_of_value(int, windowTypeOrInt) windowTypeOrInt = windowType1 # reset type and value - assert_type_windowType(windowTypeOrInt) + assert_type_of_value(OneFlagClass, windowTypeOrInt) windowTypeOrInt ^= 33 - assert_type_int(windowTypeOrInt) + assert_type_of_value(int, windowTypeOrInt) windowTypeOrInt = windowType1 # reset type and value - assert_type_windowType(windowTypeOrInt) + assert_type_of_value(OneFlagClass, windowTypeOrInt) windowTypeOrInt ^= windowType2 - assert_type_int(windowTypeOrInt) - + assert_type_of_value(int, windowTypeOrInt) -#########################################################3 -# -# tests on WindowFlags -# -#########################################################3 -def test_on_window_flags() -> None: - windowType1 = QtCore.Qt.WindowContextHelpButtonHint - windowFlags1 = QtCore.Qt.WindowFlags() - windowFlags2 = QtCore.Qt.WindowFlags() - windowFlagsTest = windowFlags1 # type: QtCore.Qt.WindowFlags +def test_on_multi_flag_class() -> None: + windowType1 = oneFlagRefValue1 + windowFlags1 = MultiFlagClass() + windowFlags2 = MultiFlagClass() + windowFlagsTest = windowFlags1 # type: MultiFlagClass intValue = 0 - assert_type_windowType(windowType1) - assert_type_windowFlags(windowFlags1) - assert_type_windowFlags(windowFlags2) - assert_type_windowFlags(windowFlagsTest) - assert_type_int(intValue) + assert_type_of_value(OneFlagClass, windowType1) + assert_type_of_value(MultiFlagClass, windowFlags1) + assert_type_of_value(MultiFlagClass, windowFlags2) + assert_type_of_value(MultiFlagClass, windowFlagsTest) + assert_type_of_value(int, intValue) # window flags may be created by combining windowFlags together - assert_type_windowFlags( ~windowFlags1 ) - assert_type_windowFlags( windowFlags1 | windowFlags2 ) - assert_type_windowFlags( windowFlags1 & windowFlags2 ) - assert_type_windowFlags( windowFlags1 ^ windowFlags2 ) + assert_type_of_value(MultiFlagClass, ~windowFlags1 ) + assert_type_of_value(MultiFlagClass, windowFlags1 | windowFlags2 ) + assert_type_of_value(MultiFlagClass, windowFlags1 & windowFlags2 ) + assert_type_of_value(MultiFlagClass, windowFlags1 ^ windowFlags2 ) # window flags may be created by combining windowFlags and windowType, left or right - assert_type_windowFlags( windowFlags1 | windowType1 ) - assert_type_windowFlags( windowFlags1 & windowType1 ) - assert_type_windowFlags( windowFlags1 ^ windowType1 ) + assert_type_of_value(MultiFlagClass, windowFlags1 | windowType1 ) + assert_type_of_value(MultiFlagClass, windowFlags1 & windowType1 ) + assert_type_of_value(MultiFlagClass, windowFlags1 ^ windowType1 ) - assert_type_windowFlags( windowType1 | windowFlags1 ) - assert_type_windowFlags( windowType1 & windowFlags1 ) - assert_type_windowFlags( windowType1 ^ windowFlags1 ) + assert_type_of_value(MultiFlagClass, windowType1 | windowFlags1 ) + assert_type_of_value(MultiFlagClass, windowType1 & windowFlags1 ) + assert_type_of_value(MultiFlagClass, windowType1 ^ windowFlags1 ) # window flags may be created by combining windowFlags and int, right only - assert_type_windowFlags(windowFlags1 | 33) - assert_type_windowFlags(windowFlags1 & 33) - assert_type_windowFlags(windowFlags1 ^ 33) + assert_type_of_value(MultiFlagClass, windowFlags1 | 33) + assert_type_of_value(MultiFlagClass, windowFlags1 & 33) + assert_type_of_value(MultiFlagClass, windowFlags1 ^ 33) # this is rejected by mypy and is slightly annoying: you can not pass a WindowType variable to a method expecting a WindowFlags @@ -168,47 +146,47 @@ def test_on_window_flags() -> None: windowFlagsTest = windowType1 # type: ignore # correct way to do it - windowFlagsTest = QtCore.Qt.WindowFlags(windowType1) - assert_type_windowFlags(windowFlagsTest) + windowFlagsTest = MultiFlagClass(windowType1) + assert_type_of_value(MultiFlagClass, windowFlagsTest) # this is rejected for the same reason as for windowType. intValue = windowFlagsTest # type: ignore # correct way to do it intValue = int(windowFlagsTest) - assert_type_int(intValue) + assert_type_of_value(int, intValue) # rejected by mypy rightfully windowFlagsTest = 33 # type: ignore # correct way to do it - windowFlagsTest = QtCore.Qt.WindowFlags(33) + windowFlagsTest = MultiFlagClass(33) # assignments operations with WindowType - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) windowFlagsTest |= windowType1 - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) windowFlagsTest &= windowType1 - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) windowFlagsTest ^= windowType1 - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) # assignments operations with int - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) windowFlagsTest |= 33 - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) windowFlagsTest &= 33 - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) windowFlagsTest ^= 33 - assert_type_windowFlags(windowFlagsTest) + assert_type_of_value(MultiFlagClass, windowFlagsTest) #########################################################3 # @@ -236,16 +214,16 @@ def test_on_window_flags() -> None: pytest.raises(TypeError, lambda: 33 - windowFlags1) # type: ignore[operator] def f1() -> None: - windowFlagsTest = QtCore.Qt.WindowFlags() + windowFlagsTest = MultiFlagClass() windowFlagsTest += windowType1 # type: ignore[assignment, operator] def f2() -> None: - windowFlagsTest = QtCore.Qt.WindowFlags() + windowFlagsTest = MultiFlagClass() windowFlagsTest += 33 # type: ignore[assignment, operator] def f3() -> None: - windowFlagsTest = QtCore.Qt.WindowFlags() + windowFlagsTest = MultiFlagClass() windowFlagsTest -= windowType1 # type: ignore[assignment, operator] def f4() -> None: - windowFlagsTest = QtCore.Qt.WindowFlags() + windowFlagsTest = MultiFlagClass() windowFlagsTest -= 33 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) From 38d86c3990fae3b22256bbecd364e721f042ccfe Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 20 Apr 2021 11:16:42 +0200 Subject: [PATCH 020/421] Make test completely generic --- tests/windowflags.py | 272 +++++++++++++++++++++---------------------- 1 file changed, 133 insertions(+), 139 deletions(-) diff --git a/tests/windowflags.py b/tests/windowflags.py index 6594f826..07f5ea63 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -14,179 +14,173 @@ def assert_type_of_value(expected_type: Type[T], value: T) -> None: assert type(value) == expected_type -#########################################################3 -# -# tests on WindowType -# -#########################################################3 - def test_on_one_flag_class() -> None: - windowType1 = oneFlagRefValue1 - windowType2 = oneFlagRefValue2 - windowTypeTest = windowType1 # type: QtCore.Qt.WindowType + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass intValue = 0 # type: int - windowFlagsOrTypeTest = windowType1 # type: Union[QtCore.Qt.WindowType, QtCore.Qt.WindowFlags] - windowTypeOrInt = windowType1 # type: Union[int, QtCore.Qt.WindowType] + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, windowType1) - assert_type_of_value(OneFlagClass, windowType2) - assert_type_of_value(OneFlagClass, windowTypeTest) + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) assert_type_of_value(int, intValue) - # upcast from WindowType to int - intValue = windowType1 + # upcast from OneFlagClass to int + intValue = oneFlagValue1 # conversion also accepted - intValue = int(windowType1) + intValue = int(oneFlagValue1) - # this is not supported for a good reason - windowTypeTest = 33 # type: ignore + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore # correct way to do it - windowTypeTest = OneFlagClass(33) - windowTypeTest = OneFlagClass(windowType1) + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) - # The rules of WindowType conversion defined in PyQt5 are: - # 1. | ~= with WindowType return a WindowFlags (which is not compatible to int) + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) # Note that this breaks Liskov principle # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, windowType1 | windowType2) - assert_type_of_value(int, ~windowType1) - assert_type_of_value(int, windowType1 & windowType2) - assert_type_of_value(int, windowType1 ^ windowType2) + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, windowType1 | 33) - assert_type_of_value(int, windowType1 & 33) - assert_type_of_value(int, windowType1 ^ 33) - assert_type_of_value(int, windowType1 + 33) - assert_type_of_value(int, windowType1 - 33) + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) # left operand - assert_type_of_value(MultiFlagClass, 33 | windowType1) - assert_type_of_value(int, 33 & windowType1) - assert_type_of_value(int, 33 ^ windowType1) - assert_type_of_value(int, 33 + windowType1) - assert_type_of_value(int, 33 - windowType1) + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) - windowFlagsOrTypeTest = windowType1 # reset type and value - assert_type_of_value(OneFlagClass, windowFlagsOrTypeTest) - windowFlagsOrTypeTest |= windowType2 - assert_type_of_value(MultiFlagClass, windowFlagsOrTypeTest) # nice violation of Liskov here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - windowTypeOrInt = windowType1 # reset type and value - assert_type_of_value(OneFlagClass, windowTypeOrInt) - windowTypeOrInt |= 33 - assert_type_of_value(int, windowTypeOrInt) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) - windowTypeOrInt = windowType1 # reset type and value - assert_type_of_value(OneFlagClass, windowTypeOrInt) - windowTypeOrInt &= 33 - assert_type_of_value(int, windowTypeOrInt) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) - windowTypeOrInt = windowType1 # reset type and value - assert_type_of_value(OneFlagClass, windowTypeOrInt) - windowTypeOrInt &= windowType2 - assert_type_of_value(int, windowTypeOrInt) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) - windowTypeOrInt = windowType1 # reset type and value - assert_type_of_value(OneFlagClass, windowTypeOrInt) - windowTypeOrInt ^= 33 - assert_type_of_value(int, windowTypeOrInt) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) - windowTypeOrInt = windowType1 # reset type and value - assert_type_of_value(OneFlagClass, windowTypeOrInt) - windowTypeOrInt ^= windowType2 - assert_type_of_value(int, windowTypeOrInt) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) def test_on_multi_flag_class() -> None: - windowType1 = oneFlagRefValue1 - windowFlags1 = MultiFlagClass() - windowFlags2 = MultiFlagClass() - windowFlagsTest = windowFlags1 # type: MultiFlagClass + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, windowType1) - assert_type_of_value(MultiFlagClass, windowFlags1) - assert_type_of_value(MultiFlagClass, windowFlags2) - assert_type_of_value(MultiFlagClass, windowFlagsTest) + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) assert_type_of_value(int, intValue) - # window flags may be created by combining windowFlags together - assert_type_of_value(MultiFlagClass, ~windowFlags1 ) - assert_type_of_value(MultiFlagClass, windowFlags1 | windowFlags2 ) - assert_type_of_value(MultiFlagClass, windowFlags1 & windowFlags2 ) - assert_type_of_value(MultiFlagClass, windowFlags1 ^ windowFlags2 ) + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) - # window flags may be created by combining windowFlags and windowType, left or right - assert_type_of_value(MultiFlagClass, windowFlags1 | windowType1 ) - assert_type_of_value(MultiFlagClass, windowFlags1 & windowType1 ) - assert_type_of_value(MultiFlagClass, windowFlags1 ^ windowType1 ) + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, windowType1 | windowFlags1 ) - assert_type_of_value(MultiFlagClass, windowType1 & windowFlags1 ) - assert_type_of_value(MultiFlagClass, windowType1 ^ windowFlags1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) - # window flags may be created by combining windowFlags and int, right only - assert_type_of_value(MultiFlagClass, windowFlags1 | 33) - assert_type_of_value(MultiFlagClass, windowFlags1 & 33) - assert_type_of_value(MultiFlagClass, windowFlags1 ^ 33) + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) - # this is rejected by mypy and is slightly annoying: you can not pass a WindowType variable to a method expecting a WindowFlags - # explicit typing must be used on those methods to accept both WindowType and WindowFlags - windowFlagsTest = windowType1 # type: ignore + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore # correct way to do it - windowFlagsTest = MultiFlagClass(windowType1) - assert_type_of_value(MultiFlagClass, windowFlagsTest) + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) - # this is rejected for the same reason as for windowType. - intValue = windowFlagsTest # type: ignore + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore # correct way to do it - intValue = int(windowFlagsTest) + intValue = int(multiFlagValueTest) assert_type_of_value(int, intValue) # rejected by mypy rightfully - windowFlagsTest = 33 # type: ignore + multiFlagValueTest = 33 # type: ignore # correct way to do it - windowFlagsTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(33) - # assignments operations with WindowType - assert_type_of_value(MultiFlagClass, windowFlagsTest) - windowFlagsTest |= windowType1 - assert_type_of_value(MultiFlagClass, windowFlagsTest) + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(MultiFlagClass, windowFlagsTest) - windowFlagsTest &= windowType1 - assert_type_of_value(MultiFlagClass, windowFlagsTest) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(MultiFlagClass, windowFlagsTest) - windowFlagsTest ^= windowType1 - assert_type_of_value(MultiFlagClass, windowFlagsTest) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, windowFlagsTest) - windowFlagsTest |= 33 - assert_type_of_value(MultiFlagClass, windowFlagsTest) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(MultiFlagClass, windowFlagsTest) - windowFlagsTest &= 33 - assert_type_of_value(MultiFlagClass, windowFlagsTest) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(MultiFlagClass, windowFlagsTest) - windowFlagsTest ^= 33 - assert_type_of_value(MultiFlagClass, windowFlagsTest) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) #########################################################3 # @@ -195,36 +189,36 @@ def test_on_multi_flag_class() -> None: #########################################################3 # This checks the following: - # + and - operations are not supported on windowFlags - # combining int with windowFlags does not work - - pytest.raises(TypeError, lambda: 33 | windowFlags1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & windowFlags1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ windowFlags1 ) # type: ignore[operator] - - pytest.raises(TypeError, lambda: windowFlags1 + windowFlags2 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: windowFlags1 - windowFlags2 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: windowFlags1 + windowType1) # type: ignore[operator] - pytest.raises(TypeError, lambda: windowFlags1 - windowType1) # type: ignore[operator] - pytest.raises(TypeError, lambda: windowFlags1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: windowFlags1 - 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: windowType1 + windowFlags1) # type: ignore[operator] - pytest.raises(TypeError, lambda: windowType1 - windowFlags1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + windowFlags1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - windowFlags1) # type: ignore[operator] + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] def f1() -> None: - windowFlagsTest = MultiFlagClass() - windowFlagsTest += windowType1 # type: ignore[assignment, operator] + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: - windowFlagsTest = MultiFlagClass() - windowFlagsTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] def f3() -> None: - windowFlagsTest = MultiFlagClass() - windowFlagsTest -= windowType1 # type: ignore[assignment, operator] + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: - windowFlagsTest = MultiFlagClass() - windowFlagsTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) From 891f062c8ec8263594d7f8fc47aad8e6a81b8af1 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 20 Apr 2021 11:17:06 +0200 Subject: [PATCH 021/421] Add tests and fixes for Alignment flags --- PyQt5-stubs/QtCore.pyi | 11 +- tests/alignmentflags.py | 227 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 tests/alignmentflags.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index c01aabf8..74ce497c 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2492,6 +2492,9 @@ class Qt(sip.simplewrapper): TextJustificationForced = ... # type: Qt.TextFlag class AlignmentFlag(int): + def __or__ (self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignment': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.Alignment': ... # type: ignore[override, misc] + AlignLeft = ... # type: Qt.AlignmentFlag AlignLeading = ... # type: Qt.AlignmentFlag AlignRight = ... # type: Qt.AlignmentFlag @@ -2749,7 +2752,7 @@ class Qt(sip.simplewrapper): @typing.overload def __init__(self) -> None: ... @typing.overload - def __init__(self, f: typing.Union['Qt.Alignment', 'Qt.AlignmentFlag']) -> None: ... + def __init__(self, f: typing.Union['Qt.Alignment', 'Qt.AlignmentFlag', int]) -> None: ... @typing.overload def __init__(self, a0: 'Qt.Alignment') -> None: ... @@ -2758,6 +2761,12 @@ class Qt(sip.simplewrapper): def __invert__(self) -> 'Qt.Alignment': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.Alignemtn', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignemtn': ... + def __and__(self, other: typing.Union['Qt.Alignemtn', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignemtn': ... + def __xor__(self, other: typing.Union['Qt.Alignemtn', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignemtn': ... + def __ror__ (self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignemtn': ... + def __rand__(self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignemtn': ... + def __rxor__(self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignemtn': ... class WindowFlags(sip.simplewrapper): diff --git a/tests/alignmentflags.py b/tests/alignmentflags.py new file mode 100644 index 00000000..a627fda1 --- /dev/null +++ b/tests/alignmentflags.py @@ -0,0 +1,227 @@ +from typing import Union, TypeVar, Type +import pytest # type: ignore +from PyQt5 import QtCore, QtWidgets + +OneFlagClass = QtCore.Qt.AlignmentFlag +MultiFlagClass = QtCore.Qt.Alignment + +oneFlagRefValue1 = QtCore.Qt.AlignLeft +oneFlagRefValue2 = QtCore.Qt.AlignRight + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From dcc03686805daca5597b4e2802eee33951a7c2b3 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 20 Apr 2021 15:22:51 +0200 Subject: [PATCH 022/421] Generator for testing QFlag based classes --- tests/generate_qflags_tests.py | 69 +++++++++++++++++++ ...nmentflags.py => qflags_alignmentflags.py} | 4 ++ tests/windowflags.py | 5 ++ 3 files changed, 78 insertions(+) create mode 100644 tests/generate_qflags_tests.py rename tests/{alignmentflags.py => qflags_alignmentflags.py} (98%) diff --git a/tests/generate_qflags_tests.py b/tests/generate_qflags_tests.py new file mode 100644 index 00000000..d410ca78 --- /dev/null +++ b/tests/generate_qflags_tests.py @@ -0,0 +1,69 @@ +from typing import Tuple, List + +SOURCE = 'windowFlags.py' +MARKER_SPECIFIC_START = '### Specific part' +MARKER_SPECIFIC_END = '### End of specific part' + +# Content is: +# - name of the file to generate +# - name of the QFlags<> class +# - name of the individual flag class (inheriting from int) +# - one individual flag value +# - a second individual flag value +FLAGS_FILES = [ + ('qflags_alignmentflags.py', 'QtCore.Qt.Alignment', 'QtCore.Qt.AlignmentFlag', 'QtCore.Qt.AlignLeft', 'QtCore.Qt.AlignRight'), + +] + +# global values for simplicity of the code +sourcePart1, sourcePart2, sourcePart3 = [], [], [] # type: Tuple[List[str], List[str], List[str]] + +def generate_qflags_files() -> None: + global sourcePart1, sourcePart2, sourcePart3 + with open(SOURCE) as f: + lines = f.readlines() + + sourcePart1, sourcePart2, sourcePart3 = [], [], [] + fillPart2, fillPart3 = False, False + for l in lines: + if fillPart3: + sourcePart3.append(l) + continue + + if fillPart2: + if MARKER_SPECIFIC_END in l: + fillPart3 = True + sourcePart3.append(l) + continue + + sourcePart2.append(l) + continue + + sourcePart1.append(l) + if MARKER_SPECIFIC_START in l: + fillPart2 = True + + for qflag_info in FLAGS_FILES: + generate_one_qflag_file(*qflag_info) + + +def generate_one_qflag_file(qflag_fname: str, multiFlagName: str, oneFlagName: str, oneFlagValue1: str, oneFlagValue2: str) -> None: + with open(qflag_fname, 'w') as f: + f.writelines(sourcePart1) + f.write('''# file generated from {source} for QFlags class "{multiFlagName}" and flag class "{oneFlagName}" + +OneFlagClass = {oneFlagName} +MultiFlagClass = {multiFlagName} + +oneFlagRefValue1 = {oneFlagValue1} +oneFlagRefValue2 = {oneFlagValue2} +'''.format(source=SOURCE, multiFlagName=multiFlagName, oneFlagName=oneFlagName, + oneFlagValue1=oneFlagValue1, oneFlagValue2=oneFlagValue2 + )) + f.writelines(sourcePart3) + print('File %s generated' % qflag_fname) + + +if __name__ == '__main__': + generate_qflags_files() + diff --git a/tests/alignmentflags.py b/tests/qflags_alignmentflags.py similarity index 98% rename from tests/alignmentflags.py rename to tests/qflags_alignmentflags.py index a627fda1..423bc809 100644 --- a/tests/alignmentflags.py +++ b/tests/qflags_alignmentflags.py @@ -2,11 +2,15 @@ import pytest # type: ignore from PyQt5 import QtCore, QtWidgets +### Specific part +# file generated from windowFlags.py for QFlags class "QtCore.Qt.Alignment" and flag class "QtCore.Qt.AlignmentFlag" + OneFlagClass = QtCore.Qt.AlignmentFlag MultiFlagClass = QtCore.Qt.Alignment oneFlagRefValue1 = QtCore.Qt.AlignLeft oneFlagRefValue2 = QtCore.Qt.AlignRight +### End of specific part T = TypeVar('T') def assert_type_of_value(expected_type: Type[T], value: T) -> None: diff --git a/tests/windowflags.py b/tests/windowflags.py index 07f5ea63..27065161 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -2,11 +2,16 @@ import pytest # type: ignore from PyQt5 import QtCore, QtWidgets +### Specific part +# This file is used as a source to generate all qflags related tests. The specific part +# changes for each test but the rest of the file is totally identical + OneFlagClass = QtCore.Qt.WindowType MultiFlagClass = QtCore.Qt.WindowFlags oneFlagRefValue1 = QtCore.Qt.WindowContextHelpButtonHint oneFlagRefValue2 = QtCore.Qt.WindowMaximizeButtonHint +### End of specific part T = TypeVar('T') def assert_type_of_value(expected_type: Type[T], value: T) -> None: From 3b1fb571ae4400723f3407622edee06b42fa5688 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 24 Apr 2021 15:28:39 +0200 Subject: [PATCH 023/421] concept of automating qflags validation --- tests/qflags/all-flags.txt | 228 ++++++++++++++++++++++++++++++++++ tests/qflags/asjust_qflags.py | 23 ++++ 2 files changed, 251 insertions(+) create mode 100644 tests/qflags/all-flags.txt create mode 100644 tests/qflags/asjust_qflags.py diff --git a/tests/qflags/all-flags.txt b/tests/qflags/all-flags.txt new file mode 100644 index 00000000..10a815a1 --- /dev/null +++ b/tests/qflags/all-flags.txt @@ -0,0 +1,228 @@ +qmake\library\qmakeevaluator.h: Q_DECLARE_FLAGS(LoadFlags, LoadFlag) +qmake\library\qmakeparser.h: Q_DECLARE_FLAGS(ParseFlags, ParseFlag) +qmake\library\qmakevfs.h: Q_DECLARE_FLAGS(VfsFlags, VfsFlag) +qmake\generators\makefile.h: Q_DECLARE_FLAGS(FileFixifyTypes, FileFixifyType) +src\concurrent\qtconcurrentreducekernel.h:Q_DECLARE_FLAGS(ReduceOptions, ReduceOption) +src\dbus\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption) +src\dbus\qdbusconnection.h: Q_DECLARE_FLAGS(VirtualObjectRegisterOptions, VirtualObjectRegisterOption) +src\dbus\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability) +src\opengl\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption) +src\opengl\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag) +src\opengl\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption) +src\opengl\qglfunctions.h: Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature) +src\opengl\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit) +src\dbus\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag) +examples\network\torrent\peerwireclient.h: Q_DECLARE_FLAGS(PeerWireState, PeerWireStateFlag) +src\corelib\codecs\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag) +src\corelib\codecs\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag) +src\gui\accessible\qaccessible.h: Q_DECLARE_FLAGS(Relation, RelationFlag) +src\corelib\io\qabstractfileengine_p.h: Q_DECLARE_FLAGS(FileFlags, FileFlag) +src\corelib\global\qflags.h:#define Q_DECLARE_FLAGS(Flags, Enum)\ +src\corelib\global\qflags.h:#define Q_DECLARE_FLAGS(Flags, Enum)\ +src\corelib\itemmodels\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption) +src\corelib\io\qdir.h: Q_DECLARE_FLAGS(Filters, Filter) +src\corelib\io\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag) +src\corelib\io\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag) +src\corelib\io\qdir_p.h: Q_DECLARE_FLAGS(PathNormalizations, PathNormalization) +src\corelib\io\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission) +src\corelib\io\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag) +src\corelib\itemmodels\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(SplitBehavior, SplitBehaviorFlags) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag) +src\corelib\io\qfilesystemmetadata_p.h: Q_DECLARE_FLAGS(MetaDataFlags, MetaDataFlag) +src\gui\image\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation) +src\gui\image\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability) +src\corelib\kernel\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag) +src\corelib\io\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag) +src\gui\kernel\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag) +src\corelib\io\qloggingregistry_p.h: Q_DECLARE_FLAGS(PatternFlags, PatternFlag) +src\corelib\plugin\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint) +src\gui\opengl\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag) +src\corelib\kernel\qmetaobjectbuilder_p.h: Q_DECLARE_FLAGS(AddMembers, AddMember) +src\corelib\kernel\qmetaobjectbuilder_p.h: Q_DECLARE_FLAGS(MetaObjectFlags, MetaObjectFlag) +src\gui\opengl\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source) +src\gui\opengl\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type) +src\gui\opengl\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity) +src\corelib\kernel\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag) +src\gui\opengl\qopenglextensions_p.h: Q_DECLARE_FLAGS(OpenGLExtensions, OpenGLExtension) +src\corelib\io\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption) +src\gui\opengl\qopenglfunctions.h: Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature) +src\corelib\kernel\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\corelib\kernel\qppsobject_p.h: Q_DECLARE_FLAGS(OpenModes, OpenMode) +src\gui\kernel\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability) +src\network\access\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag) +src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton) +src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption) +src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption) +src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FileDialogOptions, FileDialogOption) +src\gui\kernel\qplatformgraphicsbuffer.h: Q_DECLARE_FLAGS(AccessTypes, AccessType); +src\gui\painting\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability) +src\corelib\io\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption) +src\corelib\io\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption) +src\corelib\io\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption) +src\gui\painting\qcolortransform_p.h: Q_DECLARE_FLAGS(TransformFlags, TransformFlag) +src\gui\kernel\qplatformtheme.h: Q_DECLARE_FLAGS(IconOptions, IconOption) +src\network\bearer\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability) +src\network\bearer\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag) +src\gui\kernel\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption) +src\network\bearer\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy) +src\gui\painting\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag) +src\gui\painting\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature) +src\gui\painting\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag) +src\gui\kernel\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag) +src\gui\opengl\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit) +src\gui\opengl\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature) +src\gui\painting\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint) +src\gui\painting\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint) +src\gui\opengl\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption) +src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(DataFrameFlags, DataFrameFlag) +src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(ControlFrameFlags, ControlFrameFlag) +src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(SETTINGS_Flags, SETTINGS_Flag) +src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(SETTINGS_ID_Flags, SETTINGS_ID_Flag) +src\gui\painting\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\painting\qplatformbackingstore.h: Q_DECLARE_FLAGS(TextureFlags, TextureFlag) +src\gui\text\qfontengine_p.h: Q_DECLARE_FLAGS(ShaperFlags, ShaperFlag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(StageFlags, StageFlag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(UsageFlags, UsageFlag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(BeginFrameFlags, BeginFrameFlag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(EndFrameFlags, EndFrameFlag) +src\gui\rhi\qshaderdescription_p.h: Q_DECLARE_FLAGS(ImageFlags, ImageFlag) +src\gui\vulkan\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\util\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType) +src\gui\vulkan\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\text\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag) +src\gui\text\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag) +src\gui\text\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature) +src\gui\text\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag) +src\network\kernel\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag) +src\network\socket\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag) +src\network\socket\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode) +src\network\socket\qabstractsocketengine_p.h: Q_DECLARE_FLAGS(PacketHeaderOptions, PacketHeaderOption) +src\gui\text\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag) +src\network\socket\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption) +src\gui\text\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature) +src\network\kernel\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag) +src\gui\text\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag) +src\network\ssl\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption) +src\network\kernel\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability) +src\corelib\text\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option) +src\corelib\text\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption) +src\corelib\text\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat) +src\corelib\serialization\qcborvalue.h: Q_DECLARE_FLAGS(EncodingOptions, EncodingOption) +src\corelib\serialization\qcborvalue.h: Q_DECLARE_FLAGS(DiagnosticNotationOptions, DiagnosticNotationOption) +src\corelib\serialization\qcborvalue_p.h: Q_DECLARE_FLAGS(ValueFlags, ValueFlag) +src\corelib\time\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section) +src\corelib\time\qdatetimeparser_p.h: Q_DECLARE_FLAGS(FieldInfo, FieldInfoFlag) +src\corelib\time\qdatetime_p.h: Q_DECLARE_FLAGS(StatusFlags, StatusFlag) +src\corelib\text\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption) +src\corelib\text\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption) +src\corelib\text\qstring.h: Q_DECLARE_FLAGS(SectionFlags, SectionFlag) +src\corelib\serialization\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag) +src\corelib\text\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason ) +src\corelib\text\qunicodetools_p.h:Q_DECLARE_FLAGS(CharAttributeOptions, CharAttributeOption) +src\corelib\tools\qarraydata.h: Q_DECLARE_FLAGS(AllocationOptions, AllocationOption) +src\corelib\tools\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag) +src\platformheaders\windowsfunctions\qwindowswindowfunctions.h: Q_DECLARE_FLAGS(TouchWindowTouchTypes, TouchWindowTouchType) +src\platformheaders\xcbfunctions\qxcbwindowfunctions.h: Q_DECLARE_FLAGS(WmWindowTypes, WmWindowType) +src\platformsupport\devicediscovery\qdevicediscovery_p.h: Q_DECLARE_FLAGS(QDeviceTypes, QDeviceType) +src\platformsupport\eglconvenience\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\platformsupport\fbconvenience\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\printsupport\dialogs\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption) +src\platformsupport\kmsconvenience\qkmsdevice_p.h: Q_DECLARE_FLAGS(Rotations, Rotation) +src\sql\kernel\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag) +src\widgets\dialogs\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption) +src\tools\moc\token.h: F(Q_DECLARE_FLAGS_TOKEN) \ +src\widgets\dialogs\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option) +src\widgets\dialogs\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option) +src\widgets\dialogs\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption) +src\widgets\effects\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) +src\widgets\effects\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint) +src\widgets\dialogs\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption) +src\widgets\dialogs\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton) +src\widgets\dialogs\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption) +src\widgets\itemviews\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger) +src\widgets\graphicsview\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag) +src\widgets\itemviews\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option) +src\widgets\kernel\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) +src\widgets\kernel\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag) +src\widgets\graphicsview\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer) +src\widgets\graphicsview\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag) +src\widgets\graphicsview\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag) +src\widgets\kernel\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType) +src\widgets\itemviews\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag) +src\widgets\kernel\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag) +src\widgets\kernel\qwidget_p.h: Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag) +src\widgets\styles\qdrawutil.h: Q_DECLARE_FLAGS(DrawingHints, DrawingHint) +src\widgets\styles\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag) +src\widgets\styles\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl) +src\widgets\widgets\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature) +src\widgets\widgets\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton) +src\widgets\widgets\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature) +src\widgets\widgets\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter) +src\widgets\widgets\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section) +src\widgets\widgets\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption) +src\widgets\widgets\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption) +src\widgets\widgets\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption) +tests\manual\diaglib\eventfilter.h: Q_DECLARE_FLAGS(EventCategories, EventCategory) +tests\manual\diaglib\eventfilter.h: Q_DECLARE_FLAGS(ObjectTypes, ObjectType) +src\widgets\widgets\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag) +tests\manual\diaglib\qwindowdump.h:Q_DECLARE_FLAGS(FormatWindowOptions, FormatWindowOption) +src\network\access\http2\http2protocol_p.h:Q_DECLARE_FLAGS(FrameFlags, FrameFlag) +src\plugins\bearer\networkmanager\qnetworkmanagerservice.h: Q_DECLARE_FLAGS(ApFlags, ApFlag) +src\plugins\bearer\networkmanager\qnetworkmanagerservice.h: Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag) +src\plugins\bearer\networkmanager\qnetworkmanagerservice.h: Q_DECLARE_FLAGS(ModemCapabilities, ModemCapability) +src\plugins\platforms\android\qandroidinputcontext.h: Q_DECLARE_FLAGS(HandleModes, HandleMode) +src\plugins\platforms\direct2d\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag) +src\plugins\platforms\cocoa\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option) +src\plugins\platforms\wasm\qwasmcompositor.h: Q_DECLARE_FLAGS(SubControls, QWasmSubControl) +src\plugins\platforms\wasm\qwasmcompositor.h: Q_DECLARE_FLAGS(StateFlags, QWasmStateFlag) +src\plugins\platforms\cocoa\qcocoawindow.h: Q_DECLARE_FLAGS(RecreationReasons, RecreationReason) +src\plugins\platforms\qnx\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option) +src\plugins\platforms\xcb\qxcbeventqueue.h: Q_DECLARE_FLAGS(PeekOptions, PeekOption) +src\plugins\platforms\windows\qwindowsopengltester.h: Q_DECLARE_FLAGS(Renderers, Renderer) +src\plugins\platforms\xcb\qxcbwindow.h: Q_DECLARE_FLAGS(NetWmStates, NetWmState) +tests\auto\other\macgui\guitest.h: Q_DECLARE_FLAGS(Directions, Direction) +tests\auto\tools\moc\cxx11-enums.h: Q_DECLARE_FLAGS(ClassFlags, ClassFlag) +tests\auto\tools\moc\cxx11-enums.h: Q_DECLARE_FLAGS(StructFlags, StructFlag) +tests\auto\tools\moc\cxx11-enums.h: Q_DECLARE_FLAGS(ClassFlags, ClassFlag) +tests\auto\tools\moc\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag ) +src\plugins\platforms\eglfs\api\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag) +tests\auto\corelib\tools\qsharedpointer\externaltests.h: Q_DECLARE_FLAGS(QtModules, QtModule) +tests\benchmarks\corelib\io\qdiriterator\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag) +tests\benchmarks\widgets\graphicsview\functional\GraphicsViewBenchmark\widgets\settings.h: Q_DECLARE_FLAGS(Options, Option) diff --git a/tests/qflags/asjust_qflags.py b/tests/qflags/asjust_qflags.py new file mode 100644 index 00000000..00f23810 --- /dev/null +++ b/tests/qflags/asjust_qflags.py @@ -0,0 +1,23 @@ + +# command-line to generate the file: all_qflags.txt +# qt-src\qt5\qtbase>rg --type-add "headers:*.h" -t headers Q_DECLARE_FLAGS --no-heading > all-flags.txt + +# parse all-qflags.txt +# -> identify QFlag class and enum +# -> identify attached module +# save the result + +# for each module/flag +# - generate a test file is not already present +# - run test file. If it fails, skip this flag +# - find where the class is located in the module +# - check if class is in raw form (not QFlag based yet) or already patched +# - if not patched +# - modify the code of the module with better implementation +# - generate a test file is not already present +# - run test file and mypy for the qflag class +# - if successful execution, commit it +# - if unsuccessful execution, revert the changes on the module +# repeat... +# +# analyse the result From 464f1d637911fa57152a5b8e852551afc75b9f6a Mon Sep 17 00:00:00 2001 From: Philippe FREMY Date: Sun, 25 Apr 2021 15:55:17 +0200 Subject: [PATCH 024/421] Sanitize input --- tests/qflags/all-flags.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/qflags/all-flags.txt b/tests/qflags/all-flags.txt index 10a815a1..e92d42a0 100644 --- a/tests/qflags/all-flags.txt +++ b/tests/qflags/all-flags.txt @@ -160,7 +160,6 @@ src\printsupport\dialogs\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogO src\platformsupport\kmsconvenience\qkmsdevice_p.h: Q_DECLARE_FLAGS(Rotations, Rotation) src\sql\kernel\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag) src\widgets\dialogs\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption) -src\tools\moc\token.h: F(Q_DECLARE_FLAGS_TOKEN) \ src\widgets\dialogs\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option) src\widgets\dialogs\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option) src\widgets\dialogs\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption) From 4c62110e0836977776970e14328158a83f120094 Mon Sep 17 00:00:00 2001 From: Philippe FREMY Date: Sun, 25 Apr 2021 15:56:07 +0200 Subject: [PATCH 025/421] Can associate a module with most QFlags --- tests/qflags/adjust_qflags.py | 104 ++++++++++++++++++++++++++++++++++ tests/qflags/asjust_qflags.py | 23 -------- 2 files changed, 104 insertions(+), 23 deletions(-) create mode 100644 tests/qflags/adjust_qflags.py delete mode 100644 tests/qflags/asjust_qflags.py diff --git a/tests/qflags/adjust_qflags.py b/tests/qflags/adjust_qflags.py new file mode 100644 index 00000000..11905154 --- /dev/null +++ b/tests/qflags/adjust_qflags.py @@ -0,0 +1,104 @@ +import pprint + +# command-line to generate the file: all_qflags.txt +# qt-src\qt5\qtbase>rg --type-add "headers:*.h" -t headers Q_DECLARE_FLAGS --no-heading > all-flags.txt +# note add something to make re at word-boundary +DECLARED_QFLAGS_FNAME = 'all-flags.txt' +QFLAG_SRC='src\\corelib\\global\\qflags.h' + +MODULES = [ + ['QtCore', '../../PyQt5-stubs/QtCore.pyi'], + ['QtWidgets', '../../PyQt5-stubs/QtWidgets.pyi'], + ['QtGui', '../../PyQt5-stubs/QtGui.pyi'], + ['QtNetwork', '../../PyQt5-stubs/QtNetwork.pyi'], + +] + +def parse_declared_qflags(fname: str) -> None: + parsed_qflags = [] # type: List[Tuple[str, str, str]] -> fname, qflags, enum + with open(fname) as f: + for l in f.readlines()[:]: + if len(l.strip()) == 0: + continue + qflag_fname, qflag_declare_stmt = [s.strip(' \t\n') for s in l.split(':')] + if qflag_fname == QFLAG_SRC: + # do not include actual implementation of qflags + continue + assert 'Q_DECLARE_FLAGS' in qflag_declare_stmt + print(qflag_declare_stmt) + s = qflag_declare_stmt[qflag_declare_stmt.index('(')+1:qflag_declare_stmt.index(')')] + qflag_class, enum_class = [v.strip(' ') for v in s.split(',')] + parsed_qflags.append((qflag_fname, qflag_class, enum_class, [])) + # print(qflag_fname) + # print('->', qflag_class, enum_class) + + # fill up modules with content + for mod_info in MODULES: + mod_name, mod_stub_path = mod_info + mod_info.append(open(mod_stub_path).read()) + + + for qflag_info in parsed_qflags: + qflag_fname, qflag_class, enum_class, qflag_modules = qflag_info + + decl_qflag_class = 'class %s(' % qflag_class + decl_enum_class = 'class %s(' % enum_class + for mod_name, mod_stub_path, mod_content in MODULES: + + if decl_qflag_class in mod_content and decl_enum_class in mod_content: + # we have found one module + print('Adding QFlags %s to module %s' % (qflag_class, mod_name)) + qflag_modules.append(mod_name) + + + qflags_with_one_module = [ qflag_info for qflag_info in parsed_qflags if len(qflag_info[-1]) == 1] + qflags_with_no_module = [ qflag_info for qflag_info in parsed_qflags if len(qflag_info[-1]) == 0] + qflags_with_many_module = [ qflag_info for qflag_info in parsed_qflags if len(qflag_info[-1]) > 1] + + qflags_with_one_module.sort(key=lambda v: (v[-1], v[1])) + qflags_with_no_module.sort(key=lambda v: (v[-1], v[1])) + qflags_with_many_module.sort(key=lambda v: (v[-1], v[1])) + + print('\nFlags idenfied with a module') + last_mod_name = '' + for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_one_module: + mod_name = qflag_modules[0] + if mod_name != last_mod_name: + print('\t%s:' % mod_name) + last_mod_name = mod_name + print('\t\t"%s" "%s" \t\t%s' % (qflag_class, enum_class, qflag_fname)) + + + print('\nqflags without module:') + for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_no_module: + print('\t\t"%s" "%s" \t\t%s []' % (qflag_class, enum_class, qflag_fname)) + + + print('\nqflags with many module:') + for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_many_module: + print('\t\t"%s" "%s" \t\t%s [%s]' % (qflag_class, enum_class, qflag_fname, ' '.join(qflag_modules))) + + + +# parse all-qflags.txt +# -> identify QFlag class and enum +# -> identify attached module +# save the result + +# for each module/flag +# - generate a test file is not already present +# - run test file. If it fails, skip this flag +# - find where the class is located in the module +# - check if class is in raw form (not QFlag based yet) or already patched +# - if not patched +# - modify the code of the module with better implementation +# - generate a test file is not already present +# - run test file and mypy for the qflag class +# - if successful execution, commit it +# - if unsuccessful execution, revert the changes on the module +# repeat... +# +# analyse the result + +if __name__ == '__main__': + parse_declared_qflags(DECLARED_QFLAGS_FNAME) \ No newline at end of file diff --git a/tests/qflags/asjust_qflags.py b/tests/qflags/asjust_qflags.py deleted file mode 100644 index 00f23810..00000000 --- a/tests/qflags/asjust_qflags.py +++ /dev/null @@ -1,23 +0,0 @@ - -# command-line to generate the file: all_qflags.txt -# qt-src\qt5\qtbase>rg --type-add "headers:*.h" -t headers Q_DECLARE_FLAGS --no-heading > all-flags.txt - -# parse all-qflags.txt -# -> identify QFlag class and enum -# -> identify attached module -# save the result - -# for each module/flag -# - generate a test file is not already present -# - run test file. If it fails, skip this flag -# - find where the class is located in the module -# - check if class is in raw form (not QFlag based yet) or already patched -# - if not patched -# - modify the code of the module with better implementation -# - generate a test file is not already present -# - run test file and mypy for the qflag class -# - if successful execution, commit it -# - if unsuccessful execution, revert the changes on the module -# repeat... -# -# analyse the result From 73ce85819c2b8b9f1b8142bd725d484d815e4ff6 Mon Sep 17 00:00:00 2001 From: Philippe FREMY Date: Tue, 27 Apr 2021 14:13:52 +0200 Subject: [PATCH 026/421] Look for qflags in all modules of qtbase --- tests/qflags/adjust_qflags.py | 69 +++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/tests/qflags/adjust_qflags.py b/tests/qflags/adjust_qflags.py index 11905154..2a7e0685 100644 --- a/tests/qflags/adjust_qflags.py +++ b/tests/qflags/adjust_qflags.py @@ -1,4 +1,4 @@ -import pprint +import pprint, collections # command-line to generate the file: all_qflags.txt # qt-src\qt5\qtbase>rg --type-add "headers:*.h" -t headers Q_DECLARE_FLAGS --no-heading > all-flags.txt @@ -11,7 +11,12 @@ ['QtWidgets', '../../PyQt5-stubs/QtWidgets.pyi'], ['QtGui', '../../PyQt5-stubs/QtGui.pyi'], ['QtNetwork', '../../PyQt5-stubs/QtNetwork.pyi'], - + ['QtDbus', '../../PyQt5-stubs/QtDbus.pyi'], + ['QtOpengl', '../../PyQt5-stubs/QtOpengl.pyi'], + ['QtPrintsupport', '../../PyQt5-stubs/QtPrintsupport.pyi'], + ['QtSql', '../../PyQt5-stubs/QtSql.pyi'], + ['QtTest', '../../PyQt5-stubs/QtTest.pyi'], + ['QtXml', '../../PyQt5-stubs/QtXml.pyi'], ] def parse_declared_qflags(fname: str) -> None: @@ -37,6 +42,7 @@ def parse_declared_qflags(fname: str) -> None: mod_name, mod_stub_path = mod_info mod_info.append(open(mod_stub_path).read()) + mod_qflags = collections.defaultdict(lambda: collections.defaultdict(int)) for qflag_info in parsed_qflags: qflag_fname, qflag_class, enum_class, qflag_modules = qflag_info @@ -49,41 +55,56 @@ def parse_declared_qflags(fname: str) -> None: # we have found one module print('Adding QFlags %s to module %s' % (qflag_class, mod_name)) qflag_modules.append(mod_name) + mod_qflags[mod_name][qflag_class] += 1 - qflags_with_one_module = [ qflag_info for qflag_info in parsed_qflags if len(qflag_info[-1]) == 1] + qflags_with_one_module_single = [ qflag_info for qflag_info in parsed_qflags + if (len(qflag_info[-1]) == 1) and (mod_qflags[qflag_info[-1][0]][qflag_info[1]] == 1) ] + qflags_with_one_module_multiple = [ qflag_info for qflag_info in parsed_qflags + if (len(qflag_info[-1]) == 1) and (mod_qflags[qflag_info[-1][0]][qflag_info[1]] != 1) ] qflags_with_no_module = [ qflag_info for qflag_info in parsed_qflags if len(qflag_info[-1]) == 0] qflags_with_many_module = [ qflag_info for qflag_info in parsed_qflags if len(qflag_info[-1]) > 1] - qflags_with_one_module.sort(key=lambda v: (v[-1], v[1])) + qflags_with_one_module_single.sort(key=lambda v: (v[-1], v[1])) + qflags_with_one_module_multiple.sort(key=lambda v: (v[-1], v[1])) qflags_with_no_module.sort(key=lambda v: (v[-1], v[1])) qflags_with_many_module.sort(key=lambda v: (v[-1], v[1])) - print('\nFlags idenfied with a module') - last_mod_name = '' - for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_one_module: - mod_name = qflag_modules[0] - if mod_name != last_mod_name: - print('\t%s:' % mod_name) - last_mod_name = mod_name - print('\t\t"%s" "%s" \t\t%s' % (qflag_class, enum_class, qflag_fname)) + DISP_RESULTS = True + if DISP_RESULTS: + print('\nFlags identified with one module, unique in the module') + last_mod_name = '' + for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_one_module_single: + mod_name = qflag_modules[0] + if mod_name != last_mod_name: + print('\t%s:' % mod_name) + last_mod_name = mod_name + print('\t\t"%s" "%s" \t\t%s' % (qflag_class, enum_class, qflag_fname)) + + + print('\nFlags identified with one module, multiples in the module') + last_mod_name = '' + for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_one_module_multiple: + mod_name = qflag_modules[0] + if mod_name != last_mod_name: + print('\t%s:' % mod_name) + last_mod_name = mod_name + print('\t\t"%s" "%s" \t\t%s' % (qflag_class, enum_class, qflag_fname)) - print('\nqflags without module:') - for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_no_module: - print('\t\t"%s" "%s" \t\t%s []' % (qflag_class, enum_class, qflag_fname)) + print('\nqflags without module:') + for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_no_module: + print('\t\t"%s" "%s" \t\t%s []' % (qflag_class, enum_class, qflag_fname)) - print('\nqflags with many module:') - for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_many_module: - print('\t\t"%s" "%s" \t\t%s [%s]' % (qflag_class, enum_class, qflag_fname, ' '.join(qflag_modules))) + print('\nqflags with many module:') + for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_many_module: + print('\t\t"%s" "%s" \t\t%s [%s]' % (qflag_class, enum_class, qflag_fname, ' '.join(qflag_modules))) + return qflags_with_one_module_single -# parse all-qflags.txt -# -> identify QFlag class and enum -# -> identify attached module -# save the result +# TODO: # for each module/flag # - generate a test file is not already present @@ -101,4 +122,6 @@ def parse_declared_qflags(fname: str) -> None: # analyse the result if __name__ == '__main__': - parse_declared_qflags(DECLARED_QFLAGS_FNAME) \ No newline at end of file + qflags_with_module = parse_declared_qflags(DECLARED_QFLAGS_FNAME) + for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_module: + generate_test_file(qflag_class, enum_class, qflag_fname) From e66b83826dc7d8e9106303398c02161ddbcd7714 Mon Sep 17 00:00:00 2001 From: PowerSnail Date: Mon, 7 Jun 2021 17:02:08 -0700 Subject: [PATCH 027/421] add operators to QSize and QSizeF --- PyQt5-stubs/QtCore.pyi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 5a53e997..f4f0b244 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -10356,6 +10356,15 @@ class QSize(sip.simplewrapper): @typing.overload def __init__(self, a0: 'QSize') -> None: ... + def __add__(self, value: 'QSize') -> 'QSize': ... + def __eq__(self, value: 'QSize') -> 'QSize': ... + def __iadd__(self, value: 'QSize') -> 'QSize': ... + def __imul__(self, value: float) -> 'QSize': ... + def __isub__(self, value: 'QSize') -> 'QSize': ... + def __mul__(self, value: float) -> 'QSize': ... + def __ne__(self, value: 'QSize') -> 'QSize': ... + def __sub__(self, value: 'QSize') -> 'QSize': ... + def shrunkBy(self, m: QMargins) -> 'QSize': ... def grownBy(self, m: QMargins) -> 'QSize': ... def transposed(self) -> 'QSize': ... @@ -10392,6 +10401,15 @@ class QSizeF(sip.simplewrapper): @typing.overload def __init__(self, a0: 'QSizeF') -> None: ... + def __add__(self, value: 'QSizeF') -> 'QSizeF': ... + def __eq__(self, value: 'QSizeF') -> 'QSizeF': ... + def __iadd__(self, value: 'QSizeF') -> 'QSizeF': ... + def __imul__(self, value: float) -> 'QSizeF': ... + def __isub__(self, value: 'QSizeF') -> 'QSizeF': ... + def __mul__(self, value: float) -> 'QSizeF': ... + def __ne__(self, value: 'QSizeF') -> 'QSizeF': ... + def __sub__(self, value: 'QSizeF') -> 'QSizeF': ... + def shrunkBy(self, m: QMarginsF) -> 'QSizeF': ... def grownBy(self, m: QMarginsF) -> 'QSizeF': ... def transposed(self) -> 'QSizeF': ... From 058594849d85c0a45cf4c03d3dbd1140a7a7142a Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 13 Aug 2021 09:29:25 +0200 Subject: [PATCH 028/421] Update PyQt5-stubs/QtCore.pyi Co-authored-by: Kyle Altendorf --- PyQt5-stubs/QtCore.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 74ce497c..302fe779 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2761,12 +2761,12 @@ class Qt(sip.simplewrapper): def __invert__(self) -> 'Qt.Alignment': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - def __or__ (self, other: typing.Union['Qt.Alignemtn', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignemtn': ... - def __and__(self, other: typing.Union['Qt.Alignemtn', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignemtn': ... - def __xor__(self, other: typing.Union['Qt.Alignemtn', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignemtn': ... - def __ror__ (self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignemtn': ... - def __rand__(self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignemtn': ... - def __rxor__(self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignemtn': ... + def __or__ (self, other: typing.Union['Qt.Alignment', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignment': ... + def __and__(self, other: typing.Union['Qt.Alignment', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignment': ... + def __xor__(self, other: typing.Union['Qt.Alignment', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignment': ... + def __ror__ (self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignment': ... + def __rand__(self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignment': ... + def __rxor__(self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignment': ... class WindowFlags(sip.simplewrapper): From 52254c997c2593f22eab34508bc1f30a5d2cfe4c Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 13 Aug 2021 11:42:16 +0200 Subject: [PATCH 029/421] Remove unneeded #type: ignore and QtWidgets import to make CI happy --- tests/qflags_alignmentflags.py | 4 ++-- tests/windowflags.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qflags_alignmentflags.py b/tests/qflags_alignmentflags.py index 423bc809..97e4b0b9 100644 --- a/tests/qflags_alignmentflags.py +++ b/tests/qflags_alignmentflags.py @@ -1,6 +1,6 @@ from typing import Union, TypeVar, Type -import pytest # type: ignore -from PyQt5 import QtCore, QtWidgets +import pytest +from PyQt5 import QtCore ### Specific part # file generated from windowFlags.py for QFlags class "QtCore.Qt.Alignment" and flag class "QtCore.Qt.AlignmentFlag" diff --git a/tests/windowflags.py b/tests/windowflags.py index 27065161..a342bf72 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -1,6 +1,6 @@ from typing import Union, TypeVar, Type -import pytest # type: ignore -from PyQt5 import QtCore, QtWidgets +import pytest +from PyQt5 import QtCore ### Specific part # This file is used as a source to generate all qflags related tests. The specific part From b0448d4eddb8f33954f77a8c82b6df2546f15b20 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 15 Aug 2021 00:05:59 +0200 Subject: [PATCH 030/421] Add manual workflow tirgger --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d746d422..6e70acf7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,7 @@ name: CI on: + workflow_dispatch: push: branches: - master From 0047e3ac077acc2d59446ea14a47fd974510519b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 15 Aug 2021 00:10:58 +0200 Subject: [PATCH 031/421] No need for nightly CI on this repo CI already runs on branches. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e70acf7..d2c4a131 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ on: schedule: # Daily at 06:14. This is just an arbitrary time to stagger # relative to other daily builds in any given organization. - - cron: '14 6 * * *' + # - cron: '14 6 * * *' jobs: test: From 00feeb2fb16c5483b38fd6420128ef3384489983 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 15 Aug 2021 00:24:55 +0200 Subject: [PATCH 032/421] Activate CI on windows --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2c4a131..dfcb7b06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,10 +26,10 @@ jobs: - name: Linux runs-on: ubuntu-latest matrix: linux -# https://github.com/python-qt-tools/PyQt5-stubs/issues/122 -# - name: Windows -# runs-on: windows-latest -# matrix: windows + https://github.com/python-qt-tools/PyQt5-stubs/issues/122 + - name: Windows + runs-on: windows-latest + matrix: windows # https://github.com/python-qt-tools/PyQt5-stubs/issues/122 # - name: macOS # runs-on: macos-latest From eba6bdaa41b6eec13b0655fbdf171acfb65feff4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 15 Aug 2021 00:53:31 +0200 Subject: [PATCH 033/421] wip on CI with Windows --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dfcb7b06..e30511d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,13 +27,6 @@ jobs: runs-on: ubuntu-latest matrix: linux https://github.com/python-qt-tools/PyQt5-stubs/issues/122 - - name: Windows - runs-on: windows-latest - matrix: windows -# https://github.com/python-qt-tools/PyQt5-stubs/issues/122 -# - name: macOS -# runs-on: macos-latest -# matrix: macos python: - name: CPython 3.6 tox: py36 @@ -47,6 +40,13 @@ jobs: - name: CPython 3.9 tox: py39 action: 3.9 + include: + - name: Windows with python 3.9 + runs-on: windows-latest + python: + - name: CPython 3.9 + tox: py39 + action: 3.9 steps: - uses: actions/checkout@v2 - name: Set up ${{ matrix.python.name }} From 6936e73d58a96bd30b8d401daa0f8ddb1bd17dee Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 15 Aug 2021 00:56:34 +0200 Subject: [PATCH 034/421] wip make ci run on windows --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e30511d6..f9e0f726 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,6 @@ jobs: - name: Linux runs-on: ubuntu-latest matrix: linux - https://github.com/python-qt-tools/PyQt5-stubs/issues/122 python: - name: CPython 3.6 tox: py36 From e3bc65203797ac9217384c90713b7f56ea465f7b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 15 Aug 2021 00:57:31 +0200 Subject: [PATCH 035/421] Update ci.yml --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9e0f726..49e5f64e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,11 +10,6 @@ on: pull_request: branches: - "*" - schedule: - # Daily at 06:14. This is just an arbitrary time to stagger - # relative to other daily builds in any given organization. - # - cron: '14 6 * * *' - jobs: test: name: ${{ matrix.os.name }} ${{ matrix.python.name }} From 50e7e070f5222c605e63fdf8c6bf909a14b63fb0 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 15 Aug 2021 08:44:32 +0200 Subject: [PATCH 036/421] Update ci.yml --- .github/workflows/ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49e5f64e..91c58004 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,14 +13,12 @@ on: jobs: test: name: ${{ matrix.os.name }} ${{ matrix.python.name }} - runs-on: ${{ matrix.os.runs-on }} strategy: fail-fast: false matrix: os: - name: Linux runs-on: ubuntu-latest - matrix: linux python: - name: CPython 3.6 tox: py36 @@ -35,8 +33,9 @@ jobs: tox: py39 action: 3.9 include: - - name: Windows with python 3.9 - runs-on: windows-latest + os: + - name: Windows + runs-on: windows-latest python: - name: CPython 3.9 tox: py39 From 42c012178e6cb5a64ec62fa6c3914924187e81b2 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 15 Aug 2021 08:57:18 +0200 Subject: [PATCH 037/421] Update ci.yml --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91c58004..448d5d44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,7 @@ on: jobs: test: name: ${{ matrix.os.name }} ${{ matrix.python.name }} + runs-on: ${{ matrix.runs-on }} strategy: fail-fast: false matrix: @@ -33,11 +34,11 @@ jobs: tox: py39 action: 3.9 include: - os: - - name: Windows + - os: + name: Windows runs-on: windows-latest - python: - - name: CPython 3.9 + python: + name: CPython 3.9 tox: py39 action: 3.9 steps: From a866d3c203dc808b261bf8e9e69bd7cd79b58a16 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 15 Aug 2021 08:59:01 +0200 Subject: [PATCH 038/421] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 448d5d44..f6cb48e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ on: jobs: test: name: ${{ matrix.os.name }} ${{ matrix.python.name }} - runs-on: ${{ matrix.runs-on }} + runs-on: ${{ matrix.os.runs-on }} strategy: fail-fast: false matrix: From da6b2c06f411eab525cbb7aef59d2dd354b96825 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 15 Aug 2021 09:13:07 +0200 Subject: [PATCH 039/421] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6cb48e8..82066101 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: architecture: x64 - uses: twisted/python-info-action@v1.0.1 - name: Install Linux Qt5 dependencies - if: matrix.os.matrix == 'linux' + if: matrix.os.name == 'Linux' run: | sudo apt-get update --yes sudo apt-get install --yes libgl1 From 066a15802d978ebe9b8728ec1b2f06e6a918d937 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 16 Aug 2021 11:42:42 -0400 Subject: [PATCH 040/421] update requirements --- requirements/develop.txt | 41 ++++++++++++++++++------------------- requirements/production.txt | 10 +++++---- tox.ini | 3 +-- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/requirements/develop.txt b/requirements/develop.txt index 24d709ce..f129f3cb 100644 --- a/requirements/develop.txt +++ b/requirements/develop.txt @@ -1,37 +1,36 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.9 # To update, run: # -# pip-compile --output-file=develop.txt develop.in +# pip-compile --output-file=develop.txt requirements/develop.in # -atomicwrites==1.2.1 +attrs==21.2.0 # via pytest -attrs==18.2.0 +iniconfig==1.1.1 # via pytest -more-itertools==4.3.0 - # via pytest -mypy-extensions==0.4.1 +mypy==0.910 + # via -r requirements/develop.in +mypy-extensions==0.4.3 # via mypy -mypy==0.641 - # via -r develop.in -pluggy==0.8.0 +packaging==21.0 + # via pytest +pluggy==0.13.1 # via pytest py==1.10.0 # via pytest +pyparsing==2.4.7 + # via packaging +pyqt5==5.14.2 + # via -r requirements/production.txt pyqt5-sip==12.7.0 # via - # -r production.txt + # -r requirements/production.txt # pyqt5 -pyqt5==5.14.2 - # via -r production.txt -pytest==4.0.1 - # via -r develop.in -six==1.11.0 +pytest==6.2.4 + # via -r requirements/develop.in +toml==0.10.2 # via - # more-itertools + # mypy # pytest -typed-ast==1.1.0 +typing-extensions==3.10.0.0 # via mypy - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/requirements/production.txt b/requirements/production.txt index 4d7f38af..6b6d5ad9 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -1,8 +1,10 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.9 # To update, run: # -# pip-compile --output-file=production.txt production.in +# pip-compile --output-file=production.txt requirements/production.in # -pyqt5-sip==12.7.0 # via pyqt5 -pyqt5==5.14.2 # via -r production.in +pyqt5==5.14.2 + # via -r requirements/production.in +pyqt5-sip==12.9.0 + # via pyqt5 diff --git a/tox.ini b/tox.ini index 5d97a76e..9873ab61 100644 --- a/tox.ini +++ b/tox.ini @@ -3,8 +3,7 @@ envlist = py3{5,6,7,8,9} [testenv] deps = - mypy @ git+https://github.com/python/mypy@538d36481526135c44b90383663eaa177cfc32e3 - pytest + -r requirements/development.txt pip>=20.0 commands = pip install PyQt5==5.15.* PyQt3D==5.15.* PyQtChart==5.15.* PyQtDataVisualization==5.15.* PyQtNetworkAuth==5.15.* PyQtPurchasing==5.15.* PyQtWebEngine==5.15.* From 18795c4091c1eda247ec33dbb2952ad0661b9fc3 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 16 Aug 2021 11:46:49 -0400 Subject: [PATCH 041/421] it is develop.txt --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 9873ab61..12680fec 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ envlist = py3{5,6,7,8,9} [testenv] deps = - -r requirements/development.txt + -r requirements/develop.txt pip>=20.0 commands = pip install PyQt5==5.15.* PyQt3D==5.15.* PyQtChart==5.15.* PyQtDataVisualization==5.15.* PyQtNetworkAuth==5.15.* PyQtPurchasing==5.15.* PyQtWebEngine==5.15.* From c7474ccebeb0ead3acddd572a0165cba7d8539b2 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 16 Aug 2021 11:56:48 -0400 Subject: [PATCH 042/421] correct PyQt5.QtWidgets.QGraphicsScene.focusOnTouch --- PyQt5-stubs/QtWidgets.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 92d28ffb..450f742a 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -5747,7 +5747,7 @@ class QGraphicsScene(QtCore.QObject): def __init__(self, x: float, y: float, width: float, height: float, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setFocusOnTouch(self, enabled: bool) -> None: ... - focusOnTouch: typing.ClassVar[QtCore.pyqtSignal] + def focusOnTouch(self) -> bool: ... def focusItemChanged(self, newFocus: QGraphicsItem, oldFocus: QGraphicsItem, reason: QtCore.Qt.FocusReason) -> None: ... def setMinimumRenderSize(self, minSize: float) -> None: ... def minimumRenderSize(self) -> float: ... From 1936badb9ca2928a8d0db218ef535669d028e681 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 16 Aug 2021 16:37:51 -0400 Subject: [PATCH 043/421] ignore pyqtProperty and QQmlListProperty missing --- stubtest.allowlist.to_review | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stubtest.allowlist.to_review b/stubtest.allowlist.to_review index cd96ad59..fc51be1f 100644 --- a/stubtest.allowlist.to_review +++ b/stubtest.allowlist.to_review @@ -24,3 +24,5 @@ PyQt5.QtTest.QAbstractItemModelTester.FailureReportingMode.__new__ PyQt5.QtWebEngineCore.QWebEngineUrlScheme.Syntax.__new__ PyQt5.QtWebEngineWidgets.QWebEnginePage.LifecycleState.__new__ PyQt5.QtWidgets.QActionGroup.ExclusionPolicy.__new__ +PyQt5.QtCore.pyqtProperty +PyQt5.QtQml.QQmlListProperty From 1f0f0b30f452481f3908ef1813f158d2db229ac9 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Mon, 23 Aug 2021 22:39:34 +0200 Subject: [PATCH 044/421] Fixed signal type definitions in all modules with a LibCST script. --- PyQt5-stubs/Qt3DAnimation.pyi | 120 +++--- PyQt5-stubs/Qt3DCore.pyi | 66 ++- PyQt5-stubs/Qt3DExtras.pyi | 362 ++++++++--------- PyQt5-stubs/Qt3DInput.pyi | 166 ++++---- PyQt5-stubs/Qt3DLogic.pyi | 3 +- PyQt5-stubs/Qt3DRender.pyi | 599 +++++++++++++--------------- PyQt5-stubs/QtBluetooth.pyi | 106 ++--- PyQt5-stubs/QtChart.pyi | 596 +++++++++++++-------------- PyQt5-stubs/QtCore.pyi | 158 ++++---- PyQt5-stubs/QtDBus.pyi | 18 +- PyQt5-stubs/QtDataVisualization.pyi | 535 ++++++++++++------------- PyQt5-stubs/QtDesigner.pyi | 36 +- PyQt5-stubs/QtGui.pyi | 143 ++++--- PyQt5-stubs/QtHelp.pyi | 47 +-- PyQt5-stubs/QtLocation.pyi | 85 ++-- PyQt5-stubs/QtMultimedia.pyi | 543 +++++++++++-------------- PyQt5-stubs/QtMultimediaWidgets.pyi | 23 +- PyQt5-stubs/QtNetwork.pyi | 118 +++--- PyQt5-stubs/QtNetworkAuth.pyi | 61 ++- PyQt5-stubs/QtNfc.pyi | 36 +- PyQt5-stubs/QtPositioning.pyi | 33 +- PyQt5-stubs/QtPrintSupport.pyi | 6 +- PyQt5-stubs/QtPurchasing.pyi | 7 +- PyQt5-stubs/QtQml.pyi | 12 +- PyQt5-stubs/QtQuick.pyi | 40 +- PyQt5-stubs/QtQuickWidgets.pyi | 4 +- PyQt5-stubs/QtRemoteObjects.pyi | 26 +- PyQt5-stubs/QtSensors.pyi | 49 +-- PyQt5-stubs/QtSerialPort.pyi | 28 +- PyQt5-stubs/QtSql.pyi | 13 +- PyQt5-stubs/QtSvg.pyi | 2 +- PyQt5-stubs/QtWebChannel.pyi | 5 +- PyQt5-stubs/QtWebEngine.pyi | 41 +- PyQt5-stubs/QtWebEngineCore.pyi | 7 +- PyQt5-stubs/QtWebEngineWidgets.pyi | 91 +++-- PyQt5-stubs/QtWebSockets.pyi | 49 ++- PyQt5-stubs/QtWidgets.pyi | 39 +- signal_fixer.py | 76 ++++ 38 files changed, 2009 insertions(+), 2340 deletions(-) create mode 100644 signal_fixer.py diff --git a/PyQt5-stubs/Qt3DAnimation.pyi b/PyQt5-stubs/Qt3DAnimation.pyi index 90a0c766..9c4f0151 100644 --- a/PyQt5-stubs/Qt3DAnimation.pyi +++ b/PyQt5-stubs/Qt3DAnimation.pyi @@ -51,10 +51,9 @@ class QAbstractAnimation(QtCore.QObject): KeyframeAnimation = ... # type: QAbstractAnimation.AnimationType MorphingAnimation = ... # type: QAbstractAnimation.AnimationType VertexBlendAnimation = ... # type: QAbstractAnimation.AnimationType - - def durationChanged(self, duration: float) -> None: ... - def positionChanged(self, position: float) -> None: ... - def animationNameChanged(self, name: str) -> None: ... + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + animationNameChanged: typing.ClassVar[QtCore.pyqtSignal] def setDuration(self, duration: float) -> None: ... def setPosition(self, position: float) -> None: ... def setAnimationName(self, name: str) -> None: ... @@ -66,7 +65,7 @@ class QAbstractAnimation(QtCore.QObject): class QAbstractAnimationClip(Qt3DCore.QNode): def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def durationChanged(self, duration: float) -> None: ... + durationChanged: typing.ClassVar[QtCore.pyqtSignal] def duration(self) -> float: ... class QAbstractChannelMapping(Qt3DCore.QNode): ... @@ -81,11 +80,11 @@ class QAbstractClipAnimator(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def normalizedTimeChanged(self, index: float) -> None: ... - def clockChanged(self, clock: 'QClock') -> None: ... - def loopCountChanged(self, loops: int) -> None: ... - def channelMapperChanged(self, channelMapper: 'QChannelMapper') -> None: ... - def runningChanged(self, running: bool) -> None: ... + normalizedTimeChanged: typing.ClassVar[QtCore.pyqtSignal] + clockChanged: typing.ClassVar[QtCore.pyqtSignal] + loopCountChanged: typing.ClassVar[QtCore.pyqtSignal] + channelMapperChanged: typing.ClassVar[QtCore.pyqtSignal] + runningChanged: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def start(self) -> None: ... def setNormalizedTime(self, timeFraction: float) -> None: ... @@ -106,10 +105,9 @@ class QAbstractClipBlendNode(Qt3DCore.QNode): class QAdditiveClipBlend('QAbstractClipBlendNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def additiveClipChanged(self, additiveClip: 'QAbstractClipBlendNode') -> None: ... - def baseClipChanged(self, baseClip: 'QAbstractClipBlendNode') -> None: ... - def additiveFactorChanged(self, additiveFactor: float) -> None: ... + additiveClipChanged: typing.ClassVar[QtCore.pyqtSignal] + baseClipChanged: typing.ClassVar[QtCore.pyqtSignal] + additiveFactorChanged: typing.ClassVar[QtCore.pyqtSignal] def setAdditiveClip(self, additiveClip: 'QAbstractClipBlendNode') -> None: ... def setBaseClip(self, baseClip: 'QAbstractClipBlendNode') -> None: ... def setAdditiveFactor(self, additiveFactor: float) -> None: ... @@ -124,8 +122,7 @@ class QAnimationAspect(Qt3DCore.QAbstractAspect): class QAnimationClip('QAbstractAnimationClip'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def clipDataChanged(self, clipData: 'QAnimationClipData') -> None: ... + clipDataChanged: typing.ClassVar[QtCore.pyqtSignal] def setClipData(self, clipData: 'QAnimationClipData') -> None: ... def clipData(self) -> 'QAnimationClipData': ... @@ -162,8 +159,8 @@ class QAnimationClipLoader('QAbstractAnimationClip'): def __init__(self, source: QtCore.QUrl, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QAnimationClipLoader.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSource(self, source: QtCore.QUrl) -> None: ... def status(self) -> 'QAnimationClipLoader.Status': ... def source(self) -> QtCore.QUrl: ... @@ -171,13 +168,12 @@ class QAnimationClipLoader('QAbstractAnimationClip'): class QAnimationController(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def recursiveChanged(self, recursive: bool) -> None: ... - def entityChanged(self, entity: Qt3DCore.QEntity) -> None: ... - def positionOffsetChanged(self, offset: float) -> None: ... - def positionScaleChanged(self, scale: float) -> None: ... - def positionChanged(self, position: float) -> None: ... - def activeAnimationGroupChanged(self, index: int) -> None: ... + recursiveChanged: typing.ClassVar[QtCore.pyqtSignal] + entityChanged: typing.ClassVar[QtCore.pyqtSignal] + positionOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] + positionScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + activeAnimationGroupChanged: typing.ClassVar[QtCore.pyqtSignal] def setRecursive(self, recursive: bool) -> None: ... def setEntity(self, entity: Qt3DCore.QEntity) -> None: ... def setPositionOffset(self, offset: float) -> None: ... @@ -200,10 +196,9 @@ class QAnimationController(QtCore.QObject): class QAnimationGroup(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def durationChanged(self, duration: float) -> None: ... - def positionChanged(self, position: float) -> None: ... - def nameChanged(self, name: str) -> None: ... + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] def setPosition(self, position: float) -> None: ... def setName(self, name: str) -> None: ... def removeAnimation(self, animation: 'QAbstractAnimation') -> None: ... @@ -217,8 +212,7 @@ class QAnimationGroup(QtCore.QObject): class QBlendedClipAnimator('QAbstractClipAnimator'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def blendTreeChanged(self, blendTree: 'QAbstractClipBlendNode') -> None: ... + blendTreeChanged: typing.ClassVar[QtCore.pyqtSignal] def setBlendTree(self, blendTree: 'QAbstractClipBlendNode') -> None: ... def blendTree(self) -> 'QAbstractClipBlendNode': ... @@ -269,10 +263,9 @@ class QChannelMapper(Qt3DCore.QNode): class QChannelMapping('QAbstractChannelMapping'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def propertyChanged(self, property: str) -> None: ... - def targetChanged(self, target: Qt3DCore.QNode) -> None: ... - def channelNameChanged(self, channelName: str) -> None: ... + propertyChanged: typing.ClassVar[QtCore.pyqtSignal] + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + channelNameChanged: typing.ClassVar[QtCore.pyqtSignal] def setProperty(self, property: str) -> None: ... # type: ignore[override] def setTarget(self, target: Qt3DCore.QNode) -> None: ... def setChannelName(self, channelName: str) -> None: ... @@ -283,8 +276,7 @@ class QChannelMapping('QAbstractChannelMapping'): class QClipAnimator('QAbstractClipAnimator'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def clipChanged(self, clip: 'QAbstractAnimationClip') -> None: ... + clipChanged: typing.ClassVar[QtCore.pyqtSignal] def setClip(self, clip: 'QAbstractAnimationClip') -> None: ... def clip(self) -> 'QAbstractAnimationClip': ... @@ -298,16 +290,14 @@ class QClipBlendValue('QAbstractClipBlendNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... @typing.overload def __init__(self, clip: 'QAbstractAnimationClip', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def clipChanged(self, clip: 'QAbstractAnimationClip') -> None: ... + clipChanged: typing.ClassVar[QtCore.pyqtSignal] def setClip(self, clip: 'QAbstractAnimationClip') -> None: ... def clip(self) -> 'QAbstractAnimationClip': ... class QClock(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def playbackRateChanged(self, playbackRate: float) -> None: ... + playbackRateChanged: typing.ClassVar[QtCore.pyqtSignal] def setPlaybackRate(self, playbackRate: float) -> None: ... def playbackRate(self) -> float: ... @@ -352,13 +342,12 @@ class QKeyframeAnimation('QAbstractAnimation'): Repeat = ... # type: QKeyframeAnimation.RepeatMode def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def endModeChanged(self, endMode: 'QKeyframeAnimation.RepeatMode') -> None: ... - def startModeChanged(self, startMode: 'QKeyframeAnimation.RepeatMode') -> None: ... - def targetNameChanged(self, name: str) -> None: ... - def easingChanged(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... - def targetChanged(self, target: Qt3DCore.QTransform) -> None: ... - def framePositionsChanged(self, positions: typing.Iterable[float]) -> None: ... + endModeChanged: typing.ClassVar[QtCore.pyqtSignal] + startModeChanged: typing.ClassVar[QtCore.pyqtSignal] + targetNameChanged: typing.ClassVar[QtCore.pyqtSignal] + easingChanged: typing.ClassVar[QtCore.pyqtSignal] + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + framePositionsChanged: typing.ClassVar[QtCore.pyqtSignal] def setEndMode(self, mode: 'QKeyframeAnimation.RepeatMode') -> None: ... def setStartMode(self, mode: 'QKeyframeAnimation.RepeatMode') -> None: ... def setTargetName(self, name: str) -> None: ... @@ -379,10 +368,9 @@ class QKeyframeAnimation('QAbstractAnimation'): class QLerpClipBlend('QAbstractClipBlendNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def endClipChanged(self, endClip: 'QAbstractClipBlendNode') -> None: ... - def startClipChanged(self, startClip: 'QAbstractClipBlendNode') -> None: ... - def blendFactorChanged(self, blendFactor: float) -> None: ... + endClipChanged: typing.ClassVar[QtCore.pyqtSignal] + startClipChanged: typing.ClassVar[QtCore.pyqtSignal] + blendFactorChanged: typing.ClassVar[QtCore.pyqtSignal] def setEndClip(self, endClip: 'QAbstractClipBlendNode') -> None: ... def setStartClip(self, startClip: 'QAbstractClipBlendNode') -> None: ... def setBlendFactor(self, blendFactor: float) -> None: ... @@ -400,13 +388,12 @@ class QMorphingAnimation('QAbstractAnimation'): Relative = ... # type: QMorphingAnimation.Method def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def easingChanged(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... - def methodChanged(self, method: 'QMorphingAnimation.Method') -> None: ... - def targetNameChanged(self, name: str) -> None: ... - def targetChanged(self, target: Qt3DRender.QGeometryRenderer) -> None: ... - def interpolatorChanged(self, interpolator: float) -> None: ... - def targetPositionsChanged(self, targetPositions: typing.Iterable[float]) -> None: ... + easingChanged: typing.ClassVar[QtCore.pyqtSignal] + methodChanged: typing.ClassVar[QtCore.pyqtSignal] + targetNameChanged: typing.ClassVar[QtCore.pyqtSignal] + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + interpolatorChanged: typing.ClassVar[QtCore.pyqtSignal] + targetPositionsChanged: typing.ClassVar[QtCore.pyqtSignal] def setEasing(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... def setMethod(self, method: 'QMorphingAnimation.Method') -> None: ... def setTargetName(self, name: str) -> None: ... @@ -428,8 +415,7 @@ class QMorphingAnimation('QAbstractAnimation'): class QMorphTarget(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def attributeNamesChanged(self, attributeNames: typing.Iterable[str]) -> None: ... + attributeNamesChanged: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def fromGeometry(geometry: Qt3DRender.QGeometry, attributes: typing.Iterable[str]) -> 'QMorphTarget': ... def removeAttribute(self, attribute: Qt3DRender.QAttribute) -> None: ... @@ -441,19 +427,17 @@ class QMorphTarget(QtCore.QObject): class QSkeletonMapping('QAbstractChannelMapping'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def skeletonChanged(self, skeleton: Qt3DCore.QAbstractSkeleton) -> None: ... + skeletonChanged: typing.ClassVar[QtCore.pyqtSignal] def setSkeleton(self, skeleton: Qt3DCore.QAbstractSkeleton) -> None: ... def skeleton(self) -> Qt3DCore.QAbstractSkeleton: ... class QVertexBlendAnimation('QAbstractAnimation'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def targetNameChanged(self, name: str) -> None: ... - def targetChanged(self, target: Qt3DRender.QGeometryRenderer) -> None: ... - def interpolatorChanged(self, interpolator: float) -> None: ... - def targetPositionsChanged(self, targetPositions: typing.Iterable[float]) -> None: ... + targetNameChanged: typing.ClassVar[QtCore.pyqtSignal] + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + interpolatorChanged: typing.ClassVar[QtCore.pyqtSignal] + targetPositionsChanged: typing.ClassVar[QtCore.pyqtSignal] def setTargetName(self, name: str) -> None: ... def setTarget(self, target: Qt3DRender.QGeometryRenderer) -> None: ... def setTargetPositions(self, targetPositions: typing.Iterable[float]) -> None: ... diff --git a/PyQt5-stubs/Qt3DCore.pyi b/PyQt5-stubs/Qt3DCore.pyi index 66970665..51a51533 100644 --- a/PyQt5-stubs/Qt3DCore.pyi +++ b/PyQt5-stubs/Qt3DCore.pyi @@ -115,7 +115,7 @@ class QNode(QtCore.QObject): def sendReply(self, command: 'QNodeCommand') -> None: ... def sendCommand(self, name: str, data: typing.Any = ..., replyTo: int = ...) -> int: ... - def defaultPropertyTrackingModeChanged(self, mode: 'QNode.PropertyTrackingMode') -> None: ... + defaultPropertyTrackingModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setDefaultPropertyTrackingMode(self, mode: 'QNode.PropertyTrackingMode') -> None: ... def clearPropertyTrackings(self) -> None: ... def clearPropertyTracking(self, propertyName: str) -> None: ... @@ -124,9 +124,9 @@ class QNode(QtCore.QObject): def defaultPropertyTrackingMode(self) -> 'QNode.PropertyTrackingMode': ... def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... def notifyObservers(self, change: 'QSceneChange') -> None: ... - def nodeDestroyed(self) -> None: ... - def enabledChanged(self, enabled: bool) -> None: ... - def parentChanged(self, parent: QtCore.QObject) -> None: ... + nodeDestroyed: typing.ClassVar[QtCore.pyqtSignal] + enabledChanged: typing.ClassVar[QtCore.pyqtSignal] + parentChanged: typing.ClassVar[QtCore.pyqtSignal] def setEnabled(self, isEnabled: bool) -> None: ... def setParent(self, parent: 'QNode') -> None: ... # type: ignore[override] def isEnabled(self) -> bool: ... @@ -139,16 +139,15 @@ class QNode(QtCore.QObject): class QAbstractSkeleton('QNode'): def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - def jointCountChanged(self, jointCount: int) -> None: ... + jointCountChanged: typing.ClassVar[QtCore.pyqtSignal] def jointCount(self) -> int: ... class QComponent('QNode'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - - def removedFromEntity(self, entity: 'QEntity') -> None: ... - def addedToEntity(self, entity: 'QEntity') -> None: ... - def shareableChanged(self, isShareable: bool) -> None: ... + removedFromEntity: typing.ClassVar[QtCore.pyqtSignal] + addedToEntity: typing.ClassVar[QtCore.pyqtSignal] + shareableChanged: typing.ClassVar[QtCore.pyqtSignal] def setShareable(self, isShareable: bool) -> None: ... def entities(self) -> typing.List['QEntity']: ... def isShareable(self) -> bool: ... @@ -156,8 +155,7 @@ class QComponent('QNode'): class QArmature('QComponent'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - - def skeletonChanged(self, skeleton: 'QAbstractSkeleton') -> None: ... + skeletonChanged: typing.ClassVar[QtCore.pyqtSignal] def setSkeleton(self, skeleton: 'QAbstractSkeleton') -> None: ... def skeleton(self) -> 'QAbstractSkeleton': ... @@ -272,15 +270,14 @@ class QEntity('QNode'): class QJoint('QNode'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - - def nameChanged(self, name: str) -> None: ... - def rotationZChanged(self, rotationZ: float) -> None: ... - def rotationYChanged(self, rotationY: float) -> None: ... - def rotationXChanged(self, rotationX: float) -> None: ... - def inverseBindMatrixChanged(self, inverseBindMatrix: QtGui.QMatrix4x4) -> None: ... - def translationChanged(self, translation: QtGui.QVector3D) -> None: ... - def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def scaleChanged(self, scale: QtGui.QVector3D) -> None: ... + nameChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationZChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationYChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationXChanged: typing.ClassVar[QtCore.pyqtSignal] + inverseBindMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] + translationChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationChanged: typing.ClassVar[QtCore.pyqtSignal] + scaleChanged: typing.ClassVar[QtCore.pyqtSignal] def setToIdentity(self) -> None: ... def setName(self, name: str) -> None: ... def setRotationZ(self, rotationZ: float) -> None: ... @@ -436,8 +433,7 @@ class ChangeFlags(sip.simplewrapper): class QSkeleton('QAbstractSkeleton'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - - def rootJointChanged(self, rootJoint: 'QJoint') -> None: ... + rootJointChanged: typing.ClassVar[QtCore.pyqtSignal] def setRootJoint(self, rootJoint: 'QJoint') -> None: ... def rootJoint(self) -> 'QJoint': ... @@ -458,10 +454,10 @@ class QSkeletonLoader('QAbstractSkeleton'): def __init__(self, source: QtCore.QUrl, parent: typing.Optional['QNode'] = ...) -> None: ... def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - def rootJointChanged(self, rootJoint: 'QJoint') -> None: ... - def createJointsEnabledChanged(self, createJointsEnabled: bool) -> None: ... - def statusChanged(self, status: 'QSkeletonLoader.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + rootJointChanged: typing.ClassVar[QtCore.pyqtSignal] + createJointsEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setCreateJointsEnabled(self, enabled: bool) -> None: ... def setSource(self, source: QtCore.QUrl) -> None: ... def rootJoint(self) -> 'QJoint': ... @@ -474,16 +470,16 @@ class QTransform('QComponent'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - def worldMatrixChanged(self, worldMatrix: QtGui.QMatrix4x4) -> None: ... + worldMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] def worldMatrix(self) -> QtGui.QMatrix4x4: ... - def rotationZChanged(self, rotationZ: float) -> None: ... - def rotationYChanged(self, rotationY: float) -> None: ... - def rotationXChanged(self, rotationX: float) -> None: ... - def matrixChanged(self) -> None: ... - def translationChanged(self, translation: QtGui.QVector3D) -> None: ... - def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def scale3DChanged(self, scale: QtGui.QVector3D) -> None: ... - def scaleChanged(self, scale: float) -> None: ... + rotationZChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationYChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationXChanged: typing.ClassVar[QtCore.pyqtSignal] + matrixChanged: typing.ClassVar[QtCore.pyqtSignal] + translationChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationChanged: typing.ClassVar[QtCore.pyqtSignal] + scale3DChanged: typing.ClassVar[QtCore.pyqtSignal] + scaleChanged: typing.ClassVar[QtCore.pyqtSignal] def setRotationZ(self, rotationZ: float) -> None: ... def setRotationY(self, rotationY: float) -> None: ... def setRotationX(self, rotationX: float) -> None: ... diff --git a/PyQt5-stubs/Qt3DExtras.pyi b/PyQt5-stubs/Qt3DExtras.pyi index 1c3d4358..12626883 100644 --- a/PyQt5-stubs/Qt3DExtras.pyi +++ b/PyQt5-stubs/Qt3DExtras.pyi @@ -48,11 +48,11 @@ class QAbstractCameraController(Qt3DCore.QEntity): def mouseDevice(self) -> Qt3DInput.QMouseDevice: ... def keyboardDevice(self) -> Qt3DInput.QKeyboardDevice: ... - def decelerationChanged(self, deceleration: float) -> None: ... - def accelerationChanged(self, acceleration: float) -> None: ... - def lookSpeedChanged(self) -> None: ... - def linearSpeedChanged(self) -> None: ... - def cameraChanged(self) -> None: ... + decelerationChanged: typing.ClassVar[QtCore.pyqtSignal] + accelerationChanged: typing.ClassVar[QtCore.pyqtSignal] + lookSpeedChanged: typing.ClassVar[QtCore.pyqtSignal] + linearSpeedChanged: typing.ClassVar[QtCore.pyqtSignal] + cameraChanged: typing.ClassVar[QtCore.pyqtSignal] def setDeceleration(self, deceleration: float) -> None: ... def setAcceleration(self, acceleration: float) -> None: ... def setLookSpeed(self, lookSpeed: float) -> None: ... @@ -65,10 +65,9 @@ class QAbstractCameraController(Qt3DCore.QEntity): def camera(self) -> Qt3DRender.QCamera: ... class QAbstractSpriteSheet(Qt3DCore.QNode): - - def currentIndexChanged(self, currentIndex: int) -> None: ... - def textureTransformChanged(self, textureTransform: QtGui.QMatrix3x3) -> None: ... - def textureChanged(self, texture: Qt3DRender.QAbstractTexture) -> None: ... + currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] + textureTransformChanged: typing.ClassVar[QtCore.pyqtSignal] + textureChanged: typing.ClassVar[QtCore.pyqtSignal] def setCurrentIndex(self, currentIndex: int) -> None: ... def setTexture(self, texture: Qt3DRender.QAbstractTexture) -> None: ... def currentIndex(self) -> int: ... @@ -78,14 +77,13 @@ class QAbstractSpriteSheet(Qt3DCore.QNode): class QConeGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def bottomRadiusChanged(self, bottomRadius: float) -> None: ... - def topRadiusChanged(self, topRadius: float) -> None: ... - def hasBottomEndcapChanged(self, hasBottomEndcap: bool) -> None: ... - def hasTopEndcapChanged(self, hasTopEndcap: bool) -> None: ... + lengthChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + bottomRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + topRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + hasBottomEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] + hasTopEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] def setLength(self, length: float) -> None: ... def setSlices(self, slices: int) -> None: ... def setRings(self, rings: int) -> None: ... @@ -110,14 +108,13 @@ class QConeGeometry(Qt3DRender.QGeometry): class QConeMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def bottomRadiusChanged(self, bottomRadius: float) -> None: ... - def topRadiusChanged(self, topRadius: float) -> None: ... - def hasBottomEndcapChanged(self, hasBottomEndcap: bool) -> None: ... - def hasTopEndcapChanged(self, hasTopEndcap: bool) -> None: ... + lengthChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + bottomRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + topRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + hasBottomEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] + hasTopEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] def setLength(self, length: float) -> None: ... def setSlices(self, slices: int) -> None: ... def setRings(self, rings: int) -> None: ... @@ -136,13 +133,12 @@ class QConeMesh(Qt3DRender.QGeometryRenderer): class QCuboidGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def xyMeshResolutionChanged(self, xyMeshResolution: QtCore.QSize) -> None: ... - def xzMeshResolutionChanged(self, xzMeshResolution: QtCore.QSize) -> None: ... - def yzMeshResolutionChanged(self, yzMeshResolution: QtCore.QSize) -> None: ... - def zExtentChanged(self, zExtent: float) -> None: ... - def yExtentChanged(self, yExtent: float) -> None: ... - def xExtentChanged(self, xExtent: float) -> None: ... + xyMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + xzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + yzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + zExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + yExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + xExtentChanged: typing.ClassVar[QtCore.pyqtSignal] def setXYMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setXZMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setYZMeshResolution(self, resolution: QtCore.QSize) -> None: ... @@ -166,13 +162,12 @@ class QCuboidGeometry(Qt3DRender.QGeometry): class QCuboidMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def xyMeshResolutionChanged(self, xyMeshResolution: QtCore.QSize) -> None: ... - def xzMeshResolutionChanged(self, xzMeshResolution: QtCore.QSize) -> None: ... - def yzMeshResolutionChanged(self, yzMeshResolution: QtCore.QSize) -> None: ... - def zExtentChanged(self, zExtent: float) -> None: ... - def yExtentChanged(self, yExtent: float) -> None: ... - def xExtentChanged(self, xExtent: float) -> None: ... + xyMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + xzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + yzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + zExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + yExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + xExtentChanged: typing.ClassVar[QtCore.pyqtSignal] def setXYMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setXZMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setYZMeshResolution(self, resolution: QtCore.QSize) -> None: ... @@ -189,11 +184,10 @@ class QCuboidMesh(Qt3DRender.QGeometryRenderer): class QCylinderGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + lengthChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setLength(self, length: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -212,11 +206,10 @@ class QCylinderGeometry(Qt3DRender.QGeometry): class QCylinderMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + lengthChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setLength(self, length: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -229,12 +222,11 @@ class QCylinderMesh(Qt3DRender.QGeometryRenderer): class QDiffuseMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureScale(self, textureScale: float) -> None: ... def setDiffuse(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... def setShininess(self, shininess: float) -> None: ... @@ -249,12 +241,11 @@ class QDiffuseMapMaterial(Qt3DRender.QMaterial): class QDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: Qt3DRender.QAbstractTexture) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureScale(self, textureScale: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: Qt3DRender.QAbstractTexture) -> None: ... @@ -269,14 +260,13 @@ class QDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): class QDiffuseSpecularMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def alphaBlendingEnabledChanged(self, enabled: bool) -> None: ... - def textureScaleChanged(self, textureScale: float) -> None: ... - def normalChanged(self, normal: typing.Any) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Any) -> None: ... - def diffuseChanged(self, diffuse: typing.Any) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + alphaBlendingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setAlphaBlendingEnabled(self, enabled: bool) -> None: ... def setTextureScale(self, textureScale: float) -> None: ... def setNormal(self, normal: typing.Any) -> None: ... @@ -295,10 +285,9 @@ class QDiffuseSpecularMaterial(Qt3DRender.QMaterial): class QExtrudedTextGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def depthChanged(self, extrusionLength: float) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def textChanged(self, text: str) -> None: ... + depthChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + textChanged: typing.ClassVar[QtCore.pyqtSignal] def setDepth(self, extrusionLength: float) -> None: ... def setFont(self, font: QtGui.QFont) -> None: ... def setText(self, text: str) -> None: ... @@ -312,10 +301,9 @@ class QExtrudedTextGeometry(Qt3DRender.QGeometry): class QExtrudedTextMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def depthChanged(self, depth: float) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def textChanged(self, text: str) -> None: ... + depthChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + textChanged: typing.ClassVar[QtCore.pyqtSignal] def setDepth(self, depth: float) -> None: ... def setFont(self, font: QtGui.QFont) -> None: ... def setText(self, text: str) -> None: ... @@ -330,24 +318,23 @@ class QFirstPersonCameraController('QAbstractCameraController'): class QForwardRenderer(Qt3DRender.QTechniqueFilter): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def showDebugOverlayChanged(self, showDebugOverlay: bool) -> None: ... + showDebugOverlayChanged: typing.ClassVar[QtCore.pyqtSignal] def setShowDebugOverlay(self, showDebugOverlay: bool) -> None: ... def showDebugOverlay(self) -> bool: ... - def buffersToClearChanged(self, a0: Qt3DRender.QClearBuffers.BufferType) -> None: ... + buffersToClearChanged: typing.ClassVar[QtCore.pyqtSignal] def setBuffersToClear(self, a0: Qt3DRender.QClearBuffers.BufferType) -> None: ... def buffersToClear(self) -> Qt3DRender.QClearBuffers.BufferType: ... - def gammaChanged(self, gamma: float) -> None: ... - def frustumCullingEnabledChanged(self, enabled: bool) -> None: ... + gammaChanged: typing.ClassVar[QtCore.pyqtSignal] + frustumCullingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] def setGamma(self, gamma: float) -> None: ... def setFrustumCullingEnabled(self, enabled: bool) -> None: ... def gamma(self) -> float: ... def isFrustumCullingEnabled(self) -> bool: ... - def externalRenderTargetSizeChanged(self, size: QtCore.QSize) -> None: ... - def surfaceChanged(self, surface: QtCore.QObject) -> None: ... - def cameraChanged(self, camera: Qt3DCore.QEntity) -> None: ... - def clearColorChanged(self, clearColor: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def viewportRectChanged(self, viewportRect: QtCore.QRectF) -> None: ... + externalRenderTargetSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + surfaceChanged: typing.ClassVar[QtCore.pyqtSignal] + cameraChanged: typing.ClassVar[QtCore.pyqtSignal] + clearColorChanged: typing.ClassVar[QtCore.pyqtSignal] + viewportRectChanged: typing.ClassVar[QtCore.pyqtSignal] def setExternalRenderTargetSize(self, size: QtCore.QSize) -> None: ... def setSurface(self, surface: QtCore.QObject) -> None: ... def setCamera(self, camera: Qt3DCore.QEntity) -> None: ... @@ -362,14 +349,13 @@ class QForwardRenderer(Qt3DRender.QTechniqueFilter): class QGoochMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def shininessChanged(self, shininess: float) -> None: ... - def betaChanged(self, beta: float) -> None: ... - def alphaChanged(self, alpha: float) -> None: ... - def warmChanged(self, warm: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def coolChanged(self, cool: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + betaChanged: typing.ClassVar[QtCore.pyqtSignal] + alphaChanged: typing.ClassVar[QtCore.pyqtSignal] + warmChanged: typing.ClassVar[QtCore.pyqtSignal] + coolChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] def setShininess(self, shininess: float) -> None: ... def setBeta(self, beta: float) -> None: ... def setAlpha(self, alpha: float) -> None: ... @@ -388,13 +374,12 @@ class QGoochMaterial(Qt3DRender.QMaterial): class QMetalRoughMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def textureScaleChanged(self, textureScale: float) -> None: ... - def normalChanged(self, normal: typing.Any) -> None: ... - def ambientOcclusionChanged(self, ambientOcclusion: typing.Any) -> None: ... - def roughnessChanged(self, roughness: typing.Any) -> None: ... - def metalnessChanged(self, metalness: typing.Any) -> None: ... - def baseColorChanged(self, baseColor: typing.Any) -> None: ... + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientOcclusionChanged: typing.ClassVar[QtCore.pyqtSignal] + roughnessChanged: typing.ClassVar[QtCore.pyqtSignal] + metalnessChanged: typing.ClassVar[QtCore.pyqtSignal] + baseColorChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureScale(self, textureScale: float) -> None: ... def setNormal(self, normal: typing.Any) -> None: ... def setAmbientOcclusion(self, ambientOcclusion: typing.Any) -> None: ... @@ -411,12 +396,11 @@ class QMetalRoughMaterial(Qt3DRender.QMaterial): class QMorphPhongMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def interpolatorChanged(self, interpolator: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + interpolatorChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setInterpolator(self, interpolator: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... @@ -431,13 +415,12 @@ class QMorphPhongMaterial(Qt3DRender.QMaterial): class QNormalDiffuseMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def normalChanged(self, normal: Qt3DRender.QAbstractTexture) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureScale(self, textureScale: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setNormal(self, normal: Qt3DRender.QAbstractTexture) -> None: ... @@ -458,13 +441,12 @@ class QNormalDiffuseMapAlphaMaterial('QNormalDiffuseMapMaterial'): class QNormalDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: Qt3DRender.QAbstractTexture) -> None: ... - def normalChanged(self, normal: Qt3DRender.QAbstractTexture) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureScale(self, textureScale: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: Qt3DRender.QAbstractTexture) -> None: ... @@ -481,8 +463,7 @@ class QNormalDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): class QOrbitCameraController('QAbstractCameraController'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def zoomInLimitChanged(self) -> None: ... + zoomInLimitChanged: typing.ClassVar[QtCore.pyqtSignal] def setZoomInLimit(self, zoomInLimit: float) -> None: ... def zoomInLimit(self) -> float: ... @@ -493,12 +474,11 @@ class QPerVertexColorMaterial(Qt3DRender.QMaterial): class QPhongAlphaMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def blendFunctionArgChanged(self, blendFunctionArg: Qt3DRender.QBlendEquation.BlendFunction) -> None: ... - def destinationAlphaArgChanged(self, destinationAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def sourceAlphaArgChanged(self, sourceAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def destinationRgbArgChanged(self, destinationRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def sourceRgbArgChanged(self, sourceRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + blendFunctionArgChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationAlphaArgChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceAlphaArgChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationRgbArgChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceRgbArgChanged: typing.ClassVar[QtCore.pyqtSignal] def setBlendFunctionArg(self, blendFunctionArg: Qt3DRender.QBlendEquation.BlendFunction) -> None: ... def setDestinationAlphaArg(self, destinationAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... def setSourceAlphaArg(self, sourceAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... @@ -509,11 +489,11 @@ class QPhongAlphaMaterial(Qt3DRender.QMaterial): def sourceAlphaArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... def destinationRgbArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... def sourceRgbArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... - def alphaChanged(self, alpha: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + alphaChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setAlpha(self, alpha: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... @@ -528,11 +508,10 @@ class QPhongAlphaMaterial(Qt3DRender.QMaterial): class QPhongMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setDiffuse(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... @@ -545,13 +524,12 @@ class QPhongMaterial(Qt3DRender.QMaterial): class QPlaneGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def mirroredChanged(self, mirrored: bool) -> None: ... + mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] def setMirrored(self, mirrored: bool) -> None: ... def mirrored(self) -> bool: ... - def heightChanged(self, height: float) -> None: ... - def widthChanged(self, width: float) -> None: ... - def resolutionChanged(self, resolution: QtCore.QSize) -> None: ... + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + resolutionChanged: typing.ClassVar[QtCore.pyqtSignal] def setHeight(self, height: float) -> None: ... def setWidth(self, width: float) -> None: ... def setResolution(self, resolution: QtCore.QSize) -> None: ... @@ -569,13 +547,12 @@ class QPlaneGeometry(Qt3DRender.QGeometry): class QPlaneMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def mirroredChanged(self, mirrored: bool) -> None: ... + mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] def setMirrored(self, mirrored: bool) -> None: ... def mirrored(self) -> bool: ... - def heightChanged(self, height: float) -> None: ... - def widthChanged(self, width: float) -> None: ... - def meshResolutionChanged(self, meshResolution: QtCore.QSize) -> None: ... + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + meshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] def setMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setHeight(self, height: float) -> None: ... def setWidth(self, width: float) -> None: ... @@ -586,12 +563,11 @@ class QPlaneMesh(Qt3DRender.QGeometryRenderer): class QSkyboxEntity(Qt3DCore.QEntity): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def gammaCorrectEnabledChanged(self, enabled: bool) -> None: ... - def baseNameChanged(self, path: str) -> None: ... + gammaCorrectEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + baseNameChanged: typing.ClassVar[QtCore.pyqtSignal] def setGammaCorrectEnabled(self, enabled: bool) -> None: ... def isGammaCorrectEnabled(self) -> bool: ... - def extensionChanged(self, extension: str) -> None: ... + extensionChanged: typing.ClassVar[QtCore.pyqtSignal] def extension(self) -> str: ... def setExtension(self, extension: str) -> None: ... def baseName(self) -> str: ... @@ -600,11 +576,10 @@ class QSkyboxEntity(Qt3DCore.QEntity): class QSphereGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def generateTangentsChanged(self, generateTangents: bool) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + generateTangentsChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setGenerateTangents(self, gen: bool) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -624,11 +599,10 @@ class QSphereGeometry(Qt3DRender.QGeometry): class QSphereMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def generateTangentsChanged(self, generateTangents: bool) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + generateTangentsChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setGenerateTangents(self, gen: bool) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -641,9 +615,8 @@ class QSphereMesh(Qt3DRender.QGeometryRenderer): class QSpriteGrid('QAbstractSpriteSheet'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def columnsChanged(self, columns: int) -> None: ... - def rowsChanged(self, rows: int) -> None: ... + columnsChanged: typing.ClassVar[QtCore.pyqtSignal] + rowsChanged: typing.ClassVar[QtCore.pyqtSignal] def setColumns(self, columns: int) -> None: ... def setRows(self, rows: int) -> None: ... def columns(self) -> int: ... @@ -652,8 +625,7 @@ class QSpriteGrid('QAbstractSpriteSheet'): class QSpriteSheet('QAbstractSpriteSheet'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def spritesChanged(self, sprites: typing.Iterable['QSpriteSheetItem']) -> None: ... + spritesChanged: typing.ClassVar[QtCore.pyqtSignal] def setSprites(self, sprites: typing.Iterable['QSpriteSheetItem']) -> None: ... def removeSprite(self, sprite: 'QSpriteSheetItem') -> None: ... @typing.overload @@ -665,11 +637,10 @@ class QSpriteSheet('QAbstractSpriteSheet'): class QSpriteSheetItem(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def heightChanged(self, height: int) -> None: ... - def widthChanged(self, width: int) -> None: ... - def yChanged(self, y: int) -> None: ... - def xChanged(self, x: int) -> None: ... + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + yChanged: typing.ClassVar[QtCore.pyqtSignal] + xChanged: typing.ClassVar[QtCore.pyqtSignal] def setHeight(self, height: int) -> None: ... def setWidth(self, width: int) -> None: ... def setY(self, y: int) -> None: ... @@ -700,12 +671,11 @@ class Qt3DWindow(QtGui.QWindow): class QText2DEntity(Qt3DCore.QEntity): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def heightChanged(self, height: float) -> None: ... - def widthChanged(self, width: float) -> None: ... - def textChanged(self, text: str) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + textChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] def setHeight(self, height: float) -> None: ... def setWidth(self, width: float) -> None: ... def height(self) -> float: ... @@ -720,18 +690,16 @@ class QText2DEntity(Qt3DCore.QEntity): class QTexturedMetalRoughMaterial('QMetalRoughMaterial'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def normalChanged(self, normal: typing.Any) -> None: ... - def ambientOcclusionChanged(self, ambientOcclusion: typing.Any) -> None: ... + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientOcclusionChanged: typing.ClassVar[QtCore.pyqtSignal] class QTextureMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def alphaBlendingEnabledChanged(self, enabled: bool) -> None: ... - def textureTransformChanged(self, textureTransform: QtGui.QMatrix3x3) -> None: ... - def textureOffsetChanged(self, textureOffset: QtGui.QVector2D) -> None: ... - def textureChanged(self, texture: Qt3DRender.QAbstractTexture) -> None: ... + alphaBlendingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + textureTransformChanged: typing.ClassVar[QtCore.pyqtSignal] + textureOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] + textureChanged: typing.ClassVar[QtCore.pyqtSignal] def setAlphaBlendingEnabled(self, enabled: bool) -> None: ... def setTextureTransform(self, matrix: QtGui.QMatrix3x3) -> None: ... def setTextureOffset(self, textureOffset: QtGui.QVector2D) -> None: ... @@ -744,11 +712,10 @@ class QTextureMaterial(Qt3DRender.QMaterial): class QTorusGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def minorRadiusChanged(self, minorRadius: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + minorRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setMinorRadius(self, minorRadius: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -767,11 +734,10 @@ class QTorusGeometry(Qt3DRender.QGeometry): class QTorusMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def minorRadiusChanged(self, minorRadius: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + minorRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setMinorRadius(self, minorRadius: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... diff --git a/PyQt5-stubs/Qt3DInput.pyi b/PyQt5-stubs/Qt3DInput.pyi index 5c6a8256..302b56c5 100644 --- a/PyQt5-stubs/Qt3DInput.pyi +++ b/PyQt5-stubs/Qt3DInput.pyi @@ -43,8 +43,7 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], class QAbstractActionInput(Qt3DCore.QNode): ... class QAbstractAxisInput(Qt3DCore.QNode): - - def sourceDeviceChanged(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... + sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSourceDevice(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... def sourceDevice(self) -> 'QAbstractPhysicalDevice': ... @@ -67,7 +66,7 @@ class QAction(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def activeChanged(self, isActive: bool) -> None: ... + activeChanged: typing.ClassVar[QtCore.pyqtSignal] def inputs(self) -> typing.List['QAbstractActionInput']: ... def removeInput(self, input: 'QAbstractActionInput') -> None: ... def addInput(self, input: 'QAbstractActionInput') -> None: ... @@ -76,9 +75,8 @@ class QAction(Qt3DCore.QNode): class QActionInput('QAbstractActionInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def buttonsChanged(self, buttons: typing.Iterable[int]) -> None: ... - def sourceDeviceChanged(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... + buttonsChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] def setButtons(self, buttons: typing.Iterable[int]) -> None: ... def setSourceDevice(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... def buttons(self) -> typing.List[int]: ... @@ -87,8 +85,7 @@ class QActionInput('QAbstractActionInput'): class QAnalogAxisInput('QAbstractAxisInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def axisChanged(self, axis: int) -> None: ... + axisChanged: typing.ClassVar[QtCore.pyqtSignal] def setAxis(self, axis: int) -> None: ... def axis(self) -> int: ... @@ -97,7 +94,7 @@ class QAxis(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def valueChanged(self, value: float) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def value(self) -> float: ... def inputs(self) -> typing.List['QAbstractAxisInput']: ... def removeInput(self, input: 'QAbstractAxisInput') -> None: ... @@ -115,11 +112,11 @@ class QAxisAccumulator(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def scaleChanged(self, scale: float) -> None: ... - def velocityChanged(self, value: float) -> None: ... - def valueChanged(self, value: float) -> None: ... - def sourceAxisTypeChanged(self, sourceAxisType: 'QAxisAccumulator.SourceAxisType') -> None: ... - def sourceAxisChanged(self, sourceAxis: 'QAxis') -> None: ... + scaleChanged: typing.ClassVar[QtCore.pyqtSignal] + velocityChanged: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceAxisTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceAxisChanged: typing.ClassVar[QtCore.pyqtSignal] def setScale(self, scale: float) -> None: ... def setSourceAxisType(self, sourceAxisType: 'QAxisAccumulator.SourceAxisType') -> None: ... def setSourceAxis(self, sourceAxis: 'QAxis') -> None: ... @@ -132,10 +129,9 @@ class QAxisAccumulator(Qt3DCore.QComponent): class QAxisSetting(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def smoothChanged(self, smooth: bool) -> None: ... - def axesChanged(self, axes: typing.Iterable[int]) -> None: ... - def deadZoneRadiusChanged(self, deadZoneRadius: float) -> None: ... + smoothChanged: typing.ClassVar[QtCore.pyqtSignal] + axesChanged: typing.ClassVar[QtCore.pyqtSignal] + deadZoneRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setSmoothEnabled(self, enabled: bool) -> None: ... def setAxes(self, axes: typing.Iterable[int]) -> None: ... def setDeadZoneRadius(self, deadZoneRadius: float) -> None: ... @@ -146,11 +142,10 @@ class QAxisSetting(Qt3DCore.QNode): class QButtonAxisInput('QAbstractAxisInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def decelerationChanged(self, deceleration: float) -> None: ... - def accelerationChanged(self, acceleration: float) -> None: ... - def buttonsChanged(self, buttons: typing.Iterable[int]) -> None: ... - def scaleChanged(self, scale: float) -> None: ... + decelerationChanged: typing.ClassVar[QtCore.pyqtSignal] + accelerationChanged: typing.ClassVar[QtCore.pyqtSignal] + buttonsChanged: typing.ClassVar[QtCore.pyqtSignal] + scaleChanged: typing.ClassVar[QtCore.pyqtSignal] def setDeceleration(self, deceleration: float) -> None: ... def setAcceleration(self, acceleration: float) -> None: ... def setButtons(self, buttons: typing.Iterable[int]) -> None: ... @@ -170,8 +165,7 @@ class QInputAspect(Qt3DCore.QAbstractAspect): class QInputChord('QAbstractActionInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def timeoutChanged(self, timeout: int) -> None: ... + timeoutChanged: typing.ClassVar[QtCore.pyqtSignal] def setTimeout(self, timeout: int) -> None: ... def chords(self) -> typing.List['QAbstractActionInput']: ... def removeChord(self, input: 'QAbstractActionInput') -> None: ... @@ -181,9 +175,8 @@ class QInputChord('QAbstractActionInput'): class QInputSequence('QAbstractActionInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def buttonIntervalChanged(self, buttonInterval: int) -> None: ... - def timeoutChanged(self, timeout: int) -> None: ... + buttonIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + timeoutChanged: typing.ClassVar[QtCore.pyqtSignal] def setButtonInterval(self, buttonInterval: int) -> None: ... def setTimeout(self, timeout: int) -> None: ... def sequences(self) -> typing.List['QAbstractActionInput']: ... @@ -195,16 +188,14 @@ class QInputSequence('QAbstractActionInput'): class QInputSettings(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def eventSourceChanged(self, a0: QtCore.QObject) -> None: ... + eventSourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setEventSource(self, eventSource: QtCore.QObject) -> None: ... def eventSource(self) -> QtCore.QObject: ... class QKeyboardDevice('QAbstractPhysicalDevice'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def activeInputChanged(self, activeInput: 'QKeyboardHandler') -> None: ... + activeInputChanged: typing.ClassVar[QtCore.pyqtSignal] def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... def buttonIdentifier(self, name: str) -> int: ... def axisIdentifier(self, name: str) -> int: ... @@ -219,48 +210,48 @@ class QKeyboardHandler(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def released(self, event: 'QKeyEvent') -> None: ... - def pressed(self, event: 'QKeyEvent') -> None: ... - def volumeDownPressed(self, event: 'QKeyEvent') -> None: ... - def volumeUpPressed(self, event: 'QKeyEvent') -> None: ... - def menuPressed(self, event: 'QKeyEvent') -> None: ... - def flipPressed(self, event: 'QKeyEvent') -> None: ... - def hangupPressed(self, event: 'QKeyEvent') -> None: ... - def callPressed(self, event: 'QKeyEvent') -> None: ... - def context4Pressed(self, event: 'QKeyEvent') -> None: ... - def context3Pressed(self, event: 'QKeyEvent') -> None: ... - def context2Pressed(self, event: 'QKeyEvent') -> None: ... - def context1Pressed(self, event: 'QKeyEvent') -> None: ... - def noPressed(self, event: 'QKeyEvent') -> None: ... - def yesPressed(self, event: 'QKeyEvent') -> None: ... - def selectPressed(self, event: 'QKeyEvent') -> None: ... - def cancelPressed(self, event: 'QKeyEvent') -> None: ... - def backPressed(self, event: 'QKeyEvent') -> None: ... - def spacePressed(self, event: 'QKeyEvent') -> None: ... - def deletePressed(self, event: 'QKeyEvent') -> None: ... - def enterPressed(self, event: 'QKeyEvent') -> None: ... - def returnPressed(self, event: 'QKeyEvent') -> None: ... - def escapePressed(self, event: 'QKeyEvent') -> None: ... - def numberSignPressed(self, event: 'QKeyEvent') -> None: ... - def asteriskPressed(self, event: 'QKeyEvent') -> None: ... - def backtabPressed(self, event: 'QKeyEvent') -> None: ... - def tabPressed(self, event: 'QKeyEvent') -> None: ... - def downPressed(self, event: 'QKeyEvent') -> None: ... - def upPressed(self, event: 'QKeyEvent') -> None: ... - def rightPressed(self, event: 'QKeyEvent') -> None: ... - def leftPressed(self, event: 'QKeyEvent') -> None: ... - def digit9Pressed(self, event: 'QKeyEvent') -> None: ... - def digit8Pressed(self, event: 'QKeyEvent') -> None: ... - def digit7Pressed(self, event: 'QKeyEvent') -> None: ... - def digit6Pressed(self, event: 'QKeyEvent') -> None: ... - def digit5Pressed(self, event: 'QKeyEvent') -> None: ... - def digit4Pressed(self, event: 'QKeyEvent') -> None: ... - def digit3Pressed(self, event: 'QKeyEvent') -> None: ... - def digit2Pressed(self, event: 'QKeyEvent') -> None: ... - def digit1Pressed(self, event: 'QKeyEvent') -> None: ... - def digit0Pressed(self, event: 'QKeyEvent') -> None: ... - def focusChanged(self, focus: bool) -> None: ... - def sourceDeviceChanged(self, keyboardDevice: 'QKeyboardDevice') -> None: ... + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + volumeDownPressed: typing.ClassVar[QtCore.pyqtSignal] + volumeUpPressed: typing.ClassVar[QtCore.pyqtSignal] + menuPressed: typing.ClassVar[QtCore.pyqtSignal] + flipPressed: typing.ClassVar[QtCore.pyqtSignal] + hangupPressed: typing.ClassVar[QtCore.pyqtSignal] + callPressed: typing.ClassVar[QtCore.pyqtSignal] + context4Pressed: typing.ClassVar[QtCore.pyqtSignal] + context3Pressed: typing.ClassVar[QtCore.pyqtSignal] + context2Pressed: typing.ClassVar[QtCore.pyqtSignal] + context1Pressed: typing.ClassVar[QtCore.pyqtSignal] + noPressed: typing.ClassVar[QtCore.pyqtSignal] + yesPressed: typing.ClassVar[QtCore.pyqtSignal] + selectPressed: typing.ClassVar[QtCore.pyqtSignal] + cancelPressed: typing.ClassVar[QtCore.pyqtSignal] + backPressed: typing.ClassVar[QtCore.pyqtSignal] + spacePressed: typing.ClassVar[QtCore.pyqtSignal] + deletePressed: typing.ClassVar[QtCore.pyqtSignal] + enterPressed: typing.ClassVar[QtCore.pyqtSignal] + returnPressed: typing.ClassVar[QtCore.pyqtSignal] + escapePressed: typing.ClassVar[QtCore.pyqtSignal] + numberSignPressed: typing.ClassVar[QtCore.pyqtSignal] + asteriskPressed: typing.ClassVar[QtCore.pyqtSignal] + backtabPressed: typing.ClassVar[QtCore.pyqtSignal] + tabPressed: typing.ClassVar[QtCore.pyqtSignal] + downPressed: typing.ClassVar[QtCore.pyqtSignal] + upPressed: typing.ClassVar[QtCore.pyqtSignal] + rightPressed: typing.ClassVar[QtCore.pyqtSignal] + leftPressed: typing.ClassVar[QtCore.pyqtSignal] + digit9Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit8Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit7Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit6Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit5Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit4Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit3Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit2Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit1Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit0Pressed: typing.ClassVar[QtCore.pyqtSignal] + focusChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] def setFocus(self, focus: bool) -> None: ... def setSourceDevice(self, keyboardDevice: 'QKeyboardDevice') -> None: ... def focus(self) -> bool: ... @@ -309,12 +300,11 @@ class QMouseDevice('QAbstractPhysicalDevice'): WheelY = ... # type: QMouseDevice.Axis def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def updateAxesContinuouslyChanged(self, updateAxesContinuously: bool) -> None: ... + updateAxesContinuouslyChanged: typing.ClassVar[QtCore.pyqtSignal] def setUpdateAxesContinuously(self, updateAxesContinuously: bool) -> None: ... def updateAxesContinuously(self) -> bool: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def sensitivityChanged(self, value: float) -> None: ... + sensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] def setSensitivity(self, value: float) -> None: ... def sensitivity(self) -> float: ... def buttonIdentifier(self, name: str) -> int: ... @@ -412,17 +402,17 @@ class QMouseHandler(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def wheel(self, wheel: 'QWheelEvent') -> None: ... - def positionChanged(self, mouse: 'QMouseEvent') -> None: ... - def pressAndHold(self, mouse: 'QMouseEvent') -> None: ... - def released(self, mouse: 'QMouseEvent') -> None: ... - def pressed(self, mouse: 'QMouseEvent') -> None: ... - def exited(self) -> None: ... - def entered(self) -> None: ... - def doubleClicked(self, mouse: 'QMouseEvent') -> None: ... - def clicked(self, mouse: 'QMouseEvent') -> None: ... - def containsMouseChanged(self, containsMouse: bool) -> None: ... - def sourceDeviceChanged(self, mouseDevice: 'QMouseDevice') -> None: ... + wheel: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + pressAndHold: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + exited: typing.ClassVar[QtCore.pyqtSignal] + entered: typing.ClassVar[QtCore.pyqtSignal] + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + containsMouseChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSourceDevice(self, mouseDevice: 'QMouseDevice') -> None: ... def containsMouse(self) -> bool: ... def sourceDevice(self) -> 'QMouseDevice': ... diff --git a/PyQt5-stubs/Qt3DLogic.pyi b/PyQt5-stubs/Qt3DLogic.pyi index dd8cabb8..03262555 100644 --- a/PyQt5-stubs/Qt3DLogic.pyi +++ b/PyQt5-stubs/Qt3DLogic.pyi @@ -42,8 +42,7 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], class QFrameAction(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def triggered(self, dt: float) -> None: ... + triggered: typing.ClassVar[QtCore.pyqtSignal] class QLogicAspect(Qt3DCore.QAbstractAspect): diff --git a/PyQt5-stubs/Qt3DRender.pyi b/PyQt5-stubs/Qt3DRender.pyi index 43b9e810..6258830a 100644 --- a/PyQt5-stubs/Qt3DRender.pyi +++ b/PyQt5-stubs/Qt3DRender.pyi @@ -54,9 +54,8 @@ class QAbstractLight(Qt3DCore.QComponent): PointLight = ... # type: QAbstractLight.Type DirectionalLight = ... # type: QAbstractLight.Type SpotLight = ... # type: QAbstractLight.Type - - def intensityChanged(self, intensity: float) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + intensityChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] def setIntensity(self, intensity: float) -> None: ... def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def intensity(self) -> float: ... @@ -86,9 +85,9 @@ class QAbstractRayCaster(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def filterModeChanged(self, filterMode: 'QAbstractRayCaster.FilterMode') -> None: ... - def hitsChanged(self, hits: typing.Iterable['QRayCasterHit']) -> None: ... - def runModeChanged(self, runMode: 'QAbstractRayCaster.RunMode') -> None: ... + filterModeChanged: typing.ClassVar[QtCore.pyqtSignal] + hitsChanged: typing.ClassVar[QtCore.pyqtSignal] + runModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setFilterMode(self, filterMode: 'QAbstractRayCaster.FilterMode') -> None: ... def setRunMode(self, runMode: 'QAbstractRayCaster.RunMode') -> None: ... def layers(self) -> typing.List['QLayer']: ... @@ -412,25 +411,25 @@ class QAbstractTexture(Qt3DCore.QNode): def __init__(self, target: 'QAbstractTexture.Target', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def updateData(self, update: 'QTextureDataUpdate') -> None: ... - def handleChanged(self, handle: typing.Any) -> None: ... - def handleTypeChanged(self, handleType: 'QAbstractTexture.HandleType') -> None: ... + handleChanged: typing.ClassVar[QtCore.pyqtSignal] + handleTypeChanged: typing.ClassVar[QtCore.pyqtSignal] def handle(self) -> typing.Any: ... def handleType(self) -> 'QAbstractTexture.HandleType': ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... def setStatus(self, status: 'QAbstractTexture.Status') -> None: ... - def samplesChanged(self, samples: int) -> None: ... - def layersChanged(self, layers: int) -> None: ... - def comparisonModeChanged(self, comparisonMode: 'QAbstractTexture.ComparisonMode') -> None: ... - def comparisonFunctionChanged(self, comparisonFunction: 'QAbstractTexture.ComparisonFunction') -> None: ... - def maximumAnisotropyChanged(self, maximumAnisotropy: float) -> None: ... - def minificationFilterChanged(self, minificationFilter: 'QAbstractTexture.Filter') -> None: ... - def magnificationFilterChanged(self, magnificationFilter: 'QAbstractTexture.Filter') -> None: ... - def depthChanged(self, depth: int) -> None: ... - def heightChanged(self, height: int) -> None: ... - def widthChanged(self, width: int) -> None: ... - def generateMipMapsChanged(self, generateMipMaps: bool) -> None: ... - def statusChanged(self, status: 'QAbstractTexture.Status') -> None: ... - def formatChanged(self, format: 'QAbstractTexture.TextureFormat') -> None: ... + samplesChanged: typing.ClassVar[QtCore.pyqtSignal] + layersChanged: typing.ClassVar[QtCore.pyqtSignal] + comparisonModeChanged: typing.ClassVar[QtCore.pyqtSignal] + comparisonFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] + maximumAnisotropyChanged: typing.ClassVar[QtCore.pyqtSignal] + minificationFilterChanged: typing.ClassVar[QtCore.pyqtSignal] + magnificationFilterChanged: typing.ClassVar[QtCore.pyqtSignal] + depthChanged: typing.ClassVar[QtCore.pyqtSignal] + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + generateMipMapsChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + formatChanged: typing.ClassVar[QtCore.pyqtSignal] def setSamples(self, samples: int) -> None: ... def setLayers(self, layers: int) -> None: ... def setComparisonMode(self, mode: 'QAbstractTexture.ComparisonMode') -> None: ... @@ -471,9 +470,9 @@ class QAbstractTextureImage(Qt3DCore.QNode): def dataGenerator(self) -> 'QTextureImageDataGenerator': ... def notifyDataGeneratorChanged(self) -> None: ... - def faceChanged(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... - def layerChanged(self, layer: int) -> None: ... - def mipLevelChanged(self, mipLevel: int) -> None: ... + faceChanged: typing.ClassVar[QtCore.pyqtSignal] + layerChanged: typing.ClassVar[QtCore.pyqtSignal] + mipLevelChanged: typing.ClassVar[QtCore.pyqtSignal] def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... def setLayer(self, layer: int) -> None: ... def setMipLevel(self, level: int) -> None: ... @@ -509,9 +508,8 @@ class QAlphaTest('QRenderState'): NotEqual = ... # type: QAlphaTest.AlphaFunction def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def referenceValueChanged(self, referenceValue: float) -> None: ... - def alphaFunctionChanged(self, alphaFunction: 'QAlphaTest.AlphaFunction') -> None: ... + referenceValueChanged: typing.ClassVar[QtCore.pyqtSignal] + alphaFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] def setReferenceValue(self, referenceValue: float) -> None: ... def setAlphaFunction(self, alphaFunction: 'QAlphaTest.AlphaFunction') -> None: ... def referenceValue(self) -> float: ... @@ -555,18 +553,17 @@ class QAttribute(Qt3DCore.QNode): def __init__(self, buf: 'QBuffer', vertexBaseType: 'QAttribute.VertexBaseType', vertexSize: int, count: int, offset: int = ..., stride: int = ..., parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... @typing.overload def __init__(self, buf: 'QBuffer', name: str, vertexBaseType: 'QAttribute.VertexBaseType', vertexSize: int, count: int, offset: int = ..., stride: int = ..., parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def vertexSizeChanged(self, vertexSize: int) -> None: ... - def vertexBaseTypeChanged(self, vertexBaseType: 'QAttribute.VertexBaseType') -> None: ... - def attributeTypeChanged(self, attributeType: 'QAttribute.AttributeType') -> None: ... - def divisorChanged(self, divisor: int) -> None: ... - def byteOffsetChanged(self, byteOffset: int) -> None: ... - def byteStrideChanged(self, byteStride: int) -> None: ... - def countChanged(self, count: int) -> None: ... - def dataSizeChanged(self, vertexSize: int) -> None: ... - def dataTypeChanged(self, vertexBaseType: 'QAttribute.VertexBaseType') -> None: ... - def nameChanged(self, name: str) -> None: ... - def bufferChanged(self, buffer: 'QBuffer') -> None: ... + vertexSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + vertexBaseTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + attributeTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + divisorChanged: typing.ClassVar[QtCore.pyqtSignal] + byteOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] + byteStrideChanged: typing.ClassVar[QtCore.pyqtSignal] + countChanged: typing.ClassVar[QtCore.pyqtSignal] + dataSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + dataTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] + bufferChanged: typing.ClassVar[QtCore.pyqtSignal] def setVertexSize(self, size: int) -> None: ... def setVertexBaseType(self, type: 'QAttribute.VertexBaseType') -> None: ... def setAttributeType(self, attributeType: 'QAttribute.AttributeType') -> None: ... @@ -622,8 +619,7 @@ class QBlendEquation('QRenderState'): Max = ... # type: QBlendEquation.BlendFunction def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def blendFunctionChanged(self, blendFunction: 'QBlendEquation.BlendFunction') -> None: ... + blendFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] def setBlendFunction(self, blendFunction: 'QBlendEquation.BlendFunction') -> None: ... def blendFunction(self) -> 'QBlendEquation.BlendFunction': ... @@ -673,14 +669,13 @@ class QBlendEquationArguments('QRenderState'): OneMinusSource1Color = ... # type: QBlendEquationArguments.Blending def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def bufferIndexChanged(self, index: int) -> None: ... - def destinationRgbaChanged(self, destinationRgba: 'QBlendEquationArguments.Blending') -> None: ... - def sourceRgbaChanged(self, sourceRgba: 'QBlendEquationArguments.Blending') -> None: ... - def destinationAlphaChanged(self, destinationAlpha: 'QBlendEquationArguments.Blending') -> None: ... - def destinationRgbChanged(self, destinationRgb: 'QBlendEquationArguments.Blending') -> None: ... - def sourceAlphaChanged(self, sourceAlpha: 'QBlendEquationArguments.Blending') -> None: ... - def sourceRgbChanged(self, sourceRgb: 'QBlendEquationArguments.Blending') -> None: ... + bufferIndexChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationRgbaChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceRgbaChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationAlphaChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationRgbChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceAlphaChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceRgbChanged: typing.ClassVar[QtCore.pyqtSignal] def setBufferIndex(self, index: int) -> None: ... def setDestinationRgba(self, destinationRgba: 'QBlendEquationArguments.Blending') -> None: ... def setSourceRgba(self, sourceRgba: 'QBlendEquationArguments.Blending') -> None: ... @@ -710,14 +705,13 @@ class QBlitFramebuffer('QFrameGraphNode'): Linear = ... # type: QBlitFramebuffer.InterpolationMethod def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def interpolationMethodChanged(self) -> None: ... - def destinationAttachmentPointChanged(self) -> None: ... - def sourceAttachmentPointChanged(self) -> None: ... - def destinationRectChanged(self) -> None: ... - def sourceRectChanged(self) -> None: ... - def destinationChanged(self) -> None: ... - def sourceChanged(self) -> None: ... + interpolationMethodChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationAttachmentPointChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceAttachmentPointChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationRectChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceRectChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setInterpolationMethod(self, interpolationMethod: 'QBlitFramebuffer.InterpolationMethod') -> None: ... def setDestinationAttachmentPoint(self, destinationAttachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... def setSourceAttachmentPoint(self, sourceAttachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... @@ -786,17 +780,16 @@ class QBuffer(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... @typing.overload def __init__(self, ty: 'QBuffer.BufferType', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def dataAvailable(self) -> None: ... - def accessTypeChanged(self, access: 'QBuffer.AccessType') -> None: ... + dataAvailable: typing.ClassVar[QtCore.pyqtSignal] + accessTypeChanged: typing.ClassVar[QtCore.pyqtSignal] def setAccessType(self, access: 'QBuffer.AccessType') -> None: ... def accessType(self) -> 'QBuffer.AccessType': ... def updateData(self, offset: int, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def syncDataChanged(self, syncData: bool) -> None: ... - def usageChanged(self, usage: 'QBuffer.UsageType') -> None: ... - def typeChanged(self, type: 'QBuffer.BufferType') -> None: ... - def dataChanged(self, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + syncDataChanged: typing.ClassVar[QtCore.pyqtSignal] + usageChanged: typing.ClassVar[QtCore.pyqtSignal] + typeChanged: typing.ClassVar[QtCore.pyqtSignal] + dataChanged: typing.ClassVar[QtCore.pyqtSignal] def setSyncData(self, syncData: bool) -> None: ... def setUsage(self, usage: 'QBuffer.UsageType') -> None: ... def setType(self, type: 'QBuffer.BufferType') -> None: ... @@ -826,24 +819,24 @@ class QCamera(Qt3DCore.QEntity): def viewEntity(self, entity: Qt3DCore.QEntity) -> None: ... def viewSphere(self, center: QtGui.QVector3D, radius: float) -> None: ... def viewAll(self) -> None: ... - def exposureChanged(self, exposure: float) -> None: ... + exposureChanged: typing.ClassVar[QtCore.pyqtSignal] def setExposure(self, exposure: float) -> None: ... def exposure(self) -> float: ... - def viewMatrixChanged(self) -> None: ... - def viewVectorChanged(self, viewVector: QtGui.QVector3D) -> None: ... - def viewCenterChanged(self, viewCenter: QtGui.QVector3D) -> None: ... - def upVectorChanged(self, upVector: QtGui.QVector3D) -> None: ... - def positionChanged(self, position: QtGui.QVector3D) -> None: ... - def projectionMatrixChanged(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... - def topChanged(self, top: float) -> None: ... - def bottomChanged(self, bottom: float) -> None: ... - def rightChanged(self, right: float) -> None: ... - def leftChanged(self, left: float) -> None: ... - def aspectRatioChanged(self, aspectRatio: float) -> None: ... - def fieldOfViewChanged(self, fieldOfView: float) -> None: ... - def farPlaneChanged(self, farPlane: float) -> None: ... - def nearPlaneChanged(self, nearPlane: float) -> None: ... - def projectionTypeChanged(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... + viewMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] + viewVectorChanged: typing.ClassVar[QtCore.pyqtSignal] + viewCenterChanged: typing.ClassVar[QtCore.pyqtSignal] + upVectorChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + projectionMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] + topChanged: typing.ClassVar[QtCore.pyqtSignal] + bottomChanged: typing.ClassVar[QtCore.pyqtSignal] + rightChanged: typing.ClassVar[QtCore.pyqtSignal] + leftChanged: typing.ClassVar[QtCore.pyqtSignal] + aspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + fieldOfViewChanged: typing.ClassVar[QtCore.pyqtSignal] + farPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] + nearPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] + projectionTypeChanged: typing.ClassVar[QtCore.pyqtSignal] def setViewCenter(self, viewCenter: QtGui.QVector3D) -> None: ... def setUpVector(self, upVector: QtGui.QVector3D) -> None: ... def setPosition(self, position: QtGui.QVector3D) -> None: ... @@ -909,23 +902,22 @@ class QCameraLens(Qt3DCore.QComponent): CustomProjection = ... # type: QCameraLens.ProjectionType def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def viewSphere(self, center: QtGui.QVector3D, radius: float) -> None: ... + viewSphere: typing.ClassVar[QtCore.pyqtSignal] def viewEntity(self, entityId: Qt3DCore.QNodeId, cameraId: Qt3DCore.QNodeId) -> None: ... def viewAll(self, cameraId: Qt3DCore.QNodeId) -> None: ... - def exposureChanged(self, exposure: float) -> None: ... + exposureChanged: typing.ClassVar[QtCore.pyqtSignal] def setExposure(self, exposure: float) -> None: ... def exposure(self) -> float: ... - def projectionMatrixChanged(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... - def topChanged(self, top: float) -> None: ... - def bottomChanged(self, bottom: float) -> None: ... - def rightChanged(self, right: float) -> None: ... - def leftChanged(self, left: float) -> None: ... - def aspectRatioChanged(self, aspectRatio: float) -> None: ... - def fieldOfViewChanged(self, fieldOfView: float) -> None: ... - def farPlaneChanged(self, farPlane: float) -> None: ... - def nearPlaneChanged(self, nearPlane: float) -> None: ... - def projectionTypeChanged(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... + projectionMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] + topChanged: typing.ClassVar[QtCore.pyqtSignal] + bottomChanged: typing.ClassVar[QtCore.pyqtSignal] + rightChanged: typing.ClassVar[QtCore.pyqtSignal] + leftChanged: typing.ClassVar[QtCore.pyqtSignal] + aspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + fieldOfViewChanged: typing.ClassVar[QtCore.pyqtSignal] + farPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] + nearPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] + projectionTypeChanged: typing.ClassVar[QtCore.pyqtSignal] def setProjectionMatrix(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... def setTop(self, top: float) -> None: ... def setBottom(self, bottom: float) -> None: ... @@ -953,8 +945,7 @@ class QCameraLens(Qt3DCore.QComponent): class QCameraSelector('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def cameraChanged(self, camera: Qt3DCore.QEntity) -> None: ... + cameraChanged: typing.ClassVar[QtCore.pyqtSignal] def setCamera(self, camera: Qt3DCore.QEntity) -> None: ... def camera(self) -> Qt3DCore.QEntity: ... @@ -995,12 +986,11 @@ class QClearBuffers('QFrameGraphNode'): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def colorBufferChanged(self, buffer: 'QRenderTargetOutput') -> None: ... - def clearStencilValueChanged(self, clearStencilValue: int) -> None: ... - def clearDepthValueChanged(self, clearDepthValue: float) -> None: ... - def clearColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def buffersChanged(self, buffers: 'QClearBuffers.BufferType') -> None: ... + colorBufferChanged: typing.ClassVar[QtCore.pyqtSignal] + clearStencilValueChanged: typing.ClassVar[QtCore.pyqtSignal] + clearDepthValueChanged: typing.ClassVar[QtCore.pyqtSignal] + clearColorChanged: typing.ClassVar[QtCore.pyqtSignal] + buffersChanged: typing.ClassVar[QtCore.pyqtSignal] def setColorBuffer(self, buffer: 'QRenderTargetOutput') -> None: ... def setClearStencilValue(self, clearStencilValue: int) -> None: ... def setClearDepthValue(self, clearDepthValue: float) -> None: ... @@ -1015,10 +1005,9 @@ class QClearBuffers('QFrameGraphNode'): class QClipPlane('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def distanceChanged(self, distance: float) -> None: ... - def normalChanged(self, normal: QtGui.QVector3D) -> None: ... - def planeIndexChanged(self, planeIndex: int) -> None: ... + distanceChanged: typing.ClassVar[QtCore.pyqtSignal] + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + planeIndexChanged: typing.ClassVar[QtCore.pyqtSignal] def setDistance(self, a0: float) -> None: ... def setNormal(self, a0: QtGui.QVector3D) -> None: ... def setPlaneIndex(self, a0: int) -> None: ... @@ -1036,17 +1025,16 @@ class QComputeCommand(Qt3DCore.QComponent): Manual = ... # type: QComputeCommand.RunType def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def runTypeChanged(self) -> None: ... + runTypeChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def trigger(self, frameCount: int = ...) -> None: ... @typing.overload def trigger(self, workGroupX: int, workGroupY: int, workGroupZ: int, frameCount: int = ...) -> None: ... def setRunType(self, runType: 'QComputeCommand.RunType') -> None: ... def runType(self) -> 'QComputeCommand.RunType': ... - def workGroupZChanged(self) -> None: ... - def workGroupYChanged(self) -> None: ... - def workGroupXChanged(self) -> None: ... + workGroupZChanged: typing.ClassVar[QtCore.pyqtSignal] + workGroupYChanged: typing.ClassVar[QtCore.pyqtSignal] + workGroupXChanged: typing.ClassVar[QtCore.pyqtSignal] def setWorkGroupZ(self, workGroupZ: int) -> None: ... def setWorkGroupY(self, workGroupY: int) -> None: ... def setWorkGroupX(self, workGroupX: int) -> None: ... @@ -1057,11 +1045,10 @@ class QComputeCommand(Qt3DCore.QComponent): class QColorMask('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def alphaMaskedChanged(self, alphaMasked: bool) -> None: ... - def blueMaskedChanged(self, blueMasked: bool) -> None: ... - def greenMaskedChanged(self, greenMasked: bool) -> None: ... - def redMaskedChanged(self, redMasked: bool) -> None: ... + alphaMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] + blueMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] + greenMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] + redMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] def setAlphaMasked(self, alphaMasked: bool) -> None: ... def setBlueMasked(self, blueMasked: bool) -> None: ... def setGreenMasked(self, greenMasked: bool) -> None: ... @@ -1085,17 +1072,15 @@ class QCullFace('QRenderState'): FrontAndBack = ... # type: QCullFace.CullingMode def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def modeChanged(self, mode: 'QCullFace.CullingMode') -> None: ... + modeChanged: typing.ClassVar[QtCore.pyqtSignal] def setMode(self, mode: 'QCullFace.CullingMode') -> None: ... def mode(self) -> 'QCullFace.CullingMode': ... class QDepthRange('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def farValueChanged(self, farValue: float) -> None: ... - def nearValueChanged(self, nearValue: float) -> None: ... + farValueChanged: typing.ClassVar[QtCore.pyqtSignal] + nearValueChanged: typing.ClassVar[QtCore.pyqtSignal] def setFarValue(self, value: float) -> None: ... def setNearValue(self, value: float) -> None: ... def farValue(self) -> float: ... @@ -1123,26 +1108,23 @@ class QDepthTest('QRenderState'): NotEqual = ... # type: QDepthTest.DepthFunction def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def depthFunctionChanged(self, depthFunction: 'QDepthTest.DepthFunction') -> None: ... + depthFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] def setDepthFunction(self, depthFunction: 'QDepthTest.DepthFunction') -> None: ... def depthFunction(self) -> 'QDepthTest.DepthFunction': ... class QDirectionalLight('QAbstractLight'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def worldDirectionChanged(self, worldDirection: QtGui.QVector3D) -> None: ... + worldDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] def setWorldDirection(self, worldDirection: QtGui.QVector3D) -> None: ... def worldDirection(self) -> QtGui.QVector3D: ... class QDispatchCompute('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def workGroupZChanged(self) -> None: ... - def workGroupYChanged(self) -> None: ... - def workGroupXChanged(self) -> None: ... + workGroupZChanged: typing.ClassVar[QtCore.pyqtSignal] + workGroupYChanged: typing.ClassVar[QtCore.pyqtSignal] + workGroupXChanged: typing.ClassVar[QtCore.pyqtSignal] def setWorkGroupZ(self, workGroupZ: int) -> None: ... def setWorkGroupY(self, workGroupY: int) -> None: ... def setWorkGroupX(self, workGroupX: int) -> None: ... @@ -1168,9 +1150,8 @@ class QEffect(Qt3DCore.QNode): class QEnvironmentLight(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def specularChanged(self, environmentSpecular: 'QAbstractTexture') -> None: ... - def irradianceChanged(self, environmentIrradiance: 'QAbstractTexture') -> None: ... + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + irradianceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSpecular(self, specular: 'QAbstractTexture') -> None: ... def setIrradiance(self, irradiance: 'QAbstractTexture') -> None: ... def specular(self) -> 'QAbstractTexture': ... @@ -1179,9 +1160,8 @@ class QEnvironmentLight(Qt3DCore.QComponent): class QFilterKey(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def valueChanged(self, value: typing.Any) -> None: ... - def nameChanged(self, name: str) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] def setName(self, customType: str) -> None: ... def setValue(self, value: typing.Any) -> None: ... def name(self) -> str: ... @@ -1197,8 +1177,7 @@ class QFrontFace('QRenderState'): CounterClockWise = ... # type: QFrontFace.WindingDirection def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def directionChanged(self, direction: 'QFrontFace.WindingDirection') -> None: ... + directionChanged: typing.ClassVar[QtCore.pyqtSignal] def setDirection(self, direction: 'QFrontFace.WindingDirection') -> None: ... def direction(self) -> 'QFrontFace.WindingDirection': ... @@ -1211,11 +1190,11 @@ class QGeometry(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def maxExtentChanged(self, maxExtent: QtGui.QVector3D) -> None: ... - def minExtentChanged(self, minExtent: QtGui.QVector3D) -> None: ... + maxExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + minExtentChanged: typing.ClassVar[QtCore.pyqtSignal] def maxExtent(self) -> QtGui.QVector3D: ... def minExtent(self) -> QtGui.QVector3D: ... - def boundingVolumePositionAttributeChanged(self, boundingVolumePositionAttribute: 'QAttribute') -> None: ... + boundingVolumePositionAttributeChanged: typing.ClassVar[QtCore.pyqtSignal] def setBoundingVolumePositionAttribute(self, boundingVolumePositionAttribute: 'QAttribute') -> None: ... def boundingVolumePositionAttribute(self) -> 'QAttribute': ... def removeAttribute(self, attribute: 'QAttribute') -> None: ... @@ -1258,19 +1237,19 @@ class QGeometryRenderer(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def indexBufferByteOffsetChanged(self, offset: int) -> None: ... + indexBufferByteOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] def setIndexBufferByteOffset(self, offset: int) -> None: ... def indexBufferByteOffset(self) -> int: ... - def primitiveTypeChanged(self, primitiveType: 'QGeometryRenderer.PrimitiveType') -> None: ... - def geometryChanged(self, geometry: 'QGeometry') -> None: ... - def primitiveRestartEnabledChanged(self, primitiveRestartEnabled: bool) -> None: ... - def verticesPerPatchChanged(self, verticesPerPatch: int) -> None: ... - def restartIndexValueChanged(self, restartIndexValue: int) -> None: ... - def firstVertexChanged(self, firstVertex: int) -> None: ... - def firstInstanceChanged(self, firstInstance: int) -> None: ... - def indexOffsetChanged(self, indexOffset: int) -> None: ... - def vertexCountChanged(self, vertexCount: int) -> None: ... - def instanceCountChanged(self, instanceCount: int) -> None: ... + primitiveTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryChanged: typing.ClassVar[QtCore.pyqtSignal] + primitiveRestartEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + verticesPerPatchChanged: typing.ClassVar[QtCore.pyqtSignal] + restartIndexValueChanged: typing.ClassVar[QtCore.pyqtSignal] + firstVertexChanged: typing.ClassVar[QtCore.pyqtSignal] + firstInstanceChanged: typing.ClassVar[QtCore.pyqtSignal] + indexOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] + vertexCountChanged: typing.ClassVar[QtCore.pyqtSignal] + instanceCountChanged: typing.ClassVar[QtCore.pyqtSignal] def setPrimitiveType(self, primitiveType: 'QGeometryRenderer.PrimitiveType') -> None: ... def setGeometry(self, geometry: 'QGeometry') -> None: ... def setPrimitiveRestartEnabled(self, enabled: bool) -> None: ... @@ -1319,14 +1298,13 @@ class QGraphicsApiFilter(QtCore.QObject): RHI = ... # type: QGraphicsApiFilter.Api def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def graphicsApiFilterChanged(self) -> None: ... - def vendorChanged(self, vendor: str) -> None: ... - def extensionsChanged(self, extensions: typing.Iterable[str]) -> None: ... - def majorVersionChanged(self, majorVersion: int) -> None: ... - def minorVersionChanged(self, minorVersion: int) -> None: ... - def profileChanged(self, profile: 'QGraphicsApiFilter.OpenGLProfile') -> None: ... - def apiChanged(self, api: 'QGraphicsApiFilter.Api') -> None: ... + graphicsApiFilterChanged: typing.ClassVar[QtCore.pyqtSignal] + vendorChanged: typing.ClassVar[QtCore.pyqtSignal] + extensionsChanged: typing.ClassVar[QtCore.pyqtSignal] + majorVersionChanged: typing.ClassVar[QtCore.pyqtSignal] + minorVersionChanged: typing.ClassVar[QtCore.pyqtSignal] + profileChanged: typing.ClassVar[QtCore.pyqtSignal] + apiChanged: typing.ClassVar[QtCore.pyqtSignal] def setVendor(self, vendor: str) -> None: ... def setExtensions(self, extensions: typing.Iterable[str]) -> None: ... def setMajorVersion(self, majorVersion: int) -> None: ... @@ -1343,8 +1321,7 @@ class QGraphicsApiFilter(QtCore.QObject): class QLayer(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def recursiveChanged(self) -> None: ... + recursiveChanged: typing.ClassVar[QtCore.pyqtSignal] def setRecursive(self, recursive: bool) -> None: ... def recursive(self) -> bool: ... @@ -1362,8 +1339,7 @@ class QLayerFilter('QFrameGraphNode'): DiscardAllMatchingLayers = ... # type: QLayerFilter.FilterMode def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def filterModeChanged(self, filterMode: 'QLayerFilter.FilterMode') -> None: ... + filterModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setFilterMode(self, filterMode: 'QLayerFilter.FilterMode') -> None: ... def filterMode(self) -> 'QLayerFilter.FilterMode': ... def layers(self) -> typing.List['QLayer']: ... @@ -1382,11 +1358,11 @@ class QLevelOfDetail(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def volumeOverrideChanged(self, volumeOverride: 'QLevelOfDetailBoundingSphere') -> None: ... - def thresholdsChanged(self, thresholds: typing.Iterable[float]) -> None: ... - def thresholdTypeChanged(self, thresholdType: 'QLevelOfDetail.ThresholdType') -> None: ... - def currentIndexChanged(self, currentIndex: int) -> None: ... - def cameraChanged(self, camera: 'QCamera') -> None: ... + volumeOverrideChanged: typing.ClassVar[QtCore.pyqtSignal] + thresholdsChanged: typing.ClassVar[QtCore.pyqtSignal] + thresholdTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] + cameraChanged: typing.ClassVar[QtCore.pyqtSignal] def setVolumeOverride(self, volumeOverride: 'QLevelOfDetailBoundingSphere') -> None: ... def setThresholds(self, thresholds: typing.Iterable[float]) -> None: ... def setThresholdType(self, thresholdType: 'QLevelOfDetail.ThresholdType') -> None: ... @@ -1419,9 +1395,8 @@ class QLevelOfDetailSwitch('QLevelOfDetail'): class QLineWidth('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def smoothChanged(self, enabled: bool) -> None: ... - def valueChanged(self, value: float) -> None: ... + smoothChanged: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setSmooth(self, enabled: bool) -> None: ... def setValue(self, value: float) -> None: ... def smooth(self) -> bool: ... @@ -1430,8 +1405,7 @@ class QLineWidth('QRenderState'): class QMaterial(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def effectChanged(self, effect: 'QEffect') -> None: ... + effectChanged: typing.ClassVar[QtCore.pyqtSignal] def setEffect(self, effect: 'QEffect') -> None: ... def parameters(self) -> typing.List['QParameter']: ... def removeParameter(self, parameter: 'QParameter') -> None: ... @@ -1491,8 +1465,7 @@ class QMemoryBarrier('QFrameGraphNode'): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def waitOperationsChanged(self, barrierTypes: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... + waitOperationsChanged: typing.ClassVar[QtCore.pyqtSignal] def setWaitOperations(self, operations: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... def waitOperations(self) -> 'QMemoryBarrier.Operations': ... @@ -1512,10 +1485,10 @@ class QMesh('QGeometryRenderer'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QMesh.Status') -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] def status(self) -> 'QMesh.Status': ... - def meshNameChanged(self, meshName: str) -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + meshNameChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setMeshName(self, meshName: str) -> None: ... def setSource(self, source: QtCore.QUrl) -> None: ... def meshName(self) -> str: ... @@ -1540,21 +1513,20 @@ class QNoPicking('QFrameGraphNode'): class QObjectPicker(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def priorityChanged(self, priority: int) -> None: ... + priorityChanged: typing.ClassVar[QtCore.pyqtSignal] def setPriority(self, priority: int) -> None: ... def priority(self) -> int: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def containsMouseChanged(self, containsMouse: bool) -> None: ... - def pressedChanged(self, pressed: bool) -> None: ... - def dragEnabledChanged(self, dragEnabled: bool) -> None: ... - def hoverEnabledChanged(self, hoverEnabled: bool) -> None: ... - def exited(self) -> None: ... - def entered(self) -> None: ... - def moved(self, pick: 'QPickEvent') -> None: ... - def clicked(self, pick: 'QPickEvent') -> None: ... - def released(self, pick: 'QPickEvent') -> None: ... - def pressed(self, pick: 'QPickEvent') -> None: ... + containsMouseChanged: typing.ClassVar[QtCore.pyqtSignal] + pressedChanged: typing.ClassVar[QtCore.pyqtSignal] + dragEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + hoverEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + exited: typing.ClassVar[QtCore.pyqtSignal] + entered: typing.ClassVar[QtCore.pyqtSignal] + moved: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] def setDragEnabled(self, dragEnabled: bool) -> None: ... def setHoverEnabled(self, hoverEnabled: bool) -> None: ... def isPressed(self) -> bool: ... @@ -1567,9 +1539,9 @@ class QPaintedTextureImage('QAbstractTextureImage'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def paint(self, painter: QtGui.QPainter) -> None: ... - def sizeChanged(self, size: QtCore.QSize) -> None: ... - def heightChanged(self, w: int) -> None: ... - def widthChanged(self, w: int) -> None: ... + sizeChanged: typing.ClassVar[QtCore.pyqtSignal] + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] def setSize(self, size: QtCore.QSize) -> None: ... def setHeight(self, h: int) -> None: ... def setWidth(self, w: int) -> None: ... @@ -1586,9 +1558,8 @@ class QParameter(Qt3DCore.QNode): def __init__(self, name: str, value: typing.Any, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... @typing.overload def __init__(self, name: str, texture: 'QAbstractTexture', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def nameChanged(self, name: str) -> None: ... - def valueChanged(self, value: typing.Any) -> None: ... + nameChanged: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, dv: typing.Any) -> None: ... def setName(self, name: str) -> None: ... def value(self) -> typing.Any: ... @@ -1636,7 +1607,7 @@ class QPickEvent(QtCore.QObject): def modifiers(self) -> int: ... def buttons(self) -> int: ... def button(self) -> 'QPickEvent.Buttons': ... - def acceptedChanged(self, accepted: bool) -> None: ... + acceptedChanged: typing.ClassVar[QtCore.pyqtSignal] def setAccepted(self, accepted: bool) -> None: ... def localIntersection(self) -> QtGui.QVector3D: ... def worldIntersection(self) -> QtGui.QVector3D: ... @@ -1678,15 +1649,14 @@ class QPickingSettings(Qt3DCore.QNode): PrimitivePicking = ... # type: QPickingSettings.PickMethod def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def worldSpaceToleranceChanged(self, worldSpaceTolerance: float) -> None: ... + worldSpaceToleranceChanged: typing.ClassVar[QtCore.pyqtSignal] def setWorldSpaceTolerance(self, worldSpaceTolerance: float) -> None: ... def worldSpaceTolerance(self) -> float: ... - def faceOrientationPickingModeChanged(self, faceOrientationPickingMode: 'QPickingSettings.FaceOrientationPickingMode') -> None: ... + faceOrientationPickingModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setFaceOrientationPickingMode(self, faceOrientationPickingMode: 'QPickingSettings.FaceOrientationPickingMode') -> None: ... def faceOrientationPickingMode(self) -> 'QPickingSettings.FaceOrientationPickingMode': ... - def pickResultModeChanged(self, pickResult: 'QPickingSettings.PickResultMode') -> None: ... - def pickMethodChanged(self, pickMethod: 'QPickingSettings.PickMethod') -> None: ... + pickResultModeChanged: typing.ClassVar[QtCore.pyqtSignal] + pickMethodChanged: typing.ClassVar[QtCore.pyqtSignal] def setPickResultMode(self, pickResultMode: 'QPickingSettings.PickResultMode') -> None: ... def setPickMethod(self, pickMethod: 'QPickingSettings.PickMethod') -> None: ... def pickResultMode(self) -> 'QPickingSettings.PickResultMode': ... @@ -1730,10 +1700,9 @@ class QPickTriangleEvent('QPickEvent'): class QPointLight('QAbstractLight'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def quadraticAttenuationChanged(self, quadraticAttenuation: float) -> None: ... - def linearAttenuationChanged(self, linearAttenuation: float) -> None: ... - def constantAttenuationChanged(self, constantAttenuation: float) -> None: ... + quadraticAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] + linearAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] + constantAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] def setQuadraticAttenuation(self, value: float) -> None: ... def setLinearAttenuation(self, value: float) -> None: ... def setConstantAttenuation(self, value: float) -> None: ... @@ -1751,9 +1720,8 @@ class QPointSize('QRenderState'): Programmable = ... # type: QPointSize.SizeMode def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def valueChanged(self, value: float) -> None: ... - def sizeModeChanged(self, sizeMode: 'QPointSize.SizeMode') -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + sizeModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, value: float) -> None: ... def setSizeMode(self, sizeMode: 'QPointSize.SizeMode') -> None: ... def value(self) -> float: ... @@ -1762,9 +1730,8 @@ class QPointSize('QRenderState'): class QPolygonOffset('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def depthStepsChanged(self, depthSteps: float) -> None: ... - def scaleFactorChanged(self, scaleFactor: float) -> None: ... + depthStepsChanged: typing.ClassVar[QtCore.pyqtSignal] + scaleFactorChanged: typing.ClassVar[QtCore.pyqtSignal] def setDepthSteps(self, depthSteps: float) -> None: ... def setScaleFactor(self, scaleFactor: float) -> None: ... def depthSteps(self) -> float: ... @@ -1773,9 +1740,8 @@ class QPolygonOffset('QRenderState'): class QProximityFilter('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def distanceThresholdChanged(self, distanceThreshold: float) -> None: ... - def entityChanged(self, entity: Qt3DCore.QEntity) -> None: ... + distanceThresholdChanged: typing.ClassVar[QtCore.pyqtSignal] + entityChanged: typing.ClassVar[QtCore.pyqtSignal] def setDistanceThreshold(self, distanceThreshold: float) -> None: ... def setEntity(self, entity: Qt3DCore.QEntity) -> None: ... def distanceThreshold(self) -> float: ... @@ -1802,9 +1768,8 @@ class QRasterMode('QRenderState'): Fill = ... # type: QRasterMode.RasterMode def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def faceModeChanged(self, faceMode: 'QRasterMode.FaceMode') -> None: ... - def rasterModeChanged(self, rasterMode: 'QRasterMode.RasterMode') -> None: ... + faceModeChanged: typing.ClassVar[QtCore.pyqtSignal] + rasterModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setFaceMode(self, faceMode: 'QRasterMode.FaceMode') -> None: ... def setRasterMode(self, rasterMode: 'QRasterMode.RasterMode') -> None: ... def faceMode(self) -> 'QRasterMode.FaceMode': ... @@ -1813,10 +1778,9 @@ class QRasterMode('QRenderState'): class QRayCaster('QAbstractRayCaster'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def lengthChanged(self, length: float) -> None: ... - def directionChanged(self, direction: QtGui.QVector3D) -> None: ... - def originChanged(self, origin: QtGui.QVector3D) -> None: ... + lengthChanged: typing.ClassVar[QtCore.pyqtSignal] + directionChanged: typing.ClassVar[QtCore.pyqtSignal] + originChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def trigger(self) -> None: ... @typing.overload @@ -1934,10 +1898,9 @@ class QRenderCapabilities(QtCore.QObject): def isValid(self) -> bool: ... class QRenderCaptureReply(QtCore.QObject): - - def completed(self) -> None: ... + completed: typing.ClassVar[QtCore.pyqtSignal] def saveImage(self, fileName: str) -> bool: ... - def completeChanged(self, isComplete: bool) -> None: ... + completeChanged: typing.ClassVar[QtCore.pyqtSignal] def saveToFile(self, fileName: str) -> None: ... def isComplete(self) -> bool: ... def captureId(self) -> int: ... @@ -1958,8 +1921,7 @@ class QRenderCapture('QFrameGraphNode'): class QRenderPass(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def shaderProgramChanged(self, shaderProgram: 'QShaderProgram') -> None: ... + shaderProgramChanged: typing.ClassVar[QtCore.pyqtSignal] def setShaderProgram(self, shaderProgram: 'QShaderProgram') -> None: ... def parameters(self) -> typing.List['QParameter']: ... def removeParameter(self, p: 'QParameter') -> None: ... @@ -1993,9 +1955,8 @@ class QRenderSettings(Qt3DCore.QComponent): Always = ... # type: QRenderSettings.RenderPolicy def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def renderPolicyChanged(self, renderPolicy: 'QRenderSettings.RenderPolicy') -> None: ... - def activeFrameGraphChanged(self, activeFrameGraph: 'QFrameGraphNode') -> None: ... + renderPolicyChanged: typing.ClassVar[QtCore.pyqtSignal] + activeFrameGraphChanged: typing.ClassVar[QtCore.pyqtSignal] def setRenderPolicy(self, renderPolicy: 'QRenderSettings.RenderPolicy') -> None: ... def setActiveFrameGraph(self, activeFrameGraph: 'QFrameGraphNode') -> None: ... def renderCapabilities(self) -> 'QRenderCapabilities': ... @@ -2014,10 +1975,9 @@ class QRenderStateSet('QFrameGraphNode'): class QRenderSurfaceSelector('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def surfacePixelRatioChanged(self, ratio: float) -> None: ... - def externalRenderTargetSizeChanged(self, size: QtCore.QSize) -> None: ... - def surfaceChanged(self, surface: QtCore.QObject) -> None: ... + surfacePixelRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + externalRenderTargetSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + surfaceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSurfacePixelRatio(self, ratio: float) -> None: ... def setSurface(self, surfaceObject: QtCore.QObject) -> None: ... def setExternalRenderTargetSize(self, size: QtCore.QSize) -> None: ... @@ -2077,12 +2037,11 @@ class QRenderTargetOutput(Qt3DCore.QNode): DepthStencil = ... # type: QRenderTargetOutput.AttachmentPoint def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def faceChanged(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... - def layerChanged(self, layer: int) -> None: ... - def mipLevelChanged(self, mipLevel: int) -> None: ... - def textureChanged(self, texture: 'QAbstractTexture') -> None: ... - def attachmentPointChanged(self, attachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... + faceChanged: typing.ClassVar[QtCore.pyqtSignal] + layerChanged: typing.ClassVar[QtCore.pyqtSignal] + mipLevelChanged: typing.ClassVar[QtCore.pyqtSignal] + textureChanged: typing.ClassVar[QtCore.pyqtSignal] + attachmentPointChanged: typing.ClassVar[QtCore.pyqtSignal] def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... def setLayer(self, layer: int) -> None: ... def setMipLevel(self, level: int) -> None: ... @@ -2097,8 +2056,7 @@ class QRenderTargetOutput(Qt3DCore.QNode): class QRenderTargetSelector('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def targetChanged(self, target: 'QRenderTarget') -> None: ... + targetChanged: typing.ClassVar[QtCore.pyqtSignal] def setTarget(self, target: 'QRenderTarget') -> None: ... def target(self) -> 'QRenderTarget': ... def outputs(self) -> typing.List[QRenderTargetOutput.AttachmentPoint]: ... @@ -2136,8 +2094,8 @@ class QSceneLoader(Qt3DCore.QComponent): def component(self, entityName: str, componentType: 'QSceneLoader.ComponentType') -> Qt3DCore.QComponent: ... def entityNames(self) -> typing.List[str]: ... def entity(self, entityName: str) -> Qt3DCore.QEntity: ... - def statusChanged(self, status: 'QSceneLoader.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSource(self, arg: QtCore.QUrl) -> None: ... def status(self) -> 'QSceneLoader.Status': ... def source(self) -> QtCore.QUrl: ... @@ -2146,11 +2104,10 @@ class QSceneLoader(Qt3DCore.QComponent): class QScissorTest('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def heightChanged(self, height: int) -> None: ... - def widthChanged(self, width: int) -> None: ... - def bottomChanged(self, bottom: int) -> None: ... - def leftChanged(self, left: int) -> None: ... + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + bottomChanged: typing.ClassVar[QtCore.pyqtSignal] + leftChanged: typing.ClassVar[QtCore.pyqtSignal] def setHeight(self, height: int) -> None: ... def setWidth(self, width: int) -> None: ... def setBottom(self, bottom: int) -> None: ... @@ -2163,8 +2120,7 @@ class QScissorTest('QRenderState'): class QScreenRayCaster('QAbstractRayCaster'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def positionChanged(self, position: QtCore.QPoint) -> None: ... + positionChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def trigger(self) -> None: ... @typing.overload @@ -2188,8 +2144,8 @@ class QSetFence('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def handleChanged(self, handle: typing.Any) -> None: ... - def handleTypeChanged(self, handleType: 'QSetFence.HandleType') -> None: ... + handleChanged: typing.ClassVar[QtCore.pyqtSignal] + handleTypeChanged: typing.ClassVar[QtCore.pyqtSignal] def handle(self) -> typing.Any: ... def handleType(self) -> 'QSetFence.HandleType': ... @@ -2301,13 +2257,12 @@ class QShaderImage(Qt3DCore.QNode): ReadWrite = ... # type: QShaderImage.Access def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def formatChanged(self, format: 'QShaderImage.ImageFormat') -> None: ... - def accessChanged(self, access: 'QShaderImage.Access') -> None: ... - def layerChanged(self, layer: int) -> None: ... - def mipLevelChanged(self, mipLevel: int) -> None: ... - def layeredChanged(self, layered: bool) -> None: ... - def textureChanged(self, texture: 'QAbstractTexture') -> None: ... + formatChanged: typing.ClassVar[QtCore.pyqtSignal] + accessChanged: typing.ClassVar[QtCore.pyqtSignal] + layerChanged: typing.ClassVar[QtCore.pyqtSignal] + mipLevelChanged: typing.ClassVar[QtCore.pyqtSignal] + layeredChanged: typing.ClassVar[QtCore.pyqtSignal] + textureChanged: typing.ClassVar[QtCore.pyqtSignal] def setFormat(self, format: 'QShaderImage.ImageFormat') -> None: ... def setAccess(self, access: 'QShaderImage.Access') -> None: ... def setLayer(self, layer: int) -> None: ... @@ -2355,21 +2310,20 @@ class QShaderProgram(Qt3DCore.QNode): Compute = ... # type: QShaderProgram.ShaderType def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def formatChanged(self, format: 'QShaderProgram.Format') -> None: ... + formatChanged: typing.ClassVar[QtCore.pyqtSignal] def format(self) -> 'QShaderProgram.Format': ... def setFormat(self, format: 'QShaderProgram.Format') -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QShaderProgram.Status') -> None: ... - def logChanged(self, log: str) -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + logChanged: typing.ClassVar[QtCore.pyqtSignal] def status(self) -> 'QShaderProgram.Status': ... def log(self) -> str: ... - def computeShaderCodeChanged(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def fragmentShaderCodeChanged(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def geometryShaderCodeChanged(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationEvaluationShaderCodeChanged(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationControlShaderCodeChanged(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def vertexShaderCodeChanged(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + computeShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + fragmentShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationEvaluationShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationControlShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + vertexShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] def setComputeShaderCode(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def setFragmentShaderCode(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def setGeometryShaderCode(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... @@ -2392,26 +2346,26 @@ class QShaderProgramBuilder(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def computeShaderCodeChanged(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def fragmentShaderCodeChanged(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def geometryShaderCodeChanged(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationEvaluationShaderCodeChanged(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationControlShaderCodeChanged(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def vertexShaderCodeChanged(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + computeShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + fragmentShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationEvaluationShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationControlShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + vertexShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] def computeShaderCode(self) -> QtCore.QByteArray: ... def fragmentShaderCode(self) -> QtCore.QByteArray: ... def geometryShaderCode(self) -> QtCore.QByteArray: ... def tessellationEvaluationShaderCode(self) -> QtCore.QByteArray: ... def tessellationControlShaderCode(self) -> QtCore.QByteArray: ... def vertexShaderCode(self) -> QtCore.QByteArray: ... - def computeShaderGraphChanged(self, computeShaderGraph: QtCore.QUrl) -> None: ... - def fragmentShaderGraphChanged(self, fragmentShaderGraph: QtCore.QUrl) -> None: ... - def geometryShaderGraphChanged(self, geometryShaderGraph: QtCore.QUrl) -> None: ... - def tessellationEvaluationShaderGraphChanged(self, tessellationEvaluationShaderGraph: QtCore.QUrl) -> None: ... - def tessellationControlShaderGraphChanged(self, tessellationControlShaderGraph: QtCore.QUrl) -> None: ... - def vertexShaderGraphChanged(self, vertexShaderGraph: QtCore.QUrl) -> None: ... - def enabledLayersChanged(self, layers: typing.Iterable[str]) -> None: ... - def shaderProgramChanged(self, shaderProgram: 'QShaderProgram') -> None: ... + computeShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + fragmentShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationEvaluationShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationControlShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + vertexShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + enabledLayersChanged: typing.ClassVar[QtCore.pyqtSignal] + shaderProgramChanged: typing.ClassVar[QtCore.pyqtSignal] def setComputeShaderGraph(self, computeShaderGraph: QtCore.QUrl) -> None: ... def setFragmentShaderGraph(self, fragmentShaderGraph: QtCore.QUrl) -> None: ... def setGeometryShaderGraph(self, geometryShaderGraph: QtCore.QUrl) -> None: ... @@ -2447,11 +2401,7 @@ class QSortPolicy('QFrameGraphNode'): Uniform = ... # type: QSortPolicy.SortType def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - @typing.overload - def sortTypesChanged(self, sortTypes: typing.Iterable[QSortPolicy.SortType]) -> None: ... - @typing.overload - def sortTypesChanged(self, sortTypes: typing.Iterable[int]) -> None: ... + sortTypesChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def setSortTypes(self, sortTypes: typing.Iterable[QSortPolicy.SortType]) -> None: ... @typing.overload @@ -2462,12 +2412,11 @@ class QSortPolicy('QFrameGraphNode'): class QSpotLight('QAbstractLight'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def cutOffAngleChanged(self, cutOffAngle: float) -> None: ... - def localDirectionChanged(self, localDirection: QtGui.QVector3D) -> None: ... - def quadraticAttenuationChanged(self, quadraticAttenuation: float) -> None: ... - def linearAttenuationChanged(self, linearAttenuation: float) -> None: ... - def constantAttenuationChanged(self, constantAttenuation: float) -> None: ... + cutOffAngleChanged: typing.ClassVar[QtCore.pyqtSignal] + localDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] + quadraticAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] + linearAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] + constantAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] def setCutOffAngle(self, cutOffAngle: float) -> None: ... def setLocalDirection(self, localDirection: QtGui.QVector3D) -> None: ... def setQuadraticAttenuation(self, value: float) -> None: ... @@ -2482,9 +2431,8 @@ class QSpotLight('QAbstractLight'): class QStencilMask('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def backOutputMaskChanged(self, backOutputMask: int) -> None: ... - def frontOutputMaskChanged(self, frontOutputMask: int) -> None: ... + backOutputMaskChanged: typing.ClassVar[QtCore.pyqtSignal] + frontOutputMaskChanged: typing.ClassVar[QtCore.pyqtSignal] def setBackOutputMask(self, backOutputMask: int) -> None: ... def setFrontOutputMask(self, frontOutputMask: int) -> None: ... def backOutputMask(self) -> int: ... @@ -2526,11 +2474,10 @@ class QStencilOperationArguments(QtCore.QObject): Front = ... # type: QStencilOperationArguments.FaceMode Back = ... # type: QStencilOperationArguments.FaceMode FrontAndBack = ... # type: QStencilOperationArguments.FaceMode - - def faceModeChanged(self, faceMode: 'QStencilOperationArguments.FaceMode') -> None: ... - def allTestsPassOperationChanged(self, stencilDepthPass: 'QStencilOperationArguments.Operation') -> None: ... - def depthTestFailureOperationChanged(self, depthFail: 'QStencilOperationArguments.Operation') -> None: ... - def stencilTestFailureOperationChanged(self, stencilFail: 'QStencilOperationArguments.Operation') -> None: ... + faceModeChanged: typing.ClassVar[QtCore.pyqtSignal] + allTestsPassOperationChanged: typing.ClassVar[QtCore.pyqtSignal] + depthTestFailureOperationChanged: typing.ClassVar[QtCore.pyqtSignal] + stencilTestFailureOperationChanged: typing.ClassVar[QtCore.pyqtSignal] def setAllTestsPassOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... def setDepthTestFailureOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... def setStencilTestFailureOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... @@ -2575,11 +2522,10 @@ class QStencilTestArguments(QtCore.QObject): Front = ... # type: QStencilTestArguments.StencilFaceMode Back = ... # type: QStencilTestArguments.StencilFaceMode FrontAndBack = ... # type: QStencilTestArguments.StencilFaceMode - - def faceModeChanged(self, faceMode: 'QStencilTestArguments.StencilFaceMode') -> None: ... - def referenceValueChanged(self, referenceValue: int) -> None: ... - def stencilFunctionChanged(self, stencilFunction: 'QStencilTestArguments.StencilFunction') -> None: ... - def comparisonMaskChanged(self, comparisonMask: int) -> None: ... + faceModeChanged: typing.ClassVar[QtCore.pyqtSignal] + referenceValueChanged: typing.ClassVar[QtCore.pyqtSignal] + stencilFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] + comparisonMaskChanged: typing.ClassVar[QtCore.pyqtSignal] def setStencilFunction(self, stencilFunction: 'QStencilTestArguments.StencilFunction') -> None: ... def setReferenceValue(self, referenceValue: int) -> None: ... def setComparisonMask(self, comparisonMask: int) -> None: ... @@ -2598,8 +2544,7 @@ class QSubtreeEnabler('QFrameGraphNode'): SingleShot = ... # type: QSubtreeEnabler.Enablement def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def enablementChanged(self, enablement: 'QSubtreeEnabler.Enablement') -> None: ... + enablementChanged: typing.ClassVar[QtCore.pyqtSignal] def requestUpdate(self) -> None: ... def setEnablement(self, enablement: 'QSubtreeEnabler.Enablement') -> None: ... def enablement(self) -> 'QSubtreeEnabler.Enablement': ... @@ -2677,19 +2622,17 @@ class QTextureBuffer('QAbstractTexture'): class QTextureLoader('QAbstractTexture'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def mirroredChanged(self, mirrored: bool) -> None: ... + mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] def setMirrored(self, mirrored: bool) -> None: ... def isMirrored(self) -> bool: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSource(self, source: QtCore.QUrl) -> None: ... def source(self) -> QtCore.QUrl: ... class QSharedGLTexture('QAbstractTexture'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def textureIdChanged(self, textureId: int) -> None: ... + textureIdChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureId(self, id: int) -> None: ... def textureId(self) -> int: ... @@ -2774,14 +2717,13 @@ class QTextureImage('QAbstractTextureImage'): Error = ... # type: QTextureImage.Status def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def mirroredChanged(self, mirrored: bool) -> None: ... + mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] def setMirrored(self, mirrored: bool) -> None: ... def isMirrored(self) -> bool: ... def setStatus(self, status: 'QTextureImage.Status') -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QTextureImage.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSource(self, source: QtCore.QUrl) -> None: ... def status(self) -> 'QTextureImage.Status': ... def source(self) -> QtCore.QUrl: ... @@ -2840,10 +2782,9 @@ class QTextureWrapMode(QtCore.QObject): def __init__(self, wrapMode: 'QTextureWrapMode.WrapMode' = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, x: 'QTextureWrapMode.WrapMode', y: 'QTextureWrapMode.WrapMode', z: 'QTextureWrapMode.WrapMode', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def zChanged(self, z: 'QTextureWrapMode.WrapMode') -> None: ... - def yChanged(self, y: 'QTextureWrapMode.WrapMode') -> None: ... - def xChanged(self, x: 'QTextureWrapMode.WrapMode') -> None: ... + zChanged: typing.ClassVar[QtCore.pyqtSignal] + yChanged: typing.ClassVar[QtCore.pyqtSignal] + xChanged: typing.ClassVar[QtCore.pyqtSignal] def setZ(self, z: 'QTextureWrapMode.WrapMode') -> None: ... def setY(self, y: 'QTextureWrapMode.WrapMode') -> None: ... def setX(self, x: 'QTextureWrapMode.WrapMode') -> None: ... @@ -2854,11 +2795,10 @@ class QTextureWrapMode(QtCore.QObject): class QViewport('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def gammaChanged(self, gamma: float) -> None: ... + gammaChanged: typing.ClassVar[QtCore.pyqtSignal] def setGamma(self, gamma: float) -> None: ... def gamma(self) -> float: ... - def normalizedRectChanged(self, normalizedRect: QtCore.QRectF) -> None: ... + normalizedRectChanged: typing.ClassVar[QtCore.pyqtSignal] def setNormalizedRect(self, normalizedRect: QtCore.QRectF) -> None: ... def normalizedRect(self) -> QtCore.QRectF: ... @@ -2872,11 +2812,10 @@ class QWaitFence('QFrameGraphNode'): OpenGLFenceId = ... # type: QWaitFence.HandleType def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def handleChanged(self, handle: typing.Any) -> None: ... - def handleTypeChanged(self, handleType: 'QWaitFence.HandleType') -> None: ... - def timeoutChanged(self, timeoutChanged: int) -> None: ... - def waitOnCPUChanged(self, waitOnCPU: bool) -> None: ... + handleChanged: typing.ClassVar[QtCore.pyqtSignal] + handleTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + timeoutChanged: typing.ClassVar[QtCore.pyqtSignal] + waitOnCPUChanged: typing.ClassVar[QtCore.pyqtSignal] def setTimeout(self, timeout: int) -> None: ... def timeout(self) -> int: ... def setWaitOnCPU(self, waitOnCPU: bool) -> None: ... diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index b9bb57b5..a4b11401 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -163,10 +163,10 @@ class QBluetoothDeviceDiscoveryAgent(QtCore.QObject): def supportedDiscoveryMethods() -> 'QBluetoothDeviceDiscoveryAgent.DiscoveryMethods': ... def lowEnergyDiscoveryTimeout(self) -> int: ... def setLowEnergyDiscoveryTimeout(self, msTimeout: int) -> None: ... - def deviceUpdated(self, info: 'QBluetoothDeviceInfo', updatedFields: typing.Union['QBluetoothDeviceInfo.Fields', 'QBluetoothDeviceInfo.Field']) -> None: ... - def canceled(self) -> None: ... - def finished(self) -> None: ... - def deviceDiscovered(self, info: 'QBluetoothDeviceInfo') -> None: ... + deviceUpdated: typing.ClassVar[QtCore.pyqtSignal] + canceled: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + deviceDiscovered: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... @typing.overload def start(self) -> None: ... @@ -174,10 +174,7 @@ class QBluetoothDeviceDiscoveryAgent(QtCore.QObject): def start(self, method: typing.Union['QBluetoothDeviceDiscoveryAgent.DiscoveryMethods', 'QBluetoothDeviceDiscoveryAgent.DiscoveryMethod']) -> None: ... def discoveredDevices(self) -> typing.List['QBluetoothDeviceInfo']: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QBluetoothDeviceDiscoveryAgent.Error': ... - @typing.overload - def error(self, error: 'QBluetoothDeviceDiscoveryAgent.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isActive(self) -> bool: ... def setInquiryType(self, type: 'QBluetoothDeviceDiscoveryAgent.InquiryType') -> None: ... def inquiryType(self) -> 'QBluetoothDeviceDiscoveryAgent.InquiryType': ... @@ -574,14 +571,13 @@ class QBluetoothLocalDevice(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, address: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def deviceDisconnected(self, address: QBluetoothAddress) -> None: ... - def deviceConnected(self, address: QBluetoothAddress) -> None: ... - def error(self, error: 'QBluetoothLocalDevice.Error') -> None: ... - def pairingDisplayConfirmation(self, address: QBluetoothAddress, pin: str) -> None: ... - def pairingDisplayPinCode(self, address: QBluetoothAddress, pin: str) -> None: ... - def pairingFinished(self, address: QBluetoothAddress, pairing: 'QBluetoothLocalDevice.Pairing') -> None: ... - def hostModeStateChanged(self, state: 'QBluetoothLocalDevice.HostMode') -> None: ... + deviceDisconnected: typing.ClassVar[QtCore.pyqtSignal] + deviceConnected: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + pairingDisplayConfirmation: typing.ClassVar[QtCore.pyqtSignal] + pairingDisplayPinCode: typing.ClassVar[QtCore.pyqtSignal] + pairingFinished: typing.ClassVar[QtCore.pyqtSignal] + hostModeStateChanged: typing.ClassVar[QtCore.pyqtSignal] def pairingConfirmation(self, confirmation: bool) -> None: ... def connectedDevices(self) -> typing.List[QBluetoothAddress]: ... @staticmethod @@ -614,12 +610,8 @@ class QBluetoothServer(QtCore.QObject): UnsupportedProtocolError = ... # type: QBluetoothServer.Error def __init__(self, serverType: 'QBluetoothServiceInfo.Protocol', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def newConnection(self) -> None: ... - @typing.overload - def error(self) -> 'QBluetoothServer.Error': ... - @typing.overload - def error(self, a0: 'QBluetoothServer.Error') -> None: ... + newConnection: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] def serverType(self) -> 'QBluetoothServiceInfo.Protocol': ... def securityFlags(self) -> QBluetooth.SecurityFlags: ... def setSecurityFlags(self, security: typing.Union[QBluetooth.SecurityFlags, QBluetooth.Security]) -> None: ... @@ -663,10 +655,9 @@ class QBluetoothServiceDiscoveryAgent(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, deviceAdapter: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def canceled(self) -> None: ... - def finished(self) -> None: ... - def serviceDiscovered(self, info: 'QBluetoothServiceInfo') -> None: ... + canceled: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + serviceDiscovered: typing.ClassVar[QtCore.pyqtSignal] def clear(self) -> None: ... def stop(self) -> None: ... def start(self, mode: 'QBluetoothServiceDiscoveryAgent.DiscoveryMode' = ...) -> None: ... @@ -679,10 +670,7 @@ class QBluetoothServiceDiscoveryAgent(QtCore.QObject): def setUuidFilter(self, uuid: 'QBluetoothUuid') -> None: ... def discoveredServices(self) -> typing.List['QBluetoothServiceInfo']: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QBluetoothServiceDiscoveryAgent.Error': ... - @typing.overload - def error(self, error: 'QBluetoothServiceDiscoveryAgent.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isActive(self) -> bool: ... @@ -825,14 +813,11 @@ class QBluetoothSocket(QtCore.QIODevice): def setSocketState(self, state: 'QBluetoothSocket.SocketState') -> None: ... def writeData(self, data: bytes) -> int: ... def readData(self, maxlen: int) -> bytes: ... - def stateChanged(self, state: 'QBluetoothSocket.SocketState') -> None: ... - def disconnected(self) -> None: ... - def connected(self) -> None: ... + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] + connected: typing.ClassVar[QtCore.pyqtSignal] def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QBluetoothSocket.SocketError': ... - @typing.overload - def error(self, error: 'QBluetoothSocket.SocketError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def state(self) -> 'QBluetoothSocket.SocketState': ... def socketType(self) -> QBluetoothServiceInfo.Protocol: ... def socketDescriptor(self) -> int: ... @@ -861,8 +846,7 @@ class QBluetoothSocket(QtCore.QIODevice): class QBluetoothTransferManager(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def finished(self, reply: 'QBluetoothTransferReply') -> None: ... + finished: typing.ClassVar[QtCore.pyqtSignal] def put(self, request: 'QBluetoothTransferRequest', data: QtCore.QIODevice) -> 'QBluetoothTransferReply': ... @@ -891,15 +875,12 @@ class QBluetoothTransferReply(QtCore.QObject): def setRequest(self, request: 'QBluetoothTransferRequest') -> None: ... def setManager(self, manager: QBluetoothTransferManager) -> None: ... - def transferProgress(self, bytesTransferred: int, bytesTotal: int) -> None: ... - def finished(self, a0: 'QBluetoothTransferReply') -> None: ... + transferProgress: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def abort(self) -> None: ... def request(self) -> 'QBluetoothTransferRequest': ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QBluetoothTransferReply.TransferError': ... - @typing.overload - def error(self, lastError: 'QBluetoothTransferReply.TransferError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def manager(self) -> QBluetoothTransferManager: ... def isRunning(self) -> bool: ... def isFinished(self) -> bool: ... @@ -1746,7 +1727,7 @@ class QLowEnergyController(QtCore.QObject): def __init__(self, remoteDevice: QBluetoothAddress, localDevice: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def remoteDeviceUuid(self) -> QBluetoothUuid: ... - def connectionUpdated(self, parameters: QLowEnergyConnectionParameters) -> None: ... + connectionUpdated: typing.ClassVar[QtCore.pyqtSignal] def role(self) -> 'QLowEnergyController.Role': ... def requestConnectionUpdate(self, parameters: QLowEnergyConnectionParameters) -> None: ... def addService(self, service: 'QLowEnergyServiceData', parent: typing.Optional[QtCore.QObject] = ...) -> 'QLowEnergyService': ... @@ -1760,17 +1741,14 @@ class QLowEnergyController(QtCore.QObject): @typing.overload @staticmethod def createCentral(remoteDevice: QBluetoothAddress, localDevice: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> 'QLowEnergyController': ... - def discoveryFinished(self) -> None: ... - def serviceDiscovered(self, newService: QBluetoothUuid) -> None: ... - def stateChanged(self, state: 'QLowEnergyController.ControllerState') -> None: ... - def disconnected(self) -> None: ... - def connected(self) -> None: ... + discoveryFinished: typing.ClassVar[QtCore.pyqtSignal] + serviceDiscovered: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] + connected: typing.ClassVar[QtCore.pyqtSignal] def remoteName(self) -> str: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QLowEnergyController.Error': ... - @typing.overload - def error(self, newError: 'QLowEnergyController.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def createServiceObject(self, service: QBluetoothUuid, parent: typing.Optional[QtCore.QObject] = ...) -> 'QLowEnergyService': ... def services(self) -> typing.List[QBluetoothUuid]: ... def discoverServices(self) -> None: ... @@ -1883,25 +1861,21 @@ class QLowEnergyService(QtCore.QObject): def __invert__(self) -> 'QLowEnergyService.ServiceTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - - def descriptorRead(self, info: QLowEnergyDescriptor, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def characteristicRead(self, info: QLowEnergyCharacteristic, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + descriptorRead: typing.ClassVar[QtCore.pyqtSignal] + characteristicRead: typing.ClassVar[QtCore.pyqtSignal] def readDescriptor(self, descriptor: QLowEnergyDescriptor) -> None: ... def readCharacteristic(self, characteristic: QLowEnergyCharacteristic) -> None: ... - def descriptorWritten(self, info: QLowEnergyDescriptor, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def characteristicWritten(self, info: QLowEnergyCharacteristic, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def characteristicChanged(self, info: QLowEnergyCharacteristic, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def stateChanged(self, newState: 'QLowEnergyService.ServiceState') -> None: ... + descriptorWritten: typing.ClassVar[QtCore.pyqtSignal] + characteristicWritten: typing.ClassVar[QtCore.pyqtSignal] + characteristicChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def writeDescriptor(self, descriptor: QLowEnergyDescriptor, newValue: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def writeCharacteristic(self, characteristic: QLowEnergyCharacteristic, newValue: typing.Union[QtCore.QByteArray, bytes, bytearray], mode: 'QLowEnergyService.WriteMode' = ...) -> None: ... @typing.overload def contains(self, characteristic: QLowEnergyCharacteristic) -> bool: ... @typing.overload def contains(self, descriptor: QLowEnergyDescriptor) -> bool: ... - @typing.overload - def error(self) -> 'QLowEnergyService.ServiceError': ... - @typing.overload - def error(self, error: 'QLowEnergyService.ServiceError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def discoverDetails(self) -> None: ... def serviceName(self) -> str: ... def serviceUuid(self) -> QBluetoothUuid: ... diff --git a/PyQt5-stubs/QtChart.pyi b/PyQt5-stubs/QtChart.pyi index 5520a571..a4bf36a9 100644 --- a/PyQt5-stubs/QtChart.pyi +++ b/PyQt5-stubs/QtChart.pyi @@ -71,15 +71,14 @@ class QAbstractAxis(QtCore.QObject): def __invert__(self) -> 'QAbstractAxis.AxisTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - - def labelsEditableChanged(self, editable: bool) -> None: ... + labelsEditableChanged: typing.ClassVar[QtCore.pyqtSignal] def labelsEditable(self) -> bool: ... def setLabelsEditable(self, editable: bool = ...) -> None: ... - def reverseChanged(self, reverse: bool) -> None: ... - def minorGridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def gridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def minorGridLinePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def minorGridVisibleChanged(self, visible: bool) -> None: ... + reverseChanged: typing.ClassVar[QtCore.pyqtSignal] + minorGridLineColorChanged: typing.ClassVar[QtCore.pyqtSignal] + gridLineColorChanged: typing.ClassVar[QtCore.pyqtSignal] + minorGridLinePenChanged: typing.ClassVar[QtCore.pyqtSignal] + minorGridVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] def isReverse(self) -> bool: ... def setReverse(self, reverse: bool = ...) -> None: ... def minorGridLineColor(self) -> QtGui.QColor: ... @@ -90,17 +89,17 @@ class QAbstractAxis(QtCore.QObject): def setMinorGridLinePen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setMinorGridLineVisible(self, visible: bool = ...) -> None: ... def isMinorGridLineVisible(self) -> bool: ... - def shadesBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesPenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def titleFontChanged(self, font: QtGui.QFont) -> None: ... - def titleVisibleChanged(self, visible: bool) -> None: ... - def titleBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def titleTextChanged(self, title: str) -> None: ... - def gridLinePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def labelsAngleChanged(self, angle: int) -> None: ... - def labelsFontChanged(self, pen: QtGui.QFont) -> None: ... - def labelsBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def linePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + shadesBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + shadesPenChanged: typing.ClassVar[QtCore.pyqtSignal] + titleFontChanged: typing.ClassVar[QtCore.pyqtSignal] + titleVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + titleBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + titleTextChanged: typing.ClassVar[QtCore.pyqtSignal] + gridLinePenChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsAngleChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsFontChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + linePenChanged: typing.ClassVar[QtCore.pyqtSignal] def alignment(self) -> QtCore.Qt.Alignment: ... def titleText(self) -> str: ... def setTitleText(self, title: str) -> None: ... @@ -110,15 +109,15 @@ class QAbstractAxis(QtCore.QObject): def setTitleBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def setTitleVisible(self, visible: bool = ...) -> None: ... def isTitleVisible(self) -> bool: ... - def shadesBorderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesVisibleChanged(self, visible: bool) -> None: ... - def labelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def gridVisibleChanged(self, visible: bool) -> None: ... - def labelsVisibleChanged(self, visible: bool) -> None: ... - def lineVisibleChanged(self, visible: bool) -> None: ... - def visibleChanged(self, visible: bool) -> None: ... + shadesBorderColorChanged: typing.ClassVar[QtCore.pyqtSignal] + shadesColorChanged: typing.ClassVar[QtCore.pyqtSignal] + shadesVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + gridVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + lineVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] def orientation(self) -> QtCore.Qt.Orientation: ... def hide(self) -> None: ... def show(self) -> None: ... @@ -189,18 +188,17 @@ class QAbstractSeries(QtCore.QObject): SeriesTypeHorizontalPercentBar = ... # type: QAbstractSeries.SeriesType SeriesTypeBoxPlot = ... # type: QAbstractSeries.SeriesType SeriesTypeCandlestick = ... # type: QAbstractSeries.SeriesType - - def useOpenGLChanged(self) -> None: ... + useOpenGLChanged: typing.ClassVar[QtCore.pyqtSignal] def useOpenGL(self) -> bool: ... def setUseOpenGL(self, enable: bool = ...) -> None: ... - def opacityChanged(self) -> None: ... + opacityChanged: typing.ClassVar[QtCore.pyqtSignal] def attachedAxes(self) -> typing.List['QAbstractAxis']: ... def detachAxis(self, axis: 'QAbstractAxis') -> bool: ... def attachAxis(self, axis: 'QAbstractAxis') -> bool: ... def setOpacity(self, opacity: float) -> None: ... def opacity(self) -> float: ... - def visibleChanged(self) -> None: ... - def nameChanged(self) -> None: ... + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] def hide(self) -> None: ... def show(self) -> None: ... def chart(self) -> 'QChart': ... @@ -222,28 +220,27 @@ class QAbstractBarSeries('QAbstractSeries'): LabelsInsideEnd = ... # type: QAbstractBarSeries.LabelsPosition LabelsInsideBase = ... # type: QAbstractBarSeries.LabelsPosition LabelsOutsideEnd = ... # type: QAbstractBarSeries.LabelsPosition - - def labelsPrecisionChanged(self, precision: int) -> None: ... + labelsPrecisionChanged: typing.ClassVar[QtCore.pyqtSignal] def labelsPrecision(self) -> int: ... def setLabelsPrecision(self, precision: int) -> None: ... - def labelsAngleChanged(self, angle: float) -> None: ... + labelsAngleChanged: typing.ClassVar[QtCore.pyqtSignal] def labelsAngle(self) -> float: ... def setLabelsAngle(self, angle: float) -> None: ... - def doubleClicked(self, index: int, barset: 'QBarSet') -> None: ... - def released(self, index: int, barset: 'QBarSet') -> None: ... - def pressed(self, index: int, barset: 'QBarSet') -> None: ... - def labelsPositionChanged(self, position: 'QAbstractBarSeries.LabelsPosition') -> None: ... - def labelsFormatChanged(self, format: str) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + labelsPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsFormatChanged: typing.ClassVar[QtCore.pyqtSignal] def labelsPosition(self) -> 'QAbstractBarSeries.LabelsPosition': ... def setLabelsPosition(self, position: 'QAbstractBarSeries.LabelsPosition') -> None: ... def labelsFormat(self) -> str: ... def setLabelsFormat(self, format: str) -> None: ... - def barsetsRemoved(self, sets: typing.Iterable['QBarSet']) -> None: ... - def barsetsAdded(self, sets: typing.Iterable['QBarSet']) -> None: ... - def labelsVisibleChanged(self) -> None: ... - def countChanged(self) -> None: ... - def hovered(self, status: bool, index: int, barset: 'QBarSet') -> None: ... - def clicked(self, index: int, barset: 'QBarSet') -> None: ... + barsetsRemoved: typing.ClassVar[QtCore.pyqtSignal] + barsetsAdded: typing.ClassVar[QtCore.pyqtSignal] + labelsVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + countChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def take(self, set: 'QBarSet') -> bool: ... def isLabelsVisible(self) -> bool: ... def setLabelsVisible(self, visible: bool = ...) -> None: ... @@ -276,18 +273,17 @@ class QLegendMarker(QtCore.QObject): LegendMarkerTypeXY = ... # type: QLegendMarker.LegendMarkerType LegendMarkerTypeBoxPlot = ... # type: QLegendMarker.LegendMarkerType LegendMarkerTypeCandlestick = ... # type: QLegendMarker.LegendMarkerType - - def shapeChanged(self) -> None: ... + shapeChanged: typing.ClassVar[QtCore.pyqtSignal] def setShape(self, shape: 'QLegend.MarkerShape') -> None: ... def shape(self) -> 'QLegend.MarkerShape': ... - def visibleChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def fontChanged(self) -> None: ... - def labelBrushChanged(self) -> None: ... - def labelChanged(self) -> None: ... - def hovered(self, status: bool) -> None: ... - def clicked(self) -> None: ... + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + penChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + labelChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def series(self) -> 'QAbstractSeries': ... def setVisible(self, visible: bool) -> None: ... def isVisible(self) -> bool: ... @@ -316,17 +312,16 @@ class QAreaSeries('QAbstractSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, upperSeries: 'QLineSeries', lowerSeries: typing.Optional['QLineSeries'] = ...) -> None: ... - - def pointLabelsClippingChanged(self, clipping: bool) -> None: ... + pointLabelsClippingChanged: typing.ClassVar[QtCore.pyqtSignal] def pointLabelsClipping(self) -> bool: ... def setPointLabelsClipping(self, enable: bool = ...) -> None: ... - def doubleClicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def released(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pressed(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pointLabelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointLabelsFontChanged(self, font: QtGui.QFont) -> None: ... - def pointLabelsVisibilityChanged(self, visible: bool) -> None: ... - def pointLabelsFormatChanged(self, format: str) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsColorChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsFontChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsFormatChanged: typing.ClassVar[QtCore.pyqtSignal] def pointLabelsColor(self) -> QtGui.QColor: ... def setPointLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def pointLabelsFont(self) -> QtGui.QFont: ... @@ -335,11 +330,11 @@ class QAreaSeries('QAbstractSeries'): def setPointLabelsVisible(self, visible: bool = ...) -> None: ... def pointLabelsFormat(self) -> str: ... def setPointLabelsFormat(self, format: str) -> None: ... - def hovered(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint], state: bool) -> None: ... - def selected(self) -> None: ... - def clicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + hovered: typing.ClassVar[QtCore.pyqtSignal] + selected: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] def borderColor(self) -> QtGui.QColor: ... def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def color(self) -> QtGui.QColor: ... @@ -359,12 +354,11 @@ class QAreaSeries('QAbstractSeries'): class QBarCategoryAxis('QAbstractAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def countChanged(self) -> None: ... - def rangeChanged(self, min: str, max: str) -> None: ... - def maxChanged(self, max: str) -> None: ... - def minChanged(self, min: str) -> None: ... - def categoriesChanged(self) -> None: ... + countChanged: typing.ClassVar[QtCore.pyqtSignal] + rangeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxChanged: typing.ClassVar[QtCore.pyqtSignal] + minChanged: typing.ClassVar[QtCore.pyqtSignal] + categoriesChanged: typing.ClassVar[QtCore.pyqtSignal] def setRange(self, minCategory: str, maxCategory: str) -> None: ... def max(self) -> str: ... def setMax(self, maxCategory: str) -> None: ... @@ -402,23 +396,22 @@ class QBarSeries('QAbstractBarSeries'): class QBarSet(QtCore.QObject): def __init__(self, name: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def doubleClicked(self, index: int) -> None: ... - def released(self, index: int) -> None: ... - def pressed(self, index: int) -> None: ... - def labelColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def hovered(self, status: bool, index: int) -> None: ... - def clicked(self, index: int) -> None: ... - def valueChanged(self, index: int) -> None: ... - def valuesRemoved(self, index: int, count: int) -> None: ... - def valuesAdded(self, index: int, count: int) -> None: ... - def labelFontChanged(self) -> None: ... - def labelBrushChanged(self) -> None: ... - def labelChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + labelColorChanged: typing.ClassVar[QtCore.pyqtSignal] + borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + valuesRemoved: typing.ClassVar[QtCore.pyqtSignal] + valuesAdded: typing.ClassVar[QtCore.pyqtSignal] + labelFontChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + labelChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + penChanged: typing.ClassVar[QtCore.pyqtSignal] def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def labelColor(self) -> QtGui.QColor: ... def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... @@ -458,19 +451,18 @@ class QBoxPlotLegendMarker('QLegendMarker'): class QBoxPlotSeries('QAbstractSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def doubleClicked(self, boxset: 'QBoxSet') -> None: ... - def released(self, boxset: 'QBoxSet') -> None: ... - def pressed(self, boxset: 'QBoxSet') -> None: ... - def boxsetsRemoved(self, sets: typing.Iterable['QBoxSet']) -> None: ... - def boxsetsAdded(self, sets: typing.Iterable['QBoxSet']) -> None: ... - def boxWidthChanged(self) -> None: ... - def boxOutlineVisibilityChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def countChanged(self) -> None: ... - def hovered(self, status: bool, boxset: 'QBoxSet') -> None: ... - def clicked(self, boxset: 'QBoxSet') -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + boxsetsRemoved: typing.ClassVar[QtCore.pyqtSignal] + boxsetsAdded: typing.ClassVar[QtCore.pyqtSignal] + boxWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + boxOutlineVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + penChanged: typing.ClassVar[QtCore.pyqtSignal] + countChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def pen(self) -> QtGui.QPen: ... def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def brush(self) -> QtGui.QBrush: ... @@ -511,17 +503,16 @@ class QBoxSet(QtCore.QObject): def __init__(self, label: str = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, le: float, lq: float, m: float, uq: float, ue: float, label: str = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def doubleClicked(self) -> None: ... - def released(self) -> None: ... - def pressed(self) -> None: ... - def cleared(self) -> None: ... - def valueChanged(self, index: int) -> None: ... - def valuesChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def hovered(self, status: bool) -> None: ... - def clicked(self) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + cleared: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + valuesChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + penChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def brush(self) -> QtGui.QBrush: ... def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def pen(self) -> QtGui.QPen: ... @@ -564,8 +555,8 @@ class QCandlestickModelMapper(QtCore.QObject): def setOpen(self, open: int) -> None: ... def timestamp(self) -> int: ... def setTimestamp(self, timestamp: int) -> None: ... - def seriesReplaced(self) -> None: ... - def modelReplaced(self) -> None: ... + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] def orientation(self) -> QtCore.Qt.Orientation: ... def series(self) -> 'QCandlestickSeries': ... def setSeries(self, series: 'QCandlestickSeries') -> None: ... @@ -575,25 +566,24 @@ class QCandlestickModelMapper(QtCore.QObject): class QCandlestickSeries('QAbstractSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def penChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def decreasingColorChanged(self) -> None: ... - def increasingColorChanged(self) -> None: ... - def capsVisibilityChanged(self) -> None: ... - def capsWidthChanged(self) -> None: ... - def bodyOutlineVisibilityChanged(self) -> None: ... - def bodyWidthChanged(self) -> None: ... - def minimumColumnWidthChanged(self) -> None: ... - def maximumColumnWidthChanged(self) -> None: ... - def countChanged(self) -> None: ... - def candlestickSetsRemoved(self, sets: typing.Iterable['QCandlestickSet']) -> None: ... - def candlestickSetsAdded(self, sets: typing.Iterable['QCandlestickSet']) -> None: ... - def doubleClicked(self, set: 'QCandlestickSet') -> None: ... - def released(self, set: 'QCandlestickSet') -> None: ... - def pressed(self, set: 'QCandlestickSet') -> None: ... - def hovered(self, status: bool, set: 'QCandlestickSet') -> None: ... - def clicked(self, set: 'QCandlestickSet') -> None: ... + penChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + decreasingColorChanged: typing.ClassVar[QtCore.pyqtSignal] + increasingColorChanged: typing.ClassVar[QtCore.pyqtSignal] + capsVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + capsWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + bodyOutlineVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + bodyWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + minimumColumnWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + maximumColumnWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + countChanged: typing.ClassVar[QtCore.pyqtSignal] + candlestickSetsRemoved: typing.ClassVar[QtCore.pyqtSignal] + candlestickSetsAdded: typing.ClassVar[QtCore.pyqtSignal] + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def pen(self) -> QtGui.QPen: ... def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def brush(self) -> QtGui.QBrush: ... @@ -636,19 +626,18 @@ class QCandlestickSet(QtCore.QObject): def __init__(self, timestamp: float = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, open: float, high: float, low: float, close: float, timestamp: float = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def penChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def closeChanged(self) -> None: ... - def lowChanged(self) -> None: ... - def highChanged(self) -> None: ... - def openChanged(self) -> None: ... - def timestampChanged(self) -> None: ... - def doubleClicked(self) -> None: ... - def released(self) -> None: ... - def pressed(self) -> None: ... - def hovered(self, status: bool) -> None: ... - def clicked(self) -> None: ... + penChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + closeChanged: typing.ClassVar[QtCore.pyqtSignal] + lowChanged: typing.ClassVar[QtCore.pyqtSignal] + highChanged: typing.ClassVar[QtCore.pyqtSignal] + openChanged: typing.ClassVar[QtCore.pyqtSignal] + timestampChanged: typing.ClassVar[QtCore.pyqtSignal] + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def pen(self) -> QtGui.QPen: ... def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def brush(self) -> QtGui.QBrush: ... @@ -674,24 +663,23 @@ class QValueAxis('QAbstractAxis'): TicksFixed = ... # type: QValueAxis.TickType def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def tickTypeChanged(self, type: 'QValueAxis.TickType') -> None: ... - def tickAnchorChanged(self, anchor: float) -> None: ... - def tickIntervalChanged(self, interval: float) -> None: ... + tickTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + tickAnchorChanged: typing.ClassVar[QtCore.pyqtSignal] + tickIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] def tickType(self) -> 'QValueAxis.TickType': ... def setTickType(self, type: 'QValueAxis.TickType') -> None: ... def tickInterval(self) -> float: ... def setTickInterval(self, insterval: float) -> None: ... def tickAnchor(self) -> float: ... def setTickAnchor(self, anchor: float) -> None: ... - def minorTickCountChanged(self, tickCount: int) -> None: ... + minorTickCountChanged: typing.ClassVar[QtCore.pyqtSignal] def minorTickCount(self) -> int: ... def setMinorTickCount(self, count: int) -> None: ... - def labelFormatChanged(self, format: str) -> None: ... - def tickCountChanged(self, tickCount: int) -> None: ... - def rangeChanged(self, min: float, max: float) -> None: ... - def maxChanged(self, max: float) -> None: ... - def minChanged(self, min: float) -> None: ... + labelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + tickCountChanged: typing.ClassVar[QtCore.pyqtSignal] + rangeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxChanged: typing.ClassVar[QtCore.pyqtSignal] + minChanged: typing.ClassVar[QtCore.pyqtSignal] def applyNiceNumbers(self) -> None: ... def labelFormat(self) -> str: ... def setLabelFormat(self, format: str) -> None: ... @@ -714,11 +702,10 @@ class QCategoryAxis('QValueAxis'): AxisLabelsPositionOnValue = ... # type: QCategoryAxis.AxisLabelsPosition def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def labelsPositionChanged(self, position: 'QCategoryAxis.AxisLabelsPosition') -> None: ... + labelsPositionChanged: typing.ClassVar[QtCore.pyqtSignal] def setLabelsPosition(self, position: 'QCategoryAxis.AxisLabelsPosition') -> None: ... def labelsPosition(self) -> 'QCategoryAxis.AxisLabelsPosition': ... - def categoriesChanged(self) -> None: ... + categoriesChanged: typing.ClassVar[QtCore.pyqtSignal] def __len__(self) -> int: ... def count(self) -> int: ... def categoriesLabels(self) -> typing.List[str]: ... @@ -792,7 +779,7 @@ class QChart(QtWidgets.QGraphicsWidget): def setAnimationEasingCurve(self, curve: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... def animationDuration(self) -> int: ... def setAnimationDuration(self, msecs: int) -> None: ... - def plotAreaChanged(self, plotArea: QtCore.QRectF) -> None: ... + plotAreaChanged: typing.ClassVar[QtCore.pyqtSignal] def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def localizeNumbers(self) -> bool: ... @@ -899,12 +886,11 @@ class QChartView(QtWidgets.QGraphicsView): class QDateTimeAxis('QAbstractAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def tickCountChanged(self, tick: int) -> None: ... - def formatChanged(self, format: str) -> None: ... - def rangeChanged(self, min: typing.Union[QtCore.QDateTime, datetime.datetime], max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def maxChanged(self, max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def minChanged(self, min: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... + tickCountChanged: typing.ClassVar[QtCore.pyqtSignal] + formatChanged: typing.ClassVar[QtCore.pyqtSignal] + rangeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxChanged: typing.ClassVar[QtCore.pyqtSignal] + minChanged: typing.ClassVar[QtCore.pyqtSignal] def tickCount(self) -> int: ... def setTickCount(self, count: int) -> None: ... def format(self) -> str: ... @@ -919,13 +905,12 @@ class QDateTimeAxis('QAbstractAxis'): class QHBarModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def lastBarSetRowChanged(self) -> None: ... - def firstBarSetRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + lastBarSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + firstBarSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setColumnCount(self, columnCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -942,13 +927,12 @@ class QHBarModelMapper(QtCore.QObject): class QHBoxPlotModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def lastBoxSetRowChanged(self) -> None: ... - def firstBoxSetRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + lastBoxSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + firstBoxSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setColumnCount(self, rowCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -965,14 +949,13 @@ class QHBoxPlotModelMapper(QtCore.QObject): class QHCandlestickModelMapper('QCandlestickModelMapper'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def lastSetRowChanged(self) -> None: ... - def firstSetRowChanged(self) -> None: ... - def closeColumnChanged(self) -> None: ... - def lowColumnChanged(self) -> None: ... - def highColumnChanged(self) -> None: ... - def openColumnChanged(self) -> None: ... - def timestampColumnChanged(self) -> None: ... + lastSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + firstSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + closeColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + lowColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + highColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + openColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + timestampColumnChanged: typing.ClassVar[QtCore.pyqtSignal] def lastSetRow(self) -> int: ... def setLastSetRow(self, lastSetRow: int) -> None: ... def firstSetRow(self) -> int: ... @@ -1010,13 +993,12 @@ class QHorizontalStackedBarSeries('QAbstractBarSeries'): class QHPieModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def labelsRowChanged(self) -> None: ... - def valuesRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsRowChanged: typing.ClassVar[QtCore.pyqtSignal] + valuesRowChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setColumnCount(self, columnCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -1033,13 +1015,12 @@ class QHPieModelMapper(QtCore.QObject): class QHXYModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def yRowChanged(self) -> None: ... - def xRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + yRowChanged: typing.ClassVar[QtCore.pyqtSignal] + xRowChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setColumnCount(self, columnCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -1065,23 +1046,22 @@ class QLegend(QtWidgets.QGraphicsWidget): MarkerShapeRectangle = ... # type: QLegend.MarkerShape MarkerShapeCircle = ... # type: QLegend.MarkerShape MarkerShapeFromSeries = ... # type: QLegend.MarkerShape - - def markerShapeChanged(self, shape: 'QLegend.MarkerShape') -> None: ... + markerShapeChanged: typing.ClassVar[QtCore.pyqtSignal] def setMarkerShape(self, shape: 'QLegend.MarkerShape') -> None: ... def markerShape(self) -> 'QLegend.MarkerShape': ... - def showToolTipsChanged(self, showToolTips: bool) -> None: ... + showToolTipsChanged: typing.ClassVar[QtCore.pyqtSignal] def setShowToolTips(self, show: bool) -> None: ... def showToolTips(self) -> bool: ... - def reverseMarkersChanged(self, reverseMarkers: bool) -> None: ... + reverseMarkersChanged: typing.ClassVar[QtCore.pyqtSignal] def setReverseMarkers(self, reverseMarkers: bool = ...) -> None: ... def reverseMarkers(self) -> bool: ... def showEvent(self, event: QtGui.QShowEvent) -> None: ... def hideEvent(self, event: QtGui.QHideEvent) -> None: ... - def labelColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def backgroundVisibleChanged(self, visible: bool) -> None: ... + labelColorChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + backgroundVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] def markers(self, series: typing.Optional['QAbstractSeries'] = ...) -> typing.List['QLegendMarker']: ... def labelColor(self) -> QtGui.QColor: ... def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... @@ -1107,21 +1087,20 @@ class QLegend(QtWidgets.QGraphicsWidget): def paint(self, painter: QtGui.QPainter, option: QtWidgets.QStyleOptionGraphicsItem, widget: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... class QXYSeries('QAbstractSeries'): - - def penChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointsRemoved(self, index: int, count: int) -> None: ... - def pointLabelsClippingChanged(self, clipping: bool) -> None: ... + penChanged: typing.ClassVar[QtCore.pyqtSignal] + pointsRemoved: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsClippingChanged: typing.ClassVar[QtCore.pyqtSignal] def pointLabelsClipping(self) -> bool: ... def setPointLabelsClipping(self, enable: bool = ...) -> None: ... def pointsVector(self) -> typing.List[QtCore.QPointF]: ... def removePoints(self, index: int, count: int) -> None: ... - def doubleClicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def released(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pressed(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pointLabelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointLabelsFontChanged(self, font: QtGui.QFont) -> None: ... - def pointLabelsVisibilityChanged(self, visible: bool) -> None: ... - def pointLabelsFormatChanged(self, format: str) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsColorChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsFontChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsFormatChanged: typing.ClassVar[QtCore.pyqtSignal] def pointLabelsColor(self) -> QtGui.QColor: ... def setPointLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def pointLabelsFont(self) -> QtGui.QFont: ... @@ -1130,13 +1109,13 @@ class QXYSeries('QAbstractSeries'): def setPointLabelsVisible(self, visible: bool = ...) -> None: ... def pointLabelsFormat(self) -> str: ... def setPointLabelsFormat(self, format: str) -> None: ... - def hovered(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint], state: bool) -> None: ... - def pointsReplaced(self) -> None: ... - def pointAdded(self, index: int) -> None: ... - def pointRemoved(self, index: int) -> None: ... - def pointReplaced(self, index: int) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def clicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + hovered: typing.ClassVar[QtCore.pyqtSignal] + pointsReplaced: typing.ClassVar[QtCore.pyqtSignal] + pointAdded: typing.ClassVar[QtCore.pyqtSignal] + pointRemoved: typing.ClassVar[QtCore.pyqtSignal] + pointReplaced: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def at(self, index: int) -> QtCore.QPointF: ... def pointsVisible(self) -> bool: ... def setPointsVisible(self, visible: bool = ...) -> None: ... @@ -1182,17 +1161,16 @@ class QLineSeries('QXYSeries'): class QLogValueAxis('QAbstractAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def minorTickCountChanged(self, minorTickCount: int) -> None: ... - def tickCountChanged(self, tickCount: int) -> None: ... + minorTickCountChanged: typing.ClassVar[QtCore.pyqtSignal] + tickCountChanged: typing.ClassVar[QtCore.pyqtSignal] def minorTickCount(self) -> int: ... def setMinorTickCount(self, minorTickCount: int) -> None: ... def tickCount(self) -> int: ... - def baseChanged(self, base: float) -> None: ... - def labelFormatChanged(self, format: str) -> None: ... - def rangeChanged(self, min: float, max: float) -> None: ... - def maxChanged(self, max: float) -> None: ... - def minChanged(self, min: float) -> None: ... + baseChanged: typing.ClassVar[QtCore.pyqtSignal] + labelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + rangeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxChanged: typing.ClassVar[QtCore.pyqtSignal] + minChanged: typing.ClassVar[QtCore.pyqtSignal] def base(self) -> float: ... def setBase(self, base: float) -> None: ... def labelFormat(self) -> str: ... @@ -1221,20 +1199,19 @@ class QPieLegendMarker('QLegendMarker'): class QPieSeries('QAbstractSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def doubleClicked(self, slice: 'QPieSlice') -> None: ... - def released(self, slice: 'QPieSlice') -> None: ... - def pressed(self, slice: 'QPieSlice') -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] def setLabelsPosition(self, position: 'QPieSlice.LabelPosition') -> None: ... def holeSize(self) -> float: ... def setHoleSize(self, holeSize: float) -> None: ... def take(self, slice: 'QPieSlice') -> bool: ... - def sumChanged(self) -> None: ... - def countChanged(self) -> None: ... - def hovered(self, slice: 'QPieSlice', state: bool) -> None: ... - def clicked(self, slice: 'QPieSlice') -> None: ... - def removed(self, slices: typing.Iterable['QPieSlice']) -> None: ... - def added(self, slices: typing.Iterable['QPieSlice']) -> None: ... + sumChanged: typing.ClassVar[QtCore.pyqtSignal] + countChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + removed: typing.ClassVar[QtCore.pyqtSignal] + added: typing.ClassVar[QtCore.pyqtSignal] def setLabelsVisible(self, visible: bool = ...) -> None: ... def pieEndAngle(self) -> float: ... def setPieEndAngle(self, endAngle: float) -> None: ... @@ -1279,26 +1256,25 @@ class QPieSlice(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, label: str, value: float, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def doubleClicked(self) -> None: ... - def released(self) -> None: ... - def pressed(self) -> None: ... - def hovered(self, state: bool) -> None: ... - def clicked(self) -> None: ... - def labelColorChanged(self) -> None: ... - def borderWidthChanged(self) -> None: ... - def borderColorChanged(self) -> None: ... - def colorChanged(self) -> None: ... - def angleSpanChanged(self) -> None: ... - def startAngleChanged(self) -> None: ... - def percentageChanged(self) -> None: ... - def labelFontChanged(self) -> None: ... - def labelBrushChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def labelVisibleChanged(self) -> None: ... - def valueChanged(self) -> None: ... - def labelChanged(self) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + labelColorChanged: typing.ClassVar[QtCore.pyqtSignal] + borderWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + angleSpanChanged: typing.ClassVar[QtCore.pyqtSignal] + startAngleChanged: typing.ClassVar[QtCore.pyqtSignal] + percentageChanged: typing.ClassVar[QtCore.pyqtSignal] + labelFontChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + penChanged: typing.ClassVar[QtCore.pyqtSignal] + labelVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + labelChanged: typing.ClassVar[QtCore.pyqtSignal] def setLabelPosition(self, position: 'QPieSlice.LabelPosition') -> None: ... def labelPosition(self) -> 'QPieSlice.LabelPosition': ... def series(self) -> 'QPieSeries': ... @@ -1375,11 +1351,10 @@ class QScatterSeries('QXYSeries'): MarkerShapeRectangle = ... # type: QScatterSeries.MarkerShape def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def markerSizeChanged(self, size: float) -> None: ... - def markerShapeChanged(self, shape: 'QScatterSeries.MarkerShape') -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + markerSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + markerShapeChanged: typing.ClassVar[QtCore.pyqtSignal] + borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] def borderColor(self) -> QtGui.QColor: ... def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def color(self) -> QtGui.QColor: ... @@ -1408,13 +1383,12 @@ class QStackedBarSeries('QAbstractBarSeries'): class QVBarModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def lastBarSetColumnChanged(self) -> None: ... - def firstBarSetColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] + lastBarSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + firstBarSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... @@ -1431,13 +1405,12 @@ class QVBarModelMapper(QtCore.QObject): class QVBoxPlotModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def lastBoxSetColumnChanged(self) -> None: ... - def firstBoxSetColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] + lastBoxSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + firstBoxSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... @@ -1454,14 +1427,13 @@ class QVBoxPlotModelMapper(QtCore.QObject): class QVCandlestickModelMapper('QCandlestickModelMapper'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def lastSetColumnChanged(self) -> None: ... - def firstSetColumnChanged(self) -> None: ... - def closeRowChanged(self) -> None: ... - def lowRowChanged(self) -> None: ... - def highRowChanged(self) -> None: ... - def openRowChanged(self) -> None: ... - def timestampRowChanged(self) -> None: ... + lastSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + firstSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + closeRowChanged: typing.ClassVar[QtCore.pyqtSignal] + lowRowChanged: typing.ClassVar[QtCore.pyqtSignal] + highRowChanged: typing.ClassVar[QtCore.pyqtSignal] + openRowChanged: typing.ClassVar[QtCore.pyqtSignal] + timestampRowChanged: typing.ClassVar[QtCore.pyqtSignal] def lastSetColumn(self) -> int: ... def setLastSetColumn(self, lastSetColumn: int) -> None: ... def firstSetColumn(self) -> int: ... @@ -1481,13 +1453,12 @@ class QVCandlestickModelMapper('QCandlestickModelMapper'): class QVPieModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def labelsColumnChanged(self) -> None: ... - def valuesColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + valuesColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... @@ -1504,13 +1475,12 @@ class QVPieModelMapper(QtCore.QObject): class QVXYModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def yColumnChanged(self) -> None: ... - def xColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] + yColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + xColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index e430ea9a..8b89b18a 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -3135,10 +3135,10 @@ class QAbstractAnimation(QObject): def resume(self) -> None: ... def pause(self) -> None: ... def start(self, policy: 'QAbstractAnimation.DeletionPolicy' = ...) -> None: ... - def directionChanged(self, a0: 'QAbstractAnimation.Direction') -> None: ... - def currentLoopChanged(self, currentLoop: int) -> None: ... - def stateChanged(self, newState: 'QAbstractAnimation.State', oldState: 'QAbstractAnimation.State') -> None: ... - def finished(self) -> None: ... + directionChanged: typing.ClassVar[QtCore.pyqtSignal] + currentLoopChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def totalDuration(self) -> int: ... def duration(self) -> int: ... def currentLoop(self) -> int: ... @@ -3166,9 +3166,8 @@ class QAbstractEventDispatcher(QObject): def __init__(self, a0: 'QAbstractEventDispatcher.TimerInfo') -> None: ... def __init__(self, parent: typing.Optional[QObject] = ...) -> None: ... - - def awake(self) -> None: ... - def aboutToBlock(self) -> None: ... + awake: typing.ClassVar[QtCore.pyqtSignal] + aboutToBlock: typing.ClassVar[QtCore.pyqtSignal] def filterNativeEvent(self, eventType: typing.Union['QByteArray', bytes, bytearray], message: sip.voidptr) -> typing.Tuple[bool, int]: ... def removeNativeEventFilter(self, filterObj: 'QAbstractNativeEventFilter') -> None: ... def installNativeEventFilter(self, filterObj: 'QAbstractNativeEventFilter') -> None: ... @@ -3292,10 +3291,10 @@ class QAbstractItemModel(QObject): def beginMoveColumns(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationColumn: int) -> bool: ... def endMoveRows(self) -> None: ... def beginMoveRows(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationRow: int) -> bool: ... - def columnsMoved(self, parent: QModelIndex, start: int, end: int, destination: QModelIndex, column: int) -> None: ... - def columnsAboutToBeMoved(self, sourceParent: QModelIndex, sourceStart: int, sourceEnd: int, destinationParent: QModelIndex, destinationColumn: int) -> None: ... - def rowsMoved(self, parent: QModelIndex, start: int, end: int, destination: QModelIndex, row: int) -> None: ... - def rowsAboutToBeMoved(self, sourceParent: QModelIndex, sourceStart: int, sourceEnd: int, destinationParent: QModelIndex, destinationRow: int) -> None: ... + columnsMoved: typing.ClassVar[QtCore.pyqtSignal] + columnsAboutToBeMoved: typing.ClassVar[QtCore.pyqtSignal] + rowsMoved: typing.ClassVar[QtCore.pyqtSignal] + rowsAboutToBeMoved: typing.ClassVar[QtCore.pyqtSignal] def createIndex(self, row: int, column: int, object: typing.Any = ...) -> QModelIndex: ... def roleNames(self) -> typing.Dict[int, 'QByteArray']: ... def supportedDragActions(self) -> Qt.DropActions: ... @@ -3318,19 +3317,19 @@ class QAbstractItemModel(QObject): def encodeData(self, indexes: typing.Iterable[QModelIndex], stream: 'QDataStream') -> None: ... def revert(self) -> None: ... def submit(self) -> bool: ... - def modelReset(self) -> None: ... - def modelAboutToBeReset(self) -> None: ... - def columnsRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... - def columnsAboutToBeRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... - def columnsInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... - def columnsAboutToBeInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... - def rowsRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... - def rowsAboutToBeRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... - def rowsInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... - def rowsAboutToBeInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... - def layoutChanged(self, parents: typing.Iterable[QPersistentModelIndex] = ..., hint: 'QAbstractItemModel.LayoutChangeHint' = ...) -> None: ... - def layoutAboutToBeChanged(self, parents: typing.Iterable[QPersistentModelIndex] = ..., hint: 'QAbstractItemModel.LayoutChangeHint' = ...) -> None: ... - def headerDataChanged(self, orientation: Qt.Orientation, first: int, last: int) -> None: ... + modelReset: typing.ClassVar[QtCore.pyqtSignal] + modelAboutToBeReset: typing.ClassVar[QtCore.pyqtSignal] + columnsRemoved: typing.ClassVar[QtCore.pyqtSignal] + columnsAboutToBeRemoved: typing.ClassVar[QtCore.pyqtSignal] + columnsInserted: typing.ClassVar[QtCore.pyqtSignal] + columnsAboutToBeInserted: typing.ClassVar[QtCore.pyqtSignal] + rowsRemoved: typing.ClassVar[QtCore.pyqtSignal] + rowsAboutToBeRemoved: typing.ClassVar[QtCore.pyqtSignal] + rowsInserted: typing.ClassVar[QtCore.pyqtSignal] + rowsAboutToBeInserted: typing.ClassVar[QtCore.pyqtSignal] + layoutChanged: typing.ClassVar[QtCore.pyqtSignal] + layoutAboutToBeChanged: typing.ClassVar[QtCore.pyqtSignal] + headerDataChanged: typing.ClassVar[QtCore.pyqtSignal] dataChanged: typing.ClassVar[pyqtSignal] def span(self, index: QModelIndex) -> 'QSize': ... def match(self, start: QModelIndex, role: int, value: typing.Any, hits: int = ..., flags: typing.Union[Qt.MatchFlags, Qt.MatchFlag] = ...) -> typing.List[QModelIndex]: ... @@ -3401,7 +3400,7 @@ class QAbstractProxyModel(QAbstractItemModel): def supportedDragActions(self) -> Qt.DropActions: ... def dropMimeData(self, data: 'QMimeData', action: Qt.DropAction, row: int, column: int, parent: QModelIndex) -> bool: ... def canDropMimeData(self, data: 'QMimeData', action: Qt.DropAction, row: int, column: int, parent: QModelIndex) -> bool: ... - def sourceModelChanged(self) -> None: ... + sourceModelChanged: typing.ClassVar[QtCore.pyqtSignal] def resetInternalData(self) -> None: ... def sibling(self, row: int, column: int, idx: QModelIndex) -> QModelIndex: ... def supportedDropActions(self) -> Qt.DropActions: ... @@ -3437,9 +3436,9 @@ class QAbstractState(QObject): def event(self, e: 'QEvent') -> bool: ... def onExit(self, event: 'QEvent') -> None: ... def onEntry(self, event: 'QEvent') -> None: ... - def exited(self) -> None: ... - def entered(self) -> None: ... - def activeChanged(self, active: bool) -> None: ... + exited: typing.ClassVar[QtCore.pyqtSignal] + entered: typing.ClassVar[QtCore.pyqtSignal] + activeChanged: typing.ClassVar[QtCore.pyqtSignal] def active(self) -> bool: ... def machine(self) -> 'QStateMachine': ... def parentState(self) -> 'QState': ... @@ -3461,9 +3460,9 @@ class QAbstractTransition(QObject): def event(self, e: 'QEvent') -> bool: ... def onTransition(self, event: 'QEvent') -> None: ... def eventTest(self, event: 'QEvent') -> bool: ... - def targetStatesChanged(self) -> None: ... - def targetStateChanged(self) -> None: ... - def triggered(self) -> None: ... + targetStatesChanged: typing.ClassVar[QtCore.pyqtSignal] + targetStateChanged: typing.ClassVar[QtCore.pyqtSignal] + triggered: typing.ClassVar[QtCore.pyqtSignal] def animations(self) -> typing.List[QAbstractAnimation]: ... def removeAnimation(self, animation: QAbstractAnimation) -> None: ... def addAnimation(self, animation: QAbstractAnimation) -> None: ... @@ -3604,8 +3603,8 @@ class QIODevice(QObject): def __init__(self, parent: QObject) -> None: ... def skip(self, maxSize: int) -> int: ... - def channelBytesWritten(self, channel: int, bytes: int) -> None: ... - def channelReadyRead(self, channel: int) -> None: ... + channelBytesWritten: typing.ClassVar[QtCore.pyqtSignal] + channelReadyRead: typing.ClassVar[QtCore.pyqtSignal] def isTransactionStarted(self) -> bool: ... def rollbackTransaction(self) -> None: ... def commitTransaction(self) -> None: ... @@ -3621,10 +3620,10 @@ class QIODevice(QObject): def writeData(self, data: bytes) -> int: ... def readLineData(self, maxlen: int) -> bytes: ... def readData(self, maxlen: int) -> bytes: ... - def readChannelFinished(self) -> None: ... - def aboutToClose(self) -> None: ... - def bytesWritten(self, bytes: int) -> None: ... - def readyRead(self) -> None: ... + readChannelFinished: typing.ClassVar[QtCore.pyqtSignal] + aboutToClose: typing.ClassVar[QtCore.pyqtSignal] + bytesWritten: typing.ClassVar[QtCore.pyqtSignal] + readyRead: typing.ClassVar[QtCore.pyqtSignal] def errorString(self) -> str: ... def getChar(self) -> typing.Tuple[bool, bytes]: ... def putChar(self, c: str) -> bool: ... @@ -6073,9 +6072,8 @@ class QFileSystemWatcher(QObject): def __init__(self, parent: typing.Optional[QObject] = ...) -> None: ... @typing.overload def __init__(self, paths: typing.Iterable[str], parent: typing.Optional[QObject] = ...) -> None: ... - - def fileChanged(self, path: str) -> None: ... - def directoryChanged(self, path: str) -> None: ... + fileChanged: typing.ClassVar[QtCore.pyqtSignal] + directoryChanged: typing.ClassVar[QtCore.pyqtSignal] def removePaths(self, files: typing.Iterable[str]) -> typing.List[str]: ... def removePath(self, file: str) -> bool: ... def files(self) -> typing.List[str]: ... @@ -6106,12 +6104,11 @@ class QHistoryState(QAbstractState): def __init__(self, parent: typing.Optional['QState'] = ...) -> None: ... @typing.overload def __init__(self, type: 'QHistoryState.HistoryType', parent: typing.Optional['QState'] = ...) -> None: ... - - def defaultTransitionChanged(self) -> None: ... + defaultTransitionChanged: typing.ClassVar[QtCore.pyqtSignal] def setDefaultTransition(self, transition: QAbstractTransition) -> None: ... def defaultTransition(self) -> QAbstractTransition: ... - def historyTypeChanged(self) -> None: ... - def defaultStateChanged(self) -> None: ... + historyTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + defaultStateChanged: typing.ClassVar[QtCore.pyqtSignal] def event(self, e: QEvent) -> bool: ... def onExit(self, event: QEvent) -> None: ... def onEntry(self, event: QEvent) -> None: ... @@ -6226,16 +6223,15 @@ class QItemSelectionModel(QObject): def __init__(self, model: typing.Optional[QAbstractItemModel] = ...) -> None: ... @typing.overload def __init__(self, model: QAbstractItemModel, parent: QObject) -> None: ... - - def modelChanged(self, model: QAbstractItemModel) -> None: ... + modelChanged: typing.ClassVar[QtCore.pyqtSignal] def setModel(self, model: QAbstractItemModel) -> None: ... def selectedColumns(self, row: int = ...) -> typing.List[QModelIndex]: ... def selectedRows(self, column: int = ...) -> typing.List[QModelIndex]: ... def hasSelection(self) -> bool: ... def emitSelectionChanged(self, newSelection: 'QItemSelection', oldSelection: 'QItemSelection') -> None: ... - def currentColumnChanged(self, current: QModelIndex, previous: QModelIndex) -> None: ... - def currentRowChanged(self, current: QModelIndex, previous: QModelIndex) -> None: ... - def currentChanged(self, current: QModelIndex, previous: QModelIndex) -> None: ... + currentColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + currentRowChanged: typing.ClassVar[QtCore.pyqtSignal] + currentChanged: typing.ClassVar[QtCore.pyqtSignal] selectionChanged: typing.ClassVar[pyqtSignal] def clearCurrentIndex(self) -> None: ... def setCurrentIndex(self, index: QModelIndex, command: typing.Union['QItemSelectionModel.SelectionFlags', 'QItemSelectionModel.SelectionFlag']) -> None: ... @@ -9302,7 +9298,7 @@ class QVariantAnimation(QAbstractAnimation): def updateState(self, newState: QAbstractAnimation.State, oldState: QAbstractAnimation.State) -> None: ... def updateCurrentTime(self, a0: int) -> None: ... def event(self, event: QEvent) -> bool: ... - def valueChanged(self, value: typing.Any) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setEasingCurve(self, easing: typing.Union[QEasingCurve, QEasingCurve.Type]) -> None: ... def easingCurve(self) -> QEasingCurve: ... def setDuration(self, msecs: int) -> None: ... @@ -9540,10 +9536,7 @@ class QProcess(QIODevice): def waitForStarted(self, msecs: int = ...) -> bool: ... def pid(self) -> int: ... def state(self) -> 'QProcess.ProcessState': ... - @typing.overload - def error(self) -> 'QProcess.ProcessError': ... - @typing.overload - def error(self, error: 'QProcess.ProcessError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def setWorkingDirectory(self, dir: str) -> None: ... def workingDirectory(self) -> str: ... def closeWriteChannel(self) -> None: ... @@ -10166,7 +10159,7 @@ class QSequentialAnimationGroup(QAnimationGroup): def updateState(self, newState: QAbstractAnimation.State, oldState: QAbstractAnimation.State) -> None: ... def updateCurrentTime(self, a0: int) -> None: ... def event(self, event: QEvent) -> bool: ... - def currentAnimationChanged(self, current: QAbstractAnimation) -> None: ... + currentAnimationChanged: typing.ClassVar[QtCore.pyqtSignal] def duration(self) -> int: ... def currentAnimation(self) -> QAbstractAnimation: ... def insertPause(self, index: int, msecs: int) -> QPauseAnimation: ... @@ -10314,10 +10307,10 @@ class QSignalMapper(QObject): def map(self) -> None: ... @typing.overload def map(self, sender: QObject) -> None: ... - def mappedObject(self, a0: QObject) -> None: ... - def mappedWidget(self, a0: QtWidgets.QWidget) -> None: ... - def mappedString(self, a0: str) -> None: ... - def mappedInt(self, a0: int) -> None: ... + mappedObject: typing.ClassVar[QtCore.pyqtSignal] + mappedWidget: typing.ClassVar[QtCore.pyqtSignal] + mappedString: typing.ClassVar[QtCore.pyqtSignal] + mappedInt: typing.ClassVar[QtCore.pyqtSignal] mapped: typing.ClassVar[pyqtSignal] @typing.overload def mapping(self, id: int) -> QObject: ... @@ -10344,9 +10337,8 @@ class QSignalTransition(QAbstractTransition): def __init__(self, sourceState: typing.Optional['QState'] = ...) -> None: ... @typing.overload def __init__(self, signal: pyqtBoundSignal, sourceState: typing.Optional['QState'] = ...) -> None: ... - - def signalChanged(self) -> None: ... - def senderObjectChanged(self) -> None: ... + signalChanged: typing.ClassVar[QtCore.pyqtSignal] + senderObjectChanged: typing.ClassVar[QtCore.pyqtSignal] def event(self, e: QEvent) -> bool: ... def onTransition(self, event: QEvent) -> None: ... def eventTest(self, event: QEvent) -> bool: ... @@ -10441,7 +10433,7 @@ class QSocketNotifier(QObject): def __init__(self, socket: sip.voidptr, a1: 'QSocketNotifier.Type', parent: typing.Optional[QObject] = ...) -> None: ... def event(self, a0: QEvent) -> bool: ... - def activated(self, socket: int) -> None: ... + activated: typing.ClassVar[QtCore.pyqtSignal] def setEnabled(self, a0: bool) -> None: ... def isEnabled(self) -> bool: ... def type(self) -> 'QSocketNotifier.Type': ... @@ -10451,14 +10443,13 @@ class QSocketNotifier(QObject): class QSortFilterProxyModel(QAbstractProxyModel): def __init__(self, parent: typing.Optional[QObject] = ...) -> None: ... - - def recursiveFilteringEnabledChanged(self, recursiveFilteringEnabled: bool) -> None: ... - def filterRoleChanged(self, filterRole: int) -> None: ... - def sortRoleChanged(self, sortRole: int) -> None: ... - def sortLocaleAwareChanged(self, sortLocaleAware: bool) -> None: ... - def sortCaseSensitivityChanged(self, sortCaseSensitivity: Qt.CaseSensitivity) -> None: ... - def filterCaseSensitivityChanged(self, filterCaseSensitivity: Qt.CaseSensitivity) -> None: ... - def dynamicSortFilterChanged(self, dynamicSortFilter: bool) -> None: ... + recursiveFilteringEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + filterRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + sortRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + sortLocaleAwareChanged: typing.ClassVar[QtCore.pyqtSignal] + sortCaseSensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] + filterCaseSensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] + dynamicSortFilterChanged: typing.ClassVar[QtCore.pyqtSignal] def invalidateFilter(self) -> None: ... def setRecursiveFilteringEnabled(self, recursive: bool) -> None: ... def isRecursiveFilteringEnabled(self) -> bool: ... @@ -10636,15 +10627,14 @@ class QState(QAbstractState): def __init__(self, parent: typing.Optional['QState'] = ...) -> None: ... @typing.overload def __init__(self, childMode: 'QState.ChildMode', parent: typing.Optional['QState'] = ...) -> None: ... - - def errorStateChanged(self) -> None: ... - def initialStateChanged(self) -> None: ... - def childModeChanged(self) -> None: ... + errorStateChanged: typing.ClassVar[QtCore.pyqtSignal] + initialStateChanged: typing.ClassVar[QtCore.pyqtSignal] + childModeChanged: typing.ClassVar[QtCore.pyqtSignal] def event(self, e: QEvent) -> bool: ... def onExit(self, event: QEvent) -> None: ... def onEntry(self, event: QEvent) -> None: ... - def propertiesAssigned(self) -> None: ... - def finished(self) -> None: ... + propertiesAssigned: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def assignProperty(self, object: QObject, name: str, value: typing.Any) -> None: ... def setChildMode(self, mode: 'QState.ChildMode') -> None: ... def childMode(self) -> 'QState.ChildMode': ... @@ -10703,9 +10693,9 @@ class QStateMachine(QState): def event(self, e: QEvent) -> bool: ... def onExit(self, event: QEvent) -> None: ... def onEntry(self, event: QEvent) -> None: ... - def runningChanged(self, running: bool) -> None: ... - def stopped(self) -> None: ... - def started(self) -> None: ... + runningChanged: typing.ClassVar[QtCore.pyqtSignal] + stopped: typing.ClassVar[QtCore.pyqtSignal] + started: typing.ClassVar[QtCore.pyqtSignal] def setRunning(self, running: bool) -> None: ... def stop(self) -> None: ... def start(self) -> None: ... @@ -11273,10 +11263,10 @@ class QTimeLine(QObject): def setEasingCurve(self, curve: typing.Union[QEasingCurve, QEasingCurve.Type]) -> None: ... def easingCurve(self) -> QEasingCurve: ... def timerEvent(self, event: QTimerEvent) -> None: ... - def valueChanged(self, x: float) -> None: ... - def stateChanged(self, newState: 'QTimeLine.State') -> None: ... - def frameChanged(self, a0: int) -> None: ... - def finished(self) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + frameChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def toggleDirection(self) -> None: ... def stop(self) -> None: ... def start(self) -> None: ... diff --git a/PyQt5-stubs/QtDBus.pyi b/PyQt5-stubs/QtDBus.pyi index ac26141b..c84f0755 100644 --- a/PyQt5-stubs/QtDBus.pyi +++ b/PyQt5-stubs/QtDBus.pyi @@ -282,10 +282,10 @@ class QDBusConnectionInterface(QDBusAbstractInterface): def disconnectNotify(self, a0: QtCore.QMetaMethod) -> None: ... def connectNotify(self, a0: QtCore.QMetaMethod) -> None: ... - def callWithCallbackFailed(self, error: 'QDBusError', call: 'QDBusMessage') -> None: ... - def serviceOwnerChanged(self, name: str, oldOwner: str, newOwner: str) -> None: ... - def serviceUnregistered(self, service: str) -> None: ... - def serviceRegistered(self, service: str) -> None: ... + callWithCallbackFailed: typing.ClassVar[QtCore.pyqtSignal] + serviceOwnerChanged: typing.ClassVar[QtCore.pyqtSignal] + serviceUnregistered: typing.ClassVar[QtCore.pyqtSignal] + serviceRegistered: typing.ClassVar[QtCore.pyqtSignal] def startService(self, name: str) -> QDBusReply: ... def serviceUid(self, serviceName: str) -> QDBusReply: ... def servicePid(self, serviceName: str) -> QDBusReply: ... @@ -497,8 +497,7 @@ class QDBusPendingCall(sip.simplewrapper): class QDBusPendingCallWatcher(QtCore.QObject, QDBusPendingCall): def __init__(self, call: QDBusPendingCall, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def finished(self, watcher: typing.Optional['QDBusPendingCallWatcher'] = ...) -> None: ... + finished: typing.ClassVar[QtCore.pyqtSignal] def waitForFinished(self) -> None: ... def isFinished(self) -> bool: ... @@ -533,10 +532,9 @@ class QDBusServiceWatcher(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, service: str, connection: QDBusConnection, watchMode: typing.Union['QDBusServiceWatcher.WatchMode', 'QDBusServiceWatcher.WatchModeFlag'] = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def serviceOwnerChanged(self, service: str, oldOwner: str, newOwner: str) -> None: ... - def serviceUnregistered(self, service: str) -> None: ... - def serviceRegistered(self, service: str) -> None: ... + serviceOwnerChanged: typing.ClassVar[QtCore.pyqtSignal] + serviceUnregistered: typing.ClassVar[QtCore.pyqtSignal] + serviceRegistered: typing.ClassVar[QtCore.pyqtSignal] def setConnection(self, connection: QDBusConnection) -> None: ... def connection(self) -> QDBusConnection: ... def setWatchMode(self, mode: typing.Union['QDBusServiceWatcher.WatchMode', 'QDBusServiceWatcher.WatchModeFlag']) -> None: ... diff --git a/PyQt5-stubs/QtDataVisualization.pyi b/PyQt5-stubs/QtDataVisualization.pyi index b4c86933..fcf79057 100644 --- a/PyQt5-stubs/QtDataVisualization.pyi +++ b/PyQt5-stubs/QtDataVisualization.pyi @@ -134,14 +134,14 @@ class QAbstract3DGraph(QtGui.QWindow): def __int__(self) -> int: ... def hasContext(self) -> bool: ... - def marginChanged(self, margin: float) -> None: ... - def queriedGraphPositionChanged(self, data: QtGui.QVector3D) -> None: ... - def localeChanged(self, locale: QtCore.QLocale) -> None: ... - def reflectivityChanged(self, reflectivity: float) -> None: ... - def reflectionChanged(self, enabled: bool) -> None: ... - def horizontalAspectRatioChanged(self, ratio: float) -> None: ... - def radialLabelOffsetChanged(self, offset: float) -> None: ... - def polarChanged(self, enabled: bool) -> None: ... + marginChanged: typing.ClassVar[QtCore.pyqtSignal] + queriedGraphPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + localeChanged: typing.ClassVar[QtCore.pyqtSignal] + reflectivityChanged: typing.ClassVar[QtCore.pyqtSignal] + reflectionChanged: typing.ClassVar[QtCore.pyqtSignal] + horizontalAspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + radialLabelOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] + polarChanged: typing.ClassVar[QtCore.pyqtSignal] def margin(self) -> float: ... def setMargin(self, margin: float) -> None: ... def queriedGraphPosition(self) -> QtGui.QVector3D: ... @@ -158,12 +158,12 @@ class QAbstract3DGraph(QtGui.QWindow): def isPolar(self) -> bool: ... def setPolar(self, enable: bool) -> None: ... def customItems(self) -> typing.List['QCustom3DItem']: ... - def optimizationHintsChanged(self, hints: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... - def aspectRatioChanged(self, ratio: float) -> None: ... - def orthoProjectionChanged(self, enabled: bool) -> None: ... - def currentFpsChanged(self, fps: float) -> None: ... - def measureFpsChanged(self, enabled: bool) -> None: ... - def selectedElementChanged(self, type: 'QAbstract3DGraph.ElementType') -> None: ... + optimizationHintsChanged: typing.ClassVar[QtCore.pyqtSignal] + aspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + orthoProjectionChanged: typing.ClassVar[QtCore.pyqtSignal] + currentFpsChanged: typing.ClassVar[QtCore.pyqtSignal] + measureFpsChanged: typing.ClassVar[QtCore.pyqtSignal] + selectedElementChanged: typing.ClassVar[QtCore.pyqtSignal] def optimizationHints(self) -> 'QAbstract3DGraph.OptimizationHints': ... def setOptimizationHints(self, hints: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... def aspectRatio(self) -> float: ... @@ -193,10 +193,10 @@ class QAbstract3DGraph(QtGui.QWindow): def exposeEvent(self, event: QtGui.QExposeEvent) -> None: ... def resizeEvent(self, event: QtGui.QResizeEvent) -> None: ... def event(self, event: QtCore.QEvent) -> bool: ... - def shadowQualityChanged(self, quality: 'QAbstract3DGraph.ShadowQuality') -> None: ... - def selectionModeChanged(self, mode: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag']) -> None: ... - def activeThemeChanged(self, theme: 'Q3DTheme') -> None: ... - def activeInputHandlerChanged(self, inputHandler: 'QAbstract3DInputHandler') -> None: ... + shadowQualityChanged: typing.ClassVar[QtCore.pyqtSignal] + selectionModeChanged: typing.ClassVar[QtCore.pyqtSignal] + activeThemeChanged: typing.ClassVar[QtCore.pyqtSignal] + activeInputHandlerChanged: typing.ClassVar[QtCore.pyqtSignal] def shadowsSupported(self) -> bool: ... def activeInputHandler(self) -> 'QAbstract3DInputHandler': ... def clearSelection(self) -> None: ... @@ -218,19 +218,18 @@ class QAbstract3DGraph(QtGui.QWindow): class Q3DBars('QAbstract3DGraph'): def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - - def floorLevelChanged(self, level: float) -> None: ... + floorLevelChanged: typing.ClassVar[QtCore.pyqtSignal] def floorLevel(self) -> float: ... def setFloorLevel(self, level: float) -> None: ... - def selectedSeriesChanged(self, series: 'QBar3DSeries') -> None: ... - def primarySeriesChanged(self, series: 'QBar3DSeries') -> None: ... - def valueAxisChanged(self, axis: 'QValue3DAxis') -> None: ... - def columnAxisChanged(self, axis: 'QCategory3DAxis') -> None: ... - def rowAxisChanged(self, axis: 'QCategory3DAxis') -> None: ... - def barSpacingRelativeChanged(self, relative: bool) -> None: ... - def barSpacingChanged(self, spacing: QtCore.QSizeF) -> None: ... - def barThicknessChanged(self, thicknessRatio: float) -> None: ... - def multiSeriesUniformChanged(self, uniform: bool) -> None: ... + selectedSeriesChanged: typing.ClassVar[QtCore.pyqtSignal] + primarySeriesChanged: typing.ClassVar[QtCore.pyqtSignal] + valueAxisChanged: typing.ClassVar[QtCore.pyqtSignal] + columnAxisChanged: typing.ClassVar[QtCore.pyqtSignal] + rowAxisChanged: typing.ClassVar[QtCore.pyqtSignal] + barSpacingRelativeChanged: typing.ClassVar[QtCore.pyqtSignal] + barSpacingChanged: typing.ClassVar[QtCore.pyqtSignal] + barThicknessChanged: typing.ClassVar[QtCore.pyqtSignal] + multiSeriesUniformChanged: typing.ClassVar[QtCore.pyqtSignal] def selectedSeries(self) -> 'QBar3DSeries': ... def axes(self) -> typing.List['QAbstract3DAxis']: ... def releaseAxis(self, axis: 'QAbstract3DAxis') -> None: ... @@ -262,7 +261,7 @@ class Q3DObject(QtCore.QObject): def isDirty(self) -> bool: ... def setDirty(self, dirty: bool) -> None: ... - def positionChanged(self, position: QtGui.QVector3D) -> None: ... + positionChanged: typing.ClassVar[QtCore.pyqtSignal] def setPosition(self, position: QtGui.QVector3D) -> None: ... def position(self) -> QtGui.QVector3D: ... def parentScene(self) -> 'Q3DScene': ... @@ -324,22 +323,21 @@ class Q3DCamera('Q3DObject'): CameraPresetDirectlyBelow = ... # type: Q3DCamera.CameraPreset def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def targetChanged(self, target: QtGui.QVector3D) -> None: ... - def maxZoomLevelChanged(self, zoomLevel: float) -> None: ... - def minZoomLevelChanged(self, zoomLevel: float) -> None: ... + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + maxZoomLevelChanged: typing.ClassVar[QtCore.pyqtSignal] + minZoomLevelChanged: typing.ClassVar[QtCore.pyqtSignal] def setTarget(self, target: QtGui.QVector3D) -> None: ... def target(self) -> QtGui.QVector3D: ... def setMaxZoomLevel(self, zoomLevel: float) -> None: ... def maxZoomLevel(self) -> float: ... def setMinZoomLevel(self, zoomLevel: float) -> None: ... def minZoomLevel(self) -> float: ... - def wrapYRotationChanged(self, isEnabled: bool) -> None: ... - def wrapXRotationChanged(self, isEnabled: bool) -> None: ... - def cameraPresetChanged(self, preset: 'Q3DCamera.CameraPreset') -> None: ... - def zoomLevelChanged(self, zoomLevel: float) -> None: ... - def yRotationChanged(self, rotation: float) -> None: ... - def xRotationChanged(self, rotation: float) -> None: ... + wrapYRotationChanged: typing.ClassVar[QtCore.pyqtSignal] + wrapXRotationChanged: typing.ClassVar[QtCore.pyqtSignal] + cameraPresetChanged: typing.ClassVar[QtCore.pyqtSignal] + zoomLevelChanged: typing.ClassVar[QtCore.pyqtSignal] + yRotationChanged: typing.ClassVar[QtCore.pyqtSignal] + xRotationChanged: typing.ClassVar[QtCore.pyqtSignal] def setZoomLevel(self, zoomLevel: float) -> None: ... def zoomLevel(self) -> float: ... def setCameraPosition(self, horizontal: float, vertical: float, zoom: float = ...) -> None: ... @@ -372,9 +370,9 @@ class QAbstract3DInputHandler(QtCore.QObject): def setPreviousInputPos(self, position: QtCore.QPoint) -> None: ... def prevDistance(self) -> int: ... def setPrevDistance(self, distance: int) -> None: ... - def sceneChanged(self, scene: 'Q3DScene') -> None: ... - def inputViewChanged(self, view: 'QAbstract3DInputHandler.InputView') -> None: ... - def positionChanged(self, position: QtCore.QPoint) -> None: ... + sceneChanged: typing.ClassVar[QtCore.pyqtSignal] + inputViewChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] def setScene(self, scene: 'Q3DScene') -> None: ... def scene(self) -> 'Q3DScene': ... def setInputPosition(self, position: QtCore.QPoint) -> None: ... @@ -391,11 +389,10 @@ class QAbstract3DInputHandler(QtCore.QObject): class Q3DInputHandler('QAbstract3DInputHandler'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def zoomAtTargetEnabledChanged(self, enable: bool) -> None: ... - def selectionEnabledChanged(self, enable: bool) -> None: ... - def zoomEnabledChanged(self, enable: bool) -> None: ... - def rotationEnabledChanged(self, enable: bool) -> None: ... + zoomAtTargetEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + selectionEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + zoomEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] def isZoomAtTargetEnabled(self) -> bool: ... def setZoomAtTargetEnabled(self, enable: bool) -> None: ... def isSelectionEnabled(self) -> bool: ... @@ -412,19 +409,17 @@ class Q3DInputHandler('QAbstract3DInputHandler'): class Q3DLight('Q3DObject'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def autoPositionChanged(self, autoPosition: bool) -> None: ... + autoPositionChanged: typing.ClassVar[QtCore.pyqtSignal] def isAutoPosition(self) -> bool: ... def setAutoPosition(self, enabled: bool) -> None: ... class Q3DScatter('QAbstract3DGraph'): def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - - def selectedSeriesChanged(self, series: 'QScatter3DSeries') -> None: ... - def axisZChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisYChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisXChanged(self, axis: 'QValue3DAxis') -> None: ... + selectedSeriesChanged: typing.ClassVar[QtCore.pyqtSignal] + axisZChanged: typing.ClassVar[QtCore.pyqtSignal] + axisYChanged: typing.ClassVar[QtCore.pyqtSignal] + axisXChanged: typing.ClassVar[QtCore.pyqtSignal] def selectedSeries(self) -> 'QScatter3DSeries': ... def axes(self) -> typing.List['QValue3DAxis']: ... def releaseAxis(self, axis: 'QValue3DAxis') -> None: ... @@ -442,19 +437,18 @@ class Q3DScatter('QAbstract3DGraph'): class Q3DScene(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def graphPositionQueryChanged(self, position: QtCore.QPoint) -> None: ... + graphPositionQueryChanged: typing.ClassVar[QtCore.pyqtSignal] def graphPositionQuery(self) -> QtCore.QPoint: ... def setGraphPositionQuery(self, point: QtCore.QPoint) -> None: ... - def selectionQueryPositionChanged(self, position: QtCore.QPoint) -> None: ... - def devicePixelRatioChanged(self, pixelRatio: float) -> None: ... - def activeLightChanged(self, light: 'Q3DLight') -> None: ... - def activeCameraChanged(self, camera: 'Q3DCamera') -> None: ... - def slicingActiveChanged(self, isSlicingActive: bool) -> None: ... - def secondarySubviewOnTopChanged(self, isSecondaryOnTop: bool) -> None: ... - def secondarySubViewportChanged(self, subViewport: QtCore.QRect) -> None: ... - def primarySubViewportChanged(self, subViewport: QtCore.QRect) -> None: ... - def viewportChanged(self, viewport: QtCore.QRect) -> None: ... + selectionQueryPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + devicePixelRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + activeLightChanged: typing.ClassVar[QtCore.pyqtSignal] + activeCameraChanged: typing.ClassVar[QtCore.pyqtSignal] + slicingActiveChanged: typing.ClassVar[QtCore.pyqtSignal] + secondarySubviewOnTopChanged: typing.ClassVar[QtCore.pyqtSignal] + secondarySubViewportChanged: typing.ClassVar[QtCore.pyqtSignal] + primarySubViewportChanged: typing.ClassVar[QtCore.pyqtSignal] + viewportChanged: typing.ClassVar[QtCore.pyqtSignal] def setDevicePixelRatio(self, pixelRatio: float) -> None: ... def devicePixelRatio(self) -> float: ... def setActiveLight(self, light: 'Q3DLight') -> None: ... @@ -480,14 +474,13 @@ class Q3DScene(QtCore.QObject): class Q3DSurface('QAbstract3DGraph'): def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - - def flipHorizontalGridChanged(self, flip: bool) -> None: ... + flipHorizontalGridChanged: typing.ClassVar[QtCore.pyqtSignal] def flipHorizontalGrid(self) -> bool: ... def setFlipHorizontalGrid(self, flip: bool) -> None: ... - def selectedSeriesChanged(self, series: 'QSurface3DSeries') -> None: ... - def axisZChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisYChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisXChanged(self, axis: 'QValue3DAxis') -> None: ... + selectedSeriesChanged: typing.ClassVar[QtCore.pyqtSignal] + axisZChanged: typing.ClassVar[QtCore.pyqtSignal] + axisYChanged: typing.ClassVar[QtCore.pyqtSignal] + axisXChanged: typing.ClassVar[QtCore.pyqtSignal] def selectedSeries(self) -> 'QSurface3DSeries': ... def axes(self) -> typing.List['QValue3DAxis']: ... def releaseAxis(self, axis: 'QValue3DAxis') -> None: ... @@ -538,29 +531,28 @@ class Q3DTheme(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, themeType: 'Q3DTheme.Theme', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def colorStyleChanged(self, style: 'Q3DTheme.ColorStyle') -> None: ... - def labelBackgroundEnabledChanged(self, enabled: bool) -> None: ... - def gridEnabledChanged(self, enabled: bool) -> None: ... - def backgroundEnabledChanged(self, enabled: bool) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def labelBorderEnabledChanged(self, enabled: bool) -> None: ... - def highlightLightStrengthChanged(self, strength: float) -> None: ... - def ambientLightStrengthChanged(self, strength: float) -> None: ... - def lightStrengthChanged(self, strength: float) -> None: ... - def multiHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def singleHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def baseGradientsChanged(self, gradients: typing.Iterable[QtGui.QLinearGradient]) -> None: ... - def lightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def multiHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def singleHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def gridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def labelBackgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def labelTextColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def windowColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def backgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def baseColorsChanged(self, colors: typing.Iterable[typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]]) -> None: ... - def typeChanged(self, themeType: 'Q3DTheme.Theme') -> None: ... + colorStyleChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBackgroundEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + gridEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + backgroundEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBorderEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + highlightLightStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientLightStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] + lightStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] + multiHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] + singleHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] + baseGradientsChanged: typing.ClassVar[QtCore.pyqtSignal] + lightColorChanged: typing.ClassVar[QtCore.pyqtSignal] + multiHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] + singleHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] + gridLineColorChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBackgroundColorChanged: typing.ClassVar[QtCore.pyqtSignal] + labelTextColorChanged: typing.ClassVar[QtCore.pyqtSignal] + windowColorChanged: typing.ClassVar[QtCore.pyqtSignal] + backgroundColorChanged: typing.ClassVar[QtCore.pyqtSignal] + baseColorsChanged: typing.ClassVar[QtCore.pyqtSignal] + typeChanged: typing.ClassVar[QtCore.pyqtSignal] def colorStyle(self) -> 'Q3DTheme.ColorStyle': ... def setColorStyle(self, style: 'Q3DTheme.ColorStyle') -> None: ... def isLabelBackgroundEnabled(self) -> bool: ... @@ -627,23 +619,22 @@ class QAbstract3DAxis(QtCore.QObject): AxisOrientationX = ... # type: QAbstract3DAxis.AxisOrientation AxisOrientationY = ... # type: QAbstract3DAxis.AxisOrientation AxisOrientationZ = ... # type: QAbstract3DAxis.AxisOrientation - - def titleFixedChanged(self, fixed: bool) -> None: ... - def titleVisibilityChanged(self, visible: bool) -> None: ... - def labelAutoRotationChanged(self, angle: float) -> None: ... + titleFixedChanged: typing.ClassVar[QtCore.pyqtSignal] + titleVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + labelAutoRotationChanged: typing.ClassVar[QtCore.pyqtSignal] def isTitleFixed(self) -> bool: ... def setTitleFixed(self, fixed: bool) -> None: ... def isTitleVisible(self) -> bool: ... def setTitleVisible(self, visible: bool) -> None: ... def labelAutoRotation(self) -> float: ... def setLabelAutoRotation(self, angle: float) -> None: ... - def autoAdjustRangeChanged(self, autoAdjust: bool) -> None: ... - def rangeChanged(self, min: float, max: float) -> None: ... - def maxChanged(self, value: float) -> None: ... - def minChanged(self, value: float) -> None: ... - def orientationChanged(self, orientation: 'QAbstract3DAxis.AxisOrientation') -> None: ... - def labelsChanged(self) -> None: ... - def titleChanged(self, newTitle: str) -> None: ... + autoAdjustRangeChanged: typing.ClassVar[QtCore.pyqtSignal] + rangeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxChanged: typing.ClassVar[QtCore.pyqtSignal] + minChanged: typing.ClassVar[QtCore.pyqtSignal] + orientationChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsChanged: typing.ClassVar[QtCore.pyqtSignal] + titleChanged: typing.ClassVar[QtCore.pyqtSignal] def setTitle(self, title: str) -> None: ... def setRange(self, min: float, max: float) -> None: ... def isAutoAdjustRange(self) -> bool: ... @@ -697,26 +688,25 @@ class QAbstract3DSeries(QtCore.QObject): SeriesTypeBar = ... # type: QAbstract3DSeries.SeriesType SeriesTypeScatter = ... # type: QAbstract3DSeries.SeriesType SeriesTypeSurface = ... # type: QAbstract3DSeries.SeriesType - - def itemLabelVisibilityChanged(self, visible: bool) -> None: ... - def itemLabelChanged(self, label: str) -> None: ... + itemLabelVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + itemLabelChanged: typing.ClassVar[QtCore.pyqtSignal] def isItemLabelVisible(self) -> bool: ... def setItemLabelVisible(self, visible: bool) -> None: ... def itemLabel(self) -> str: ... - def nameChanged(self, name: str) -> None: ... - def multiHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def multiHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def singleHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def singleHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def baseGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def baseColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def colorStyleChanged(self, style: 'Q3DTheme.ColorStyle') -> None: ... - def userDefinedMeshChanged(self, fileName: str) -> None: ... - def meshRotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def meshSmoothChanged(self, enabled: bool) -> None: ... - def meshChanged(self, mesh: 'QAbstract3DSeries.Mesh') -> None: ... - def visibilityChanged(self, visible: bool) -> None: ... - def itemLabelFormatChanged(self, format: str) -> None: ... + nameChanged: typing.ClassVar[QtCore.pyqtSignal] + multiHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] + multiHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] + singleHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] + singleHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] + baseGradientChanged: typing.ClassVar[QtCore.pyqtSignal] + baseColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorStyleChanged: typing.ClassVar[QtCore.pyqtSignal] + userDefinedMeshChanged: typing.ClassVar[QtCore.pyqtSignal] + meshRotationChanged: typing.ClassVar[QtCore.pyqtSignal] + meshSmoothChanged: typing.ClassVar[QtCore.pyqtSignal] + meshChanged: typing.ClassVar[QtCore.pyqtSignal] + visibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + itemLabelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] def setMeshAxisAndAngle(self, axis: QtGui.QVector3D, angle: float) -> None: ... def name(self) -> str: ... def setName(self, name: str) -> None: ... @@ -769,10 +759,9 @@ class QBar3DSeries('QAbstract3DSeries'): def __init__(self, dataProxy: 'QBarDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def meshAngleChanged(self, angle: float) -> None: ... - def selectedBarChanged(self, position: QtCore.QPoint) -> None: ... - def dataProxyChanged(self, proxy: 'QBarDataProxy') -> None: ... + meshAngleChanged: typing.ClassVar[QtCore.pyqtSignal] + selectedBarChanged: typing.ClassVar[QtCore.pyqtSignal] + dataProxyChanged: typing.ClassVar[QtCore.pyqtSignal] def meshAngle(self) -> float: ... def setMeshAngle(self, angle: float) -> None: ... @staticmethod @@ -801,17 +790,16 @@ class QBarDataItem(sip.simplewrapper): class QBarDataProxy('QAbstractDataProxy'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def seriesChanged(self, series: 'QBar3DSeries') -> None: ... - def columnLabelsChanged(self) -> None: ... - def rowLabelsChanged(self) -> None: ... - def rowCountChanged(self, count: int) -> None: ... - def itemChanged(self, rowIndex: int, columnIndex: int) -> None: ... - def rowsInserted(self, startIndex: int, count: int) -> None: ... - def rowsRemoved(self, startIndex: int, count: int) -> None: ... - def rowsChanged(self, startIndex: int, count: int) -> None: ... - def rowsAdded(self, startIndex: int, count: int) -> None: ... - def arrayReset(self) -> None: ... + seriesChanged: typing.ClassVar[QtCore.pyqtSignal] + columnLabelsChanged: typing.ClassVar[QtCore.pyqtSignal] + rowLabelsChanged: typing.ClassVar[QtCore.pyqtSignal] + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + itemChanged: typing.ClassVar[QtCore.pyqtSignal] + rowsInserted: typing.ClassVar[QtCore.pyqtSignal] + rowsRemoved: typing.ClassVar[QtCore.pyqtSignal] + rowsChanged: typing.ClassVar[QtCore.pyqtSignal] + rowsAdded: typing.ClassVar[QtCore.pyqtSignal] + arrayReset: typing.ClassVar[QtCore.pyqtSignal] def series(self) -> 'QBar3DSeries': ... def removeRows(self, rowIndex: int, removeCount: int, removeLabels: bool = ...) -> None: ... @typing.overload @@ -863,8 +851,7 @@ class QBarDataProxy('QAbstractDataProxy'): class QCategory3DAxis('QAbstract3DAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def labelsChanged(self) -> None: ... + labelsChanged: typing.ClassVar[QtCore.pyqtSignal] def labels(self) -> typing.List[str]: ... def setLabels(self, labels: typing.Iterable[str]) -> None: ... @@ -874,18 +861,17 @@ class QCustom3DItem(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, meshFile: str, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, texture: QtGui.QImage, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def scalingAbsoluteChanged(self, scalingAbsolute: bool) -> None: ... + scalingAbsoluteChanged: typing.ClassVar[QtCore.pyqtSignal] def isScalingAbsolute(self) -> bool: ... def setScalingAbsolute(self, scalingAbsolute: bool) -> None: ... - def shadowCastingChanged(self, shadowCasting: bool) -> None: ... - def visibleChanged(self, visible: bool) -> None: ... - def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def scalingChanged(self, scaling: QtGui.QVector3D) -> None: ... - def positionAbsoluteChanged(self, positionAbsolute: bool) -> None: ... - def positionChanged(self, position: QtGui.QVector3D) -> None: ... - def textureFileChanged(self, textureFile: str) -> None: ... - def meshFileChanged(self, meshFile: str) -> None: ... + shadowCastingChanged: typing.ClassVar[QtCore.pyqtSignal] + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationChanged: typing.ClassVar[QtCore.pyqtSignal] + scalingChanged: typing.ClassVar[QtCore.pyqtSignal] + positionAbsoluteChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + textureFileChanged: typing.ClassVar[QtCore.pyqtSignal] + meshFileChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureImage(self, textureImage: QtGui.QImage) -> None: ... def setRotationAxisAndAngle(self, axis: QtGui.QVector3D, angle: float) -> None: ... def isShadowCasting(self) -> bool: ... @@ -911,14 +897,13 @@ class QCustom3DLabel('QCustom3DItem'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, text: str, font: QtGui.QFont, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def facingCameraChanged(self, enabled: bool) -> None: ... - def backgroundEnabledChanged(self, enabled: bool) -> None: ... - def borderEnabledChanged(self, enabled: bool) -> None: ... - def backgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def textColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def textChanged(self, text: str) -> None: ... + facingCameraChanged: typing.ClassVar[QtCore.pyqtSignal] + backgroundEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + borderEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + backgroundColorChanged: typing.ClassVar[QtCore.pyqtSignal] + textColorChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + textChanged: typing.ClassVar[QtCore.pyqtSignal] def isFacingCamera(self) -> bool: ... def setFacingCamera(self, enabled: bool) -> None: ... def isBackgroundEnabled(self) -> bool: ... @@ -940,25 +925,24 @@ class QCustom3DVolume('QCustom3DItem'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, textureWidth: int, textureHeight: int, textureDepth: int, textureData: sip.array[int], textureFormat: QtGui.QImage.Format, colorTable: typing.Iterable[int], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def sliceFrameThicknessesChanged(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameGapsChanged(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameWidthsChanged(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def drawSliceFramesChanged(self, enabled: bool) -> None: ... - def drawSlicesChanged(self, enabled: bool) -> None: ... - def useHighDefShaderChanged(self, enabled: bool) -> None: ... - def preserveOpacityChanged(self, enabled: bool) -> None: ... - def alphaMultiplierChanged(self, mult: float) -> None: ... - def textureFormatChanged(self, format: QtGui.QImage.Format) -> None: ... - def textureDataChanged(self, data: sip.array[int]) -> None: ... - def colorTableChanged(self) -> None: ... - def sliceIndexZChanged(self, value: int) -> None: ... - def sliceIndexYChanged(self, value: int) -> None: ... - def sliceIndexXChanged(self, value: int) -> None: ... - def textureDepthChanged(self, value: int) -> None: ... - def textureHeightChanged(self, value: int) -> None: ... - def textureWidthChanged(self, value: int) -> None: ... + sliceFrameThicknessesChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceFrameGapsChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceFrameWidthsChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceFrameColorChanged: typing.ClassVar[QtCore.pyqtSignal] + drawSliceFramesChanged: typing.ClassVar[QtCore.pyqtSignal] + drawSlicesChanged: typing.ClassVar[QtCore.pyqtSignal] + useHighDefShaderChanged: typing.ClassVar[QtCore.pyqtSignal] + preserveOpacityChanged: typing.ClassVar[QtCore.pyqtSignal] + alphaMultiplierChanged: typing.ClassVar[QtCore.pyqtSignal] + textureFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + textureDataChanged: typing.ClassVar[QtCore.pyqtSignal] + colorTableChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceIndexZChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceIndexYChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceIndexXChanged: typing.ClassVar[QtCore.pyqtSignal] + textureDepthChanged: typing.ClassVar[QtCore.pyqtSignal] + textureHeightChanged: typing.ClassVar[QtCore.pyqtSignal] + textureWidthChanged: typing.ClassVar[QtCore.pyqtSignal] def renderSlice(self, axis: QtCore.Qt.Axis, index: int) -> QtGui.QImage: ... def sliceFrameThicknesses(self) -> QtGui.QVector3D: ... def setSliceFrameThicknesses(self, values: QtGui.QVector3D) -> None: ... @@ -1008,16 +992,15 @@ class QCustom3DVolume('QCustom3DItem'): class QSurfaceDataProxy('QAbstractDataProxy'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def seriesChanged(self, series: 'QSurface3DSeries') -> None: ... - def columnCountChanged(self, count: int) -> None: ... - def rowCountChanged(self, count: int) -> None: ... - def itemChanged(self, rowIndex: int, columnIndex: int) -> None: ... - def rowsInserted(self, startIndex: int, count: int) -> None: ... - def rowsRemoved(self, startIndex: int, count: int) -> None: ... - def rowsChanged(self, startIndex: int, count: int) -> None: ... - def rowsAdded(self, startIndex: int, count: int) -> None: ... - def arrayReset(self) -> None: ... + seriesChanged: typing.ClassVar[QtCore.pyqtSignal] + columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + itemChanged: typing.ClassVar[QtCore.pyqtSignal] + rowsInserted: typing.ClassVar[QtCore.pyqtSignal] + rowsRemoved: typing.ClassVar[QtCore.pyqtSignal] + rowsChanged: typing.ClassVar[QtCore.pyqtSignal] + rowsAdded: typing.ClassVar[QtCore.pyqtSignal] + arrayReset: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def itemAt(self, rowIndex: int, columnIndex: int) -> 'QSurfaceDataItem': ... @typing.overload @@ -1047,13 +1030,12 @@ class QHeightMapSurfaceDataProxy('QSurfaceDataProxy'): def __init__(self, image: QtGui.QImage, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, filename: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def maxZValueChanged(self, value: float) -> None: ... - def minZValueChanged(self, value: float) -> None: ... - def maxXValueChanged(self, value: float) -> None: ... - def minXValueChanged(self, value: float) -> None: ... - def heightMapFileChanged(self, filename: str) -> None: ... - def heightMapChanged(self, image: QtGui.QImage) -> None: ... + maxZValueChanged: typing.ClassVar[QtCore.pyqtSignal] + minZValueChanged: typing.ClassVar[QtCore.pyqtSignal] + maxXValueChanged: typing.ClassVar[QtCore.pyqtSignal] + minXValueChanged: typing.ClassVar[QtCore.pyqtSignal] + heightMapFileChanged: typing.ClassVar[QtCore.pyqtSignal] + heightMapChanged: typing.ClassVar[QtCore.pyqtSignal] def maxZValue(self) -> float: ... def setMaxZValue(self, max: float) -> None: ... def minZValue(self) -> float: ... @@ -1095,16 +1077,15 @@ class QItemModelBarDataProxy('QBarDataProxy'): def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, valueRole: str, rotationRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def multiMatchBehaviorChanged(self, behavior: 'QItemModelBarDataProxy.MultiMatchBehavior') -> None: ... - def rotationRoleReplaceChanged(self, replace: str) -> None: ... - def valueRoleReplaceChanged(self, replace: str) -> None: ... - def columnRoleReplaceChanged(self, replace: str) -> None: ... - def rowRoleReplaceChanged(self, replace: str) -> None: ... - def rotationRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def valueRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def columnRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def rowRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + multiMatchBehaviorChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + valueRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + valueRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] def multiMatchBehavior(self) -> 'QItemModelBarDataProxy.MultiMatchBehavior': ... def setMultiMatchBehavior(self, behavior: 'QItemModelBarDataProxy.MultiMatchBehavior') -> None: ... def rotationRoleReplace(self) -> str: ... @@ -1123,16 +1104,16 @@ class QItemModelBarDataProxy('QBarDataProxy'): def setColumnRolePattern(self, pattern: QtCore.QRegExp) -> None: ... def rowRolePattern(self) -> QtCore.QRegExp: ... def setRowRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def autoColumnCategoriesChanged(self, enable: bool) -> None: ... - def autoRowCategoriesChanged(self, enable: bool) -> None: ... - def useModelCategoriesChanged(self, enable: bool) -> None: ... - def columnCategoriesChanged(self) -> None: ... - def rowCategoriesChanged(self) -> None: ... - def rotationRoleChanged(self, role: str) -> None: ... - def valueRoleChanged(self, role: str) -> None: ... - def columnRoleChanged(self, role: str) -> None: ... - def rowRoleChanged(self, role: str) -> None: ... - def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + autoColumnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + autoRowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + useModelCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + columnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + rowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + valueRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + itemModelChanged: typing.ClassVar[QtCore.pyqtSignal] def remap(self, rowRole: str, columnRole: str, valueRole: str, rotationRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str]) -> None: ... def rotationRole(self) -> str: ... def setRotationRole(self, role: str) -> None: ... @@ -1160,14 +1141,13 @@ class QItemModelBarDataProxy('QBarDataProxy'): class QScatterDataProxy('QAbstractDataProxy'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def seriesChanged(self, series: 'QScatter3DSeries') -> None: ... - def itemCountChanged(self, count: int) -> None: ... - def itemsInserted(self, startIndex: int, count: int) -> None: ... - def itemsRemoved(self, startIndex: int, count: int) -> None: ... - def itemsChanged(self, startIndex: int, count: int) -> None: ... - def itemsAdded(self, startIndex: int, count: int) -> None: ... - def arrayReset(self) -> None: ... + seriesChanged: typing.ClassVar[QtCore.pyqtSignal] + itemCountChanged: typing.ClassVar[QtCore.pyqtSignal] + itemsInserted: typing.ClassVar[QtCore.pyqtSignal] + itemsRemoved: typing.ClassVar[QtCore.pyqtSignal] + itemsChanged: typing.ClassVar[QtCore.pyqtSignal] + itemsAdded: typing.ClassVar[QtCore.pyqtSignal] + arrayReset: typing.ClassVar[QtCore.pyqtSignal] def series(self) -> 'QScatter3DSeries': ... def removeItems(self, index: int, removeCount: int) -> None: ... def insertItems(self, index: int, items: typing.Iterable['QScatterDataItem']) -> None: ... @@ -1191,15 +1171,14 @@ class QItemModelScatterDataProxy('QScatterDataProxy'): def __init__(self, itemModel: QtCore.QAbstractItemModel, xPosRole: str, yPosRole: str, zPosRole: str, rotationRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def zPosRoleReplaceChanged(self, replace: str) -> None: ... - def yPosRoleReplaceChanged(self, replace: str) -> None: ... - def xPosRoleReplaceChanged(self, replace: str) -> None: ... - def rotationRoleReplaceChanged(self, replace: str) -> None: ... - def rotationRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def zPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def yPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def xPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + zPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + zPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] def rotationRoleReplace(self) -> str: ... def setRotationRoleReplace(self, replace: str) -> None: ... def zPosRoleReplace(self) -> str: ... @@ -1216,11 +1195,11 @@ class QItemModelScatterDataProxy('QScatterDataProxy'): def setYPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... def xPosRolePattern(self) -> QtCore.QRegExp: ... def setXPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def rotationRoleChanged(self, role: str) -> None: ... - def zPosRoleChanged(self, role: str) -> None: ... - def yPosRoleChanged(self, role: str) -> None: ... - def xPosRoleChanged(self, role: str) -> None: ... - def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + rotationRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + zPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + itemModelChanged: typing.ClassVar[QtCore.pyqtSignal] def remap(self, xPosRole: str, yPosRole: str, zPosRole: str, rotationRole: str) -> None: ... def rotationRole(self) -> str: ... def setRotationRole(self, role: str) -> None: ... @@ -1260,18 +1239,17 @@ class QItemModelSurfaceDataProxy('QSurfaceDataProxy'): def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, xPosRole: str, yPosRole: str, zPosRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def multiMatchBehaviorChanged(self, behavior: 'QItemModelSurfaceDataProxy.MultiMatchBehavior') -> None: ... - def zPosRoleReplaceChanged(self, replace: str) -> None: ... - def yPosRoleReplaceChanged(self, replace: str) -> None: ... - def xPosRoleReplaceChanged(self, replace: str) -> None: ... - def columnRoleReplaceChanged(self, replace: str) -> None: ... - def rowRoleReplaceChanged(self, replace: str) -> None: ... - def zPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def yPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def xPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def columnRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def rowRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + multiMatchBehaviorChanged: typing.ClassVar[QtCore.pyqtSignal] + zPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + zPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] def multiMatchBehavior(self) -> 'QItemModelSurfaceDataProxy.MultiMatchBehavior': ... def setMultiMatchBehavior(self, behavior: 'QItemModelSurfaceDataProxy.MultiMatchBehavior') -> None: ... def zPosRoleReplace(self) -> str: ... @@ -1294,17 +1272,17 @@ class QItemModelSurfaceDataProxy('QSurfaceDataProxy'): def setColumnRolePattern(self, pattern: QtCore.QRegExp) -> None: ... def rowRolePattern(self) -> QtCore.QRegExp: ... def setRowRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def autoColumnCategoriesChanged(self, enable: bool) -> None: ... - def autoRowCategoriesChanged(self, enable: bool) -> None: ... - def useModelCategoriesChanged(self, enable: bool) -> None: ... - def columnCategoriesChanged(self) -> None: ... - def rowCategoriesChanged(self) -> None: ... - def zPosRoleChanged(self, role: str) -> None: ... - def yPosRoleChanged(self, role: str) -> None: ... - def xPosRoleChanged(self, role: str) -> None: ... - def columnRoleChanged(self, role: str) -> None: ... - def rowRoleChanged(self, role: str) -> None: ... - def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + autoColumnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + autoRowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + useModelCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + columnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + rowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + zPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + itemModelChanged: typing.ClassVar[QtCore.pyqtSignal] def remap(self, rowRole: str, columnRole: str, xPosRole: str, yPosRole: str, zPosRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str]) -> None: ... def zPosRole(self) -> str: ... def setZPosRole(self, role: str) -> None: ... @@ -1363,9 +1341,9 @@ class QLogValue3DAxisFormatter('QValue3DAxisFormatter'): def positionAt(self, value: float) -> float: ... def recalculate(self) -> None: ... def createNewInstance(self) -> 'QValue3DAxisFormatter': ... - def showEdgeLabelsChanged(self, enabled: bool) -> None: ... - def autoSubGridChanged(self, enabled: bool) -> None: ... - def baseChanged(self, base: float) -> None: ... + showEdgeLabelsChanged: typing.ClassVar[QtCore.pyqtSignal] + autoSubGridChanged: typing.ClassVar[QtCore.pyqtSignal] + baseChanged: typing.ClassVar[QtCore.pyqtSignal] def showEdgeLabels(self) -> bool: ... def setShowEdgeLabels(self, enabled: bool) -> None: ... def autoSubGrid(self) -> bool: ... @@ -1379,10 +1357,9 @@ class QScatter3DSeries('QAbstract3DSeries'): def __init__(self, dataProxy: 'QScatterDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def itemSizeChanged(self, size: float) -> None: ... - def selectedItemChanged(self, index: int) -> None: ... - def dataProxyChanged(self, proxy: 'QScatterDataProxy') -> None: ... + itemSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + selectedItemChanged: typing.ClassVar[QtCore.pyqtSignal] + dataProxyChanged: typing.ClassVar[QtCore.pyqtSignal] def itemSize(self) -> float: ... def setItemSize(self, size: float) -> None: ... @staticmethod @@ -1444,18 +1421,17 @@ class QSurface3DSeries('QAbstract3DSeries'): def __init__(self, dataProxy: 'QSurfaceDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def textureFileChanged(self, filename: str) -> None: ... - def textureChanged(self, image: QtGui.QImage) -> None: ... + textureFileChanged: typing.ClassVar[QtCore.pyqtSignal] + textureChanged: typing.ClassVar[QtCore.pyqtSignal] def textureFile(self) -> str: ... def setTextureFile(self, filename: str) -> None: ... def texture(self) -> QtGui.QImage: ... def setTexture(self, texture: QtGui.QImage) -> None: ... - def drawModeChanged(self, mode: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... - def flatShadingSupportedChanged(self, enable: bool) -> None: ... - def flatShadingEnabledChanged(self, enable: bool) -> None: ... - def selectedPointChanged(self, position: QtCore.QPoint) -> None: ... - def dataProxyChanged(self, proxy: 'QSurfaceDataProxy') -> None: ... + drawModeChanged: typing.ClassVar[QtCore.pyqtSignal] + flatShadingSupportedChanged: typing.ClassVar[QtCore.pyqtSignal] + flatShadingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + selectedPointChanged: typing.ClassVar[QtCore.pyqtSignal] + dataProxyChanged: typing.ClassVar[QtCore.pyqtSignal] def isFlatShadingSupported(self) -> bool: ... def drawMode(self) -> 'QSurface3DSeries.DrawFlags': ... def setDrawMode(self, mode: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... @@ -1495,16 +1471,15 @@ class QTouch3DInputHandler('Q3DInputHandler'): class QValue3DAxis('QAbstract3DAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def reversedChanged(self, enable: bool) -> None: ... - def formatterChanged(self, formatter: 'QValue3DAxisFormatter') -> None: ... + reversedChanged: typing.ClassVar[QtCore.pyqtSignal] + formatterChanged: typing.ClassVar[QtCore.pyqtSignal] def reversed(self) -> bool: ... def setReversed(self, enable: bool) -> None: ... def formatter(self) -> 'QValue3DAxisFormatter': ... def setFormatter(self, formatter: 'QValue3DAxisFormatter') -> None: ... - def labelFormatChanged(self, format: str) -> None: ... - def subSegmentCountChanged(self, count: int) -> None: ... - def segmentCountChanged(self, count: int) -> None: ... + labelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + subSegmentCountChanged: typing.ClassVar[QtCore.pyqtSignal] + segmentCountChanged: typing.ClassVar[QtCore.pyqtSignal] def labelFormat(self) -> str: ... def setLabelFormat(self, format: str) -> None: ... def subSegmentCount(self) -> int: ... diff --git a/PyQt5-stubs/QtDesigner.pyi b/PyQt5-stubs/QtDesigner.pyi index 8bd1874d..e24e8cf4 100644 --- a/PyQt5-stubs/QtDesigner.pyi +++ b/PyQt5-stubs/QtDesigner.pyi @@ -112,19 +112,19 @@ class QDesignerFormWindowInterface(QtWidgets.QWidget): def formContainer(self) -> QtWidgets.QWidget: ... def activeResourceFilePaths(self) -> typing.List[str]: ... def checkContents(self) -> typing.List[str]: ... - def objectRemoved(self, o: QtCore.QObject) -> None: ... - def widgetRemoved(self, w: QtWidgets.QWidget) -> None: ... - def changed(self) -> None: ... - def activated(self, widget: QtWidgets.QWidget) -> None: ... - def aboutToUnmanageWidget(self, widget: QtWidgets.QWidget) -> None: ... - def widgetUnmanaged(self, widget: QtWidgets.QWidget) -> None: ... - def widgetManaged(self, widget: QtWidgets.QWidget) -> None: ... - def resourceFilesChanged(self) -> None: ... - def geometryChanged(self) -> None: ... - def selectionChanged(self) -> None: ... - def featureChanged(self, f: typing.Union['QDesignerFormWindowInterface.Feature', 'QDesignerFormWindowInterface.FeatureFlag']) -> None: ... - def fileNameChanged(self, fileName: str) -> None: ... - def mainContainerChanged(self, mainContainer: QtWidgets.QWidget) -> None: ... + objectRemoved: typing.ClassVar[QtCore.pyqtSignal] + widgetRemoved: typing.ClassVar[QtCore.pyqtSignal] + changed: typing.ClassVar[QtCore.pyqtSignal] + activated: typing.ClassVar[QtCore.pyqtSignal] + aboutToUnmanageWidget: typing.ClassVar[QtCore.pyqtSignal] + widgetUnmanaged: typing.ClassVar[QtCore.pyqtSignal] + widgetManaged: typing.ClassVar[QtCore.pyqtSignal] + resourceFilesChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryChanged: typing.ClassVar[QtCore.pyqtSignal] + selectionChanged: typing.ClassVar[QtCore.pyqtSignal] + featureChanged: typing.ClassVar[QtCore.pyqtSignal] + fileNameChanged: typing.ClassVar[QtCore.pyqtSignal] + mainContainerChanged: typing.ClassVar[QtCore.pyqtSignal] def setFileName(self, fileName: str) -> None: ... def setGrid(self, grid: QtCore.QPoint) -> None: ... def selectWidget(self, widget: QtWidgets.QWidget, select: bool = ...) -> None: ... @@ -286,10 +286,10 @@ class QDesignerFormWindowManagerInterface(QtCore.QObject): def setActiveFormWindow(self, formWindow: QDesignerFormWindowInterface) -> None: ... def removeFormWindow(self, formWindow: QDesignerFormWindowInterface) -> None: ... def addFormWindow(self, formWindow: QDesignerFormWindowInterface) -> None: ... - def formWindowSettingsChanged(self, fw: QDesignerFormWindowInterface) -> None: ... - def activeFormWindowChanged(self, formWindow: QDesignerFormWindowInterface) -> None: ... - def formWindowRemoved(self, formWindow: QDesignerFormWindowInterface) -> None: ... - def formWindowAdded(self, formWindow: QDesignerFormWindowInterface) -> None: ... + formWindowSettingsChanged: typing.ClassVar[QtCore.pyqtSignal] + activeFormWindowChanged: typing.ClassVar[QtCore.pyqtSignal] + formWindowRemoved: typing.ClassVar[QtCore.pyqtSignal] + formWindowAdded: typing.ClassVar[QtCore.pyqtSignal] def core(self) -> QDesignerFormEditorInterface: ... def createFormWindow(self, parent: typing.Optional[QtWidgets.QWidget] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> QDesignerFormWindowInterface: ... def formWindow(self, index: int) -> QDesignerFormWindowInterface: ... @@ -314,7 +314,7 @@ class QDesignerPropertyEditorInterface(QtWidgets.QWidget): def setReadOnly(self, readOnly: bool) -> None: ... def setPropertyValue(self, name: str, value: typing.Any, changed: bool = ...) -> None: ... def setObject(self, object: QtCore.QObject) -> None: ... - def propertyChanged(self, name: str, value: typing.Any) -> None: ... + propertyChanged: typing.ClassVar[QtCore.pyqtSignal] def currentPropertyName(self) -> str: ... def object(self) -> QtCore.QObject: ... def isReadOnly(self) -> bool: ... diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 2dddd700..bc251f19 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -80,10 +80,10 @@ class QAbstractTextDocumentLayout(QtCore.QObject): def positionInlineObject(self, item: 'QTextInlineObject', posInDocument: int, format: 'QTextFormat') -> None: ... def resizeInlineObject(self, item: 'QTextInlineObject', posInDocument: int, format: 'QTextFormat') -> None: ... def documentChanged(self, from_: int, charsRemoved: int, charsAdded: int) -> None: ... - def updateBlock(self, block: 'QTextBlock') -> None: ... - def pageCountChanged(self, newPages: int) -> None: ... - def documentSizeChanged(self, newSize: QtCore.QSizeF) -> None: ... - def update(self, rect: QtCore.QRectF = ...) -> None: ... + updateBlock: typing.ClassVar[QtCore.pyqtSignal] + pageCountChanged: typing.ClassVar[QtCore.pyqtSignal] + documentSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + update: typing.ClassVar[QtCore.pyqtSignal] def handlerForObject(self, objectType: int) -> 'QTextObjectInterface': ... def unregisterHandler(self, objectType: int, component: typing.Optional[QtCore.QObject] = ...) -> None: ... def registerHandler(self, objectType: int, component: QtCore.QObject) -> None: ... @@ -1291,8 +1291,8 @@ class QDrag(QtCore.QObject): def defaultAction(self) -> QtCore.Qt.DropAction: ... def supportedActions(self) -> QtCore.Qt.DropActions: ... def dragCursor(self, action: QtCore.Qt.DropAction) -> QPixmap: ... - def targetChanged(self, newTarget: QtCore.QObject) -> None: ... - def actionChanged(self, action: QtCore.Qt.DropAction) -> None: ... + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + actionChanged: typing.ClassVar[QtCore.pyqtSignal] def setDragCursor(self, cursor: QPixmap, action: QtCore.Qt.DropAction) -> None: ... def target(self) -> QtCore.QObject: ... def source(self) -> QtCore.QObject: ... @@ -2653,21 +2653,21 @@ class QGuiApplication(QtCore.QCoreApplication): def highDpiScaleFactorRoundingPolicy() -> QtCore.Qt.HighDpiScaleFactorRoundingPolicy: ... @staticmethod def setHighDpiScaleFactorRoundingPolicy(policy: QtCore.Qt.HighDpiScaleFactorRoundingPolicy) -> None: ... - def fontChanged(self, font: QFont) -> None: ... + fontChanged: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def screenAt(point: QtCore.QPoint) -> 'QScreen': ... @staticmethod def desktopFileName() -> str: ... @staticmethod def setDesktopFileName(name: str) -> None: ... - def primaryScreenChanged(self, screen: 'QScreen') -> None: ... + primaryScreenChanged: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def setFallbackSessionManagementEnabled(a0: bool) -> None: ... @staticmethod def isFallbackSessionManagementEnabled() -> bool: ... - def paletteChanged(self, pal: 'QPalette') -> None: ... - def layoutDirectionChanged(self, direction: QtCore.Qt.LayoutDirection) -> None: ... - def screenRemoved(self, screen: 'QScreen') -> None: ... + paletteChanged: typing.ClassVar[QtCore.pyqtSignal] + layoutDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] + screenRemoved: typing.ClassVar[QtCore.pyqtSignal] def event(self, a0: QtCore.QEvent) -> bool: ... @staticmethod def windowIcon() -> 'QIcon': ... @@ -2692,15 +2692,15 @@ class QGuiApplication(QtCore.QCoreApplication): def applicationDisplayName() -> str: ... @staticmethod def setApplicationDisplayName(name: str) -> None: ... - def applicationDisplayNameChanged(self) -> None: ... - def applicationStateChanged(self, state: QtCore.Qt.ApplicationState) -> None: ... - def focusWindowChanged(self, focusWindow: 'QWindow') -> None: ... - def saveStateRequest(self, sessionManager: 'QSessionManager') -> None: ... - def commitDataRequest(self, sessionManager: 'QSessionManager') -> None: ... - def focusObjectChanged(self, focusObject: QtCore.QObject) -> None: ... + applicationDisplayNameChanged: typing.ClassVar[QtCore.pyqtSignal] + applicationStateChanged: typing.ClassVar[QtCore.pyqtSignal] + focusWindowChanged: typing.ClassVar[QtCore.pyqtSignal] + saveStateRequest: typing.ClassVar[QtCore.pyqtSignal] + commitDataRequest: typing.ClassVar[QtCore.pyqtSignal] + focusObjectChanged: typing.ClassVar[QtCore.pyqtSignal] lastWindowClosed: typing.ClassVar[QtCore.pyqtSignal] - def screenAdded(self, screen: 'QScreen') -> None: ... - def fontDatabaseChanged(self) -> None: ... + screenAdded: typing.ClassVar[QtCore.pyqtSignal] + fontDatabaseChanged: typing.ClassVar[QtCore.pyqtSignal] def notify(self, a0: QtCore.QObject, a1: QtCore.QEvent) -> bool: ... @staticmethod def exec() -> int: ... @@ -3375,17 +3375,16 @@ class QInputMethod(QtCore.QObject): Click = ... # type: QInputMethod.Action ContextMenu = ... # type: QInputMethod.Action - - def inputItemClipRectangleChanged(self) -> None: ... - def anchorRectangleChanged(self) -> None: ... + inputItemClipRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] + anchorRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] def inputItemClipRectangle(self) -> QtCore.QRectF: ... def anchorRectangle(self) -> QtCore.QRectF: ... - def inputDirectionChanged(self, newDirection: QtCore.Qt.LayoutDirection) -> None: ... - def localeChanged(self) -> None: ... - def animatingChanged(self) -> None: ... - def visibleChanged(self) -> None: ... - def keyboardRectangleChanged(self) -> None: ... - def cursorRectangleChanged(self) -> None: ... + inputDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] + localeChanged: typing.ClassVar[QtCore.pyqtSignal] + animatingChanged: typing.ClassVar[QtCore.pyqtSignal] + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] + keyboardRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] + cursorRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] def invokeAction(self, a: 'QInputMethod.Action', cursorPosition: int) -> None: ... def commit(self) -> None: ... def reset(self) -> None: ... @@ -3717,13 +3716,13 @@ class QMovie(QtCore.QObject): def setPaused(self, paused: bool) -> None: ... def jumpToNextFrame(self) -> bool: ... def start(self) -> None: ... - def frameChanged(self, frameNumber: int) -> None: ... - def finished(self) -> None: ... - def error(self, error: QImageReader.ImageReaderError) -> None: ... - def stateChanged(self, state: 'QMovie.MovieState') -> None: ... - def updated(self, rect: QtCore.QRect) -> None: ... - def resized(self, size: QtCore.QSize) -> None: ... - def started(self) -> None: ... + frameChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + updated: typing.ClassVar[QtCore.pyqtSignal] + resized: typing.ClassVar[QtCore.pyqtSignal] + started: typing.ClassVar[QtCore.pyqtSignal] def setCacheMode(self, mode: 'QMovie.CacheMode') -> None: ... def cacheMode(self) -> 'QMovie.CacheMode': ... def setScaledSize(self, size: QtCore.QSize) -> None: ... @@ -3797,7 +3796,7 @@ class QOffscreenSurface(QtCore.QObject, QSurface): def setNativeHandle(self, handle: sip.voidptr) -> None: ... def nativeHandle(self) -> sip.voidptr: ... - def screenChanged(self, screen: 'QScreen') -> None: ... + screenChanged: typing.ClassVar[QtCore.pyqtSignal] def setScreen(self, screen: 'QScreen') -> None: ... def screen(self) -> 'QScreen': ... def size(self) -> QtCore.QSize: ... @@ -3946,7 +3945,7 @@ class QOpenGLContext(QtCore.QObject): @staticmethod def openGLModuleHandle() -> sip.voidptr: ... def versionFunctions(self, versionProfile: typing.Optional['QOpenGLVersionProfile'] = ...) -> typing.Any: ... - def aboutToBeDestroyed(self) -> None: ... + aboutToBeDestroyed: typing.ClassVar[QtCore.pyqtSignal] def hasExtension(self, extension: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> bool: ... def extensions(self) -> typing.Set[QtCore.QByteArray]: ... @staticmethod @@ -4121,8 +4120,7 @@ class QOpenGLDebugLogger(QtCore.QObject): SynchronousLogging = ... # type: QOpenGLDebugLogger.LoggingMode def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def messageLogged(self, debugMessage: QOpenGLDebugMessage) -> None: ... + messageLogged: typing.ClassVar[QtCore.pyqtSignal] def stopLogging(self) -> None: ... def startLogging(self, loggingMode: 'QOpenGLDebugLogger.LoggingMode' = ...) -> None: ... def logMessage(self, debugMessage: QOpenGLDebugMessage) -> None: ... @@ -5548,7 +5546,7 @@ class QOpenGLWindow(QPaintDeviceWindow): def paintGL(self) -> None: ... def resizeGL(self, w: int, h: int) -> None: ... def initializeGL(self) -> None: ... - def frameSwapped(self) -> None: ... + frameSwapped: typing.ClassVar[QtCore.pyqtSignal] def shareContext(self) -> QOpenGLContext: ... def grabFramebuffer(self) -> QImage: ... def defaultFramebufferObject(self) -> int: ... @@ -8088,15 +8086,15 @@ class QScreen(QtCore.QObject): def serialNumber(self) -> str: ... def model(self) -> str: ... def manufacturer(self) -> str: ... - def availableGeometryChanged(self, geometry: QtCore.QRect) -> None: ... - def virtualGeometryChanged(self, rect: QtCore.QRect) -> None: ... - def physicalSizeChanged(self, size: QtCore.QSizeF) -> None: ... - def refreshRateChanged(self, refreshRate: float) -> None: ... - def orientationChanged(self, orientation: QtCore.Qt.ScreenOrientation) -> None: ... - def primaryOrientationChanged(self, orientation: QtCore.Qt.ScreenOrientation) -> None: ... - def logicalDotsPerInchChanged(self, dpi: float) -> None: ... - def physicalDotsPerInchChanged(self, dpi: float) -> None: ... - def geometryChanged(self, geometry: QtCore.QRect) -> None: ... + availableGeometryChanged: typing.ClassVar[QtCore.pyqtSignal] + virtualGeometryChanged: typing.ClassVar[QtCore.pyqtSignal] + physicalSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + refreshRateChanged: typing.ClassVar[QtCore.pyqtSignal] + orientationChanged: typing.ClassVar[QtCore.pyqtSignal] + primaryOrientationChanged: typing.ClassVar[QtCore.pyqtSignal] + logicalDotsPerInchChanged: typing.ClassVar[QtCore.pyqtSignal] + physicalDotsPerInchChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryChanged: typing.ClassVar[QtCore.pyqtSignal] def devicePixelRatio(self) -> float: ... def refreshRate(self) -> float: ... def grabWindow(self, window: sip.voidptr, x: int = ..., y: int = ..., width: int = ..., height: int = ...) -> QPixmap: ... @@ -8171,7 +8169,7 @@ class QStandardItemModel(QtCore.QAbstractItemModel): def __init__(self, rows: int, columns: int, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def clearItemData(self, index: QtCore.QModelIndex) -> bool: ... - def itemChanged(self, item: 'QStandardItem') -> None: ... + itemChanged: typing.ClassVar[QtCore.pyqtSignal] def setItemRoleNames(self, roleNames: typing.Dict[int, typing.Union[QtCore.QByteArray, bytes, bytearray]]) -> None: ... def sibling(self, row: int, column: int, idx: QtCore.QModelIndex) -> QtCore.QModelIndex: ... def dropMimeData(self, data: QtCore.QMimeData, action: QtCore.Qt.DropAction, row: int, column: int, parent: QtCore.QModelIndex) -> bool: ... @@ -8392,24 +8390,24 @@ class QStyleHints(QtCore.QObject): def touchDoubleTapDistance(self) -> int: ... def mouseDoubleClickDistance(self) -> int: ... - def showShortcutsInContextMenusChanged(self, a0: bool) -> None: ... + showShortcutsInContextMenusChanged: typing.ClassVar[QtCore.pyqtSignal] def setShowShortcutsInContextMenus(self, showShortcutsInContextMenus: bool) -> None: ... - def mouseQuickSelectionThresholdChanged(self, threshold: int) -> None: ... + mouseQuickSelectionThresholdChanged: typing.ClassVar[QtCore.pyqtSignal] def mouseQuickSelectionThreshold(self) -> int: ... def showShortcutsInContextMenus(self) -> bool: ... - def wheelScrollLinesChanged(self, scrollLines: int) -> None: ... + wheelScrollLinesChanged: typing.ClassVar[QtCore.pyqtSignal] def wheelScrollLines(self) -> int: ... - def useHoverEffectsChanged(self, useHoverEffects: bool) -> None: ... + useHoverEffectsChanged: typing.ClassVar[QtCore.pyqtSignal] def setUseHoverEffects(self, useHoverEffects: bool) -> None: ... def useHoverEffects(self) -> bool: ... def showIsMaximized(self) -> bool: ... - def tabFocusBehaviorChanged(self, tabFocusBehavior: QtCore.Qt.TabFocusBehavior) -> None: ... - def mousePressAndHoldIntervalChanged(self, mousePressAndHoldInterval: int) -> None: ... - def startDragTimeChanged(self, startDragTime: int) -> None: ... - def startDragDistanceChanged(self, startDragDistance: int) -> None: ... - def mouseDoubleClickIntervalChanged(self, mouseDoubleClickInterval: int) -> None: ... - def keyboardInputIntervalChanged(self, keyboardInputInterval: int) -> None: ... - def cursorFlashTimeChanged(self, cursorFlashTime: int) -> None: ... + tabFocusBehaviorChanged: typing.ClassVar[QtCore.pyqtSignal] + mousePressAndHoldIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + startDragTimeChanged: typing.ClassVar[QtCore.pyqtSignal] + startDragDistanceChanged: typing.ClassVar[QtCore.pyqtSignal] + mouseDoubleClickIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + keyboardInputIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + cursorFlashTimeChanged: typing.ClassVar[QtCore.pyqtSignal] def singleClickActivation(self) -> bool: ... def tabFocusBehavior(self) -> QtCore.Qt.TabFocusBehavior: ... def mousePressAndHoldInterval(self) -> int: ... @@ -8834,7 +8832,7 @@ class QTextDocument(QtCore.QObject): def setMarkdown(self, markdown: str, features: typing.Union['QTextDocument.MarkdownFeatures', 'QTextDocument.MarkdownFeature'] = ...) -> None: ... def toMarkdown(self, features: typing.Union['QTextDocument.MarkdownFeatures', 'QTextDocument.MarkdownFeature'] = ...) -> str: ... def toRawText(self) -> str: ... - def baseUrlChanged(self, url: QtCore.QUrl) -> None: ... + baseUrlChanged: typing.ClassVar[QtCore.pyqtSignal] def setBaseUrl(self, url: QtCore.QUrl) -> None: ... def baseUrl(self) -> QtCore.QUrl: ... def setDefaultCursorMoveStyle(self, style: QtCore.Qt.CursorMoveStyle) -> None: ... @@ -8847,8 +8845,8 @@ class QTextDocument(QtCore.QObject): def setDocumentMargin(self, margin: float) -> None: ... def documentMargin(self) -> float: ... def characterAt(self, pos: int) -> str: ... - def documentLayoutChanged(self) -> None: ... - def undoCommandAdded(self) -> None: ... + documentLayoutChanged: typing.ClassVar[QtCore.pyqtSignal] + undoCommandAdded: typing.ClassVar[QtCore.pyqtSignal] def setIndentWidth(self, width: float) -> None: ... def indentWidth(self) -> float: ... def lastBlock(self) -> 'QTextBlock': ... @@ -8880,13 +8878,13 @@ class QTextDocument(QtCore.QObject): def undo(self) -> None: ... @typing.overload def undo(self, cursor: QTextCursor) -> None: ... - def undoAvailable(self, a0: bool) -> None: ... - def redoAvailable(self, a0: bool) -> None: ... - def modificationChanged(self, m: bool) -> None: ... - def cursorPositionChanged(self, cursor: QTextCursor) -> None: ... - def contentsChanged(self) -> None: ... - def contentsChange(self, from_: int, charsRemoves: int, charsAdded: int) -> None: ... - def blockCountChanged(self, newBlockCount: int) -> None: ... + undoAvailable: typing.ClassVar[QtCore.pyqtSignal] + redoAvailable: typing.ClassVar[QtCore.pyqtSignal] + modificationChanged: typing.ClassVar[QtCore.pyqtSignal] + cursorPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + contentsChanged: typing.ClassVar[QtCore.pyqtSignal] + contentsChange: typing.ClassVar[QtCore.pyqtSignal] + blockCountChanged: typing.ClassVar[QtCore.pyqtSignal] def useDesignMetrics(self) -> bool: ... def setUseDesignMetrics(self, b: bool) -> None: ... def markContentsDirty(self, from_: int, length: int) -> None: ... @@ -10313,8 +10311,7 @@ class QValidator(QtCore.QObject): Acceptable = ... # type: QValidator.State def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def changed(self) -> None: ... + changed: typing.ClassVar[QtCore.pyqtSignal] def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def fixup(self, a0: str) -> str: ... diff --git a/PyQt5-stubs/QtHelp.pyi b/PyQt5-stubs/QtHelp.pyi index 0b87c478..4b2dca21 100644 --- a/PyQt5-stubs/QtHelp.pyi +++ b/PyQt5-stubs/QtHelp.pyi @@ -68,9 +68,8 @@ class QHelpContentItem(sip.simplewrapper): class QHelpContentModel(QtCore.QAbstractItemModel): - - def contentsCreated(self) -> None: ... - def contentsCreationStarted(self) -> None: ... + contentsCreated: typing.ClassVar[QtCore.pyqtSignal] + contentsCreationStarted: typing.ClassVar[QtCore.pyqtSignal] def isCreatingContents(self) -> bool: ... def columnCount(self, parent: QtCore.QModelIndex = ...) -> int: ... def rowCount(self, parent: QtCore.QModelIndex = ...) -> int: ... @@ -82,8 +81,7 @@ class QHelpContentModel(QtCore.QAbstractItemModel): class QHelpContentWidget(QtWidgets.QTreeView): - - def linkActivated(self, link: QtCore.QUrl) -> None: ... + linkActivated: typing.ClassVar[QtCore.pyqtSignal] def indexOf(self, link: QtCore.QUrl) -> QtCore.QModelIndex: ... @@ -102,11 +100,11 @@ class QHelpEngineCore(QtCore.QObject): def usesFilterEngine(self) -> bool: ... def setUsesFilterEngine(self, uses: bool) -> None: ... def filterEngine(self) -> 'QHelpFilterEngine': ... - def readersAboutToBeInvalidated(self) -> None: ... - def warning(self, msg: str) -> None: ... - def currentFilterChanged(self, newFilter: str) -> None: ... - def setupFinished(self) -> None: ... - def setupStarted(self) -> None: ... + readersAboutToBeInvalidated: typing.ClassVar[QtCore.pyqtSignal] + warning: typing.ClassVar[QtCore.pyqtSignal] + currentFilterChanged: typing.ClassVar[QtCore.pyqtSignal] + setupFinished: typing.ClassVar[QtCore.pyqtSignal] + setupStarted: typing.ClassVar[QtCore.pyqtSignal] def setAutoSaveFilter(self, save: bool) -> None: ... def autoSaveFilter(self) -> bool: ... def error(self) -> str: ... @@ -177,7 +175,7 @@ class QHelpFilterEngine(QtCore.QObject): @typing.overload def indices(self, filterName: str) -> typing.List[str]: ... def availableVersions(self) -> typing.List[QtCore.QVersionNumber]: ... - def filterActivated(self, newFilter: str) -> None: ... + filterActivated: typing.ClassVar[QtCore.pyqtSignal] def namespacesForFilter(self, filterName: str) -> typing.List[str]: ... def removeFilter(self, filterName: str) -> bool: ... def setFilterData(self, filterName: str, filterData: QHelpFilterData) -> bool: ... @@ -201,9 +199,8 @@ class QHelpFilterSettingsWidget(QtWidgets.QWidget): class QHelpIndexModel(QtCore.QStringListModel): - - def indexCreated(self) -> None: ... - def indexCreationStarted(self) -> None: ... + indexCreated: typing.ClassVar[QtCore.pyqtSignal] + indexCreationStarted: typing.ClassVar[QtCore.pyqtSignal] def isCreatingIndex(self) -> bool: ... def linksForKeyword(self, keyword: str) -> typing.Dict[str, QtCore.QUrl]: ... def filter(self, filter: str, wildcard: str = ...) -> QtCore.QModelIndex: ... @@ -212,13 +209,12 @@ class QHelpIndexModel(QtCore.QStringListModel): class QHelpIndexWidget(QtWidgets.QListView): - - def documentsActivated(self, documents: typing.Iterable['QHelpLink'], keyword: str) -> None: ... - def documentActivated(self, document: 'QHelpLink', keyword: str) -> None: ... + documentsActivated: typing.ClassVar[QtCore.pyqtSignal] + documentActivated: typing.ClassVar[QtCore.pyqtSignal] def activateCurrentItem(self) -> None: ... def filterIndices(self, filter: str, wildcard: str = ...) -> None: ... - def linksActivated(self, links: typing.Dict[str, QtCore.QUrl], keyword: str) -> None: ... - def linkActivated(self, link: QtCore.QUrl, keyword: str) -> None: ... + linksActivated: typing.ClassVar[QtCore.pyqtSignal] + linkActivated: typing.ClassVar[QtCore.pyqtSignal] class QHelpLink(sip.simplewrapper): @@ -264,10 +260,10 @@ class QHelpSearchEngine(QtCore.QObject): def searchInput(self) -> str: ... def searchResults(self, start: int, end: int) -> typing.List['QHelpSearchResult']: ... def searchResultCount(self) -> int: ... - def searchingFinished(self, hits: int) -> None: ... - def searchingStarted(self) -> None: ... - def indexingFinished(self) -> None: ... - def indexingStarted(self) -> None: ... + searchingFinished: typing.ClassVar[QtCore.pyqtSignal] + searchingStarted: typing.ClassVar[QtCore.pyqtSignal] + indexingFinished: typing.ClassVar[QtCore.pyqtSignal] + indexingStarted: typing.ClassVar[QtCore.pyqtSignal] def cancelSearching(self) -> None: ... @typing.overload def search(self, queryList: typing.Iterable[QHelpSearchQuery]) -> None: ... @@ -304,7 +300,7 @@ class QHelpSearchQueryWidget(QtWidgets.QWidget): def searchInput(self) -> str: ... def setCompactMode(self, on: bool) -> None: ... def isCompactMode(self) -> bool: ... - def search(self) -> None: ... + search: typing.ClassVar[QtCore.pyqtSignal] def collapseExtendedSearch(self) -> None: ... def expandExtendedSearch(self) -> None: ... def setQuery(self, queryList: typing.Iterable[QHelpSearchQuery]) -> None: ... @@ -312,6 +308,5 @@ class QHelpSearchQueryWidget(QtWidgets.QWidget): class QHelpSearchResultWidget(QtWidgets.QWidget): - - def requestShowLink(self, url: QtCore.QUrl) -> None: ... + requestShowLink: typing.ClassVar[QtCore.pyqtSignal] def linkAt(self, point: QtCore.QPoint) -> QtCore.QUrl: ... diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index 3926f660..492c2180 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -64,25 +64,21 @@ class QGeoCodeReply(QtCore.QObject): def setViewport(self, viewport: QtPositioning.QGeoShape) -> None: ... def setFinished(self, finished: bool) -> None: ... def setError(self, error: 'QGeoCodeReply.Error', errorString: str) -> None: ... - def finished(self) -> None: ... - def aborted(self) -> None: ... + finished: typing.ClassVar[QtCore.pyqtSignal] + aborted: typing.ClassVar[QtCore.pyqtSignal] def abort(self) -> None: ... def offset(self) -> int: ... def limit(self) -> int: ... def locations(self) -> typing.List[QtPositioning.QGeoLocation]: ... def viewport(self) -> QtPositioning.QGeoShape: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QGeoCodeReply.Error': ... - @typing.overload - def error(self, error: 'QGeoCodeReply.Error', errorString: str = ...) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isFinished(self) -> bool: ... class QGeoCodingManager(QtCore.QObject): - - def error(self, reply: QGeoCodeReply, error: QGeoCodeReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QGeoCodeReply) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def reverseGeocode(self, coordinate: QtPositioning.QGeoCoordinate, bounds: QtPositioning.QGeoShape = ...) -> QGeoCodeReply: ... @@ -97,9 +93,8 @@ class QGeoCodingManager(QtCore.QObject): class QGeoCodingManagerEngine(QtCore.QObject): def __init__(self, parameters: typing.Dict[str, typing.Any], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def error(self, reply: QGeoCodeReply, error: QGeoCodeReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QGeoCodeReply) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def reverseGeocode(self, coordinate: QtPositioning.QGeoCoordinate, bounds: QtPositioning.QGeoShape) -> QGeoCodeReply: ... @@ -230,16 +225,13 @@ class QGeoRouteReply(QtCore.QObject): def setRoutes(self, routes: typing.Iterable[QGeoRoute]) -> None: ... def setFinished(self, finished: bool) -> None: ... def setError(self, error: 'QGeoRouteReply.Error', errorString: str) -> None: ... - def finished(self) -> None: ... - def aborted(self) -> None: ... + finished: typing.ClassVar[QtCore.pyqtSignal] + aborted: typing.ClassVar[QtCore.pyqtSignal] def abort(self) -> None: ... def routes(self) -> typing.List[QGeoRoute]: ... def request(self) -> 'QGeoRouteRequest': ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QGeoRouteReply.Error': ... - @typing.overload - def error(self, error: 'QGeoRouteReply.Error', errorString: str = ...) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isFinished(self) -> bool: ... @@ -463,9 +455,8 @@ class QGeoRouteSegment(sip.simplewrapper): class QGeoRoutingManager(QtCore.QObject): - - def error(self, reply: QGeoRouteReply, error: QGeoRouteReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QGeoRouteReply) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def measurementSystem(self) -> QtCore.QLocale.MeasurementSystem: ... def setMeasurementSystem(self, system: QtCore.QLocale.MeasurementSystem) -> None: ... def locale(self) -> QtCore.QLocale: ... @@ -492,8 +483,8 @@ class QGeoRoutingManagerEngine(QtCore.QObject): def setSupportedFeatureWeights(self, featureWeights: typing.Union[QGeoRouteRequest.FeatureWeights, QGeoRouteRequest.FeatureWeight]) -> None: ... def setSupportedFeatureTypes(self, featureTypes: typing.Union[QGeoRouteRequest.FeatureTypes, QGeoRouteRequest.FeatureType]) -> None: ... def setSupportedTravelModes(self, travelModes: typing.Union[QGeoRouteRequest.TravelModes, QGeoRouteRequest.TravelMode]) -> None: ... - def error(self, reply: QGeoRouteReply, error: QGeoRouteReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QGeoRouteReply) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def measurementSystem(self) -> QtCore.QLocale.MeasurementSystem: ... def setMeasurementSystem(self, system: QtCore.QLocale.MeasurementSystem) -> None: ... def locale(self) -> QtCore.QLocale: ... @@ -930,14 +921,11 @@ class QPlaceReply(QtCore.QObject): def setError(self, error: 'QPlaceReply.Error', errorString: str) -> None: ... def setFinished(self, finished: bool) -> None: ... - def contentUpdated(self) -> None: ... - def finished(self) -> None: ... - def aborted(self) -> None: ... + contentUpdated: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + aborted: typing.ClassVar[QtCore.pyqtSignal] def abort(self) -> None: ... - @typing.overload - def error(self) -> 'QPlaceReply.Error': ... - @typing.overload - def error(self, error: 'QPlaceReply.Error', errorString: str = ...) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def errorString(self) -> str: ... def type(self) -> 'QPlaceReply.Type': ... def isFinished(self) -> bool: ... @@ -1060,16 +1048,15 @@ class QPlaceImage(QPlaceContent): class QPlaceManager(QtCore.QObject): - - def dataChanged(self) -> None: ... - def categoryRemoved(self, categoryId: str, parentId: str) -> None: ... - def categoryUpdated(self, category: QPlaceCategory, parentId: str) -> None: ... - def categoryAdded(self, category: QPlaceCategory, parentId: str) -> None: ... - def placeRemoved(self, placeId: str) -> None: ... - def placeUpdated(self, placeId: str) -> None: ... - def placeAdded(self, placeId: str) -> None: ... - def error(self, a0: QPlaceReply, error: QPlaceReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QPlaceReply) -> None: ... + dataChanged: typing.ClassVar[QtCore.pyqtSignal] + categoryRemoved: typing.ClassVar[QtCore.pyqtSignal] + categoryUpdated: typing.ClassVar[QtCore.pyqtSignal] + categoryAdded: typing.ClassVar[QtCore.pyqtSignal] + placeRemoved: typing.ClassVar[QtCore.pyqtSignal] + placeUpdated: typing.ClassVar[QtCore.pyqtSignal] + placeAdded: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def matchingPlaces(self, request: 'QPlaceMatchRequest') -> 'QPlaceMatchReply': ... def compatiblePlace(self, place: QPlace) -> QPlace: ... def setLocales(self, locale: typing.Iterable[QtCore.QLocale]) -> None: ... @@ -1097,15 +1084,15 @@ class QPlaceManagerEngine(QtCore.QObject): def __init__(self, parameters: typing.Dict[str, typing.Any], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def manager(self) -> QPlaceManager: ... - def dataChanged(self) -> None: ... - def categoryRemoved(self, categoryId: str, parentCategoryId: str) -> None: ... - def categoryUpdated(self, category: QPlaceCategory, parentCategoryId: str) -> None: ... - def categoryAdded(self, category: QPlaceCategory, parentCategoryId: str) -> None: ... - def placeRemoved(self, placeId: str) -> None: ... - def placeUpdated(self, placeId: str) -> None: ... - def placeAdded(self, placeId: str) -> None: ... - def error(self, a0: QPlaceReply, error: QPlaceReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QPlaceReply) -> None: ... + dataChanged: typing.ClassVar[QtCore.pyqtSignal] + categoryRemoved: typing.ClassVar[QtCore.pyqtSignal] + categoryUpdated: typing.ClassVar[QtCore.pyqtSignal] + categoryAdded: typing.ClassVar[QtCore.pyqtSignal] + placeRemoved: typing.ClassVar[QtCore.pyqtSignal] + placeUpdated: typing.ClassVar[QtCore.pyqtSignal] + placeAdded: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def matchingPlaces(self, request: 'QPlaceMatchRequest') -> 'QPlaceMatchReply': ... def compatiblePlace(self, original: QPlace) -> QPlace: ... def constructIconUrl(self, icon: QPlaceIcon, size: QtCore.QSize) -> QtCore.QUrl: ... diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index e574b8cd..d57f1f63 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -114,8 +114,7 @@ class QVideoFilterRunnable(sip.simplewrapper): class QAbstractVideoFilter(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def activeChanged(self) -> None: ... + activeChanged: typing.ClassVar[QtCore.pyqtSignal] def createFilterRunnable(self) -> QVideoFilterRunnable: ... def isActive(self) -> bool: ... @@ -136,14 +135,13 @@ class QAbstractVideoSurface(QtCore.QObject): ResourceError = ... # type: QAbstractVideoSurface.Error def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def nativeResolutionChanged(self, a0: QtCore.QSize) -> None: ... + nativeResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] def setNativeResolution(self, resolution: QtCore.QSize) -> None: ... def nativeResolution(self) -> QtCore.QSize: ... def setError(self, error: 'QAbstractVideoSurface.Error') -> None: ... - def supportedFormatsChanged(self) -> None: ... - def surfaceFormatChanged(self, format: 'QVideoSurfaceFormat') -> None: ... - def activeChanged(self, active: bool) -> None: ... + supportedFormatsChanged: typing.ClassVar[QtCore.pyqtSignal] + surfaceFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + activeChanged: typing.ClassVar[QtCore.pyqtSignal] def error(self) -> 'QAbstractVideoSurface.Error': ... def present(self, frame: 'QVideoFrame') -> bool: ... def isActive(self) -> bool: ... @@ -257,16 +255,10 @@ class QMediaObject(QtCore.QObject): def removePropertyWatch(self, name: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def addPropertyWatch(self, name: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - @typing.overload - def availabilityChanged(self, availability: 'QMultimedia.AvailabilityStatus') -> None: ... - @typing.overload - def availabilityChanged(self, available: bool) -> None: ... - @typing.overload - def metaDataChanged(self) -> None: ... - @typing.overload - def metaDataChanged(self, key: str, value: typing.Any) -> None: ... - def metaDataAvailableChanged(self, available: bool) -> None: ... - def notifyIntervalChanged(self, milliSeconds: int) -> None: ... + availabilityChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + notifyIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] def availableMetaData(self) -> typing.List[str]: ... def metaData(self, key: str) -> typing.Any: ... def isMetaDataAvailable(self) -> bool: ... @@ -305,14 +297,14 @@ class QAudioDecoder(QMediaObject): def unbind(self, a0: QtCore.QObject) -> None: ... def bind(self, a0: QtCore.QObject) -> bool: ... - def durationChanged(self, duration: int) -> None: ... - def positionChanged(self, position: int) -> None: ... - def sourceChanged(self) -> None: ... - def formatChanged(self, format: 'QAudioFormat') -> None: ... - def stateChanged(self, newState: 'QAudioDecoder.State') -> None: ... - def finished(self) -> None: ... - def bufferReady(self) -> None: ... - def bufferAvailableChanged(self, a0: bool) -> None: ... + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + formatChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + bufferReady: typing.ClassVar[QtCore.pyqtSignal] + bufferAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def start(self) -> None: ... def duration(self) -> int: ... @@ -320,10 +312,7 @@ class QAudioDecoder(QMediaObject): def bufferAvailable(self) -> bool: ... def read(self) -> QAudioBuffer: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QAudioDecoder.Error': ... - @typing.overload - def error(self, error: 'QAudioDecoder.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def setAudioFormat(self, format: 'QAudioFormat') -> None: ... def audioFormat(self) -> 'QAudioFormat': ... def setSourceDevice(self, device: QtCore.QIODevice) -> None: ... @@ -343,16 +332,15 @@ class QMediaControl(QtCore.QObject): class QAudioDecoderControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def durationChanged(self, duration: int) -> None: ... - def positionChanged(self, position: int) -> None: ... - def finished(self) -> None: ... - def bufferAvailableChanged(self, available: bool) -> None: ... - def bufferReady(self) -> None: ... - def error(self, error: int, errorString: str) -> None: ... - def sourceChanged(self) -> None: ... - def formatChanged(self, format: 'QAudioFormat') -> None: ... - def stateChanged(self, newState: QAudioDecoder.State) -> None: ... + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + bufferAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + bufferReady: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + formatChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def duration(self) -> int: ... def position(self) -> int: ... def bufferAvailable(self) -> bool: ... @@ -462,8 +450,8 @@ class QAudioInput(QtCore.QObject): def volume(self) -> float: ... def setVolume(self, volume: float) -> None: ... - def notify(self) -> None: ... - def stateChanged(self, a0: QAudio.State) -> None: ... + notify: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def state(self) -> QAudio.State: ... def error(self) -> QAudio.Error: ... def elapsedUSecs(self) -> int: ... @@ -488,9 +476,8 @@ class QAudioInput(QtCore.QObject): class QAudioInputSelectorControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def availableInputsChanged(self) -> None: ... - def activeInputChanged(self, name: str) -> None: ... + availableInputsChanged: typing.ClassVar[QtCore.pyqtSignal] + activeInputChanged: typing.ClassVar[QtCore.pyqtSignal] def setActiveInput(self, name: str) -> None: ... def activeInput(self) -> str: ... def defaultInput(self) -> str: ... @@ -509,8 +496,8 @@ class QAudioOutput(QtCore.QObject): def category(self) -> str: ... def volume(self) -> float: ... def setVolume(self, a0: float) -> None: ... - def notify(self) -> None: ... - def stateChanged(self, a0: QAudio.State) -> None: ... + notify: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def state(self) -> QAudio.State: ... def error(self) -> QAudio.Error: ... def elapsedUSecs(self) -> int: ... @@ -535,9 +522,8 @@ class QAudioOutput(QtCore.QObject): class QAudioOutputSelectorControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def availableOutputsChanged(self) -> None: ... - def activeOutputChanged(self, name: str) -> None: ... + availableOutputsChanged: typing.ClassVar[QtCore.pyqtSignal] + activeOutputChanged: typing.ClassVar[QtCore.pyqtSignal] def setActiveOutput(self, name: str) -> None: ... def activeOutput(self) -> str: ... def defaultOutput(self) -> str: ... @@ -548,9 +534,8 @@ class QAudioOutputSelectorControl(QMediaControl): class QAudioProbe(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def flush(self) -> None: ... - def audioBufferProbed(self, audioBuffer: QAudioBuffer) -> None: ... + flush: typing.ClassVar[QtCore.pyqtSignal] + audioBufferProbed: typing.ClassVar[QtCore.pyqtSignal] def isActive(self) -> bool: ... @typing.overload def setSource(self, source: QMediaObject) -> bool: ... @@ -613,22 +598,16 @@ class QMediaRecorder(QtCore.QObject, QMediaBindableInterface): def __init__(self, mediaObject: QMediaObject, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, object: QMediaObject) -> bool: ... - @typing.overload - def availabilityChanged(self, availability: 'QMultimedia.AvailabilityStatus') -> None: ... - @typing.overload - def availabilityChanged(self, available: bool) -> None: ... - @typing.overload - def metaDataChanged(self, key: str, value: typing.Any) -> None: ... - @typing.overload - def metaDataChanged(self) -> None: ... - def metaDataWritableChanged(self, writable: bool) -> None: ... - def metaDataAvailableChanged(self, available: bool) -> None: ... - def actualLocationChanged(self, location: QtCore.QUrl) -> None: ... - def volumeChanged(self, volume: float) -> None: ... - def mutedChanged(self, muted: bool) -> None: ... - def durationChanged(self, duration: int) -> None: ... - def statusChanged(self, status: 'QMediaRecorder.Status') -> None: ... - def stateChanged(self, state: 'QMediaRecorder.State') -> None: ... + availabilityChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataWritableChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + actualLocationChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def setVolume(self, volume: float) -> None: ... def setMuted(self, muted: bool) -> None: ... def stop(self) -> None: ... @@ -659,10 +638,7 @@ class QMediaRecorder(QtCore.QObject, QMediaBindableInterface): def isMuted(self) -> bool: ... def duration(self) -> int: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QMediaRecorder.Error': ... - @typing.overload - def error(self, error: 'QMediaRecorder.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def status(self) -> 'QMediaRecorder.Status': ... def state(self) -> 'QMediaRecorder.State': ... def actualLocation(self) -> QtCore.QUrl: ... @@ -676,9 +652,8 @@ class QMediaRecorder(QtCore.QObject, QMediaBindableInterface): class QAudioRecorder(QMediaRecorder): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def availableAudioInputsChanged(self) -> None: ... - def audioInputChanged(self, name: str) -> None: ... + availableAudioInputsChanged: typing.ClassVar[QtCore.pyqtSignal] + audioInputChanged: typing.ClassVar[QtCore.pyqtSignal] def setAudioInput(self, name: str) -> None: ... def audioInput(self) -> str: ... def audioInputDescription(self, name: str) -> str: ... @@ -689,8 +664,7 @@ class QAudioRecorder(QMediaRecorder): class QAudioRoleControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def audioRoleChanged(self, role: QAudio.Role) -> None: ... + audioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] def supportedAudioRoles(self) -> typing.List[QAudio.Role]: ... def setAudioRole(self, role: QAudio.Role) -> None: ... def audioRole(self) -> QAudio.Role: ... @@ -849,16 +823,13 @@ class QCamera(QMediaObject): def supportedViewfinderSettings(self, settings: 'QCameraViewfinderSettings' = ...) -> typing.List['QCameraViewfinderSettings']: ... def setViewfinderSettings(self, settings: 'QCameraViewfinderSettings') -> None: ... def viewfinderSettings(self) -> 'QCameraViewfinderSettings': ... - def errorOccurred(self, a0: 'QCamera.Error') -> None: ... - @typing.overload - def lockStatusChanged(self, a0: 'QCamera.LockStatus', a1: 'QCamera.LockChangeReason') -> None: ... - @typing.overload - def lockStatusChanged(self, a0: 'QCamera.LockType', a1: 'QCamera.LockStatus', a2: 'QCamera.LockChangeReason') -> None: ... - def lockFailed(self) -> None: ... - def locked(self) -> None: ... - def statusChanged(self, a0: 'QCamera.Status') -> None: ... - def captureModeChanged(self, a0: typing.Union['QCamera.CaptureModes', 'QCamera.CaptureMode']) -> None: ... - def stateChanged(self, a0: 'QCamera.State') -> None: ... + errorOccurred: typing.ClassVar[QtCore.pyqtSignal] + lockStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + lockFailed: typing.ClassVar[QtCore.pyqtSignal] + locked: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + captureModeChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def unlock(self) -> None: ... @typing.overload @@ -879,10 +850,7 @@ class QCamera(QMediaObject): def requestedLocks(self) -> 'QCamera.LockTypes': ... def supportedLocks(self) -> 'QCamera.LockTypes': ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QCamera.Error': ... - @typing.overload - def error(self, a0: 'QCamera.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def setViewfinder(self, viewfinder: QtMultimediaWidgets.QVideoWidget) -> None: ... @typing.overload @@ -906,8 +874,7 @@ class QCamera(QMediaObject): class QCameraCaptureBufferFormatControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def bufferFormatChanged(self, format: 'QVideoFrame.PixelFormat') -> None: ... + bufferFormatChanged: typing.ClassVar[QtCore.pyqtSignal] def setBufferFormat(self, format: 'QVideoFrame.PixelFormat') -> None: ... def bufferFormat(self) -> 'QVideoFrame.PixelFormat': ... def supportedBufferFormats(self) -> typing.List['QVideoFrame.PixelFormat']: ... @@ -916,8 +883,7 @@ class QCameraCaptureBufferFormatControl(QMediaControl): class QCameraCaptureDestinationControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def captureDestinationChanged(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... + captureDestinationChanged: typing.ClassVar[QtCore.pyqtSignal] def setCaptureDestination(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... def captureDestination(self) -> 'QCameraImageCapture.CaptureDestinations': ... def isCaptureDestinationSupported(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> bool: ... @@ -939,11 +905,10 @@ class QCameraControl(QMediaControl): ViewfinderSettings = ... # type: QCameraControl.PropertyChangeType def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def captureModeChanged(self, mode: typing.Union[QCamera.CaptureModes, QCamera.CaptureMode]) -> None: ... - def error(self, error: int, errorString: str) -> None: ... - def statusChanged(self, a0: QCamera.Status) -> None: ... - def stateChanged(self, a0: QCamera.State) -> None: ... + captureModeChanged: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def canChangeProperty(self, changeType: 'QCameraControl.PropertyChangeType', status: QCamera.Status) -> bool: ... def isCaptureModeSupported(self, mode: typing.Union[QCamera.CaptureModes, QCamera.CaptureMode]) -> bool: ... def setCaptureMode(self, a0: typing.Union[QCamera.CaptureModes, QCamera.CaptureMode]) -> None: ... @@ -1048,14 +1013,13 @@ class QCameraExposure(QtCore.QObject): def __invert__(self) -> 'QCameraExposure.FlashModes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - - def exposureCompensationChanged(self, a0: float) -> None: ... - def isoSensitivityChanged(self, a0: int) -> None: ... - def shutterSpeedRangeChanged(self) -> None: ... - def shutterSpeedChanged(self, a0: float) -> None: ... - def apertureRangeChanged(self) -> None: ... - def apertureChanged(self, a0: float) -> None: ... - def flashReady(self, a0: bool) -> None: ... + exposureCompensationChanged: typing.ClassVar[QtCore.pyqtSignal] + isoSensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] + shutterSpeedRangeChanged: typing.ClassVar[QtCore.pyqtSignal] + shutterSpeedChanged: typing.ClassVar[QtCore.pyqtSignal] + apertureRangeChanged: typing.ClassVar[QtCore.pyqtSignal] + apertureChanged: typing.ClassVar[QtCore.pyqtSignal] + flashReady: typing.ClassVar[QtCore.pyqtSignal] def setAutoShutterSpeed(self) -> None: ... def setManualShutterSpeed(self, seconds: float) -> None: ... def setAutoAperture(self) -> None: ... @@ -1116,10 +1080,9 @@ class QCameraExposureControl(QMediaControl): ExtendedExposureParameter = ... # type: QCameraExposureControl.ExposureParameter def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def parameterRangeChanged(self, parameter: int) -> None: ... - def actualValueChanged(self, parameter: int) -> None: ... - def requestedValueChanged(self, parameter: int) -> None: ... + parameterRangeChanged: typing.ClassVar[QtCore.pyqtSignal] + actualValueChanged: typing.ClassVar[QtCore.pyqtSignal] + requestedValueChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, parameter: 'QCameraExposureControl.ExposureParameter', value: typing.Any) -> bool: ... def actualValue(self, parameter: 'QCameraExposureControl.ExposureParameter') -> typing.Any: ... def requestedValue(self, parameter: 'QCameraExposureControl.ExposureParameter') -> typing.Any: ... @@ -1166,8 +1129,7 @@ class QCameraFeedbackControl(QMediaControl): class QCameraFlashControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def flashReady(self, a0: bool) -> None: ... + flashReady: typing.ClassVar[QtCore.pyqtSignal] def isFlashReady(self) -> bool: ... def isFlashModeSupported(self, mode: typing.Union[QCameraExposure.FlashModes, QCameraExposure.FlashMode]) -> bool: ... def setFlashMode(self, mode: typing.Union[QCameraExposure.FlashModes, QCameraExposure.FlashMode]) -> None: ... @@ -1236,12 +1198,11 @@ class QCameraFocus(QtCore.QObject): def __invert__(self) -> 'QCameraFocus.FocusModes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - - def maximumDigitalZoomChanged(self, a0: float) -> None: ... - def maximumOpticalZoomChanged(self, a0: float) -> None: ... - def focusZonesChanged(self) -> None: ... - def digitalZoomChanged(self, a0: float) -> None: ... - def opticalZoomChanged(self, a0: float) -> None: ... + maximumDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + maximumOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + focusZonesChanged: typing.ClassVar[QtCore.pyqtSignal] + digitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + opticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] def zoomTo(self, opticalZoom: float, digitalZoom: float) -> None: ... def digitalZoom(self) -> float: ... def opticalZoom(self) -> float: ... @@ -1262,11 +1223,10 @@ class QCameraFocus(QtCore.QObject): class QCameraFocusControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def focusZonesChanged(self) -> None: ... - def customFocusPointChanged(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def focusPointModeChanged(self, mode: QCameraFocus.FocusPointMode) -> None: ... - def focusModeChanged(self, mode: typing.Union[QCameraFocus.FocusModes, QCameraFocus.FocusMode]) -> None: ... + focusZonesChanged: typing.ClassVar[QtCore.pyqtSignal] + customFocusPointChanged: typing.ClassVar[QtCore.pyqtSignal] + focusPointModeChanged: typing.ClassVar[QtCore.pyqtSignal] + focusModeChanged: typing.ClassVar[QtCore.pyqtSignal] def focusZones(self) -> typing.List[QCameraFocusZone]: ... def setCustomFocusPoint(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... def customFocusPoint(self) -> QtCore.QPointF: ... @@ -1325,14 +1285,14 @@ class QCameraImageCapture(QtCore.QObject, QMediaBindableInterface): def __init__(self, mediaObject: QMediaObject, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, a0: QMediaObject) -> bool: ... - def imageSaved(self, id: int, fileName: str) -> None: ... - def imageAvailable(self, id: int, image: 'QVideoFrame') -> None: ... - def imageMetadataAvailable(self, id: int, key: str, value: typing.Any) -> None: ... - def imageCaptured(self, id: int, preview: QtGui.QImage) -> None: ... - def imageExposed(self, id: int) -> None: ... - def captureDestinationChanged(self, a0: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... - def bufferFormatChanged(self, a0: 'QVideoFrame.PixelFormat') -> None: ... - def readyForCaptureChanged(self, a0: bool) -> None: ... + imageSaved: typing.ClassVar[QtCore.pyqtSignal] + imageAvailable: typing.ClassVar[QtCore.pyqtSignal] + imageMetadataAvailable: typing.ClassVar[QtCore.pyqtSignal] + imageCaptured: typing.ClassVar[QtCore.pyqtSignal] + imageExposed: typing.ClassVar[QtCore.pyqtSignal] + captureDestinationChanged: typing.ClassVar[QtCore.pyqtSignal] + bufferFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + readyForCaptureChanged: typing.ClassVar[QtCore.pyqtSignal] def cancelCapture(self) -> None: ... def capture(self, file: str = ...) -> int: ... def setCaptureDestination(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... @@ -1348,10 +1308,7 @@ class QCameraImageCapture(QtCore.QObject, QMediaBindableInterface): def supportedImageCodecs(self) -> typing.List[str]: ... def isReadyForCapture(self) -> bool: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QCameraImageCapture.Error': ... - @typing.overload - def error(self, id: int, error: 'QCameraImageCapture.Error', errorString: str) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def mediaObject(self) -> QMediaObject: ... def availability(self) -> 'QMultimedia.AvailabilityStatus': ... def isAvailable(self) -> bool: ... @@ -1360,14 +1317,13 @@ class QCameraImageCapture(QtCore.QObject, QMediaBindableInterface): class QCameraImageCaptureControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def error(self, id: int, error: int, errorString: str) -> None: ... - def imageSaved(self, requestId: int, fileName: str) -> None: ... - def imageAvailable(self, requestId: int, buffer: 'QVideoFrame') -> None: ... - def imageMetadataAvailable(self, id: int, key: str, value: typing.Any) -> None: ... - def imageCaptured(self, requestId: int, preview: QtGui.QImage) -> None: ... - def imageExposed(self, requestId: int) -> None: ... - def readyForCaptureChanged(self, ready: bool) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + imageSaved: typing.ClassVar[QtCore.pyqtSignal] + imageAvailable: typing.ClassVar[QtCore.pyqtSignal] + imageMetadataAvailable: typing.ClassVar[QtCore.pyqtSignal] + imageCaptured: typing.ClassVar[QtCore.pyqtSignal] + imageExposed: typing.ClassVar[QtCore.pyqtSignal] + readyForCaptureChanged: typing.ClassVar[QtCore.pyqtSignal] def cancelCapture(self) -> None: ... def capture(self, fileName: str) -> int: ... def setDriveMode(self, mode: QCameraImageCapture.DriveMode) -> None: ... @@ -1516,8 +1472,7 @@ class QCameraInfoControl(QMediaControl): class QCameraLocksControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def lockStatusChanged(self, type: QCamera.LockType, status: QCamera.LockStatus, reason: QCamera.LockChangeReason) -> None: ... + lockStatusChanged: typing.ClassVar[QtCore.pyqtSignal] def unlock(self, locks: typing.Union[QCamera.LockTypes, QCamera.LockType]) -> None: ... def searchAndLock(self, locks: typing.Union[QCamera.LockTypes, QCamera.LockType]) -> None: ... def lockStatus(self, lock: QCamera.LockType) -> QCamera.LockStatus: ... @@ -1587,13 +1542,12 @@ class QCameraViewfinderSettingsControl2(QMediaControl): class QCameraZoomControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def currentDigitalZoomChanged(self, digitalZoom: float) -> None: ... - def currentOpticalZoomChanged(self, opticalZoom: float) -> None: ... - def requestedDigitalZoomChanged(self, digitalZoom: float) -> None: ... - def requestedOpticalZoomChanged(self, opticalZoom: float) -> None: ... - def maximumDigitalZoomChanged(self, a0: float) -> None: ... - def maximumOpticalZoomChanged(self, a0: float) -> None: ... + currentDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + currentOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + requestedDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + requestedOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + maximumDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + maximumOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] def zoomTo(self, optical: float, digital: float) -> None: ... def currentDigitalZoom(self) -> float: ... def currentOpticalZoom(self) -> float: ... @@ -1606,8 +1560,7 @@ class QCameraZoomControl(QMediaControl): class QCustomAudioRoleControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def customAudioRoleChanged(self, role: str) -> None: ... + customAudioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] def supportedCustomAudioRoles(self) -> typing.List[str]: ... def setCustomAudioRole(self, role: str) -> None: ... def customAudioRole(self) -> str: ... @@ -1627,16 +1580,14 @@ class QImageEncoderControl(QMediaControl): class QMediaAudioProbeControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def flush(self) -> None: ... - def audioBufferProbed(self, buffer: QAudioBuffer) -> None: ... + flush: typing.ClassVar[QtCore.pyqtSignal] + audioBufferProbed: typing.ClassVar[QtCore.pyqtSignal] class QMediaAvailabilityControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def availabilityChanged(self, availability: 'QMultimedia.AvailabilityStatus') -> None: ... + availabilityChanged: typing.ClassVar[QtCore.pyqtSignal] def availability(self) -> 'QMultimedia.AvailabilityStatus': ... @@ -1757,10 +1708,9 @@ class QImageEncoderSettings(sip.simplewrapper): class QMediaGaplessPlaybackControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def advancedToNextMedia(self) -> None: ... - def nextMediaChanged(self, media: QMediaContent) -> None: ... - def crossfadeTimeChanged(self, crossfadeTime: float) -> None: ... + advancedToNextMedia: typing.ClassVar[QtCore.pyqtSignal] + nextMediaChanged: typing.ClassVar[QtCore.pyqtSignal] + crossfadeTimeChanged: typing.ClassVar[QtCore.pyqtSignal] def setCrossfadeTime(self, crossfadeTime: float) -> None: ... def crossfadeTime(self) -> float: ... def isCrossfadeSupported(self) -> bool: ... @@ -1866,8 +1816,7 @@ class QMediaMetaData(sip.simplewrapper): class QMediaNetworkAccessControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def configurationChanged(self, configuration: QtNetwork.QNetworkConfiguration) -> None: ... + configurationChanged: typing.ClassVar[QtCore.pyqtSignal] def currentConfiguration(self) -> QtNetwork.QNetworkConfiguration: ... def setConfigurations(self, configuration: typing.Iterable[QtNetwork.QNetworkConfiguration]) -> None: ... @@ -1944,31 +1893,30 @@ class QMediaPlayer(QMediaObject): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ..., flags: typing.Union['QMediaPlayer.Flags', 'QMediaPlayer.Flag'] = ...) -> None: ... - - def customAudioRoleChanged(self, role: str) -> None: ... + customAudioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] def supportedCustomAudioRoles(self) -> typing.List[str]: ... def setCustomAudioRole(self, audioRole: str) -> None: ... def customAudioRole(self) -> str: ... - def audioRoleChanged(self, role: QAudio.Role) -> None: ... + audioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] def supportedAudioRoles(self) -> typing.List[QAudio.Role]: ... def setAudioRole(self, audioRole: QAudio.Role) -> None: ... def audioRole(self) -> QAudio.Role: ... def unbind(self, a0: QtCore.QObject) -> None: ... def bind(self, a0: QtCore.QObject) -> bool: ... - def networkConfigurationChanged(self, configuration: QtNetwork.QNetworkConfiguration) -> None: ... - def playbackRateChanged(self, rate: float) -> None: ... - def seekableChanged(self, seekable: bool) -> None: ... - def bufferStatusChanged(self, percentFilled: int) -> None: ... - def videoAvailableChanged(self, videoAvailable: bool) -> None: ... - def audioAvailableChanged(self, available: bool) -> None: ... - def mutedChanged(self, muted: bool) -> None: ... - def volumeChanged(self, volume: int) -> None: ... - def positionChanged(self, position: int) -> None: ... - def durationChanged(self, duration: int) -> None: ... - def mediaStatusChanged(self, status: 'QMediaPlayer.MediaStatus') -> None: ... - def stateChanged(self, newState: 'QMediaPlayer.State') -> None: ... - def currentMediaChanged(self, media: QMediaContent) -> None: ... - def mediaChanged(self, media: QMediaContent) -> None: ... + networkConfigurationChanged: typing.ClassVar[QtCore.pyqtSignal] + playbackRateChanged: typing.ClassVar[QtCore.pyqtSignal] + seekableChanged: typing.ClassVar[QtCore.pyqtSignal] + bufferStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + videoAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + audioAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + mediaStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + currentMediaChanged: typing.ClassVar[QtCore.pyqtSignal] + mediaChanged: typing.ClassVar[QtCore.pyqtSignal] def setNetworkConfigurations(self, configurations: typing.Iterable[QtNetwork.QNetworkConfiguration]) -> None: ... def setPlaylist(self, playlist: 'QMediaPlaylist') -> None: ... def setMedia(self, media: QMediaContent, stream: typing.Optional[QtCore.QIODevice] = ...) -> None: ... @@ -1982,10 +1930,7 @@ class QMediaPlayer(QMediaObject): def availability(self) -> 'QMultimedia.AvailabilityStatus': ... def currentNetworkConfiguration(self) -> QtNetwork.QNetworkConfiguration: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QMediaPlayer.Error': ... - @typing.overload - def error(self, error: 'QMediaPlayer.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def playbackRate(self) -> float: ... def isSeekable(self) -> bool: ... def bufferStatus(self) -> int: ... @@ -2018,21 +1963,20 @@ class QMediaPlayer(QMediaObject): class QMediaPlayerControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def error(self, error: int, errorString: str) -> None: ... - def playbackRateChanged(self, rate: float) -> None: ... - def availablePlaybackRangesChanged(self, ranges: 'QMediaTimeRange') -> None: ... - def seekableChanged(self, seekable: bool) -> None: ... - def bufferStatusChanged(self, percentFilled: int) -> None: ... - def videoAvailableChanged(self, videoAvailable: bool) -> None: ... - def audioAvailableChanged(self, audioAvailable: bool) -> None: ... - def mutedChanged(self, mute: bool) -> None: ... - def volumeChanged(self, volume: int) -> None: ... - def mediaStatusChanged(self, status: QMediaPlayer.MediaStatus) -> None: ... - def stateChanged(self, newState: QMediaPlayer.State) -> None: ... - def positionChanged(self, position: int) -> None: ... - def durationChanged(self, duration: int) -> None: ... - def mediaChanged(self, content: QMediaContent) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + playbackRateChanged: typing.ClassVar[QtCore.pyqtSignal] + availablePlaybackRangesChanged: typing.ClassVar[QtCore.pyqtSignal] + seekableChanged: typing.ClassVar[QtCore.pyqtSignal] + bufferStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + videoAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + audioAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + mediaStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + mediaChanged: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def pause(self) -> None: ... def play(self) -> None: ... @@ -2088,16 +2032,16 @@ class QMediaPlaylist(QtCore.QObject, QMediaBindableInterface): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, object: QMediaObject) -> bool: ... - def loadFailed(self) -> None: ... - def loaded(self) -> None: ... - def mediaChanged(self, start: int, end: int) -> None: ... - def mediaRemoved(self, start: int, end: int) -> None: ... - def mediaAboutToBeRemoved(self, start: int, end: int) -> None: ... - def mediaInserted(self, start: int, end: int) -> None: ... - def mediaAboutToBeInserted(self, start: int, end: int) -> None: ... - def currentMediaChanged(self, a0: QMediaContent) -> None: ... - def playbackModeChanged(self, mode: 'QMediaPlaylist.PlaybackMode') -> None: ... - def currentIndexChanged(self, index: int) -> None: ... + loadFailed: typing.ClassVar[QtCore.pyqtSignal] + loaded: typing.ClassVar[QtCore.pyqtSignal] + mediaChanged: typing.ClassVar[QtCore.pyqtSignal] + mediaRemoved: typing.ClassVar[QtCore.pyqtSignal] + mediaAboutToBeRemoved: typing.ClassVar[QtCore.pyqtSignal] + mediaInserted: typing.ClassVar[QtCore.pyqtSignal] + mediaAboutToBeInserted: typing.ClassVar[QtCore.pyqtSignal] + currentMediaChanged: typing.ClassVar[QtCore.pyqtSignal] + playbackModeChanged: typing.ClassVar[QtCore.pyqtSignal] + currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] def setCurrentIndex(self, index: int) -> None: ... def previous(self) -> None: ... def next(self) -> None: ... @@ -2148,13 +2092,13 @@ class QMediaRecorderControl(QMediaControl): def setVolume(self, volume: float) -> None: ... def setMuted(self, muted: bool) -> None: ... def setState(self, state: QMediaRecorder.State) -> None: ... - def error(self, error: int, errorString: str) -> None: ... - def actualLocationChanged(self, location: QtCore.QUrl) -> None: ... - def volumeChanged(self, volume: float) -> None: ... - def mutedChanged(self, muted: bool) -> None: ... - def durationChanged(self, position: int) -> None: ... - def statusChanged(self, status: QMediaRecorder.Status) -> None: ... - def stateChanged(self, state: QMediaRecorder.State) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + actualLocationChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def applySettings(self) -> None: ... def volume(self) -> float: ... def isMuted(self) -> bool: ... @@ -2227,9 +2171,8 @@ class QMediaStreamsControl(QMediaControl): DataStream = ... # type: QMediaStreamsControl.StreamType def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def activeStreamsChanged(self) -> None: ... - def streamsChanged(self) -> None: ... + activeStreamsChanged: typing.ClassVar[QtCore.pyqtSignal] + streamsChanged: typing.ClassVar[QtCore.pyqtSignal] def setActive(self, streamNumber: int, state: bool) -> None: ... def isActive(self, streamNumber: int) -> bool: ... def metaData(self, streamNumber: int, key: str) -> typing.Any: ... @@ -2287,20 +2230,15 @@ class QMediaTimeRange(sip.simplewrapper): class QMediaVideoProbeControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def flush(self) -> None: ... - def videoFrameProbed(self, frame: 'QVideoFrame') -> None: ... + flush: typing.ClassVar[QtCore.pyqtSignal] + videoFrameProbed: typing.ClassVar[QtCore.pyqtSignal] class QMetaDataReaderControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def metaDataAvailableChanged(self, available: bool) -> None: ... - @typing.overload - def metaDataChanged(self) -> None: ... - @typing.overload - def metaDataChanged(self, key: str, value: typing.Any) -> None: ... + metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] def availableMetaData(self) -> typing.List[str]: ... def metaData(self, key: str) -> typing.Any: ... def isMetaDataAvailable(self) -> bool: ... @@ -2309,13 +2247,9 @@ class QMetaDataReaderControl(QMediaControl): class QMetaDataWriterControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def metaDataAvailableChanged(self, available: bool) -> None: ... - def writableChanged(self, writable: bool) -> None: ... - @typing.overload - def metaDataChanged(self) -> None: ... - @typing.overload - def metaDataChanged(self, key: str, value: typing.Any) -> None: ... + metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + writableChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] def availableMetaData(self) -> typing.List[str]: ... def setMetaData(self, key: str, value: typing.Any) -> None: ... def metaData(self, key: str) -> typing.Any: ... @@ -2487,18 +2421,15 @@ class QRadioData(QtCore.QObject, QMediaBindableInterface): def __init__(self, mediaObject: QMediaObject, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, a0: QMediaObject) -> bool: ... - def alternativeFrequenciesEnabledChanged(self, enabled: bool) -> None: ... - def radioTextChanged(self, radioText: str) -> None: ... - def stationNameChanged(self, stationName: str) -> None: ... - def programTypeNameChanged(self, programTypeName: str) -> None: ... - def programTypeChanged(self, programType: 'QRadioData.ProgramType') -> None: ... - def stationIdChanged(self, stationId: str) -> None: ... + alternativeFrequenciesEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + radioTextChanged: typing.ClassVar[QtCore.pyqtSignal] + stationNameChanged: typing.ClassVar[QtCore.pyqtSignal] + programTypeNameChanged: typing.ClassVar[QtCore.pyqtSignal] + programTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + stationIdChanged: typing.ClassVar[QtCore.pyqtSignal] def setAlternativeFrequenciesEnabled(self, enabled: bool) -> None: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QRadioData.Error': ... - @typing.overload - def error(self, error: 'QRadioData.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isAlternativeFrequenciesEnabled(self) -> bool: ... def radioText(self) -> str: ... def stationName(self) -> str: ... @@ -2512,18 +2443,14 @@ class QRadioData(QtCore.QObject, QMediaBindableInterface): class QRadioDataControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def alternativeFrequenciesEnabledChanged(self, enabled: bool) -> None: ... - def radioTextChanged(self, radioText: str) -> None: ... - def stationNameChanged(self, stationName: str) -> None: ... - def programTypeNameChanged(self, programTypeName: str) -> None: ... - def programTypeChanged(self, programType: QRadioData.ProgramType) -> None: ... - def stationIdChanged(self, stationId: str) -> None: ... + alternativeFrequenciesEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + radioTextChanged: typing.ClassVar[QtCore.pyqtSignal] + stationNameChanged: typing.ClassVar[QtCore.pyqtSignal] + programTypeNameChanged: typing.ClassVar[QtCore.pyqtSignal] + programTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + stationIdChanged: typing.ClassVar[QtCore.pyqtSignal] def errorString(self) -> str: ... - @typing.overload - def error(self) -> QRadioData.Error: ... - @typing.overload - def error(self, err: QRadioData.Error) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isAlternativeFrequenciesEnabled(self) -> bool: ... def setAlternativeFrequenciesEnabled(self, enabled: bool) -> None: ... def radioText(self) -> str: ... @@ -2583,17 +2510,16 @@ class QRadioTuner(QMediaObject): StoppedState = ... # type: QRadioTuner.State def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def antennaConnectedChanged(self, connectionStatus: bool) -> None: ... - def stationFound(self, frequency: int, stationId: str) -> None: ... - def mutedChanged(self, muted: bool) -> None: ... - def volumeChanged(self, volume: int) -> None: ... - def signalStrengthChanged(self, signalStrength: int) -> None: ... - def searchingChanged(self, searching: bool) -> None: ... - def stereoStatusChanged(self, stereo: bool) -> None: ... - def frequencyChanged(self, frequency: int) -> None: ... - def bandChanged(self, band: 'QRadioTuner.Band') -> None: ... - def stateChanged(self, state: 'QRadioTuner.State') -> None: ... + antennaConnectedChanged: typing.ClassVar[QtCore.pyqtSignal] + stationFound: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + signalStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] + searchingChanged: typing.ClassVar[QtCore.pyqtSignal] + stereoStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + frequencyChanged: typing.ClassVar[QtCore.pyqtSignal] + bandChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def start(self) -> None: ... def setMuted(self, muted: bool) -> None: ... @@ -2606,10 +2532,7 @@ class QRadioTuner(QMediaObject): def searchForward(self) -> None: ... def radioData(self) -> QRadioData: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QRadioTuner.Error': ... - @typing.overload - def error(self, error: 'QRadioTuner.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isAntennaConnected(self) -> bool: ... def isSearching(self) -> bool: ... def isMuted(self) -> bool: ... @@ -2630,22 +2553,18 @@ class QRadioTuner(QMediaObject): class QRadioTunerControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def antennaConnectedChanged(self, connectionStatus: bool) -> None: ... - def stationFound(self, frequency: int, stationId: str) -> None: ... - def mutedChanged(self, muted: bool) -> None: ... - def volumeChanged(self, volume: int) -> None: ... - def signalStrengthChanged(self, signalStrength: int) -> None: ... - def searchingChanged(self, searching: bool) -> None: ... - def stereoStatusChanged(self, stereo: bool) -> None: ... - def frequencyChanged(self, frequency: int) -> None: ... - def bandChanged(self, band: QRadioTuner.Band) -> None: ... - def stateChanged(self, state: QRadioTuner.State) -> None: ... + antennaConnectedChanged: typing.ClassVar[QtCore.pyqtSignal] + stationFound: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + signalStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] + searchingChanged: typing.ClassVar[QtCore.pyqtSignal] + stereoStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + frequencyChanged: typing.ClassVar[QtCore.pyqtSignal] + bandChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def errorString(self) -> str: ... - @typing.overload - def error(self) -> QRadioTuner.Error: ... - @typing.overload - def error(self, err: QRadioTuner.Error) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def start(self) -> None: ... def cancelSearch(self) -> None: ... @@ -2719,15 +2638,15 @@ class QSoundEffect(QtCore.QObject): def stop(self) -> None: ... def play(self) -> None: ... - def categoryChanged(self) -> None: ... - def statusChanged(self) -> None: ... - def playingChanged(self) -> None: ... - def loadedChanged(self) -> None: ... - def mutedChanged(self) -> None: ... - def volumeChanged(self) -> None: ... - def loopsRemainingChanged(self) -> None: ... - def loopCountChanged(self) -> None: ... - def sourceChanged(self) -> None: ... + categoryChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + playingChanged: typing.ClassVar[QtCore.pyqtSignal] + loadedChanged: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + loopsRemainingChanged: typing.ClassVar[QtCore.pyqtSignal] + loopCountChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setCategory(self, category: str) -> None: ... def category(self) -> str: ... def status(self) -> 'QSoundEffect.Status': ... @@ -2749,12 +2668,8 @@ class QSoundEffect(QtCore.QObject): class QVideoDeviceSelectorControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def devicesChanged(self) -> None: ... - @typing.overload - def selectedDeviceChanged(self, index: int) -> None: ... - @typing.overload - def selectedDeviceChanged(self, name: str) -> None: ... + devicesChanged: typing.ClassVar[QtCore.pyqtSignal] + selectedDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSelectedDevice(self, index: int) -> None: ... def selectedDevice(self) -> int: ... def defaultDevice(self) -> int: ... @@ -2917,9 +2832,8 @@ class QVideoFrame(sip.simplewrapper): class QVideoProbe(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def flush(self) -> None: ... - def videoFrameProbed(self, videoFrame: QVideoFrame) -> None: ... + flush: typing.ClassVar[QtCore.pyqtSignal] + videoFrameProbed: typing.ClassVar[QtCore.pyqtSignal] def isActive(self) -> bool: ... @typing.overload def setSource(self, source: QMediaObject) -> bool: ... @@ -3000,13 +2914,12 @@ class QVideoSurfaceFormat(sip.simplewrapper): class QVideoWindowControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def nativeSizeChanged(self) -> None: ... - def saturationChanged(self, saturation: int) -> None: ... - def hueChanged(self, hue: int) -> None: ... - def contrastChanged(self, contrast: int) -> None: ... - def brightnessChanged(self, brightness: int) -> None: ... - def fullScreenChanged(self, fullScreen: bool) -> None: ... + nativeSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + saturationChanged: typing.ClassVar[QtCore.pyqtSignal] + hueChanged: typing.ClassVar[QtCore.pyqtSignal] + contrastChanged: typing.ClassVar[QtCore.pyqtSignal] + brightnessChanged: typing.ClassVar[QtCore.pyqtSignal] + fullScreenChanged: typing.ClassVar[QtCore.pyqtSignal] def setSaturation(self, saturation: int) -> None: ... def saturation(self) -> int: ... def setHue(self, hue: int) -> None: ... diff --git a/PyQt5-stubs/QtMultimediaWidgets.pyi b/PyQt5-stubs/QtMultimediaWidgets.pyi index c7a0cc68..d9b678fb 100644 --- a/PyQt5-stubs/QtMultimediaWidgets.pyi +++ b/PyQt5-stubs/QtMultimediaWidgets.pyi @@ -53,11 +53,11 @@ class QVideoWidget(QtWidgets.QWidget, QtMultimedia.QMediaBindableInterface): def hideEvent(self, event: QtGui.QHideEvent) -> None: ... def showEvent(self, event: QtGui.QShowEvent) -> None: ... def event(self, event: QtCore.QEvent) -> bool: ... - def saturationChanged(self, saturation: int) -> None: ... - def hueChanged(self, hue: int) -> None: ... - def contrastChanged(self, contrast: int) -> None: ... - def brightnessChanged(self, brightness: int) -> None: ... - def fullScreenChanged(self, fullScreen: bool) -> None: ... + saturationChanged: typing.ClassVar[QtCore.pyqtSignal] + hueChanged: typing.ClassVar[QtCore.pyqtSignal] + contrastChanged: typing.ClassVar[QtCore.pyqtSignal] + brightnessChanged: typing.ClassVar[QtCore.pyqtSignal] + fullScreenChanged: typing.ClassVar[QtCore.pyqtSignal] def setSaturation(self, saturation: int) -> None: ... def setHue(self, hue: int) -> None: ... def setContrast(self, contrast: int) -> None: ... @@ -89,7 +89,7 @@ class QGraphicsVideoItem(QtWidgets.QGraphicsObject, QtMultimedia.QMediaBindableI def setMediaObject(self, object: QtMultimedia.QMediaObject) -> bool: ... def itemChange(self, change: QtWidgets.QGraphicsItem.GraphicsItemChange, value: typing.Any) -> typing.Any: ... def timerEvent(self, event: QtCore.QTimerEvent) -> None: ... - def nativeSizeChanged(self, size: QtCore.QSizeF) -> None: ... + nativeSizeChanged: typing.ClassVar[QtCore.pyqtSignal] def paint(self, painter: QtGui.QPainter, option: QtWidgets.QStyleOptionGraphicsItem, widget: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... def boundingRect(self) -> QtCore.QRectF: ... def nativeSize(self) -> QtCore.QSizeF: ... @@ -105,12 +105,11 @@ class QGraphicsVideoItem(QtWidgets.QGraphicsObject, QtMultimedia.QMediaBindableI class QVideoWidgetControl(QtMultimedia.QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def saturationChanged(self, saturation: int) -> None: ... - def hueChanged(self, hue: int) -> None: ... - def contrastChanged(self, contrast: int) -> None: ... - def brightnessChanged(self, brightness: int) -> None: ... - def fullScreenChanged(self, fullScreen: bool) -> None: ... + saturationChanged: typing.ClassVar[QtCore.pyqtSignal] + hueChanged: typing.ClassVar[QtCore.pyqtSignal] + contrastChanged: typing.ClassVar[QtCore.pyqtSignal] + brightnessChanged: typing.ClassVar[QtCore.pyqtSignal] + fullScreenChanged: typing.ClassVar[QtCore.pyqtSignal] def setSaturation(self, saturation: int) -> None: ... def saturation(self) -> int: ... def setHue(self, hue: int) -> None: ... diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 4acd10cb..e7186771 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -270,12 +270,12 @@ class QAbstractSocket(QtCore.QIODevice): def writeData(self, data: bytes) -> int: ... def readLineData(self, maxlen: int) -> bytes: ... def readData(self, maxlen: int) -> bytes: ... - def proxyAuthenticationRequired(self, proxy: 'QNetworkProxy', authenticator: 'QAuthenticator') -> None: ... - def errorOccurred(self, a0: 'QAbstractSocket.SocketError') -> None: ... - def stateChanged(self, a0: 'QAbstractSocket.SocketState') -> None: ... - def disconnected(self) -> None: ... - def connected(self) -> None: ... - def hostFound(self) -> None: ... + proxyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + errorOccurred: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] + connected: typing.ClassVar[QtCore.pyqtSignal] + hostFound: typing.ClassVar[QtCore.pyqtSignal] def proxy(self) -> 'QNetworkProxy': ... def setProxy(self, networkProxy: 'QNetworkProxy') -> None: ... def waitForDisconnected(self, msecs: int = ...) -> bool: ... @@ -286,10 +286,7 @@ class QAbstractSocket(QtCore.QIODevice): def atEnd(self) -> bool: ... def isSequential(self) -> bool: ... def close(self) -> None: ... - @typing.overload - def error(self) -> 'QAbstractSocket.SocketError': ... - @typing.overload - def error(self, a0: 'QAbstractSocket.SocketError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def state(self) -> 'QAbstractSocket.SocketState': ... def socketType(self) -> 'QAbstractSocket.SocketType': ... def socketDescriptor(self) -> sip.voidptr: ... @@ -448,13 +445,12 @@ class QDnsLookup(QtCore.QObject): def __init__(self, type: 'QDnsLookup.Type', name: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, type: 'QDnsLookup.Type', name: str, nameserver: typing.Union['QHostAddress', 'QHostAddress.SpecialAddress'], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def nameserverChanged(self, nameserver: typing.Union['QHostAddress', 'QHostAddress.SpecialAddress']) -> None: ... + nameserverChanged: typing.ClassVar[QtCore.pyqtSignal] def setNameserver(self, nameserver: typing.Union['QHostAddress', 'QHostAddress.SpecialAddress']) -> None: ... def nameserver(self) -> 'QHostAddress': ... - def typeChanged(self, type: 'QDnsLookup.Type') -> None: ... - def nameChanged(self, name: str) -> None: ... - def finished(self) -> None: ... + typeChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def lookup(self) -> None: ... def abort(self) -> None: ... def textRecords(self) -> typing.List[QDnsTextRecord]: ... @@ -739,7 +735,7 @@ class QLocalServer(QtCore.QObject): def socketOptions(self) -> 'QLocalServer.SocketOptions': ... def setSocketOptions(self, options: typing.Union['QLocalServer.SocketOptions', 'QLocalServer.SocketOption']) -> None: ... def incomingConnection(self, socketDescriptor: sip.voidptr) -> None: ... - def newConnection(self) -> None: ... + newConnection: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def removeServer(name: str) -> bool: ... def waitForNewConnection(self, msecs: int = ...) -> typing.Tuple[bool, bool]: ... @@ -801,10 +797,10 @@ class QLocalSocket(QtCore.QIODevice): def writeData(self, a0: bytes) -> int: ... def readData(self, maxlen: int) -> bytes: ... - def stateChanged(self, socketState: 'QLocalSocket.LocalSocketState') -> None: ... - def errorOccurred(self, socketError: 'QLocalSocket.LocalSocketError') -> None: ... - def disconnected(self) -> None: ... - def connected(self) -> None: ... + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + errorOccurred: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] + connected: typing.ClassVar[QtCore.pyqtSignal] def waitForReadyRead(self, msecs: int = ...) -> bool: ... def waitForDisconnected(self, msecs: int = ...) -> bool: ... def waitForConnected(self, msecs: int = ...) -> bool: ... @@ -816,10 +812,7 @@ class QLocalSocket(QtCore.QIODevice): def readBufferSize(self) -> int: ... def isValid(self) -> bool: ... def flush(self) -> bool: ... - @typing.overload - def error(self) -> 'QLocalSocket.LocalSocketError': ... - @typing.overload - def error(self, socketError: 'QLocalSocket.LocalSocketError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def close(self) -> None: ... def canReadLine(self) -> bool: ... def bytesToWrite(self) -> int: ... @@ -965,12 +958,11 @@ class QNetworkConfigurationManager(QtCore.QObject): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def updateCompleted(self) -> None: ... - def onlineStateChanged(self, isOnline: bool) -> None: ... - def configurationChanged(self, config: 'QNetworkConfiguration') -> None: ... - def configurationRemoved(self, config: 'QNetworkConfiguration') -> None: ... - def configurationAdded(self, config: 'QNetworkConfiguration') -> None: ... + updateCompleted: typing.ClassVar[QtCore.pyqtSignal] + onlineStateChanged: typing.ClassVar[QtCore.pyqtSignal] + configurationChanged: typing.ClassVar[QtCore.pyqtSignal] + configurationRemoved: typing.ClassVar[QtCore.pyqtSignal] + configurationAdded: typing.ClassVar[QtCore.pyqtSignal] def isOnline(self) -> bool: ... def updateConfigurations(self) -> None: ... def configurationFromIdentifier(self, identifier: str) -> 'QNetworkConfiguration': ... @@ -1552,16 +1544,16 @@ class QNetworkReply(QtCore.QIODevice): def setRequest(self, request: 'QNetworkRequest') -> None: ... def setOperation(self, operation: QNetworkAccessManager.Operation) -> None: ... def writeData(self, data: bytes) -> int: ... - def redirectAllowed(self) -> None: ... - def redirected(self, url: QtCore.QUrl) -> None: ... - def preSharedKeyAuthenticationRequired(self, authenticator: 'QSslPreSharedKeyAuthenticator') -> None: ... - def downloadProgress(self, bytesReceived: int, bytesTotal: int) -> None: ... - def uploadProgress(self, bytesSent: int, bytesTotal: int) -> None: ... - def sslErrors(self, errors: typing.Iterable['QSslError']) -> None: ... - def errorOccurred(self, a0: 'QNetworkReply.NetworkError') -> None: ... - def encrypted(self) -> None: ... - def finished(self) -> None: ... - def metaDataChanged(self) -> None: ... + redirectAllowed: typing.ClassVar[QtCore.pyqtSignal] + redirected: typing.ClassVar[QtCore.pyqtSignal] + preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + downloadProgress: typing.ClassVar[QtCore.pyqtSignal] + uploadProgress: typing.ClassVar[QtCore.pyqtSignal] + sslErrors: typing.ClassVar[QtCore.pyqtSignal] + errorOccurred: typing.ClassVar[QtCore.pyqtSignal] + encrypted: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def ignoreSslErrors(self) -> None: ... @typing.overload @@ -1574,10 +1566,7 @@ class QNetworkReply(QtCore.QIODevice): def hasRawHeader(self, headerName: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> bool: ... def header(self, header: 'QNetworkRequest.KnownHeaders') -> typing.Any: ... def url(self) -> QtCore.QUrl: ... - @typing.overload - def error(self) -> 'QNetworkReply.NetworkError': ... - @typing.overload - def error(self, a0: 'QNetworkReply.NetworkError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def request(self) -> 'QNetworkRequest': ... def operation(self) -> QNetworkAccessManager.Operation: ... def manager(self) -> QNetworkAccessManager: ... @@ -1810,16 +1799,15 @@ class QNetworkSession(QtCore.QObject): def __int__(self) -> int: ... def __init__(self, connConfig: QNetworkConfiguration, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def usagePoliciesChanged(self, usagePolicies: typing.Union['QNetworkSession.UsagePolicies', 'QNetworkSession.UsagePolicy']) -> None: ... + usagePoliciesChanged: typing.ClassVar[QtCore.pyqtSignal] def usagePolicies(self) -> 'QNetworkSession.UsagePolicies': ... def disconnectNotify(self, signal: QtCore.QMetaMethod) -> None: ... def connectNotify(self, signal: QtCore.QMetaMethod) -> None: ... - def newConfigurationActivated(self) -> None: ... - def preferredConfigurationChanged(self, config: QNetworkConfiguration, isSeamless: bool) -> None: ... - def closed(self) -> None: ... - def opened(self) -> None: ... - def stateChanged(self, a0: 'QNetworkSession.State') -> None: ... + newConfigurationActivated: typing.ClassVar[QtCore.pyqtSignal] + preferredConfigurationChanged: typing.ClassVar[QtCore.pyqtSignal] + closed: typing.ClassVar[QtCore.pyqtSignal] + opened: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def reject(self) -> None: ... def accept(self) -> None: ... def ignore(self) -> None: ... @@ -1834,10 +1822,7 @@ class QNetworkSession(QtCore.QObject): def setSessionProperty(self, key: str, value: typing.Any) -> None: ... def sessionProperty(self, key: str) -> typing.Any: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QNetworkSession.SessionError': ... - @typing.overload - def error(self, a0: 'QNetworkSession.SessionError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def state(self) -> 'QNetworkSession.State': ... def interface(self) -> QNetworkInterface: ... def configuration(self) -> QNetworkConfiguration: ... @@ -2391,8 +2376,7 @@ class QSslSocket(QTcpSocket): SslServerMode = ... # type: QSslSocket.SslMode def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def newSessionTicketReceived(self) -> None: ... + newSessionTicketReceived: typing.ClassVar[QtCore.pyqtSignal] def sslHandshakeErrors(self) -> typing.List[QSslError]: ... def ocspResponses(self) -> typing.List[QOcspResponse]: ... @staticmethod @@ -2413,8 +2397,8 @@ class QSslSocket(QTcpSocket): def peerVerifyName(self) -> str: ... def socketOption(self, option: QAbstractSocket.SocketOption) -> typing.Any: ... def setSocketOption(self, option: QAbstractSocket.SocketOption, value: typing.Any) -> None: ... - def encryptedBytesWritten(self, totalBytes: int) -> None: ... - def peerVerifyError(self, error: QSslError) -> None: ... + encryptedBytesWritten: typing.ClassVar[QtCore.pyqtSignal] + peerVerifyError: typing.ClassVar[QtCore.pyqtSignal] def setSslConfiguration(self, config: QSslConfiguration) -> None: ... def sslConfiguration(self) -> QSslConfiguration: ... def encryptedBytesToWrite(self) -> int: ... @@ -2426,9 +2410,9 @@ class QSslSocket(QTcpSocket): def peerVerifyMode(self) -> 'QSslSocket.PeerVerifyMode': ... def writeData(self, data: bytes) -> int: ... def readData(self, maxlen: int) -> bytes: ... - def preSharedKeyAuthenticationRequired(self, authenticator: QSslPreSharedKeyAuthenticator) -> None: ... - def modeChanged(self, newMode: 'QSslSocket.SslMode') -> None: ... - def encrypted(self) -> None: ... + preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + modeChanged: typing.ClassVar[QtCore.pyqtSignal] + encrypted: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def ignoreSslErrors(self) -> None: ... @typing.overload @@ -2437,10 +2421,7 @@ class QSslSocket(QTcpSocket): def startClientEncryption(self) -> None: ... @staticmethod def supportsSsl() -> bool: ... - @typing.overload - def sslErrors(self) -> typing.List[QSslError]: ... - @typing.overload - def sslErrors(self, errors: typing.Iterable[QSslError]) -> None: ... + sslErrors: typing.ClassVar[QtCore.pyqtSignal] def waitForDisconnected(self, msecs: int = ...) -> bool: ... def waitForBytesWritten(self, msecs: int = ...) -> bool: ... def waitForReadyRead(self, msecs: int = ...) -> bool: ... @@ -2512,9 +2493,8 @@ class QSslSocket(QTcpSocket): class QTcpServer(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def acceptError(self, socketError: QAbstractSocket.SocketError) -> None: ... - def newConnection(self) -> None: ... + acceptError: typing.ClassVar[QtCore.pyqtSignal] + newConnection: typing.ClassVar[QtCore.pyqtSignal] def addPendingConnection(self, socket: QTcpSocket) -> None: ... def incomingConnection(self, handle: sip.voidptr) -> None: ... def resumeAccepting(self) -> None: ... diff --git a/PyQt5-stubs/QtNetworkAuth.pyi b/PyQt5-stubs/QtNetworkAuth.pyi index b9f650b4..6fb0f628 100644 --- a/PyQt5-stubs/QtNetworkAuth.pyi +++ b/PyQt5-stubs/QtNetworkAuth.pyi @@ -64,17 +64,17 @@ class QAbstractOAuth(QtCore.QObject): def resourceOwnerAuthorization(self, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any]) -> None: ... def callback(self) -> str: ... def setStatus(self, status: 'QAbstractOAuth.Status') -> None: ... - def replyDataReceived(self, data: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def finished(self, reply: QtNetwork.QNetworkReply) -> None: ... - def granted(self) -> None: ... - def authorizeWithBrowser(self, url: QtCore.QUrl) -> None: ... - def requestFailed(self, error: 'QAbstractOAuth.Error') -> None: ... - def contentTypeChanged(self, contentType: 'QAbstractOAuth.ContentType') -> None: ... - def extraTokensChanged(self, tokens: typing.Dict[str, typing.Any]) -> None: ... - def authorizationUrlChanged(self, url: QtCore.QUrl) -> None: ... - def statusChanged(self, status: 'QAbstractOAuth.Status') -> None: ... - def tokenChanged(self, token: str) -> None: ... - def clientIdentifierChanged(self, clientIdentifier: str) -> None: ... + replyDataReceived: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + granted: typing.ClassVar[QtCore.pyqtSignal] + authorizeWithBrowser: typing.ClassVar[QtCore.pyqtSignal] + requestFailed: typing.ClassVar[QtCore.pyqtSignal] + contentTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + extraTokensChanged: typing.ClassVar[QtCore.pyqtSignal] + authorizationUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + tokenChanged: typing.ClassVar[QtCore.pyqtSignal] + clientIdentifierChanged: typing.ClassVar[QtCore.pyqtSignal] def grant(self) -> None: ... def prepareRequest(self, request: QtNetwork.QNetworkRequest, verb: typing.Union[QtCore.QByteArray, bytes, bytearray], body: typing.Union[QtCore.QByteArray, bytes, bytearray] = ...) -> None: ... def setContentType(self, contentType: 'QAbstractOAuth.ContentType') -> None: ... @@ -108,15 +108,15 @@ class QAbstractOAuth2(QAbstractOAuth): def __init__(self, manager: QtNetwork.QNetworkAccessManager, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setResponseType(self, responseType: str) -> None: ... - def authorizationCallbackReceived(self, data: typing.Dict[str, typing.Any]) -> None: ... - def error(self, error: str, errorDescription: str, uri: QtCore.QUrl) -> None: ... - def expirationAtChanged(self, expiration: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def stateChanged(self, state: str) -> None: ... - def clientIdentifierSharedKeyChanged(self, clientIdentifierSharedKey: str) -> None: ... - def responseTypeChanged(self, responseType: str) -> None: ... - def refreshTokenChanged(self, refreshToken: str) -> None: ... - def userAgentChanged(self, userAgent: str) -> None: ... - def scopeChanged(self, scope: str) -> None: ... + authorizationCallbackReceived: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + expirationAtChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + clientIdentifierSharedKeyChanged: typing.ClassVar[QtCore.pyqtSignal] + responseTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + refreshTokenChanged: typing.ClassVar[QtCore.pyqtSignal] + userAgentChanged: typing.ClassVar[QtCore.pyqtSignal] + scopeChanged: typing.ClassVar[QtCore.pyqtSignal] def setRefreshToken(self, refreshToken: str) -> None: ... def refreshToken(self) -> str: ... def expirationAt(self) -> QtCore.QDateTime: ... @@ -150,11 +150,10 @@ class QAbstractOAuth2(QAbstractOAuth): class QAbstractOAuthReplyHandler(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def callbackDataReceived(self, data: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def replyDataReceived(self, data: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tokensReceived(self, tokens: typing.Dict[str, typing.Any]) -> None: ... - def callbackReceived(self, values: typing.Dict[str, typing.Any]) -> None: ... + callbackDataReceived: typing.ClassVar[QtCore.pyqtSignal] + replyDataReceived: typing.ClassVar[QtCore.pyqtSignal] + tokensReceived: typing.ClassVar[QtCore.pyqtSignal] + callbackReceived: typing.ClassVar[QtCore.pyqtSignal] def networkReplyFinished(self, reply: QtNetwork.QNetworkReply) -> None: ... def callback(self) -> str: ... @@ -183,11 +182,11 @@ class QOAuth1(QAbstractOAuth): def setup(self, request: QtNetwork.QNetworkRequest, signingParameters: typing.Dict[str, typing.Any], operationVerb: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def requestTokenCredentials(self, operation: QtNetwork.QNetworkAccessManager.Operation, url: QtCore.QUrl, temporaryToken: typing.Tuple[str, str], parameters: typing.Dict[str, typing.Any] = ...) -> QtNetwork.QNetworkReply: ... def requestTemporaryCredentials(self, operation: QtNetwork.QNetworkAccessManager.Operation, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any] = ...) -> QtNetwork.QNetworkReply: ... - def tokenCredentialsUrlChanged(self, url: QtCore.QUrl) -> None: ... - def temporaryCredentialsUrlChanged(self, url: QtCore.QUrl) -> None: ... - def tokenSecretChanged(self, token: str) -> None: ... - def clientSharedSecretChanged(self, credential: str) -> None: ... - def signatureMethodChanged(self, method: 'QOAuth1.SignatureMethod') -> None: ... + tokenCredentialsUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + temporaryCredentialsUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + tokenSecretChanged: typing.ClassVar[QtCore.pyqtSignal] + clientSharedSecretChanged: typing.ClassVar[QtCore.pyqtSignal] + signatureMethodChanged: typing.ClassVar[QtCore.pyqtSignal] def continueGrantWithVerifier(self, verifier: str) -> None: ... def grant(self) -> None: ... def deleteResource(self, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any] = ...) -> QtNetwork.QNetworkReply: ... @@ -278,7 +277,7 @@ class QOAuth2AuthorizationCodeFlow(QAbstractOAuth2): def resourceOwnerAuthorization(self, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any] = ...) -> None: ... def requestAccessToken(self, code: str) -> None: ... def buildAuthenticateUrl(self, parameters: typing.Dict[str, typing.Any] = ...) -> QtCore.QUrl: ... - def accessTokenUrlChanged(self, accessTokenUrl: QtCore.QUrl) -> None: ... + accessTokenUrlChanged: typing.ClassVar[QtCore.pyqtSignal] def refreshAccessToken(self) -> None: ... def grant(self) -> None: ... def setAccessTokenUrl(self, accessTokenUrl: QtCore.QUrl) -> None: ... diff --git a/PyQt5-stubs/QtNfc.pyi b/PyQt5-stubs/QtNfc.pyi index 669afa27..caaa56c0 100644 --- a/PyQt5-stubs/QtNfc.pyi +++ b/PyQt5-stubs/QtNfc.pyi @@ -273,11 +273,10 @@ class QNearFieldManager(QtCore.QObject): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def adapterStateChanged(self, state: 'QNearFieldManager.AdapterState') -> None: ... + adapterStateChanged: typing.ClassVar[QtCore.pyqtSignal] def isSupported(self) -> bool: ... - def targetLost(self, target: 'QNearFieldTarget') -> None: ... - def targetDetected(self, target: 'QNearFieldTarget') -> None: ... + targetLost: typing.ClassVar[QtCore.pyqtSignal] + targetDetected: typing.ClassVar[QtCore.pyqtSignal] def unregisterNdefMessageHandler(self, handlerId: int) -> bool: ... @typing.overload def registerNdefMessageHandler(self, slot: PYQT_SLOT) -> int: ... @@ -340,10 +339,9 @@ class QNearFieldShareManager(QtCore.QObject): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def error(self, error: 'QNearFieldShareManager.ShareError') -> None: ... - def shareModesChanged(self, modes: typing.Union['QNearFieldShareManager.ShareModes', 'QNearFieldShareManager.ShareMode']) -> None: ... - def targetDetected(self, shareTarget: 'QNearFieldShareTarget') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + shareModesChanged: typing.ClassVar[QtCore.pyqtSignal] + targetDetected: typing.ClassVar[QtCore.pyqtSignal] def shareError(self) -> 'QNearFieldShareManager.ShareError': ... def shareModes(self) -> 'QNearFieldShareManager.ShareModes': ... def setShareModes(self, modes: typing.Union['QNearFieldShareManager.ShareModes', 'QNearFieldShareManager.ShareMode']) -> None: ... @@ -352,9 +350,8 @@ class QNearFieldShareManager(QtCore.QObject): class QNearFieldShareTarget(QtCore.QObject): - - def shareFinished(self) -> None: ... - def error(self, error: QNearFieldShareManager.ShareError) -> None: ... + shareFinished: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] def shareError(self) -> QNearFieldShareManager.ShareError: ... def isShareInProgress(self) -> bool: ... def cancel(self) -> None: ... @@ -447,11 +444,11 @@ class QNearFieldTarget(QtCore.QObject): def disconnect(self) -> bool: ... # type: ignore[override] def setKeepConnection(self, isPersistent: bool) -> bool: ... def keepConnection(self) -> bool: ... - def error(self, error: 'QNearFieldTarget.Error', id: 'QNearFieldTarget.RequestId') -> None: ... - def requestCompleted(self, id: 'QNearFieldTarget.RequestId') -> None: ... - def ndefMessagesWritten(self) -> None: ... - def ndefMessageRead(self, message: QNdefMessage) -> None: ... - def disconnected(self) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + requestCompleted: typing.ClassVar[QtCore.pyqtSignal] + ndefMessagesWritten: typing.ClassVar[QtCore.pyqtSignal] + ndefMessageRead: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] def reportError(self, error: 'QNearFieldTarget.Error', id: 'QNearFieldTarget.RequestId') -> None: ... def handleResponse(self, id: 'QNearFieldTarget.RequestId', response: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> bool: ... def setResponseForRequest(self, id: 'QNearFieldTarget.RequestId', response: typing.Any, emitRequestCompleted: bool = ...) -> None: ... @@ -490,10 +487,9 @@ class QQmlNdefRecord(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, record: QNdefRecord, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def recordChanged(self) -> None: ... - def typeNameFormatChanged(self) -> None: ... - def typeChanged(self) -> None: ... + recordChanged: typing.ClassVar[QtCore.pyqtSignal] + typeNameFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + typeChanged: typing.ClassVar[QtCore.pyqtSignal] def setRecord(self, record: QNdefRecord) -> None: ... def record(self) -> QNdefRecord: ... def typeNameFormat(self) -> 'QQmlNdefRecord.TypeNameFormat': ... diff --git a/PyQt5-stubs/QtPositioning.pyi b/PyQt5-stubs/QtPositioning.pyi index de57e255..d4914699 100644 --- a/PyQt5-stubs/QtPositioning.pyi +++ b/PyQt5-stubs/QtPositioning.pyi @@ -119,10 +119,9 @@ class QGeoAreaMonitorSource(QtCore.QObject): def __int__(self) -> int: ... def __init__(self, parent: QtCore.QObject) -> None: ... - - def monitorExpired(self, monitor: QGeoAreaMonitorInfo) -> None: ... - def areaExited(self, monitor: QGeoAreaMonitorInfo, update: 'QGeoPositionInfo') -> None: ... - def areaEntered(self, monitor: QGeoAreaMonitorInfo, update: 'QGeoPositionInfo') -> None: ... + monitorExpired: typing.ClassVar[QtCore.pyqtSignal] + areaExited: typing.ClassVar[QtCore.pyqtSignal] + areaEntered: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def activeMonitors(self) -> typing.List[QGeoAreaMonitorInfo]: ... @typing.overload @@ -131,10 +130,7 @@ class QGeoAreaMonitorSource(QtCore.QObject): def stopMonitoring(self, monitor: QGeoAreaMonitorInfo) -> bool: ... def startMonitoring(self, monitor: QGeoAreaMonitorInfo) -> bool: ... def supportedAreaMonitorFeatures(self) -> 'QGeoAreaMonitorSource.AreaMonitorFeatures': ... - @typing.overload - def error(self) -> 'QGeoAreaMonitorSource.Error': ... - @typing.overload - def error(self, error: 'QGeoAreaMonitorSource.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def sourceName(self) -> str: ... def positionInfoSource(self) -> 'QGeoPositionInfoSource': ... def setPositionInfoSource(self, source: 'QGeoPositionInfoSource') -> None: ... @@ -414,14 +410,13 @@ class QGeoPositionInfoSource(QtCore.QObject): def backendProperty(self, name: str) -> typing.Any: ... def setBackendProperty(self, name: str, value: typing.Any) -> bool: ... - def supportedPositioningMethodsChanged(self) -> None: ... - def updateTimeout(self) -> None: ... - def positionUpdated(self, update: QGeoPositionInfo) -> None: ... + supportedPositioningMethodsChanged: typing.ClassVar[QtCore.pyqtSignal] + updateTimeout: typing.ClassVar[QtCore.pyqtSignal] + positionUpdated: typing.ClassVar[QtCore.pyqtSignal] def requestUpdate(self, timeout: int = ...) -> None: ... def stopUpdates(self) -> None: ... def startUpdates(self) -> None: ... - # If the error signal is real, it isn't accessible in PyQt 5.15.1 - def error(self) -> 'QGeoPositionInfoSource.Error': ... + error: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def availableSources() -> typing.List[str]: ... @typing.overload @@ -533,17 +528,13 @@ class QGeoSatelliteInfoSource(QtCore.QObject): UnknownSourceError = ... # type: QGeoSatelliteInfoSource.Error def __init__(self, parent: QtCore.QObject) -> None: ... - - def requestTimeout(self) -> None: ... - def satellitesInUseUpdated(self, satellites: typing.Iterable[QGeoSatelliteInfo]) -> None: ... - def satellitesInViewUpdated(self, satellites: typing.Iterable[QGeoSatelliteInfo]) -> None: ... + requestTimeout: typing.ClassVar[QtCore.pyqtSignal] + satellitesInUseUpdated: typing.ClassVar[QtCore.pyqtSignal] + satellitesInViewUpdated: typing.ClassVar[QtCore.pyqtSignal] def requestUpdate(self, timeout: int = ...) -> None: ... def stopUpdates(self) -> None: ... def startUpdates(self) -> None: ... - @typing.overload - def error(self) -> 'QGeoSatelliteInfoSource.Error': ... - @typing.overload - def error(self, a0: 'QGeoSatelliteInfoSource.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def minimumUpdateInterval(self) -> int: ... def updateInterval(self) -> int: ... def setUpdateInterval(self, msec: int) -> None: ... diff --git a/PyQt5-stubs/QtPrintSupport.pyi b/PyQt5-stubs/QtPrintSupport.pyi index c49a0efa..4c6c6977 100644 --- a/PyQt5-stubs/QtPrintSupport.pyi +++ b/PyQt5-stubs/QtPrintSupport.pyi @@ -128,11 +128,7 @@ class QPrintDialog(QAbstractPrintDialog): def __init__(self, printer: 'QPrinter', parent: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... - - @typing.overload # type: ignore[override] - def accepted(self) -> None: ... - @typing.overload - def accepted(self, printer: 'QPrinter') -> None: ... + accepted: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def open(self) -> None: ... @typing.overload diff --git a/PyQt5-stubs/QtPurchasing.pyi b/PyQt5-stubs/QtPurchasing.pyi index 5dc2605a..45707d83 100644 --- a/PyQt5-stubs/QtPurchasing.pyi +++ b/PyQt5-stubs/QtPurchasing.pyi @@ -52,10 +52,9 @@ class QInAppProduct(QtCore.QObject): class QInAppStore(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def transactionReady(self, transaction: 'QInAppTransaction') -> None: ... - def productUnknown(self, productType: QInAppProduct.ProductType, identifier: str) -> None: ... - def productRegistered(self, product: QInAppProduct) -> None: ... + transactionReady: typing.ClassVar[QtCore.pyqtSignal] + productUnknown: typing.ClassVar[QtCore.pyqtSignal] + productRegistered: typing.ClassVar[QtCore.pyqtSignal] def setPlatformProperty(self, propertyName: str, value: str) -> None: ... def registeredProduct(self, identifier: str) -> QInAppProduct: ... def registerProduct(self, productType: QInAppProduct.ProductType, identifier: str) -> None: ... diff --git a/PyQt5-stubs/QtQml.pyi b/PyQt5-stubs/QtQml.pyi index 78e530bd..c285e435 100644 --- a/PyQt5-stubs/QtQml.pyi +++ b/PyQt5-stubs/QtQml.pyi @@ -65,8 +65,7 @@ class QJSEngine(QtCore.QObject): def __init__(self) -> None: ... @typing.overload def __init__(self, parent: QtCore.QObject) -> None: ... - - def uiLanguageChanged(self) -> None: ... + uiLanguageChanged: typing.ClassVar[QtCore.pyqtSignal] def setUiLanguage(self, language: str) -> None: ... def uiLanguage(self) -> str: ... def isInterrupted(self) -> bool: ... @@ -299,8 +298,8 @@ class QQmlComponent(QtCore.QObject): def setInitialProperties(self, component: QtCore.QObject, properties: typing.Dict[str, typing.Any]) -> None: ... def engine(self) -> QQmlEngine: ... - def progressChanged(self, a0: float) -> None: ... - def statusChanged(self, a0: 'QQmlComponent.Status') -> None: ... + progressChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] def setData(self, a0: typing.Union[QtCore.QByteArray, bytes, bytearray], baseUrl: QtCore.QUrl) -> None: ... @typing.overload def loadUrl(self, url: QtCore.QUrl) -> None: ... @@ -428,8 +427,7 @@ class QQmlExpression(QtCore.QObject): def __init__(self, a0: QQmlContext, a1: QtCore.QObject, a2: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, a0: 'QQmlScriptString', context: typing.Optional[QQmlContext] = ..., scope: typing.Optional[QtCore.QObject] = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def valueChanged(self) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def evaluate(self) -> typing.Tuple[typing.Any, bool]: ... def error(self) -> QQmlError: ... def clearError(self) -> None: ... @@ -663,7 +661,7 @@ class QQmlPropertyMap(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def updateValue(self, key: str, input: typing.Any) -> typing.Any: ... - def valueChanged(self, key: str, value: typing.Any) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def __getitem__(self, key: str) -> typing.Any: ... def contains(self, key: str) -> bool: ... def isEmpty(self) -> bool: ... diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 0f9ea248..662e8c63 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -141,8 +141,7 @@ class QQuickItem(QtCore.QObject, QtQml.QQmlParserStatus): def __init__(self, a0: 'QQuickItem.UpdatePaintNodeData') -> None: ... def __init__(self, parent: typing.Optional['QQuickItem'] = ...) -> None: ... - - def containmentMaskChanged(self) -> None: ... + containmentMaskChanged: typing.ClassVar[QtCore.pyqtSignal] def setContainmentMask(self, mask: QtCore.QObject) -> None: ... def containmentMask(self) -> QtCore.QObject: ... def setAcceptTouchEvents(self, accept: bool) -> None: ... @@ -153,7 +152,7 @@ class QQuickItem(QtCore.QObject, QtQml.QQmlParserStatus): def isAncestorOf(self, child: 'QQuickItem') -> bool: ... def grabToImage(self, targetSize: QtCore.QSize = ...) -> 'QQuickItemGrabResult': ... def resetAntialiasing(self) -> None: ... - def windowChanged(self, window: 'QQuickWindow') -> None: ... + windowChanged: typing.ClassVar[QtCore.pyqtSignal] def nextItemInFocusChain(self, forward: bool = ...) -> 'QQuickItem': ... def setActiveFocusOnTab(self, a0: bool) -> None: ... def activeFocusOnTab(self) -> bool: ... @@ -301,14 +300,13 @@ class QQuickFramebufferObject(QQuickItem): def render(self) -> None: ... def __init__(self, parent: typing.Optional[QQuickItem] = ...) -> None: ... - - def mirrorVerticallyChanged(self, a0: bool) -> None: ... + mirrorVerticallyChanged: typing.ClassVar[QtCore.pyqtSignal] def setMirrorVertically(self, enable: bool) -> None: ... def mirrorVertically(self) -> bool: ... def releaseResources(self) -> None: ... def textureProvider(self) -> 'QSGTextureProvider': ... def isTextureProvider(self) -> bool: ... - def textureFollowsItemSizeChanged(self, a0: bool) -> None: ... + textureFollowsItemSizeChanged: typing.ClassVar[QtCore.pyqtSignal] def updatePaintNode(self, a0: 'QSGNode', a1: QQuickItem.UpdatePaintNodeData) -> 'QSGNode': ... def geometryChanged(self, newGeometry: QtCore.QRectF, oldGeometry: QtCore.QRectF) -> None: ... def createRenderer(self) -> 'QQuickFramebufferObject.Renderer': ... @@ -345,8 +343,7 @@ class QQuickImageProvider(QtQml.QQmlImageProviderBase): class QQuickImageResponse(QtCore.QObject): def __init__(self) -> None: ... - - def finished(self) -> None: ... + finished: typing.ClassVar[QtCore.pyqtSignal] def cancel(self) -> None: ... def errorString(self) -> str: ... def textureFactory(self) -> QQuickTextureFactory: ... @@ -363,8 +360,7 @@ class QQuickAsyncImageProvider(QQuickImageProvider): class QQuickItemGrabResult(QtCore.QObject): - - def ready(self) -> None: ... + ready: typing.ClassVar[QtCore.pyqtSignal] def event(self, a0: QtCore.QEvent) -> bool: ... def saveToFile(self, fileName: str) -> bool: ... def url(self) -> QtCore.QUrl: ... @@ -403,8 +399,7 @@ class QQuickPaintedItem(QQuickItem): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[QQuickItem] = ...) -> None: ... - - def textureSizeChanged(self) -> None: ... + textureSizeChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureSize(self, size: QtCore.QSize) -> None: ... def textureSize(self) -> QtCore.QSize: ... def itemChange(self, a0: QQuickItem.ItemChange, a1: QQuickItem.ItemChangeData) -> None: ... @@ -412,10 +407,10 @@ class QQuickPaintedItem(QQuickItem): def textureProvider(self) -> 'QSGTextureProvider': ... def isTextureProvider(self) -> bool: ... def updatePaintNode(self, a0: 'QSGNode', a1: QQuickItem.UpdatePaintNodeData) -> 'QSGNode': ... - def renderTargetChanged(self) -> None: ... - def contentsScaleChanged(self) -> None: ... - def contentsSizeChanged(self) -> None: ... - def fillColorChanged(self) -> None: ... + renderTargetChanged: typing.ClassVar[QtCore.pyqtSignal] + contentsScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + contentsSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + fillColorChanged: typing.ClassVar[QtCore.pyqtSignal] def paint(self, painter: QtGui.QPainter) -> None: ... def setRenderTarget(self, target: 'QQuickPaintedItem.RenderTarget') -> None: ... def renderTarget(self) -> 'QQuickPaintedItem.RenderTarget': ... @@ -442,9 +437,8 @@ class QQuickPaintedItem(QQuickItem): class QQuickRenderControl(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def sceneChanged(self) -> None: ... - def renderRequested(self) -> None: ... + sceneChanged: typing.ClassVar[QtCore.pyqtSignal] + renderRequested: typing.ClassVar[QtCore.pyqtSignal] def prepareThread(self, targetThread: QtCore.QThread) -> None: ... def renderWindow(self, offset: QtCore.QPoint) -> QtGui.QWindow: ... @staticmethod @@ -651,7 +645,7 @@ class QQuickView(QQuickWindow): def keyPressEvent(self, a0: QtGui.QKeyEvent) -> None: ... def timerEvent(self, a0: QtCore.QTimerEvent) -> None: ... def resizeEvent(self, a0: QtGui.QResizeEvent) -> None: ... - def statusChanged(self, a0: 'QQuickView.Status') -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] def setInitialProperties(self, initialProperties: typing.Dict[str, typing.Any]) -> None: ... def setSource(self, a0: QtCore.QUrl) -> None: ... def initialSize(self) -> QtCore.QSize: ... @@ -713,8 +707,7 @@ class QSGAbstractRenderer(QtCore.QObject): def __invert__(self) -> 'QSGAbstractRenderer.MatrixTransformFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - - def sceneGraphChanged(self) -> None: ... + sceneGraphChanged: typing.ClassVar[QtCore.pyqtSignal] def renderScene(self, fboId: int = ...) -> None: ... def clearMode(self) -> 'QSGAbstractRenderer.ClearMode': ... def setClearMode(self, mode: typing.Union['QSGAbstractRenderer.ClearMode', 'QSGAbstractRenderer.ClearModeBit']) -> None: ... @@ -1804,8 +1797,7 @@ class QSGTextureMaterial(QSGOpaqueTextureMaterial): class QSGTextureProvider(QtCore.QObject): def __init__(self) -> None: ... - - def textureChanged(self) -> None: ... + textureChanged: typing.ClassVar[QtCore.pyqtSignal] def texture(self) -> QSGTexture: ... diff --git a/PyQt5-stubs/QtQuickWidgets.pyi b/PyQt5-stubs/QtQuickWidgets.pyi index e3cc6b57..62c14f4b 100644 --- a/PyQt5-stubs/QtQuickWidgets.pyi +++ b/PyQt5-stubs/QtQuickWidgets.pyi @@ -92,8 +92,8 @@ class QQuickWidget(QtWidgets.QWidget): def keyPressEvent(self, a0: QtGui.QKeyEvent) -> None: ... def timerEvent(self, a0: QtCore.QTimerEvent) -> None: ... def resizeEvent(self, a0: QtGui.QResizeEvent) -> None: ... - def sceneGraphError(self, error: QtQuick.QQuickWindow.SceneGraphError, message: str) -> None: ... - def statusChanged(self, a0: 'QQuickWidget.Status') -> None: ... + sceneGraphError: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] def setSource(self, a0: QtCore.QUrl) -> None: ... def format(self) -> QtGui.QSurfaceFormat: ... def setFormat(self, format: QtGui.QSurfaceFormat) -> None: ... diff --git a/PyQt5-stubs/QtRemoteObjects.pyi b/PyQt5-stubs/QtRemoteObjects.pyi index 8ae155b2..142f600d 100644 --- a/PyQt5-stubs/QtRemoteObjects.pyi +++ b/PyQt5-stubs/QtRemoteObjects.pyi @@ -33,8 +33,7 @@ PYQT_SLOT = typing.Union[typing.Callable[..., None], QtCore.pyqtBoundSignal] class QAbstractItemModelReplica(QtCore.QAbstractItemModel): - - def initialized(self) -> None: ... + initialized: typing.ClassVar[QtCore.pyqtSignal] def setRootCacheSize(self, rootCacheSize: int) -> None: ... def rootCacheSize(self) -> int: ... def hasData(self, index: QtCore.QModelIndex, role: int) -> bool: ... @@ -67,10 +66,9 @@ class QRemoteObjectReplica(QtCore.QObject): Valid = ... # type: QRemoteObjectReplica.State Suspect = ... # type: QRemoteObjectReplica.State SignatureMismatch = ... # type: QRemoteObjectReplica.State - - def notified(self) -> None: ... - def stateChanged(self, state: 'QRemoteObjectReplica.State', oldState: 'QRemoteObjectReplica.State') -> None: ... - def initialized(self) -> None: ... + notified: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + initialized: typing.ClassVar[QtCore.pyqtSignal] def setNode(self, node: 'QRemoteObjectNode') -> None: ... def node(self) -> 'QRemoteObjectNode': ... def state(self) -> 'QRemoteObjectReplica.State': ... @@ -125,10 +123,10 @@ class QRemoteObjectNode(QtCore.QObject): def __init__(self, registryAddress: QtCore.QUrl, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def timerEvent(self, a0: QtCore.QTimerEvent) -> None: ... - def heartbeatIntervalChanged(self, heartbeatInterval: int) -> None: ... - def error(self, errorCode: 'QRemoteObjectNode.ErrorCode') -> None: ... - def remoteObjectRemoved(self, a0: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... - def remoteObjectAdded(self, a0: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... + heartbeatIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + remoteObjectRemoved: typing.ClassVar[QtCore.pyqtSignal] + remoteObjectAdded: typing.ClassVar[QtCore.pyqtSignal] def setHeartbeatInterval(self, interval: int) -> None: ... def heartbeatInterval(self) -> int: ... def lastError(self) -> 'QRemoteObjectNode.ErrorCode': ... @@ -174,8 +172,7 @@ class QRemoteObjectHost(QRemoteObjectHostBase): def __init__(self, address: QtCore.QUrl, registryAddress: QtCore.QUrl = ..., allowedSchemas: QRemoteObjectHostBase.AllowedSchemas = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, address: QtCore.QUrl, parent: QtCore.QObject) -> None: ... - - def hostUrlChanged(self) -> None: ... + hostUrlChanged: typing.ClassVar[QtCore.pyqtSignal] def setHostUrl(self, hostAddress: QtCore.QUrl, allowedSchemas: QRemoteObjectHostBase.AllowedSchemas = ...) -> bool: ... def hostUrl(self) -> QtCore.QUrl: ... @@ -188,9 +185,8 @@ class QRemoteObjectRegistryHost(QRemoteObjectHostBase): class QRemoteObjectRegistry(QRemoteObjectReplica): - - def remoteObjectRemoved(self, entry: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... - def remoteObjectAdded(self, entry: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... + remoteObjectRemoved: typing.ClassVar[QtCore.pyqtSignal] + remoteObjectAdded: typing.ClassVar[QtCore.pyqtSignal] def sourceLocations(self) -> typing.Dict[str, 'QRemoteObjectSourceLocationInfo']: ... diff --git a/PyQt5-stubs/QtSensors.pyi b/PyQt5-stubs/QtSensors.pyi index 017cbd80..b94922ec 100644 --- a/PyQt5-stubs/QtSensors.pyi +++ b/PyQt5-stubs/QtSensors.pyi @@ -101,21 +101,20 @@ class QSensor(QtCore.QObject): PressureSensorTemperature = ... # type: QSensor.Feature def __init__(self, type: typing.Union[QtCore.QByteArray, bytes, bytearray], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def bufferSizeChanged(self, bufferSize: int) -> None: ... - def efficientBufferSizeChanged(self, efficientBufferSize: int) -> None: ... - def maxBufferSizeChanged(self, maxBufferSize: int) -> None: ... - def userOrientationChanged(self, userOrientation: int) -> None: ... - def currentOrientationChanged(self, currentOrientation: int) -> None: ... - def axesOrientationModeChanged(self, axesOrientationMode: 'QSensor.AxesOrientationMode') -> None: ... - def skipDuplicatesChanged(self, skipDuplicates: bool) -> None: ... - def dataRateChanged(self) -> None: ... - def alwaysOnChanged(self) -> None: ... - def availableSensorsChanged(self) -> None: ... - def sensorError(self, error: int) -> None: ... - def readingChanged(self) -> None: ... - def activeChanged(self) -> None: ... - def busyChanged(self) -> None: ... + bufferSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + efficientBufferSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxBufferSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + userOrientationChanged: typing.ClassVar[QtCore.pyqtSignal] + currentOrientationChanged: typing.ClassVar[QtCore.pyqtSignal] + axesOrientationModeChanged: typing.ClassVar[QtCore.pyqtSignal] + skipDuplicatesChanged: typing.ClassVar[QtCore.pyqtSignal] + dataRateChanged: typing.ClassVar[QtCore.pyqtSignal] + alwaysOnChanged: typing.ClassVar[QtCore.pyqtSignal] + availableSensorsChanged: typing.ClassVar[QtCore.pyqtSignal] + sensorError: typing.ClassVar[QtCore.pyqtSignal] + readingChanged: typing.ClassVar[QtCore.pyqtSignal] + activeChanged: typing.ClassVar[QtCore.pyqtSignal] + busyChanged: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def start(self) -> bool: ... def setBufferSize(self, bufferSize: int) -> None: ... @@ -175,8 +174,7 @@ class QAccelerometer(QSensor): User = ... # type: QAccelerometer.AccelerationMode def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def accelerationModeChanged(self, accelerationMode: 'QAccelerometer.AccelerationMode') -> None: ... + accelerationModeChanged: typing.ClassVar[QtCore.pyqtSignal] def reading(self) -> QAccelerometerReading: ... def setAccelerationMode(self, accelerationMode: 'QAccelerometer.AccelerationMode') -> None: ... def accelerationMode(self) -> 'QAccelerometer.AccelerationMode': ... @@ -413,9 +411,8 @@ class QIRProximitySensor(QSensor): class QLidReading(QSensorReading): - - def frontLidChanged(self, closed: bool) -> None: ... - def backLidChanged(self, closed: bool) -> None: ... + frontLidChanged: typing.ClassVar[QtCore.pyqtSignal] + backLidChanged: typing.ClassVar[QtCore.pyqtSignal] def setFrontLidClosed(self, closed: bool) -> None: ... def frontLidClosed(self) -> bool: ... def setBackLidClosed(self, closed: bool) -> None: ... @@ -458,8 +455,7 @@ class QLightFilter(QSensorFilter): class QLightSensor(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def fieldOfViewChanged(self, fieldOfView: float) -> None: ... + fieldOfViewChanged: typing.ClassVar[QtCore.pyqtSignal] def setFieldOfView(self, fieldOfView: float) -> None: ... def fieldOfView(self) -> float: ... def reading(self) -> QLightReading: ... @@ -490,8 +486,7 @@ class QMagnetometerFilter(QSensorFilter): class QMagnetometer(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def returnGeoValuesChanged(self, returnGeoValues: bool) -> None: ... + returnGeoValuesChanged: typing.ClassVar[QtCore.pyqtSignal] def setReturnGeoValues(self, returnGeoValues: bool) -> None: ... def returnGeoValues(self) -> bool: ... def reading(self) -> QMagnetometerReading: ... @@ -647,8 +642,7 @@ class QTapFilter(QSensorFilter): class QTapSensor(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def returnDoubleTapEventsChanged(self, returnDoubleTapEvents: bool) -> None: ... + returnDoubleTapEventsChanged: typing.ClassVar[QtCore.pyqtSignal] def setReturnDoubleTapEvents(self, returnDoubleTapEvents: bool) -> None: ... def returnDoubleTapEvents(self) -> bool: ... def reading(self) -> QTapReading: ... @@ -701,8 +695,7 @@ class QRotationFilter(QSensorFilter): class QRotationSensor(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def hasZChanged(self, hasZ: bool) -> None: ... + hasZChanged: typing.ClassVar[QtCore.pyqtSignal] def setHasZ(self, hasZ: bool) -> None: ... def hasZ(self) -> bool: ... def reading(self) -> QRotationReading: ... diff --git a/PyQt5-stubs/QtSerialPort.pyi b/PyQt5-stubs/QtSerialPort.pyi index 607e7f50..aea12ea3 100644 --- a/PyQt5-stubs/QtSerialPort.pyi +++ b/PyQt5-stubs/QtSerialPort.pyi @@ -219,23 +219,22 @@ class QSerialPort(QtCore.QIODevice): def __init__(self, name: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, info: 'QSerialPortInfo', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def errorOccurred(self, error: 'QSerialPort.SerialPortError') -> None: ... - def breakEnabledChanged(self, set: bool) -> None: ... + errorOccurred: typing.ClassVar[QtCore.pyqtSignal] + breakEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] def isBreakEnabled(self) -> bool: ... def handle(self) -> int: ... def writeData(self, data: bytes) -> int: ... def readLineData(self, maxlen: int) -> bytes: ... def readData(self, maxlen: int) -> bytes: ... - def settingsRestoredOnCloseChanged(self, restore: bool) -> None: ... - def requestToSendChanged(self, set: bool) -> None: ... - def dataTerminalReadyChanged(self, set: bool) -> None: ... - def dataErrorPolicyChanged(self, policy: 'QSerialPort.DataErrorPolicy') -> None: ... - def flowControlChanged(self, flow: 'QSerialPort.FlowControl') -> None: ... - def stopBitsChanged(self, stopBits: 'QSerialPort.StopBits') -> None: ... - def parityChanged(self, parity: 'QSerialPort.Parity') -> None: ... - def dataBitsChanged(self, dataBits: 'QSerialPort.DataBits') -> None: ... - def baudRateChanged(self, baudRate: int, directions: typing.Union['QSerialPort.Directions', 'QSerialPort.Direction']) -> None: ... + settingsRestoredOnCloseChanged: typing.ClassVar[QtCore.pyqtSignal] + requestToSendChanged: typing.ClassVar[QtCore.pyqtSignal] + dataTerminalReadyChanged: typing.ClassVar[QtCore.pyqtSignal] + dataErrorPolicyChanged: typing.ClassVar[QtCore.pyqtSignal] + flowControlChanged: typing.ClassVar[QtCore.pyqtSignal] + stopBitsChanged: typing.ClassVar[QtCore.pyqtSignal] + parityChanged: typing.ClassVar[QtCore.pyqtSignal] + dataBitsChanged: typing.ClassVar[QtCore.pyqtSignal] + baudRateChanged: typing.ClassVar[QtCore.pyqtSignal] def setBreakEnabled(self, enabled: bool = ...) -> bool: ... def sendBreak(self, duration: int = ...) -> bool: ... def waitForBytesWritten(self, msecs: int = ...) -> bool: ... @@ -247,10 +246,7 @@ class QSerialPort(QtCore.QIODevice): def setReadBufferSize(self, size: int) -> None: ... def readBufferSize(self) -> int: ... def clearError(self) -> None: ... - @typing.overload - def error(self) -> 'QSerialPort.SerialPortError': ... - @typing.overload - def error(self, serialPortError: 'QSerialPort.SerialPortError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def dataErrorPolicy(self) -> 'QSerialPort.DataErrorPolicy': ... def setDataErrorPolicy(self, policy: 'QSerialPort.DataErrorPolicy' = ...) -> bool: ... def atEnd(self) -> bool: ... diff --git a/PyQt5-stubs/QtSql.pyi b/PyQt5-stubs/QtSql.pyi index 160fcf4e..558e4ea9 100644 --- a/PyQt5-stubs/QtSql.pyi +++ b/PyQt5-stubs/QtSql.pyi @@ -213,10 +213,7 @@ class QSqlDriver(QtCore.QObject): def setNumericalPrecisionPolicy(self, precisionPolicy: 'QSql.NumericalPrecisionPolicy') -> None: ... def stripDelimiters(self, identifier: str, type: 'QSqlDriver.IdentifierType') -> str: ... def isIdentifierEscaped(self, identifier: str, type: 'QSqlDriver.IdentifierType') -> bool: ... - @typing.overload - def notification(self, name: str) -> None: ... - @typing.overload - def notification(self, name: str, source: 'QSqlDriver.NotificationSource', payload: typing.Any) -> None: ... + notification: typing.ClassVar[QtCore.pyqtSignal] def subscribedToNotifications(self) -> typing.List[str]: ... def unsubscribeFromNotification(self, name: str) -> bool: ... def subscribeToNotification(self, name: str) -> bool: ... @@ -560,10 +557,10 @@ class QSqlTableModel(QSqlQueryModel): def deleteRowFromTable(self, row: int) -> bool: ... def insertRowIntoTable(self, values: QSqlRecord) -> bool: ... def updateRowInTable(self, row: int, values: QSqlRecord) -> bool: ... - def beforeDelete(self, row: int) -> None: ... - def beforeUpdate(self, row: int, record: QSqlRecord) -> None: ... - def beforeInsert(self, record: QSqlRecord) -> None: ... - def primeInsert(self, row: int, record: QSqlRecord) -> None: ... + beforeDelete: typing.ClassVar[QtCore.pyqtSignal] + beforeUpdate: typing.ClassVar[QtCore.pyqtSignal] + beforeInsert: typing.ClassVar[QtCore.pyqtSignal] + primeInsert: typing.ClassVar[QtCore.pyqtSignal] def revertAll(self) -> None: ... def submitAll(self) -> bool: ... def revert(self) -> None: ... diff --git a/PyQt5-stubs/QtSvg.pyi b/PyQt5-stubs/QtSvg.pyi index 97d2b50b..608b3393 100644 --- a/PyQt5-stubs/QtSvg.pyi +++ b/PyQt5-stubs/QtSvg.pyi @@ -98,7 +98,7 @@ class QSvgRenderer(QtCore.QObject): def transformForElement(self, id: str) -> QtGui.QTransform: ... def setAspectRatioMode(self, mode: QtCore.Qt.AspectRatioMode) -> None: ... def aspectRatioMode(self) -> QtCore.Qt.AspectRatioMode: ... - def repaintNeeded(self) -> None: ... + repaintNeeded: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def render(self, p: QtGui.QPainter) -> None: ... @typing.overload diff --git a/PyQt5-stubs/QtWebChannel.pyi b/PyQt5-stubs/QtWebChannel.pyi index 4ff9b336..2a5bd122 100644 --- a/PyQt5-stubs/QtWebChannel.pyi +++ b/PyQt5-stubs/QtWebChannel.pyi @@ -38,7 +38,7 @@ class QWebChannel(QtCore.QObject): def disconnectFrom(self, transport: 'QWebChannelAbstractTransport') -> None: ... def connectTo(self, transport: 'QWebChannelAbstractTransport') -> None: ... - def blockUpdatesChanged(self, block: bool) -> None: ... + blockUpdatesChanged: typing.ClassVar[QtCore.pyqtSignal] def setBlockUpdates(self, block: bool) -> None: ... def blockUpdates(self) -> bool: ... def deregisterObject(self, object: QtCore.QObject) -> None: ... @@ -50,6 +50,5 @@ class QWebChannel(QtCore.QObject): class QWebChannelAbstractTransport(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def messageReceived(self, message: typing.Dict[str, typing.Union[QtCore.QJsonValue, QtCore.QJsonValue.Type, typing.Iterable[QtCore.QJsonValue], bool, int, float, None, str]], transport: 'QWebChannelAbstractTransport') -> None: ... + messageReceived: typing.ClassVar[QtCore.pyqtSignal] def sendMessage(self, message: typing.Dict[str, typing.Union[QtCore.QJsonValue, QtCore.QJsonValue.Type, typing.Iterable[QtCore.QJsonValue], bool, int, float, None, str]]) -> None: ... diff --git a/PyQt5-stubs/QtWebEngine.pyi b/PyQt5-stubs/QtWebEngine.pyi index 7b3c7fe0..2b78da94 100644 --- a/PyQt5-stubs/QtWebEngine.pyi +++ b/PyQt5-stubs/QtWebEngine.pyi @@ -60,30 +60,29 @@ class QQuickWebEngineProfile(QtCore.QObject): NoCache = ... # type: QQuickWebEngineProfile.HttpCacheType def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def presentNotification(self, notification: QtWebEngineCore.QWebEngineNotification) -> None: ... - def downloadPathChanged(self) -> None: ... - def useForGlobalCertificateVerificationChanged(self) -> None: ... + presentNotification: typing.ClassVar[QtCore.pyqtSignal] + downloadPathChanged: typing.ClassVar[QtCore.pyqtSignal] + useForGlobalCertificateVerificationChanged: typing.ClassVar[QtCore.pyqtSignal] def clientCertificateStore(self) -> QtWebEngineCore.QWebEngineClientCertificateStore: ... def setDownloadPath(self, path: str) -> None: ... def downloadPath(self) -> str: ... def isUsedForGlobalCertificateVerification(self) -> bool: ... def setUseForGlobalCertificateVerification(self, b: bool) -> None: ... - def spellCheckEnabledChanged(self) -> None: ... - def spellCheckLanguagesChanged(self) -> None: ... + spellCheckEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + spellCheckLanguagesChanged: typing.ClassVar[QtCore.pyqtSignal] def isSpellCheckEnabled(self) -> bool: ... def setSpellCheckEnabled(self, enabled: bool) -> None: ... def spellCheckLanguages(self) -> typing.List[str]: ... def setSpellCheckLanguages(self, languages: typing.Iterable[str]) -> None: ... - def httpAcceptLanguageChanged(self) -> None: ... - def httpCacheMaximumSizeChanged(self) -> None: ... - def persistentCookiesPolicyChanged(self) -> None: ... - def httpCacheTypeChanged(self) -> None: ... - def httpUserAgentChanged(self) -> None: ... - def cachePathChanged(self) -> None: ... - def persistentStoragePathChanged(self) -> None: ... - def offTheRecordChanged(self) -> None: ... - def storageNameChanged(self) -> None: ... + httpAcceptLanguageChanged: typing.ClassVar[QtCore.pyqtSignal] + httpCacheMaximumSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + persistentCookiesPolicyChanged: typing.ClassVar[QtCore.pyqtSignal] + httpCacheTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + httpUserAgentChanged: typing.ClassVar[QtCore.pyqtSignal] + cachePathChanged: typing.ClassVar[QtCore.pyqtSignal] + persistentStoragePathChanged: typing.ClassVar[QtCore.pyqtSignal] + offTheRecordChanged: typing.ClassVar[QtCore.pyqtSignal] + storageNameChanged: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def defaultProfile() -> 'QQuickWebEngineProfile': ... def clearHttpCache(self) -> None: ... @@ -138,12 +137,12 @@ class QQuickWebEngineScript(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def timerEvent(self, e: QtCore.QTimerEvent) -> None: ... - def runOnSubframesChanged(self, on: bool) -> None: ... - def worldIdChanged(self, scriptWorldId: 'QQuickWebEngineScript.ScriptWorldId') -> None: ... - def injectionPointChanged(self, injectionPoint: 'QQuickWebEngineScript.InjectionPoint') -> None: ... - def sourceCodeChanged(self, code: str) -> None: ... - def sourceUrlChanged(self, url: QtCore.QUrl) -> None: ... - def nameChanged(self, name: str) -> None: ... + runOnSubframesChanged: typing.ClassVar[QtCore.pyqtSignal] + worldIdChanged: typing.ClassVar[QtCore.pyqtSignal] + injectionPointChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] def setRunOnSubframes(self, on: bool) -> None: ... def setWorldId(self, scriptWorldId: 'QQuickWebEngineScript.ScriptWorldId') -> None: ... def setInjectionPoint(self, injectionPoint: 'QQuickWebEngineScript.InjectionPoint') -> None: ... diff --git a/PyQt5-stubs/QtWebEngineCore.pyi b/PyQt5-stubs/QtWebEngineCore.pyi index 4fd28480..8b60c11b 100644 --- a/PyQt5-stubs/QtWebEngineCore.pyi +++ b/PyQt5-stubs/QtWebEngineCore.pyi @@ -65,8 +65,8 @@ class QWebEngineCookieStore(QtCore.QObject): def __init__(self, a0: 'QWebEngineCookieStore.FilterRequest') -> None: ... def setCookieFilter(self, filterCallback: typing.Optional[typing.Callable[[FilterRequest], bool]] = ...) -> None: ... - def cookieRemoved(self, cookie: QtNetwork.QNetworkCookie) -> None: ... - def cookieAdded(self, cookie: QtNetwork.QNetworkCookie) -> None: ... + cookieRemoved: typing.ClassVar[QtCore.pyqtSignal] + cookieAdded: typing.ClassVar[QtCore.pyqtSignal] def loadAllCookies(self) -> None: ... def deleteAllCookies(self) -> None: ... def deleteSessionCookies(self) -> None: ... @@ -116,8 +116,7 @@ class QWebEngineHttpRequest(sip.simplewrapper): class QWebEngineNotification(QtCore.QObject): - - def closed(self) -> None: ... + closed: typing.ClassVar[QtCore.pyqtSignal] def close(self) -> None: ... def click(self) -> None: ... def show(self) -> None: ... diff --git a/PyQt5-stubs/QtWebEngineWidgets.pyi b/PyQt5-stubs/QtWebEngineWidgets.pyi index fe699fc7..f7cda7ee 100644 --- a/PyQt5-stubs/QtWebEngineWidgets.pyi +++ b/PyQt5-stubs/QtWebEngineWidgets.pyi @@ -312,7 +312,7 @@ class QWebEngineDownloadItem(QtCore.QObject): def suggestedFileName(self) -> str: ... def page(self) -> 'QWebEnginePage': ... def isSavePageDownload(self) -> bool: ... - def isPausedChanged(self, isPaused: bool) -> None: ... + isPausedChanged: typing.ClassVar[QtCore.pyqtSignal] def resume(self) -> None: ... def pause(self) -> None: ... def isPaused(self) -> bool: ... @@ -322,9 +322,9 @@ class QWebEngineDownloadItem(QtCore.QObject): def setSavePageFormat(self, format: 'QWebEngineDownloadItem.SavePageFormat') -> None: ... def savePageFormat(self) -> 'QWebEngineDownloadItem.SavePageFormat': ... def mimeType(self) -> str: ... - def downloadProgress(self, bytesReceived: int, bytesTotal: int) -> None: ... - def stateChanged(self, state: 'QWebEngineDownloadItem.DownloadState') -> None: ... - def finished(self) -> None: ... + downloadProgress: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def cancel(self) -> None: ... def accept(self) -> None: ... def isFinished(self) -> bool: ... @@ -593,23 +593,22 @@ class QWebEnginePage(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, profile: 'QWebEngineProfile', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def renderProcessPidChanged(self, pid: int) -> None: ... + renderProcessPidChanged: typing.ClassVar[QtCore.pyqtSignal] def renderProcessPid(self) -> int: ... - def findTextFinished(self, result: QtWebEngineCore.QWebEngineFindTextResult) -> None: ... - def recommendedStateChanged(self, state: 'QWebEnginePage.LifecycleState') -> None: ... - def lifecycleStateChanged(self, state: 'QWebEnginePage.LifecycleState') -> None: ... - def visibleChanged(self, visible: bool) -> None: ... + findTextFinished: typing.ClassVar[QtCore.pyqtSignal] + recommendedStateChanged: typing.ClassVar[QtCore.pyqtSignal] + lifecycleStateChanged: typing.ClassVar[QtCore.pyqtSignal] + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] def setVisible(self, visible: bool) -> None: ... def isVisible(self) -> bool: ... def recommendedState(self) -> 'QWebEnginePage.LifecycleState': ... def setLifecycleState(self, state: 'QWebEnginePage.LifecycleState') -> None: ... def lifecycleState(self) -> 'QWebEnginePage.LifecycleState': ... def setUrlRequestInterceptor(self, interceptor: QtWebEngineCore.QWebEngineUrlRequestInterceptor) -> None: ... - def printRequested(self) -> None: ... - def selectClientCertificate(self, clientCertSelection: QWebEngineClientCertificateSelection) -> None: ... - def registerProtocolHandlerRequested(self, request: QtWebEngineCore.QWebEngineRegisterProtocolHandlerRequest) -> None: ... - def quotaRequested(self, quotaRequest: QtWebEngineCore.QWebEngineQuotaRequest) -> None: ... + printRequested: typing.ClassVar[QtCore.pyqtSignal] + selectClientCertificate: typing.ClassVar[QtCore.pyqtSignal] + registerProtocolHandlerRequested: typing.ClassVar[QtCore.pyqtSignal] + quotaRequested: typing.ClassVar[QtCore.pyqtSignal] def devToolsPage(self) -> 'QWebEnginePage': ... def setDevToolsPage(self, page: 'QWebEnginePage') -> None: ... def inspectedPage(self) -> 'QWebEnginePage': ... @@ -618,12 +617,12 @@ class QWebEnginePage(QtCore.QObject): def print(self, printer: QtPrintSupport.QPrinter, resultCallback: typing.Callable[[bool], None]) -> None: ... def save(self, filePath: str, format: QWebEngineDownloadItem.SavePageFormat = ...) -> None: ... def replaceMisspelledWord(self, replacement: str) -> None: ... - def pdfPrintingFinished(self, filePath: str, success: bool) -> None: ... - def recentlyAudibleChanged(self, recentlyAudible: bool) -> None: ... - def audioMutedChanged(self, muted: bool) -> None: ... - def contentsSizeChanged(self, size: QtCore.QSizeF) -> None: ... - def scrollPositionChanged(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def iconChanged(self, icon: QtGui.QIcon) -> None: ... + pdfPrintingFinished: typing.ClassVar[QtCore.pyqtSignal] + recentlyAudibleChanged: typing.ClassVar[QtCore.pyqtSignal] + audioMutedChanged: typing.ClassVar[QtCore.pyqtSignal] + contentsSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + scrollPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + iconChanged: typing.ClassVar[QtCore.pyqtSignal] def contextMenuData(self) -> QWebEngineContextMenuData: ... @typing.overload def printToPdf(self, filePath: str, pageLayout: QtGui.QPageLayout = ...) -> None: ... @@ -635,8 +634,8 @@ class QWebEnginePage(QtCore.QObject): def contentsSize(self) -> QtCore.QSizeF: ... def scrollPosition(self) -> QtCore.QPointF: ... def icon(self) -> QtGui.QIcon: ... - def renderProcessTerminated(self, terminationStatus: 'QWebEnginePage.RenderProcessTerminationStatus', exitCode: int) -> None: ... - def fullScreenRequested(self, fullScreenRequest: QWebEngineFullScreenRequest) -> None: ... + renderProcessTerminated: typing.ClassVar[QtCore.pyqtSignal] + fullScreenRequested: typing.ClassVar[QtCore.pyqtSignal] def setBackgroundColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def backgroundColor(self) -> QtGui.QColor: ... def acceptNavigationRequest(self, url: QtCore.QUrl, type: 'QWebEnginePage.NavigationType', isMainFrame: bool) -> bool: ... @@ -654,20 +653,20 @@ class QWebEnginePage(QtCore.QObject): def javaScriptAlert(self, securityOrigin: QtCore.QUrl, msg: str) -> None: ... def chooseFiles(self, mode: 'QWebEnginePage.FileSelectionMode', oldFiles: typing.Iterable[str], acceptedMimeTypes: typing.Iterable[str]) -> typing.List[str]: ... def createWindow(self, type: 'QWebEnginePage.WebWindowType') -> 'QWebEnginePage': ... - def iconUrlChanged(self, url: QtCore.QUrl) -> None: ... - def urlChanged(self, url: QtCore.QUrl) -> None: ... - def titleChanged(self, title: str) -> None: ... - def proxyAuthenticationRequired(self, requestUrl: QtCore.QUrl, authenticator: QtNetwork.QAuthenticator, proxyHost: str) -> None: ... - def authenticationRequired(self, requestUrl: QtCore.QUrl, authenticator: QtNetwork.QAuthenticator) -> None: ... - def featurePermissionRequestCanceled(self, securityOrigin: QtCore.QUrl, feature: 'QWebEnginePage.Feature') -> None: ... - def featurePermissionRequested(self, securityOrigin: QtCore.QUrl, feature: 'QWebEnginePage.Feature') -> None: ... - def windowCloseRequested(self) -> None: ... - def geometryChangeRequested(self, geom: QtCore.QRect) -> None: ... - def selectionChanged(self) -> None: ... - def linkHovered(self, url: str) -> None: ... - def loadFinished(self, ok: bool) -> None: ... - def loadProgress(self, progress: int) -> None: ... - def loadStarted(self) -> None: ... + iconUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + urlChanged: typing.ClassVar[QtCore.pyqtSignal] + titleChanged: typing.ClassVar[QtCore.pyqtSignal] + proxyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + authenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + featurePermissionRequestCanceled: typing.ClassVar[QtCore.pyqtSignal] + featurePermissionRequested: typing.ClassVar[QtCore.pyqtSignal] + windowCloseRequested: typing.ClassVar[QtCore.pyqtSignal] + geometryChangeRequested: typing.ClassVar[QtCore.pyqtSignal] + selectionChanged: typing.ClassVar[QtCore.pyqtSignal] + linkHovered: typing.ClassVar[QtCore.pyqtSignal] + loadFinished: typing.ClassVar[QtCore.pyqtSignal] + loadProgress: typing.ClassVar[QtCore.pyqtSignal] + loadStarted: typing.ClassVar[QtCore.pyqtSignal] def settings(self) -> 'QWebEngineSettings': ... @typing.overload def runJavaScript(self, scriptSource: str, worldId: int) -> None: ... @@ -751,7 +750,7 @@ class QWebEngineProfile(QtCore.QObject): def cookieStore(self) -> QtWebEngineCore.QWebEngineCookieStore: ... def httpAcceptLanguage(self) -> str: ... def setHttpAcceptLanguage(self, httpAcceptLanguage: str) -> None: ... - def downloadRequested(self, download: QWebEngineDownloadItem) -> None: ... + downloadRequested: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def defaultProfile() -> 'QWebEngineProfile': ... def scripts(self) -> 'QWebEngineScriptCollection': ... @@ -964,21 +963,21 @@ class QWebEngineView(QtWidgets.QWidget): def dragMoveEvent(self, e: QtGui.QDragMoveEvent) -> None: ... def dragLeaveEvent(self, e: QtGui.QDragLeaveEvent) -> None: ... def dragEnterEvent(self, e: QtGui.QDragEnterEvent) -> None: ... - def iconChanged(self, a0: QtGui.QIcon) -> None: ... + iconChanged: typing.ClassVar[QtCore.pyqtSignal] def icon(self) -> QtGui.QIcon: ... def hideEvent(self, a0: QtGui.QHideEvent) -> None: ... def showEvent(self, a0: QtGui.QShowEvent) -> None: ... def event(self, a0: QtCore.QEvent) -> bool: ... def contextMenuEvent(self, a0: QtGui.QContextMenuEvent) -> None: ... def createWindow(self, type: QWebEnginePage.WebWindowType) -> 'QWebEngineView': ... - def renderProcessTerminated(self, terminationStatus: QWebEnginePage.RenderProcessTerminationStatus, exitCode: int) -> None: ... - def iconUrlChanged(self, a0: QtCore.QUrl) -> None: ... - def urlChanged(self, a0: QtCore.QUrl) -> None: ... - def selectionChanged(self) -> None: ... - def titleChanged(self, title: str) -> None: ... - def loadFinished(self, a0: bool) -> None: ... - def loadProgress(self, progress: int) -> None: ... - def loadStarted(self) -> None: ... + renderProcessTerminated: typing.ClassVar[QtCore.pyqtSignal] + iconUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + urlChanged: typing.ClassVar[QtCore.pyqtSignal] + selectionChanged: typing.ClassVar[QtCore.pyqtSignal] + titleChanged: typing.ClassVar[QtCore.pyqtSignal] + loadFinished: typing.ClassVar[QtCore.pyqtSignal] + loadProgress: typing.ClassVar[QtCore.pyqtSignal] + loadStarted: typing.ClassVar[QtCore.pyqtSignal] def reload(self) -> None: ... def forward(self) -> None: ... def back(self) -> None: ... diff --git a/PyQt5-stubs/QtWebSockets.pyi b/PyQt5-stubs/QtWebSockets.pyi index bdb0d168..b331369a 100644 --- a/PyQt5-stubs/QtWebSockets.pyi +++ b/PyQt5-stubs/QtWebSockets.pyi @@ -58,20 +58,20 @@ class QWebSocket(QtCore.QObject): def maxAllowedIncomingFrameSize(self) -> int: ... def setMaxAllowedIncomingFrameSize(self, maxAllowedIncomingFrameSize: int) -> None: ... def bytesToWrite(self) -> int: ... - def preSharedKeyAuthenticationRequired(self, authenticator: QtNetwork.QSslPreSharedKeyAuthenticator) -> None: ... - def sslErrors(self, errors: typing.Iterable[QtNetwork.QSslError]) -> None: ... - def bytesWritten(self, bytes: int) -> None: ... - def pong(self, elapsedTime: int, payload: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def binaryMessageReceived(self, message: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def textMessageReceived(self, message: str) -> None: ... - def binaryFrameReceived(self, frame: typing.Union[QtCore.QByteArray, bytes, bytearray], isLastFrame: bool) -> None: ... - def textFrameReceived(self, frame: str, isLastFrame: bool) -> None: ... - def readChannelFinished(self) -> None: ... - def proxyAuthenticationRequired(self, proxy: QtNetwork.QNetworkProxy, pAuthenticator: QtNetwork.QAuthenticator) -> None: ... - def stateChanged(self, state: QtNetwork.QAbstractSocket.SocketState) -> None: ... - def disconnected(self) -> None: ... - def connected(self) -> None: ... - def aboutToClose(self) -> None: ... + preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + sslErrors: typing.ClassVar[QtCore.pyqtSignal] + bytesWritten: typing.ClassVar[QtCore.pyqtSignal] + pong: typing.ClassVar[QtCore.pyqtSignal] + binaryMessageReceived: typing.ClassVar[QtCore.pyqtSignal] + textMessageReceived: typing.ClassVar[QtCore.pyqtSignal] + binaryFrameReceived: typing.ClassVar[QtCore.pyqtSignal] + textFrameReceived: typing.ClassVar[QtCore.pyqtSignal] + readChannelFinished: typing.ClassVar[QtCore.pyqtSignal] + proxyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] + connected: typing.ClassVar[QtCore.pyqtSignal] + aboutToClose: typing.ClassVar[QtCore.pyqtSignal] def ping(self, payload: typing.Union[QtCore.QByteArray, bytes, bytearray] = ...) -> None: ... @typing.overload def open(self, url: QtCore.QUrl) -> None: ... @@ -111,10 +111,7 @@ class QWebSocket(QtCore.QObject): def isValid(self) -> bool: ... def flush(self) -> bool: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> QtNetwork.QAbstractSocket.SocketError: ... - @typing.overload - def error(self, error: QtNetwork.QAbstractSocket.SocketError) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def abort(self) -> None: ... @@ -199,14 +196,14 @@ class QWebSocketServer(QtCore.QObject): def setHandshakeTimeout(self, msec: int) -> None: ... def nativeDescriptor(self) -> sip.voidptr: ... def setNativeDescriptor(self, descriptor: sip.voidptr) -> bool: ... - def preSharedKeyAuthenticationRequired(self, authenticator: QtNetwork.QSslPreSharedKeyAuthenticator) -> None: ... - def closed(self) -> None: ... - def sslErrors(self, errors: typing.Iterable[QtNetwork.QSslError]) -> None: ... - def peerVerifyError(self, error: QtNetwork.QSslError) -> None: ... - def newConnection(self) -> None: ... - def originAuthenticationRequired(self, pAuthenticator: QWebSocketCorsAuthenticator) -> None: ... - def serverError(self, closeCode: QWebSocketProtocol.CloseCode) -> None: ... - def acceptError(self, socketError: QtNetwork.QAbstractSocket.SocketError) -> None: ... + preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + closed: typing.ClassVar[QtCore.pyqtSignal] + sslErrors: typing.ClassVar[QtCore.pyqtSignal] + peerVerifyError: typing.ClassVar[QtCore.pyqtSignal] + newConnection: typing.ClassVar[QtCore.pyqtSignal] + originAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + serverError: typing.ClassVar[QtCore.pyqtSignal] + acceptError: typing.ClassVar[QtCore.pyqtSignal] def handleConnection(self, socket: QtNetwork.QTcpSocket) -> None: ... def serverUrl(self) -> QtCore.QUrl: ... def supportedVersions(self) -> typing.List[QWebSocketProtocol.Version]: ... diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 92d28ffb..284bf8ba 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -1514,11 +1514,10 @@ class QVBoxLayout(QBoxLayout): class QButtonGroup(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def idToggled(self, a0: int, a1: bool) -> None: ... - def idReleased(self, a0: int) -> None: ... - def idPressed(self, a0: int) -> None: ... - def idClicked(self, a0: int) -> None: ... + idToggled: typing.ClassVar[QtCore.pyqtSignal] + idReleased: typing.ClassVar[QtCore.pyqtSignal] + idPressed: typing.ClassVar[QtCore.pyqtSignal] + idClicked: typing.ClassVar[QtCore.pyqtSignal] buttonToggled: typing.ClassVar[QtCore.pyqtSignal] buttonReleased: typing.ClassVar[QtCore.pyqtSignal] buttonPressed: typing.ClassVar[QtCore.pyqtSignal] @@ -1810,8 +1809,8 @@ class QComboBox(QWidget): def placeholderText(self) -> str: ... def setPlaceholderText(self, placeholderText: str) -> None: ... - def textHighlighted(self, a0: str) -> None: ... - def textActivated(self, a0: str) -> None: ... + textHighlighted: typing.ClassVar[QtCore.pyqtSignal] + textActivated: typing.ClassVar[QtCore.pyqtSignal] def currentData(self, role: int = ...) -> typing.Any: ... @typing.overload def inputMethodQuery(self, a0: QtCore.Qt.InputMethodQuery) -> typing.Any: ... @@ -1832,10 +1831,7 @@ class QComboBox(QWidget): def focusOutEvent(self, e: QtGui.QFocusEvent) -> None: ... def focusInEvent(self, e: QtGui.QFocusEvent) -> None: ... def initStyleOption(self, option: 'QStyleOptionComboBox') -> None: ... - @typing.overload - def highlighted(self, index: int) -> None: ... - @typing.overload - def highlighted(self, a0: str) -> None: ... + highlighted: typing.ClassVar[QtCore.pyqtSignal] currentTextChanged: typing.ClassVar[QtCore.pyqtSignal] currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] activated: typing.ClassVar[QtCore.pyqtSignal] @@ -3478,10 +3474,10 @@ class QDesktopWidget(QWidget): def __init__(self) -> None: ... def resizeEvent(self, e: QtGui.QResizeEvent) -> None: ... - def primaryScreenChanged(self) -> None: ... - def screenCountChanged(self, a0: int) -> None: ... - def workAreaResized(self, a0: int) -> None: ... - def resized(self, a0: int) -> None: ... + primaryScreenChanged: typing.ClassVar[QtCore.pyqtSignal] + screenCountChanged: typing.ClassVar[QtCore.pyqtSignal] + workAreaResized: typing.ClassVar[QtCore.pyqtSignal] + resized: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def availableGeometry(self, screen: int = ...) -> QtCore.QRect: ... @typing.overload @@ -5748,7 +5744,7 @@ class QGraphicsScene(QtCore.QObject): def setFocusOnTouch(self, enabled: bool) -> None: ... focusOnTouch: typing.ClassVar[QtCore.pyqtSignal] - def focusItemChanged(self, newFocus: QGraphicsItem, oldFocus: QGraphicsItem, reason: QtCore.Qt.FocusReason) -> None: ... + focusItemChanged: typing.ClassVar[QtCore.pyqtSignal] def setMinimumRenderSize(self, minSize: float) -> None: ... def minimumRenderSize(self) -> float: ... def sendEvent(self, item: QGraphicsItem, event: QtCore.QEvent) -> bool: ... @@ -5991,7 +5987,7 @@ class QGraphicsScale(QGraphicsTransform): yScaleChanged: typing.ClassVar[QtCore.pyqtSignal] xScaleChanged: typing.ClassVar[QtCore.pyqtSignal] scaleChanged: typing.ClassVar[QtCore.pyqtSignal] - def originChanged(self) -> None: ... + originChanged: typing.ClassVar[QtCore.pyqtSignal] def applyTo(self, matrix: QtGui.QMatrix4x4) -> None: ... def setZScale(self, a0: float) -> None: ... def zScale(self) -> float: ... @@ -6838,8 +6834,7 @@ class QLineEdit(QWidget): def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... @typing.overload def __init__(self, contents: str, parent: typing.Optional[QWidget] = ...) -> None: ... - - def inputRejected(self) -> None: ... + inputRejected: typing.ClassVar[QtCore.pyqtSignal] def selectionLength(self) -> int: ... def selectionEnd(self) -> int: ... @typing.overload @@ -7702,7 +7697,7 @@ class QMessageBox(QDialog): def setCheckBox(self, cb: QCheckBox) -> None: ... def textInteractionFlags(self) -> QtCore.Qt.TextInteractionFlags: ... def setTextInteractionFlags(self, flags: typing.Union[QtCore.Qt.TextInteractionFlags, QtCore.Qt.TextInteractionFlag]) -> None: ... - def buttonClicked(self, button: QAbstractButton) -> None: ... + buttonClicked: typing.ClassVar[QtCore.pyqtSignal] def buttonRole(self, button: QAbstractButton) -> 'QMessageBox.ButtonRole': ... def buttons(self) -> typing.List[QAbstractButton]: ... @typing.overload @@ -8536,7 +8531,7 @@ class QSpinBox(QAbstractSpinBox): def stepType(self) -> QAbstractSpinBox.StepType: ... def setDisplayIntegerBase(self, base: int) -> None: ... def displayIntegerBase(self) -> int: ... - def textChanged(self, a0: str) -> None: ... + textChanged: typing.ClassVar[QtCore.pyqtSignal] valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, val: int) -> None: ... def event(self, e: QtCore.QEvent) -> bool: ... @@ -8565,7 +8560,7 @@ class QDoubleSpinBox(QAbstractSpinBox): def setStepType(self, stepType: QAbstractSpinBox.StepType) -> None: ... def stepType(self) -> QAbstractSpinBox.StepType: ... - def textChanged(self, a0: str) -> None: ... + textChanged: typing.ClassVar[QtCore.pyqtSignal] valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, val: float) -> None: ... def fixup(self, str: str) -> str: ... diff --git a/signal_fixer.py b/signal_fixer.py new file mode 100644 index 00000000..6524f9eb --- /dev/null +++ b/signal_fixer.py @@ -0,0 +1,76 @@ +"""Script that will check stub files and fix signal annotations.""" +import importlib +import os +from typing import List, Optional, Union + +import libcst as cst +from PyQt5 import QtCore + + +def is_signal(module: object, cls_name: str, func_name: str) -> bool: + """Check if a method of the given Qt class is a signal.""" + cls = getattr(module, cls_name) + try: + func = getattr(cls, func_name) + except AttributeError: + print(f"Warning! Could not find {cls_name}.{func_name}") + return False + return isinstance(func, QtCore.pyqtSignal) + + +class TypingTransformer(cst.CSTTransformer): + """TypingTransformer that visits classes and methods.""" + + def __init__(self, mod_name: str): + super().__init__() + self._last_class: List[cst.ClassDef] = [] + self._fixed_signals: List[str] = [] + self._module = importlib.import_module(f"PyQt5.{mod_name}") + + def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: + """Put a class on top of the stack when visiting.""" + self._last_class.append(node) + return True + + def leave_FunctionDef( + self, original_node: cst.FunctionDef, _: cst.FunctionDef + ) -> Union[cst.BaseStatement, cst.FlattenSentinel[cst.BaseStatement], cst.RemovalSentinel]: + """Leave the method and change signature if a signal.""" + if not self._last_class: + return original_node + if len(self._last_class) > 1: + return original_node + + f_name = original_node.name.value + if is_signal(self._module, self._last_class[-1].name.value, f_name): + full_name = f"{self._last_class[-1].name.value}.{f_name}" + if full_name in self._fixed_signals: + # Handle the use-case of overloaded signals, i.e.: + # QComboBox.highlighted + return cst.RemovalSentinel.REMOVE + self._fixed_signals.append(full_name) + return cst.parse_statement(f"{f_name}: typing.ClassVar[QtCore.pyqtSignal]") + return original_node + + def leave_ClassDef( + self, original_node: cst.ClassDef, updated_node: cst.ClassDef + ) -> Union[cst.BaseStatement, cst.FlattenSentinel[cst.BaseStatement], cst.RemovalSentinel]: + """Remove a class from the stack and return the updated node.""" + self._last_class.pop() + return updated_node + + +if __name__ == '__main__': + for file in os.listdir("PyQt5-stubs"): + if file.startswith("QtWebKit") or file in ["QtX11Extras.pyi", "sip.pyi", "__init__.pyi"]: + continue + print("Fixing signals in " + file) + path = os.path.join("PyQt5-stubs", file) + with open(path, "r", encoding="utf-8") as fhandle: + stub_tree = cst.parse_module(fhandle.read()) + + transformer = TypingTransformer(file.replace(".pyi", "")) + modified_tree = stub_tree.visit(transformer) + + with open(path, "w", encoding="utf-8") as fhandle: + fhandle.write(modified_tree.code) From e90634c030b49b8108d8bea64db4763681724957 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Mon, 23 Aug 2021 22:42:13 +0200 Subject: [PATCH 045/421] Reverted changes on files. --- PyQt5-stubs/Qt3DAnimation.pyi | 120 +++--- PyQt5-stubs/Qt3DCore.pyi | 66 +-- PyQt5-stubs/Qt3DExtras.pyi | 362 +++++++++-------- PyQt5-stubs/Qt3DInput.pyi | 166 ++++---- PyQt5-stubs/Qt3DLogic.pyi | 3 +- PyQt5-stubs/Qt3DRender.pyi | 599 +++++++++++++++------------- PyQt5-stubs/QtBluetooth.pyi | 106 +++-- PyQt5-stubs/QtChart.pyi | 596 ++++++++++++++------------- PyQt5-stubs/QtCore.pyi | 158 ++++---- PyQt5-stubs/QtDBus.pyi | 18 +- PyQt5-stubs/QtDataVisualization.pyi | 535 +++++++++++++------------ PyQt5-stubs/QtDesigner.pyi | 36 +- PyQt5-stubs/QtGui.pyi | 143 +++---- PyQt5-stubs/QtHelp.pyi | 47 ++- PyQt5-stubs/QtLocation.pyi | 85 ++-- PyQt5-stubs/QtMultimedia.pyi | 543 ++++++++++++++----------- PyQt5-stubs/QtMultimediaWidgets.pyi | 23 +- PyQt5-stubs/QtNetwork.pyi | 118 +++--- PyQt5-stubs/QtNetworkAuth.pyi | 61 +-- PyQt5-stubs/QtNfc.pyi | 36 +- PyQt5-stubs/QtPositioning.pyi | 33 +- PyQt5-stubs/QtPrintSupport.pyi | 6 +- PyQt5-stubs/QtPurchasing.pyi | 7 +- PyQt5-stubs/QtQml.pyi | 12 +- PyQt5-stubs/QtQuick.pyi | 40 +- PyQt5-stubs/QtQuickWidgets.pyi | 4 +- PyQt5-stubs/QtRemoteObjects.pyi | 26 +- PyQt5-stubs/QtSensors.pyi | 49 ++- PyQt5-stubs/QtSerialPort.pyi | 28 +- PyQt5-stubs/QtSql.pyi | 13 +- PyQt5-stubs/QtSvg.pyi | 2 +- PyQt5-stubs/QtWebChannel.pyi | 5 +- PyQt5-stubs/QtWebEngine.pyi | 41 +- PyQt5-stubs/QtWebEngineCore.pyi | 7 +- PyQt5-stubs/QtWebEngineWidgets.pyi | 91 ++--- PyQt5-stubs/QtWebSockets.pyi | 49 +-- PyQt5-stubs/QtWidgets.pyi | 39 +- 37 files changed, 2340 insertions(+), 1933 deletions(-) diff --git a/PyQt5-stubs/Qt3DAnimation.pyi b/PyQt5-stubs/Qt3DAnimation.pyi index 9c4f0151..90a0c766 100644 --- a/PyQt5-stubs/Qt3DAnimation.pyi +++ b/PyQt5-stubs/Qt3DAnimation.pyi @@ -51,9 +51,10 @@ class QAbstractAnimation(QtCore.QObject): KeyframeAnimation = ... # type: QAbstractAnimation.AnimationType MorphingAnimation = ... # type: QAbstractAnimation.AnimationType VertexBlendAnimation = ... # type: QAbstractAnimation.AnimationType - durationChanged: typing.ClassVar[QtCore.pyqtSignal] - positionChanged: typing.ClassVar[QtCore.pyqtSignal] - animationNameChanged: typing.ClassVar[QtCore.pyqtSignal] + + def durationChanged(self, duration: float) -> None: ... + def positionChanged(self, position: float) -> None: ... + def animationNameChanged(self, name: str) -> None: ... def setDuration(self, duration: float) -> None: ... def setPosition(self, position: float) -> None: ... def setAnimationName(self, name: str) -> None: ... @@ -65,7 +66,7 @@ class QAbstractAnimation(QtCore.QObject): class QAbstractAnimationClip(Qt3DCore.QNode): def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - durationChanged: typing.ClassVar[QtCore.pyqtSignal] + def durationChanged(self, duration: float) -> None: ... def duration(self) -> float: ... class QAbstractChannelMapping(Qt3DCore.QNode): ... @@ -80,11 +81,11 @@ class QAbstractClipAnimator(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - normalizedTimeChanged: typing.ClassVar[QtCore.pyqtSignal] - clockChanged: typing.ClassVar[QtCore.pyqtSignal] - loopCountChanged: typing.ClassVar[QtCore.pyqtSignal] - channelMapperChanged: typing.ClassVar[QtCore.pyqtSignal] - runningChanged: typing.ClassVar[QtCore.pyqtSignal] + def normalizedTimeChanged(self, index: float) -> None: ... + def clockChanged(self, clock: 'QClock') -> None: ... + def loopCountChanged(self, loops: int) -> None: ... + def channelMapperChanged(self, channelMapper: 'QChannelMapper') -> None: ... + def runningChanged(self, running: bool) -> None: ... def stop(self) -> None: ... def start(self) -> None: ... def setNormalizedTime(self, timeFraction: float) -> None: ... @@ -105,9 +106,10 @@ class QAbstractClipBlendNode(Qt3DCore.QNode): class QAdditiveClipBlend('QAbstractClipBlendNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - additiveClipChanged: typing.ClassVar[QtCore.pyqtSignal] - baseClipChanged: typing.ClassVar[QtCore.pyqtSignal] - additiveFactorChanged: typing.ClassVar[QtCore.pyqtSignal] + + def additiveClipChanged(self, additiveClip: 'QAbstractClipBlendNode') -> None: ... + def baseClipChanged(self, baseClip: 'QAbstractClipBlendNode') -> None: ... + def additiveFactorChanged(self, additiveFactor: float) -> None: ... def setAdditiveClip(self, additiveClip: 'QAbstractClipBlendNode') -> None: ... def setBaseClip(self, baseClip: 'QAbstractClipBlendNode') -> None: ... def setAdditiveFactor(self, additiveFactor: float) -> None: ... @@ -122,7 +124,8 @@ class QAnimationAspect(Qt3DCore.QAbstractAspect): class QAnimationClip('QAbstractAnimationClip'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - clipDataChanged: typing.ClassVar[QtCore.pyqtSignal] + + def clipDataChanged(self, clipData: 'QAnimationClipData') -> None: ... def setClipData(self, clipData: 'QAnimationClipData') -> None: ... def clipData(self) -> 'QAnimationClipData': ... @@ -159,8 +162,8 @@ class QAnimationClipLoader('QAbstractAnimationClip'): def __init__(self, source: QtCore.QUrl, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + def statusChanged(self, status: 'QAnimationClipLoader.Status') -> None: ... + def sourceChanged(self, source: QtCore.QUrl) -> None: ... def setSource(self, source: QtCore.QUrl) -> None: ... def status(self) -> 'QAnimationClipLoader.Status': ... def source(self) -> QtCore.QUrl: ... @@ -168,12 +171,13 @@ class QAnimationClipLoader('QAbstractAnimationClip'): class QAnimationController(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - recursiveChanged: typing.ClassVar[QtCore.pyqtSignal] - entityChanged: typing.ClassVar[QtCore.pyqtSignal] - positionOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] - positionScaleChanged: typing.ClassVar[QtCore.pyqtSignal] - positionChanged: typing.ClassVar[QtCore.pyqtSignal] - activeAnimationGroupChanged: typing.ClassVar[QtCore.pyqtSignal] + + def recursiveChanged(self, recursive: bool) -> None: ... + def entityChanged(self, entity: Qt3DCore.QEntity) -> None: ... + def positionOffsetChanged(self, offset: float) -> None: ... + def positionScaleChanged(self, scale: float) -> None: ... + def positionChanged(self, position: float) -> None: ... + def activeAnimationGroupChanged(self, index: int) -> None: ... def setRecursive(self, recursive: bool) -> None: ... def setEntity(self, entity: Qt3DCore.QEntity) -> None: ... def setPositionOffset(self, offset: float) -> None: ... @@ -196,9 +200,10 @@ class QAnimationController(QtCore.QObject): class QAnimationGroup(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - durationChanged: typing.ClassVar[QtCore.pyqtSignal] - positionChanged: typing.ClassVar[QtCore.pyqtSignal] - nameChanged: typing.ClassVar[QtCore.pyqtSignal] + + def durationChanged(self, duration: float) -> None: ... + def positionChanged(self, position: float) -> None: ... + def nameChanged(self, name: str) -> None: ... def setPosition(self, position: float) -> None: ... def setName(self, name: str) -> None: ... def removeAnimation(self, animation: 'QAbstractAnimation') -> None: ... @@ -212,7 +217,8 @@ class QAnimationGroup(QtCore.QObject): class QBlendedClipAnimator('QAbstractClipAnimator'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - blendTreeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def blendTreeChanged(self, blendTree: 'QAbstractClipBlendNode') -> None: ... def setBlendTree(self, blendTree: 'QAbstractClipBlendNode') -> None: ... def blendTree(self) -> 'QAbstractClipBlendNode': ... @@ -263,9 +269,10 @@ class QChannelMapper(Qt3DCore.QNode): class QChannelMapping('QAbstractChannelMapping'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - propertyChanged: typing.ClassVar[QtCore.pyqtSignal] - targetChanged: typing.ClassVar[QtCore.pyqtSignal] - channelNameChanged: typing.ClassVar[QtCore.pyqtSignal] + + def propertyChanged(self, property: str) -> None: ... + def targetChanged(self, target: Qt3DCore.QNode) -> None: ... + def channelNameChanged(self, channelName: str) -> None: ... def setProperty(self, property: str) -> None: ... # type: ignore[override] def setTarget(self, target: Qt3DCore.QNode) -> None: ... def setChannelName(self, channelName: str) -> None: ... @@ -276,7 +283,8 @@ class QChannelMapping('QAbstractChannelMapping'): class QClipAnimator('QAbstractClipAnimator'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - clipChanged: typing.ClassVar[QtCore.pyqtSignal] + + def clipChanged(self, clip: 'QAbstractAnimationClip') -> None: ... def setClip(self, clip: 'QAbstractAnimationClip') -> None: ... def clip(self) -> 'QAbstractAnimationClip': ... @@ -290,14 +298,16 @@ class QClipBlendValue('QAbstractClipBlendNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... @typing.overload def __init__(self, clip: 'QAbstractAnimationClip', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - clipChanged: typing.ClassVar[QtCore.pyqtSignal] + + def clipChanged(self, clip: 'QAbstractAnimationClip') -> None: ... def setClip(self, clip: 'QAbstractAnimationClip') -> None: ... def clip(self) -> 'QAbstractAnimationClip': ... class QClock(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - playbackRateChanged: typing.ClassVar[QtCore.pyqtSignal] + + def playbackRateChanged(self, playbackRate: float) -> None: ... def setPlaybackRate(self, playbackRate: float) -> None: ... def playbackRate(self) -> float: ... @@ -342,12 +352,13 @@ class QKeyframeAnimation('QAbstractAnimation'): Repeat = ... # type: QKeyframeAnimation.RepeatMode def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - endModeChanged: typing.ClassVar[QtCore.pyqtSignal] - startModeChanged: typing.ClassVar[QtCore.pyqtSignal] - targetNameChanged: typing.ClassVar[QtCore.pyqtSignal] - easingChanged: typing.ClassVar[QtCore.pyqtSignal] - targetChanged: typing.ClassVar[QtCore.pyqtSignal] - framePositionsChanged: typing.ClassVar[QtCore.pyqtSignal] + + def endModeChanged(self, endMode: 'QKeyframeAnimation.RepeatMode') -> None: ... + def startModeChanged(self, startMode: 'QKeyframeAnimation.RepeatMode') -> None: ... + def targetNameChanged(self, name: str) -> None: ... + def easingChanged(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... + def targetChanged(self, target: Qt3DCore.QTransform) -> None: ... + def framePositionsChanged(self, positions: typing.Iterable[float]) -> None: ... def setEndMode(self, mode: 'QKeyframeAnimation.RepeatMode') -> None: ... def setStartMode(self, mode: 'QKeyframeAnimation.RepeatMode') -> None: ... def setTargetName(self, name: str) -> None: ... @@ -368,9 +379,10 @@ class QKeyframeAnimation('QAbstractAnimation'): class QLerpClipBlend('QAbstractClipBlendNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - endClipChanged: typing.ClassVar[QtCore.pyqtSignal] - startClipChanged: typing.ClassVar[QtCore.pyqtSignal] - blendFactorChanged: typing.ClassVar[QtCore.pyqtSignal] + + def endClipChanged(self, endClip: 'QAbstractClipBlendNode') -> None: ... + def startClipChanged(self, startClip: 'QAbstractClipBlendNode') -> None: ... + def blendFactorChanged(self, blendFactor: float) -> None: ... def setEndClip(self, endClip: 'QAbstractClipBlendNode') -> None: ... def setStartClip(self, startClip: 'QAbstractClipBlendNode') -> None: ... def setBlendFactor(self, blendFactor: float) -> None: ... @@ -388,12 +400,13 @@ class QMorphingAnimation('QAbstractAnimation'): Relative = ... # type: QMorphingAnimation.Method def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - easingChanged: typing.ClassVar[QtCore.pyqtSignal] - methodChanged: typing.ClassVar[QtCore.pyqtSignal] - targetNameChanged: typing.ClassVar[QtCore.pyqtSignal] - targetChanged: typing.ClassVar[QtCore.pyqtSignal] - interpolatorChanged: typing.ClassVar[QtCore.pyqtSignal] - targetPositionsChanged: typing.ClassVar[QtCore.pyqtSignal] + + def easingChanged(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... + def methodChanged(self, method: 'QMorphingAnimation.Method') -> None: ... + def targetNameChanged(self, name: str) -> None: ... + def targetChanged(self, target: Qt3DRender.QGeometryRenderer) -> None: ... + def interpolatorChanged(self, interpolator: float) -> None: ... + def targetPositionsChanged(self, targetPositions: typing.Iterable[float]) -> None: ... def setEasing(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... def setMethod(self, method: 'QMorphingAnimation.Method') -> None: ... def setTargetName(self, name: str) -> None: ... @@ -415,7 +428,8 @@ class QMorphingAnimation('QAbstractAnimation'): class QMorphTarget(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - attributeNamesChanged: typing.ClassVar[QtCore.pyqtSignal] + + def attributeNamesChanged(self, attributeNames: typing.Iterable[str]) -> None: ... @staticmethod def fromGeometry(geometry: Qt3DRender.QGeometry, attributes: typing.Iterable[str]) -> 'QMorphTarget': ... def removeAttribute(self, attribute: Qt3DRender.QAttribute) -> None: ... @@ -427,17 +441,19 @@ class QMorphTarget(QtCore.QObject): class QSkeletonMapping('QAbstractChannelMapping'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - skeletonChanged: typing.ClassVar[QtCore.pyqtSignal] + + def skeletonChanged(self, skeleton: Qt3DCore.QAbstractSkeleton) -> None: ... def setSkeleton(self, skeleton: Qt3DCore.QAbstractSkeleton) -> None: ... def skeleton(self) -> Qt3DCore.QAbstractSkeleton: ... class QVertexBlendAnimation('QAbstractAnimation'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - targetNameChanged: typing.ClassVar[QtCore.pyqtSignal] - targetChanged: typing.ClassVar[QtCore.pyqtSignal] - interpolatorChanged: typing.ClassVar[QtCore.pyqtSignal] - targetPositionsChanged: typing.ClassVar[QtCore.pyqtSignal] + + def targetNameChanged(self, name: str) -> None: ... + def targetChanged(self, target: Qt3DRender.QGeometryRenderer) -> None: ... + def interpolatorChanged(self, interpolator: float) -> None: ... + def targetPositionsChanged(self, targetPositions: typing.Iterable[float]) -> None: ... def setTargetName(self, name: str) -> None: ... def setTarget(self, target: Qt3DRender.QGeometryRenderer) -> None: ... def setTargetPositions(self, targetPositions: typing.Iterable[float]) -> None: ... diff --git a/PyQt5-stubs/Qt3DCore.pyi b/PyQt5-stubs/Qt3DCore.pyi index 51a51533..66970665 100644 --- a/PyQt5-stubs/Qt3DCore.pyi +++ b/PyQt5-stubs/Qt3DCore.pyi @@ -115,7 +115,7 @@ class QNode(QtCore.QObject): def sendReply(self, command: 'QNodeCommand') -> None: ... def sendCommand(self, name: str, data: typing.Any = ..., replyTo: int = ...) -> int: ... - defaultPropertyTrackingModeChanged: typing.ClassVar[QtCore.pyqtSignal] + def defaultPropertyTrackingModeChanged(self, mode: 'QNode.PropertyTrackingMode') -> None: ... def setDefaultPropertyTrackingMode(self, mode: 'QNode.PropertyTrackingMode') -> None: ... def clearPropertyTrackings(self) -> None: ... def clearPropertyTracking(self, propertyName: str) -> None: ... @@ -124,9 +124,9 @@ class QNode(QtCore.QObject): def defaultPropertyTrackingMode(self) -> 'QNode.PropertyTrackingMode': ... def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... def notifyObservers(self, change: 'QSceneChange') -> None: ... - nodeDestroyed: typing.ClassVar[QtCore.pyqtSignal] - enabledChanged: typing.ClassVar[QtCore.pyqtSignal] - parentChanged: typing.ClassVar[QtCore.pyqtSignal] + def nodeDestroyed(self) -> None: ... + def enabledChanged(self, enabled: bool) -> None: ... + def parentChanged(self, parent: QtCore.QObject) -> None: ... def setEnabled(self, isEnabled: bool) -> None: ... def setParent(self, parent: 'QNode') -> None: ... # type: ignore[override] def isEnabled(self) -> bool: ... @@ -139,15 +139,16 @@ class QNode(QtCore.QObject): class QAbstractSkeleton('QNode'): def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - jointCountChanged: typing.ClassVar[QtCore.pyqtSignal] + def jointCountChanged(self, jointCount: int) -> None: ... def jointCount(self) -> int: ... class QComponent('QNode'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - removedFromEntity: typing.ClassVar[QtCore.pyqtSignal] - addedToEntity: typing.ClassVar[QtCore.pyqtSignal] - shareableChanged: typing.ClassVar[QtCore.pyqtSignal] + + def removedFromEntity(self, entity: 'QEntity') -> None: ... + def addedToEntity(self, entity: 'QEntity') -> None: ... + def shareableChanged(self, isShareable: bool) -> None: ... def setShareable(self, isShareable: bool) -> None: ... def entities(self) -> typing.List['QEntity']: ... def isShareable(self) -> bool: ... @@ -155,7 +156,8 @@ class QComponent('QNode'): class QArmature('QComponent'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - skeletonChanged: typing.ClassVar[QtCore.pyqtSignal] + + def skeletonChanged(self, skeleton: 'QAbstractSkeleton') -> None: ... def setSkeleton(self, skeleton: 'QAbstractSkeleton') -> None: ... def skeleton(self) -> 'QAbstractSkeleton': ... @@ -270,14 +272,15 @@ class QEntity('QNode'): class QJoint('QNode'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - nameChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationZChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationYChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationXChanged: typing.ClassVar[QtCore.pyqtSignal] - inverseBindMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] - translationChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationChanged: typing.ClassVar[QtCore.pyqtSignal] - scaleChanged: typing.ClassVar[QtCore.pyqtSignal] + + def nameChanged(self, name: str) -> None: ... + def rotationZChanged(self, rotationZ: float) -> None: ... + def rotationYChanged(self, rotationY: float) -> None: ... + def rotationXChanged(self, rotationX: float) -> None: ... + def inverseBindMatrixChanged(self, inverseBindMatrix: QtGui.QMatrix4x4) -> None: ... + def translationChanged(self, translation: QtGui.QVector3D) -> None: ... + def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... + def scaleChanged(self, scale: QtGui.QVector3D) -> None: ... def setToIdentity(self) -> None: ... def setName(self, name: str) -> None: ... def setRotationZ(self, rotationZ: float) -> None: ... @@ -433,7 +436,8 @@ class ChangeFlags(sip.simplewrapper): class QSkeleton('QAbstractSkeleton'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - rootJointChanged: typing.ClassVar[QtCore.pyqtSignal] + + def rootJointChanged(self, rootJoint: 'QJoint') -> None: ... def setRootJoint(self, rootJoint: 'QJoint') -> None: ... def rootJoint(self) -> 'QJoint': ... @@ -454,10 +458,10 @@ class QSkeletonLoader('QAbstractSkeleton'): def __init__(self, source: QtCore.QUrl, parent: typing.Optional['QNode'] = ...) -> None: ... def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - rootJointChanged: typing.ClassVar[QtCore.pyqtSignal] - createJointsEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + def rootJointChanged(self, rootJoint: 'QJoint') -> None: ... + def createJointsEnabledChanged(self, createJointsEnabled: bool) -> None: ... + def statusChanged(self, status: 'QSkeletonLoader.Status') -> None: ... + def sourceChanged(self, source: QtCore.QUrl) -> None: ... def setCreateJointsEnabled(self, enabled: bool) -> None: ... def setSource(self, source: QtCore.QUrl) -> None: ... def rootJoint(self) -> 'QJoint': ... @@ -470,16 +474,16 @@ class QTransform('QComponent'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - worldMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] + def worldMatrixChanged(self, worldMatrix: QtGui.QMatrix4x4) -> None: ... def worldMatrix(self) -> QtGui.QMatrix4x4: ... - rotationZChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationYChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationXChanged: typing.ClassVar[QtCore.pyqtSignal] - matrixChanged: typing.ClassVar[QtCore.pyqtSignal] - translationChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationChanged: typing.ClassVar[QtCore.pyqtSignal] - scale3DChanged: typing.ClassVar[QtCore.pyqtSignal] - scaleChanged: typing.ClassVar[QtCore.pyqtSignal] + def rotationZChanged(self, rotationZ: float) -> None: ... + def rotationYChanged(self, rotationY: float) -> None: ... + def rotationXChanged(self, rotationX: float) -> None: ... + def matrixChanged(self) -> None: ... + def translationChanged(self, translation: QtGui.QVector3D) -> None: ... + def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... + def scale3DChanged(self, scale: QtGui.QVector3D) -> None: ... + def scaleChanged(self, scale: float) -> None: ... def setRotationZ(self, rotationZ: float) -> None: ... def setRotationY(self, rotationY: float) -> None: ... def setRotationX(self, rotationX: float) -> None: ... diff --git a/PyQt5-stubs/Qt3DExtras.pyi b/PyQt5-stubs/Qt3DExtras.pyi index 12626883..1c3d4358 100644 --- a/PyQt5-stubs/Qt3DExtras.pyi +++ b/PyQt5-stubs/Qt3DExtras.pyi @@ -48,11 +48,11 @@ class QAbstractCameraController(Qt3DCore.QEntity): def mouseDevice(self) -> Qt3DInput.QMouseDevice: ... def keyboardDevice(self) -> Qt3DInput.QKeyboardDevice: ... - decelerationChanged: typing.ClassVar[QtCore.pyqtSignal] - accelerationChanged: typing.ClassVar[QtCore.pyqtSignal] - lookSpeedChanged: typing.ClassVar[QtCore.pyqtSignal] - linearSpeedChanged: typing.ClassVar[QtCore.pyqtSignal] - cameraChanged: typing.ClassVar[QtCore.pyqtSignal] + def decelerationChanged(self, deceleration: float) -> None: ... + def accelerationChanged(self, acceleration: float) -> None: ... + def lookSpeedChanged(self) -> None: ... + def linearSpeedChanged(self) -> None: ... + def cameraChanged(self) -> None: ... def setDeceleration(self, deceleration: float) -> None: ... def setAcceleration(self, acceleration: float) -> None: ... def setLookSpeed(self, lookSpeed: float) -> None: ... @@ -65,9 +65,10 @@ class QAbstractCameraController(Qt3DCore.QEntity): def camera(self) -> Qt3DRender.QCamera: ... class QAbstractSpriteSheet(Qt3DCore.QNode): - currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] - textureTransformChanged: typing.ClassVar[QtCore.pyqtSignal] - textureChanged: typing.ClassVar[QtCore.pyqtSignal] + + def currentIndexChanged(self, currentIndex: int) -> None: ... + def textureTransformChanged(self, textureTransform: QtGui.QMatrix3x3) -> None: ... + def textureChanged(self, texture: Qt3DRender.QAbstractTexture) -> None: ... def setCurrentIndex(self, currentIndex: int) -> None: ... def setTexture(self, texture: Qt3DRender.QAbstractTexture) -> None: ... def currentIndex(self) -> int: ... @@ -77,13 +78,14 @@ class QAbstractSpriteSheet(Qt3DCore.QNode): class QConeGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - lengthChanged: typing.ClassVar[QtCore.pyqtSignal] - slicesChanged: typing.ClassVar[QtCore.pyqtSignal] - ringsChanged: typing.ClassVar[QtCore.pyqtSignal] - bottomRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] - topRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] - hasBottomEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] - hasTopEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] + + def lengthChanged(self, length: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def bottomRadiusChanged(self, bottomRadius: float) -> None: ... + def topRadiusChanged(self, topRadius: float) -> None: ... + def hasBottomEndcapChanged(self, hasBottomEndcap: bool) -> None: ... + def hasTopEndcapChanged(self, hasTopEndcap: bool) -> None: ... def setLength(self, length: float) -> None: ... def setSlices(self, slices: int) -> None: ... def setRings(self, rings: int) -> None: ... @@ -108,13 +110,14 @@ class QConeGeometry(Qt3DRender.QGeometry): class QConeMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - lengthChanged: typing.ClassVar[QtCore.pyqtSignal] - slicesChanged: typing.ClassVar[QtCore.pyqtSignal] - ringsChanged: typing.ClassVar[QtCore.pyqtSignal] - bottomRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] - topRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] - hasBottomEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] - hasTopEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] + + def lengthChanged(self, length: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def bottomRadiusChanged(self, bottomRadius: float) -> None: ... + def topRadiusChanged(self, topRadius: float) -> None: ... + def hasBottomEndcapChanged(self, hasBottomEndcap: bool) -> None: ... + def hasTopEndcapChanged(self, hasTopEndcap: bool) -> None: ... def setLength(self, length: float) -> None: ... def setSlices(self, slices: int) -> None: ... def setRings(self, rings: int) -> None: ... @@ -133,12 +136,13 @@ class QConeMesh(Qt3DRender.QGeometryRenderer): class QCuboidGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - xyMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] - xzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] - yzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] - zExtentChanged: typing.ClassVar[QtCore.pyqtSignal] - yExtentChanged: typing.ClassVar[QtCore.pyqtSignal] - xExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + + def xyMeshResolutionChanged(self, xyMeshResolution: QtCore.QSize) -> None: ... + def xzMeshResolutionChanged(self, xzMeshResolution: QtCore.QSize) -> None: ... + def yzMeshResolutionChanged(self, yzMeshResolution: QtCore.QSize) -> None: ... + def zExtentChanged(self, zExtent: float) -> None: ... + def yExtentChanged(self, yExtent: float) -> None: ... + def xExtentChanged(self, xExtent: float) -> None: ... def setXYMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setXZMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setYZMeshResolution(self, resolution: QtCore.QSize) -> None: ... @@ -162,12 +166,13 @@ class QCuboidGeometry(Qt3DRender.QGeometry): class QCuboidMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - xyMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] - xzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] - yzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] - zExtentChanged: typing.ClassVar[QtCore.pyqtSignal] - yExtentChanged: typing.ClassVar[QtCore.pyqtSignal] - xExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + + def xyMeshResolutionChanged(self, xyMeshResolution: QtCore.QSize) -> None: ... + def xzMeshResolutionChanged(self, xzMeshResolution: QtCore.QSize) -> None: ... + def yzMeshResolutionChanged(self, yzMeshResolution: QtCore.QSize) -> None: ... + def zExtentChanged(self, zExtent: float) -> None: ... + def yExtentChanged(self, yExtent: float) -> None: ... + def xExtentChanged(self, xExtent: float) -> None: ... def setXYMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setXZMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setYZMeshResolution(self, resolution: QtCore.QSize) -> None: ... @@ -184,10 +189,11 @@ class QCuboidMesh(Qt3DRender.QGeometryRenderer): class QCylinderGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - lengthChanged: typing.ClassVar[QtCore.pyqtSignal] - slicesChanged: typing.ClassVar[QtCore.pyqtSignal] - ringsChanged: typing.ClassVar[QtCore.pyqtSignal] - radiusChanged: typing.ClassVar[QtCore.pyqtSignal] + + def lengthChanged(self, length: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... def setLength(self, length: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -206,10 +212,11 @@ class QCylinderGeometry(Qt3DRender.QGeometry): class QCylinderMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - lengthChanged: typing.ClassVar[QtCore.pyqtSignal] - slicesChanged: typing.ClassVar[QtCore.pyqtSignal] - ringsChanged: typing.ClassVar[QtCore.pyqtSignal] - radiusChanged: typing.ClassVar[QtCore.pyqtSignal] + + def lengthChanged(self, length: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... def setLength(self, length: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -222,11 +229,12 @@ class QCylinderMesh(Qt3DRender.QGeometryRenderer): class QDiffuseMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] - shininessChanged: typing.ClassVar[QtCore.pyqtSignal] - specularChanged: typing.ClassVar[QtCore.pyqtSignal] - diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] - ambientChanged: typing.ClassVar[QtCore.pyqtSignal] + + def textureScaleChanged(self, textureScale: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setTextureScale(self, textureScale: float) -> None: ... def setDiffuse(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... def setShininess(self, shininess: float) -> None: ... @@ -241,11 +249,12 @@ class QDiffuseMapMaterial(Qt3DRender.QMaterial): class QDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] - shininessChanged: typing.ClassVar[QtCore.pyqtSignal] - specularChanged: typing.ClassVar[QtCore.pyqtSignal] - diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] - ambientChanged: typing.ClassVar[QtCore.pyqtSignal] + + def textureScaleChanged(self, textureScale: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: Qt3DRender.QAbstractTexture) -> None: ... + def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setTextureScale(self, textureScale: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: Qt3DRender.QAbstractTexture) -> None: ... @@ -260,13 +269,14 @@ class QDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): class QDiffuseSpecularMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - alphaBlendingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] - normalChanged: typing.ClassVar[QtCore.pyqtSignal] - shininessChanged: typing.ClassVar[QtCore.pyqtSignal] - specularChanged: typing.ClassVar[QtCore.pyqtSignal] - diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] - ambientChanged: typing.ClassVar[QtCore.pyqtSignal] + + def alphaBlendingEnabledChanged(self, enabled: bool) -> None: ... + def textureScaleChanged(self, textureScale: float) -> None: ... + def normalChanged(self, normal: typing.Any) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Any) -> None: ... + def diffuseChanged(self, diffuse: typing.Any) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setAlphaBlendingEnabled(self, enabled: bool) -> None: ... def setTextureScale(self, textureScale: float) -> None: ... def setNormal(self, normal: typing.Any) -> None: ... @@ -285,9 +295,10 @@ class QDiffuseSpecularMaterial(Qt3DRender.QMaterial): class QExtrudedTextGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - depthChanged: typing.ClassVar[QtCore.pyqtSignal] - fontChanged: typing.ClassVar[QtCore.pyqtSignal] - textChanged: typing.ClassVar[QtCore.pyqtSignal] + + def depthChanged(self, extrusionLength: float) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... + def textChanged(self, text: str) -> None: ... def setDepth(self, extrusionLength: float) -> None: ... def setFont(self, font: QtGui.QFont) -> None: ... def setText(self, text: str) -> None: ... @@ -301,9 +312,10 @@ class QExtrudedTextGeometry(Qt3DRender.QGeometry): class QExtrudedTextMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - depthChanged: typing.ClassVar[QtCore.pyqtSignal] - fontChanged: typing.ClassVar[QtCore.pyqtSignal] - textChanged: typing.ClassVar[QtCore.pyqtSignal] + + def depthChanged(self, depth: float) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... + def textChanged(self, text: str) -> None: ... def setDepth(self, depth: float) -> None: ... def setFont(self, font: QtGui.QFont) -> None: ... def setText(self, text: str) -> None: ... @@ -318,23 +330,24 @@ class QFirstPersonCameraController('QAbstractCameraController'): class QForwardRenderer(Qt3DRender.QTechniqueFilter): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - showDebugOverlayChanged: typing.ClassVar[QtCore.pyqtSignal] + + def showDebugOverlayChanged(self, showDebugOverlay: bool) -> None: ... def setShowDebugOverlay(self, showDebugOverlay: bool) -> None: ... def showDebugOverlay(self) -> bool: ... - buffersToClearChanged: typing.ClassVar[QtCore.pyqtSignal] + def buffersToClearChanged(self, a0: Qt3DRender.QClearBuffers.BufferType) -> None: ... def setBuffersToClear(self, a0: Qt3DRender.QClearBuffers.BufferType) -> None: ... def buffersToClear(self) -> Qt3DRender.QClearBuffers.BufferType: ... - gammaChanged: typing.ClassVar[QtCore.pyqtSignal] - frustumCullingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + def gammaChanged(self, gamma: float) -> None: ... + def frustumCullingEnabledChanged(self, enabled: bool) -> None: ... def setGamma(self, gamma: float) -> None: ... def setFrustumCullingEnabled(self, enabled: bool) -> None: ... def gamma(self) -> float: ... def isFrustumCullingEnabled(self) -> bool: ... - externalRenderTargetSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - surfaceChanged: typing.ClassVar[QtCore.pyqtSignal] - cameraChanged: typing.ClassVar[QtCore.pyqtSignal] - clearColorChanged: typing.ClassVar[QtCore.pyqtSignal] - viewportRectChanged: typing.ClassVar[QtCore.pyqtSignal] + def externalRenderTargetSizeChanged(self, size: QtCore.QSize) -> None: ... + def surfaceChanged(self, surface: QtCore.QObject) -> None: ... + def cameraChanged(self, camera: Qt3DCore.QEntity) -> None: ... + def clearColorChanged(self, clearColor: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def viewportRectChanged(self, viewportRect: QtCore.QRectF) -> None: ... def setExternalRenderTargetSize(self, size: QtCore.QSize) -> None: ... def setSurface(self, surface: QtCore.QObject) -> None: ... def setCamera(self, camera: Qt3DCore.QEntity) -> None: ... @@ -349,13 +362,14 @@ class QForwardRenderer(Qt3DRender.QTechniqueFilter): class QGoochMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - shininessChanged: typing.ClassVar[QtCore.pyqtSignal] - betaChanged: typing.ClassVar[QtCore.pyqtSignal] - alphaChanged: typing.ClassVar[QtCore.pyqtSignal] - warmChanged: typing.ClassVar[QtCore.pyqtSignal] - coolChanged: typing.ClassVar[QtCore.pyqtSignal] - specularChanged: typing.ClassVar[QtCore.pyqtSignal] - diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + + def shininessChanged(self, shininess: float) -> None: ... + def betaChanged(self, beta: float) -> None: ... + def alphaChanged(self, alpha: float) -> None: ... + def warmChanged(self, warm: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def coolChanged(self, cool: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setShininess(self, shininess: float) -> None: ... def setBeta(self, beta: float) -> None: ... def setAlpha(self, alpha: float) -> None: ... @@ -374,12 +388,13 @@ class QGoochMaterial(Qt3DRender.QMaterial): class QMetalRoughMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] - normalChanged: typing.ClassVar[QtCore.pyqtSignal] - ambientOcclusionChanged: typing.ClassVar[QtCore.pyqtSignal] - roughnessChanged: typing.ClassVar[QtCore.pyqtSignal] - metalnessChanged: typing.ClassVar[QtCore.pyqtSignal] - baseColorChanged: typing.ClassVar[QtCore.pyqtSignal] + + def textureScaleChanged(self, textureScale: float) -> None: ... + def normalChanged(self, normal: typing.Any) -> None: ... + def ambientOcclusionChanged(self, ambientOcclusion: typing.Any) -> None: ... + def roughnessChanged(self, roughness: typing.Any) -> None: ... + def metalnessChanged(self, metalness: typing.Any) -> None: ... + def baseColorChanged(self, baseColor: typing.Any) -> None: ... def setTextureScale(self, textureScale: float) -> None: ... def setNormal(self, normal: typing.Any) -> None: ... def setAmbientOcclusion(self, ambientOcclusion: typing.Any) -> None: ... @@ -396,11 +411,12 @@ class QMetalRoughMaterial(Qt3DRender.QMaterial): class QMorphPhongMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - interpolatorChanged: typing.ClassVar[QtCore.pyqtSignal] - shininessChanged: typing.ClassVar[QtCore.pyqtSignal] - specularChanged: typing.ClassVar[QtCore.pyqtSignal] - diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] - ambientChanged: typing.ClassVar[QtCore.pyqtSignal] + + def interpolatorChanged(self, interpolator: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setInterpolator(self, interpolator: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... @@ -415,12 +431,13 @@ class QMorphPhongMaterial(Qt3DRender.QMaterial): class QNormalDiffuseMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] - shininessChanged: typing.ClassVar[QtCore.pyqtSignal] - specularChanged: typing.ClassVar[QtCore.pyqtSignal] - normalChanged: typing.ClassVar[QtCore.pyqtSignal] - diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] - ambientChanged: typing.ClassVar[QtCore.pyqtSignal] + + def textureScaleChanged(self, textureScale: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def normalChanged(self, normal: Qt3DRender.QAbstractTexture) -> None: ... + def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setTextureScale(self, textureScale: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setNormal(self, normal: Qt3DRender.QAbstractTexture) -> None: ... @@ -441,12 +458,13 @@ class QNormalDiffuseMapAlphaMaterial('QNormalDiffuseMapMaterial'): class QNormalDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] - shininessChanged: typing.ClassVar[QtCore.pyqtSignal] - specularChanged: typing.ClassVar[QtCore.pyqtSignal] - normalChanged: typing.ClassVar[QtCore.pyqtSignal] - diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] - ambientChanged: typing.ClassVar[QtCore.pyqtSignal] + + def textureScaleChanged(self, textureScale: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: Qt3DRender.QAbstractTexture) -> None: ... + def normalChanged(self, normal: Qt3DRender.QAbstractTexture) -> None: ... + def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setTextureScale(self, textureScale: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: Qt3DRender.QAbstractTexture) -> None: ... @@ -463,7 +481,8 @@ class QNormalDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): class QOrbitCameraController('QAbstractCameraController'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - zoomInLimitChanged: typing.ClassVar[QtCore.pyqtSignal] + + def zoomInLimitChanged(self) -> None: ... def setZoomInLimit(self, zoomInLimit: float) -> None: ... def zoomInLimit(self) -> float: ... @@ -474,11 +493,12 @@ class QPerVertexColorMaterial(Qt3DRender.QMaterial): class QPhongAlphaMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - blendFunctionArgChanged: typing.ClassVar[QtCore.pyqtSignal] - destinationAlphaArgChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceAlphaArgChanged: typing.ClassVar[QtCore.pyqtSignal] - destinationRgbArgChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceRgbArgChanged: typing.ClassVar[QtCore.pyqtSignal] + + def blendFunctionArgChanged(self, blendFunctionArg: Qt3DRender.QBlendEquation.BlendFunction) -> None: ... + def destinationAlphaArgChanged(self, destinationAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + def sourceAlphaArgChanged(self, sourceAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + def destinationRgbArgChanged(self, destinationRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + def sourceRgbArgChanged(self, sourceRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... def setBlendFunctionArg(self, blendFunctionArg: Qt3DRender.QBlendEquation.BlendFunction) -> None: ... def setDestinationAlphaArg(self, destinationAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... def setSourceAlphaArg(self, sourceAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... @@ -489,11 +509,11 @@ class QPhongAlphaMaterial(Qt3DRender.QMaterial): def sourceAlphaArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... def destinationRgbArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... def sourceRgbArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... - alphaChanged: typing.ClassVar[QtCore.pyqtSignal] - shininessChanged: typing.ClassVar[QtCore.pyqtSignal] - specularChanged: typing.ClassVar[QtCore.pyqtSignal] - diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] - ambientChanged: typing.ClassVar[QtCore.pyqtSignal] + def alphaChanged(self, alpha: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setAlpha(self, alpha: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... @@ -508,10 +528,11 @@ class QPhongAlphaMaterial(Qt3DRender.QMaterial): class QPhongMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - shininessChanged: typing.ClassVar[QtCore.pyqtSignal] - specularChanged: typing.ClassVar[QtCore.pyqtSignal] - diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] - ambientChanged: typing.ClassVar[QtCore.pyqtSignal] + + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setDiffuse(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... @@ -524,12 +545,13 @@ class QPhongMaterial(Qt3DRender.QMaterial): class QPlaneGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] + + def mirroredChanged(self, mirrored: bool) -> None: ... def setMirrored(self, mirrored: bool) -> None: ... def mirrored(self) -> bool: ... - heightChanged: typing.ClassVar[QtCore.pyqtSignal] - widthChanged: typing.ClassVar[QtCore.pyqtSignal] - resolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + def heightChanged(self, height: float) -> None: ... + def widthChanged(self, width: float) -> None: ... + def resolutionChanged(self, resolution: QtCore.QSize) -> None: ... def setHeight(self, height: float) -> None: ... def setWidth(self, width: float) -> None: ... def setResolution(self, resolution: QtCore.QSize) -> None: ... @@ -547,12 +569,13 @@ class QPlaneGeometry(Qt3DRender.QGeometry): class QPlaneMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] + + def mirroredChanged(self, mirrored: bool) -> None: ... def setMirrored(self, mirrored: bool) -> None: ... def mirrored(self) -> bool: ... - heightChanged: typing.ClassVar[QtCore.pyqtSignal] - widthChanged: typing.ClassVar[QtCore.pyqtSignal] - meshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + def heightChanged(self, height: float) -> None: ... + def widthChanged(self, width: float) -> None: ... + def meshResolutionChanged(self, meshResolution: QtCore.QSize) -> None: ... def setMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setHeight(self, height: float) -> None: ... def setWidth(self, width: float) -> None: ... @@ -563,11 +586,12 @@ class QPlaneMesh(Qt3DRender.QGeometryRenderer): class QSkyboxEntity(Qt3DCore.QEntity): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - gammaCorrectEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - baseNameChanged: typing.ClassVar[QtCore.pyqtSignal] + + def gammaCorrectEnabledChanged(self, enabled: bool) -> None: ... + def baseNameChanged(self, path: str) -> None: ... def setGammaCorrectEnabled(self, enabled: bool) -> None: ... def isGammaCorrectEnabled(self) -> bool: ... - extensionChanged: typing.ClassVar[QtCore.pyqtSignal] + def extensionChanged(self, extension: str) -> None: ... def extension(self) -> str: ... def setExtension(self, extension: str) -> None: ... def baseName(self) -> str: ... @@ -576,10 +600,11 @@ class QSkyboxEntity(Qt3DCore.QEntity): class QSphereGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - generateTangentsChanged: typing.ClassVar[QtCore.pyqtSignal] - slicesChanged: typing.ClassVar[QtCore.pyqtSignal] - ringsChanged: typing.ClassVar[QtCore.pyqtSignal] - radiusChanged: typing.ClassVar[QtCore.pyqtSignal] + + def generateTangentsChanged(self, generateTangents: bool) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... def setGenerateTangents(self, gen: bool) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -599,10 +624,11 @@ class QSphereGeometry(Qt3DRender.QGeometry): class QSphereMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - generateTangentsChanged: typing.ClassVar[QtCore.pyqtSignal] - slicesChanged: typing.ClassVar[QtCore.pyqtSignal] - ringsChanged: typing.ClassVar[QtCore.pyqtSignal] - radiusChanged: typing.ClassVar[QtCore.pyqtSignal] + + def generateTangentsChanged(self, generateTangents: bool) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... def setGenerateTangents(self, gen: bool) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -615,8 +641,9 @@ class QSphereMesh(Qt3DRender.QGeometryRenderer): class QSpriteGrid('QAbstractSpriteSheet'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - columnsChanged: typing.ClassVar[QtCore.pyqtSignal] - rowsChanged: typing.ClassVar[QtCore.pyqtSignal] + + def columnsChanged(self, columns: int) -> None: ... + def rowsChanged(self, rows: int) -> None: ... def setColumns(self, columns: int) -> None: ... def setRows(self, rows: int) -> None: ... def columns(self) -> int: ... @@ -625,7 +652,8 @@ class QSpriteGrid('QAbstractSpriteSheet'): class QSpriteSheet('QAbstractSpriteSheet'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - spritesChanged: typing.ClassVar[QtCore.pyqtSignal] + + def spritesChanged(self, sprites: typing.Iterable['QSpriteSheetItem']) -> None: ... def setSprites(self, sprites: typing.Iterable['QSpriteSheetItem']) -> None: ... def removeSprite(self, sprite: 'QSpriteSheetItem') -> None: ... @typing.overload @@ -637,10 +665,11 @@ class QSpriteSheet('QAbstractSpriteSheet'): class QSpriteSheetItem(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - heightChanged: typing.ClassVar[QtCore.pyqtSignal] - widthChanged: typing.ClassVar[QtCore.pyqtSignal] - yChanged: typing.ClassVar[QtCore.pyqtSignal] - xChanged: typing.ClassVar[QtCore.pyqtSignal] + + def heightChanged(self, height: int) -> None: ... + def widthChanged(self, width: int) -> None: ... + def yChanged(self, y: int) -> None: ... + def xChanged(self, x: int) -> None: ... def setHeight(self, height: int) -> None: ... def setWidth(self, width: int) -> None: ... def setY(self, y: int) -> None: ... @@ -671,11 +700,12 @@ class Qt3DWindow(QtGui.QWindow): class QText2DEntity(Qt3DCore.QEntity): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - heightChanged: typing.ClassVar[QtCore.pyqtSignal] - widthChanged: typing.ClassVar[QtCore.pyqtSignal] - textChanged: typing.ClassVar[QtCore.pyqtSignal] - colorChanged: typing.ClassVar[QtCore.pyqtSignal] - fontChanged: typing.ClassVar[QtCore.pyqtSignal] + + def heightChanged(self, height: float) -> None: ... + def widthChanged(self, width: float) -> None: ... + def textChanged(self, text: str) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... def setHeight(self, height: float) -> None: ... def setWidth(self, width: float) -> None: ... def height(self) -> float: ... @@ -690,16 +720,18 @@ class QText2DEntity(Qt3DCore.QEntity): class QTexturedMetalRoughMaterial('QMetalRoughMaterial'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - normalChanged: typing.ClassVar[QtCore.pyqtSignal] - ambientOcclusionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def normalChanged(self, normal: typing.Any) -> None: ... + def ambientOcclusionChanged(self, ambientOcclusion: typing.Any) -> None: ... class QTextureMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - alphaBlendingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - textureTransformChanged: typing.ClassVar[QtCore.pyqtSignal] - textureOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] - textureChanged: typing.ClassVar[QtCore.pyqtSignal] + + def alphaBlendingEnabledChanged(self, enabled: bool) -> None: ... + def textureTransformChanged(self, textureTransform: QtGui.QMatrix3x3) -> None: ... + def textureOffsetChanged(self, textureOffset: QtGui.QVector2D) -> None: ... + def textureChanged(self, texture: Qt3DRender.QAbstractTexture) -> None: ... def setAlphaBlendingEnabled(self, enabled: bool) -> None: ... def setTextureTransform(self, matrix: QtGui.QMatrix3x3) -> None: ... def setTextureOffset(self, textureOffset: QtGui.QVector2D) -> None: ... @@ -712,10 +744,11 @@ class QTextureMaterial(Qt3DRender.QMaterial): class QTorusGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - minorRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] - slicesChanged: typing.ClassVar[QtCore.pyqtSignal] - ringsChanged: typing.ClassVar[QtCore.pyqtSignal] - radiusChanged: typing.ClassVar[QtCore.pyqtSignal] + + def minorRadiusChanged(self, minorRadius: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... def setMinorRadius(self, minorRadius: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -734,10 +767,11 @@ class QTorusGeometry(Qt3DRender.QGeometry): class QTorusMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - minorRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] - slicesChanged: typing.ClassVar[QtCore.pyqtSignal] - ringsChanged: typing.ClassVar[QtCore.pyqtSignal] - radiusChanged: typing.ClassVar[QtCore.pyqtSignal] + + def minorRadiusChanged(self, minorRadius: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... def setMinorRadius(self, minorRadius: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... diff --git a/PyQt5-stubs/Qt3DInput.pyi b/PyQt5-stubs/Qt3DInput.pyi index 302b56c5..5c6a8256 100644 --- a/PyQt5-stubs/Qt3DInput.pyi +++ b/PyQt5-stubs/Qt3DInput.pyi @@ -43,7 +43,8 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], class QAbstractActionInput(Qt3DCore.QNode): ... class QAbstractAxisInput(Qt3DCore.QNode): - sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] + + def sourceDeviceChanged(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... def setSourceDevice(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... def sourceDevice(self) -> 'QAbstractPhysicalDevice': ... @@ -66,7 +67,7 @@ class QAction(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - activeChanged: typing.ClassVar[QtCore.pyqtSignal] + def activeChanged(self, isActive: bool) -> None: ... def inputs(self) -> typing.List['QAbstractActionInput']: ... def removeInput(self, input: 'QAbstractActionInput') -> None: ... def addInput(self, input: 'QAbstractActionInput') -> None: ... @@ -75,8 +76,9 @@ class QAction(Qt3DCore.QNode): class QActionInput('QAbstractActionInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - buttonsChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] + + def buttonsChanged(self, buttons: typing.Iterable[int]) -> None: ... + def sourceDeviceChanged(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... def setButtons(self, buttons: typing.Iterable[int]) -> None: ... def setSourceDevice(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... def buttons(self) -> typing.List[int]: ... @@ -85,7 +87,8 @@ class QActionInput('QAbstractActionInput'): class QAnalogAxisInput('QAbstractAxisInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - axisChanged: typing.ClassVar[QtCore.pyqtSignal] + + def axisChanged(self, axis: int) -> None: ... def setAxis(self, axis: int) -> None: ... def axis(self) -> int: ... @@ -94,7 +97,7 @@ class QAxis(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - valueChanged: typing.ClassVar[QtCore.pyqtSignal] + def valueChanged(self, value: float) -> None: ... def value(self) -> float: ... def inputs(self) -> typing.List['QAbstractAxisInput']: ... def removeInput(self, input: 'QAbstractAxisInput') -> None: ... @@ -112,11 +115,11 @@ class QAxisAccumulator(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - scaleChanged: typing.ClassVar[QtCore.pyqtSignal] - velocityChanged: typing.ClassVar[QtCore.pyqtSignal] - valueChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceAxisTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceAxisChanged: typing.ClassVar[QtCore.pyqtSignal] + def scaleChanged(self, scale: float) -> None: ... + def velocityChanged(self, value: float) -> None: ... + def valueChanged(self, value: float) -> None: ... + def sourceAxisTypeChanged(self, sourceAxisType: 'QAxisAccumulator.SourceAxisType') -> None: ... + def sourceAxisChanged(self, sourceAxis: 'QAxis') -> None: ... def setScale(self, scale: float) -> None: ... def setSourceAxisType(self, sourceAxisType: 'QAxisAccumulator.SourceAxisType') -> None: ... def setSourceAxis(self, sourceAxis: 'QAxis') -> None: ... @@ -129,9 +132,10 @@ class QAxisAccumulator(Qt3DCore.QComponent): class QAxisSetting(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - smoothChanged: typing.ClassVar[QtCore.pyqtSignal] - axesChanged: typing.ClassVar[QtCore.pyqtSignal] - deadZoneRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + + def smoothChanged(self, smooth: bool) -> None: ... + def axesChanged(self, axes: typing.Iterable[int]) -> None: ... + def deadZoneRadiusChanged(self, deadZoneRadius: float) -> None: ... def setSmoothEnabled(self, enabled: bool) -> None: ... def setAxes(self, axes: typing.Iterable[int]) -> None: ... def setDeadZoneRadius(self, deadZoneRadius: float) -> None: ... @@ -142,10 +146,11 @@ class QAxisSetting(Qt3DCore.QNode): class QButtonAxisInput('QAbstractAxisInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - decelerationChanged: typing.ClassVar[QtCore.pyqtSignal] - accelerationChanged: typing.ClassVar[QtCore.pyqtSignal] - buttonsChanged: typing.ClassVar[QtCore.pyqtSignal] - scaleChanged: typing.ClassVar[QtCore.pyqtSignal] + + def decelerationChanged(self, deceleration: float) -> None: ... + def accelerationChanged(self, acceleration: float) -> None: ... + def buttonsChanged(self, buttons: typing.Iterable[int]) -> None: ... + def scaleChanged(self, scale: float) -> None: ... def setDeceleration(self, deceleration: float) -> None: ... def setAcceleration(self, acceleration: float) -> None: ... def setButtons(self, buttons: typing.Iterable[int]) -> None: ... @@ -165,7 +170,8 @@ class QInputAspect(Qt3DCore.QAbstractAspect): class QInputChord('QAbstractActionInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - timeoutChanged: typing.ClassVar[QtCore.pyqtSignal] + + def timeoutChanged(self, timeout: int) -> None: ... def setTimeout(self, timeout: int) -> None: ... def chords(self) -> typing.List['QAbstractActionInput']: ... def removeChord(self, input: 'QAbstractActionInput') -> None: ... @@ -175,8 +181,9 @@ class QInputChord('QAbstractActionInput'): class QInputSequence('QAbstractActionInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - buttonIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] - timeoutChanged: typing.ClassVar[QtCore.pyqtSignal] + + def buttonIntervalChanged(self, buttonInterval: int) -> None: ... + def timeoutChanged(self, timeout: int) -> None: ... def setButtonInterval(self, buttonInterval: int) -> None: ... def setTimeout(self, timeout: int) -> None: ... def sequences(self) -> typing.List['QAbstractActionInput']: ... @@ -188,14 +195,16 @@ class QInputSequence('QAbstractActionInput'): class QInputSettings(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - eventSourceChanged: typing.ClassVar[QtCore.pyqtSignal] + + def eventSourceChanged(self, a0: QtCore.QObject) -> None: ... def setEventSource(self, eventSource: QtCore.QObject) -> None: ... def eventSource(self) -> QtCore.QObject: ... class QKeyboardDevice('QAbstractPhysicalDevice'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - activeInputChanged: typing.ClassVar[QtCore.pyqtSignal] + + def activeInputChanged(self, activeInput: 'QKeyboardHandler') -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... def buttonIdentifier(self, name: str) -> int: ... def axisIdentifier(self, name: str) -> int: ... @@ -210,48 +219,48 @@ class QKeyboardHandler(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] - volumeDownPressed: typing.ClassVar[QtCore.pyqtSignal] - volumeUpPressed: typing.ClassVar[QtCore.pyqtSignal] - menuPressed: typing.ClassVar[QtCore.pyqtSignal] - flipPressed: typing.ClassVar[QtCore.pyqtSignal] - hangupPressed: typing.ClassVar[QtCore.pyqtSignal] - callPressed: typing.ClassVar[QtCore.pyqtSignal] - context4Pressed: typing.ClassVar[QtCore.pyqtSignal] - context3Pressed: typing.ClassVar[QtCore.pyqtSignal] - context2Pressed: typing.ClassVar[QtCore.pyqtSignal] - context1Pressed: typing.ClassVar[QtCore.pyqtSignal] - noPressed: typing.ClassVar[QtCore.pyqtSignal] - yesPressed: typing.ClassVar[QtCore.pyqtSignal] - selectPressed: typing.ClassVar[QtCore.pyqtSignal] - cancelPressed: typing.ClassVar[QtCore.pyqtSignal] - backPressed: typing.ClassVar[QtCore.pyqtSignal] - spacePressed: typing.ClassVar[QtCore.pyqtSignal] - deletePressed: typing.ClassVar[QtCore.pyqtSignal] - enterPressed: typing.ClassVar[QtCore.pyqtSignal] - returnPressed: typing.ClassVar[QtCore.pyqtSignal] - escapePressed: typing.ClassVar[QtCore.pyqtSignal] - numberSignPressed: typing.ClassVar[QtCore.pyqtSignal] - asteriskPressed: typing.ClassVar[QtCore.pyqtSignal] - backtabPressed: typing.ClassVar[QtCore.pyqtSignal] - tabPressed: typing.ClassVar[QtCore.pyqtSignal] - downPressed: typing.ClassVar[QtCore.pyqtSignal] - upPressed: typing.ClassVar[QtCore.pyqtSignal] - rightPressed: typing.ClassVar[QtCore.pyqtSignal] - leftPressed: typing.ClassVar[QtCore.pyqtSignal] - digit9Pressed: typing.ClassVar[QtCore.pyqtSignal] - digit8Pressed: typing.ClassVar[QtCore.pyqtSignal] - digit7Pressed: typing.ClassVar[QtCore.pyqtSignal] - digit6Pressed: typing.ClassVar[QtCore.pyqtSignal] - digit5Pressed: typing.ClassVar[QtCore.pyqtSignal] - digit4Pressed: typing.ClassVar[QtCore.pyqtSignal] - digit3Pressed: typing.ClassVar[QtCore.pyqtSignal] - digit2Pressed: typing.ClassVar[QtCore.pyqtSignal] - digit1Pressed: typing.ClassVar[QtCore.pyqtSignal] - digit0Pressed: typing.ClassVar[QtCore.pyqtSignal] - focusChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] + def released(self, event: 'QKeyEvent') -> None: ... + def pressed(self, event: 'QKeyEvent') -> None: ... + def volumeDownPressed(self, event: 'QKeyEvent') -> None: ... + def volumeUpPressed(self, event: 'QKeyEvent') -> None: ... + def menuPressed(self, event: 'QKeyEvent') -> None: ... + def flipPressed(self, event: 'QKeyEvent') -> None: ... + def hangupPressed(self, event: 'QKeyEvent') -> None: ... + def callPressed(self, event: 'QKeyEvent') -> None: ... + def context4Pressed(self, event: 'QKeyEvent') -> None: ... + def context3Pressed(self, event: 'QKeyEvent') -> None: ... + def context2Pressed(self, event: 'QKeyEvent') -> None: ... + def context1Pressed(self, event: 'QKeyEvent') -> None: ... + def noPressed(self, event: 'QKeyEvent') -> None: ... + def yesPressed(self, event: 'QKeyEvent') -> None: ... + def selectPressed(self, event: 'QKeyEvent') -> None: ... + def cancelPressed(self, event: 'QKeyEvent') -> None: ... + def backPressed(self, event: 'QKeyEvent') -> None: ... + def spacePressed(self, event: 'QKeyEvent') -> None: ... + def deletePressed(self, event: 'QKeyEvent') -> None: ... + def enterPressed(self, event: 'QKeyEvent') -> None: ... + def returnPressed(self, event: 'QKeyEvent') -> None: ... + def escapePressed(self, event: 'QKeyEvent') -> None: ... + def numberSignPressed(self, event: 'QKeyEvent') -> None: ... + def asteriskPressed(self, event: 'QKeyEvent') -> None: ... + def backtabPressed(self, event: 'QKeyEvent') -> None: ... + def tabPressed(self, event: 'QKeyEvent') -> None: ... + def downPressed(self, event: 'QKeyEvent') -> None: ... + def upPressed(self, event: 'QKeyEvent') -> None: ... + def rightPressed(self, event: 'QKeyEvent') -> None: ... + def leftPressed(self, event: 'QKeyEvent') -> None: ... + def digit9Pressed(self, event: 'QKeyEvent') -> None: ... + def digit8Pressed(self, event: 'QKeyEvent') -> None: ... + def digit7Pressed(self, event: 'QKeyEvent') -> None: ... + def digit6Pressed(self, event: 'QKeyEvent') -> None: ... + def digit5Pressed(self, event: 'QKeyEvent') -> None: ... + def digit4Pressed(self, event: 'QKeyEvent') -> None: ... + def digit3Pressed(self, event: 'QKeyEvent') -> None: ... + def digit2Pressed(self, event: 'QKeyEvent') -> None: ... + def digit1Pressed(self, event: 'QKeyEvent') -> None: ... + def digit0Pressed(self, event: 'QKeyEvent') -> None: ... + def focusChanged(self, focus: bool) -> None: ... + def sourceDeviceChanged(self, keyboardDevice: 'QKeyboardDevice') -> None: ... def setFocus(self, focus: bool) -> None: ... def setSourceDevice(self, keyboardDevice: 'QKeyboardDevice') -> None: ... def focus(self) -> bool: ... @@ -300,11 +309,12 @@ class QMouseDevice('QAbstractPhysicalDevice'): WheelY = ... # type: QMouseDevice.Axis def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - updateAxesContinuouslyChanged: typing.ClassVar[QtCore.pyqtSignal] + + def updateAxesContinuouslyChanged(self, updateAxesContinuously: bool) -> None: ... def setUpdateAxesContinuously(self, updateAxesContinuously: bool) -> None: ... def updateAxesContinuously(self) -> bool: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - sensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] + def sensitivityChanged(self, value: float) -> None: ... def setSensitivity(self, value: float) -> None: ... def sensitivity(self) -> float: ... def buttonIdentifier(self, name: str) -> int: ... @@ -402,17 +412,17 @@ class QMouseHandler(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - wheel: typing.ClassVar[QtCore.pyqtSignal] - positionChanged: typing.ClassVar[QtCore.pyqtSignal] - pressAndHold: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] - exited: typing.ClassVar[QtCore.pyqtSignal] - entered: typing.ClassVar[QtCore.pyqtSignal] - doubleClicked: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] - containsMouseChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] + def wheel(self, wheel: 'QWheelEvent') -> None: ... + def positionChanged(self, mouse: 'QMouseEvent') -> None: ... + def pressAndHold(self, mouse: 'QMouseEvent') -> None: ... + def released(self, mouse: 'QMouseEvent') -> None: ... + def pressed(self, mouse: 'QMouseEvent') -> None: ... + def exited(self) -> None: ... + def entered(self) -> None: ... + def doubleClicked(self, mouse: 'QMouseEvent') -> None: ... + def clicked(self, mouse: 'QMouseEvent') -> None: ... + def containsMouseChanged(self, containsMouse: bool) -> None: ... + def sourceDeviceChanged(self, mouseDevice: 'QMouseDevice') -> None: ... def setSourceDevice(self, mouseDevice: 'QMouseDevice') -> None: ... def containsMouse(self) -> bool: ... def sourceDevice(self) -> 'QMouseDevice': ... diff --git a/PyQt5-stubs/Qt3DLogic.pyi b/PyQt5-stubs/Qt3DLogic.pyi index 03262555..dd8cabb8 100644 --- a/PyQt5-stubs/Qt3DLogic.pyi +++ b/PyQt5-stubs/Qt3DLogic.pyi @@ -42,7 +42,8 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], class QFrameAction(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - triggered: typing.ClassVar[QtCore.pyqtSignal] + + def triggered(self, dt: float) -> None: ... class QLogicAspect(Qt3DCore.QAbstractAspect): diff --git a/PyQt5-stubs/Qt3DRender.pyi b/PyQt5-stubs/Qt3DRender.pyi index 6258830a..43b9e810 100644 --- a/PyQt5-stubs/Qt3DRender.pyi +++ b/PyQt5-stubs/Qt3DRender.pyi @@ -54,8 +54,9 @@ class QAbstractLight(Qt3DCore.QComponent): PointLight = ... # type: QAbstractLight.Type DirectionalLight = ... # type: QAbstractLight.Type SpotLight = ... # type: QAbstractLight.Type - intensityChanged: typing.ClassVar[QtCore.pyqtSignal] - colorChanged: typing.ClassVar[QtCore.pyqtSignal] + + def intensityChanged(self, intensity: float) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setIntensity(self, intensity: float) -> None: ... def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def intensity(self) -> float: ... @@ -85,9 +86,9 @@ class QAbstractRayCaster(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - filterModeChanged: typing.ClassVar[QtCore.pyqtSignal] - hitsChanged: typing.ClassVar[QtCore.pyqtSignal] - runModeChanged: typing.ClassVar[QtCore.pyqtSignal] + def filterModeChanged(self, filterMode: 'QAbstractRayCaster.FilterMode') -> None: ... + def hitsChanged(self, hits: typing.Iterable['QRayCasterHit']) -> None: ... + def runModeChanged(self, runMode: 'QAbstractRayCaster.RunMode') -> None: ... def setFilterMode(self, filterMode: 'QAbstractRayCaster.FilterMode') -> None: ... def setRunMode(self, runMode: 'QAbstractRayCaster.RunMode') -> None: ... def layers(self) -> typing.List['QLayer']: ... @@ -411,25 +412,25 @@ class QAbstractTexture(Qt3DCore.QNode): def __init__(self, target: 'QAbstractTexture.Target', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def updateData(self, update: 'QTextureDataUpdate') -> None: ... - handleChanged: typing.ClassVar[QtCore.pyqtSignal] - handleTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + def handleChanged(self, handle: typing.Any) -> None: ... + def handleTypeChanged(self, handleType: 'QAbstractTexture.HandleType') -> None: ... def handle(self) -> typing.Any: ... def handleType(self) -> 'QAbstractTexture.HandleType': ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... def setStatus(self, status: 'QAbstractTexture.Status') -> None: ... - samplesChanged: typing.ClassVar[QtCore.pyqtSignal] - layersChanged: typing.ClassVar[QtCore.pyqtSignal] - comparisonModeChanged: typing.ClassVar[QtCore.pyqtSignal] - comparisonFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] - maximumAnisotropyChanged: typing.ClassVar[QtCore.pyqtSignal] - minificationFilterChanged: typing.ClassVar[QtCore.pyqtSignal] - magnificationFilterChanged: typing.ClassVar[QtCore.pyqtSignal] - depthChanged: typing.ClassVar[QtCore.pyqtSignal] - heightChanged: typing.ClassVar[QtCore.pyqtSignal] - widthChanged: typing.ClassVar[QtCore.pyqtSignal] - generateMipMapsChanged: typing.ClassVar[QtCore.pyqtSignal] - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - formatChanged: typing.ClassVar[QtCore.pyqtSignal] + def samplesChanged(self, samples: int) -> None: ... + def layersChanged(self, layers: int) -> None: ... + def comparisonModeChanged(self, comparisonMode: 'QAbstractTexture.ComparisonMode') -> None: ... + def comparisonFunctionChanged(self, comparisonFunction: 'QAbstractTexture.ComparisonFunction') -> None: ... + def maximumAnisotropyChanged(self, maximumAnisotropy: float) -> None: ... + def minificationFilterChanged(self, minificationFilter: 'QAbstractTexture.Filter') -> None: ... + def magnificationFilterChanged(self, magnificationFilter: 'QAbstractTexture.Filter') -> None: ... + def depthChanged(self, depth: int) -> None: ... + def heightChanged(self, height: int) -> None: ... + def widthChanged(self, width: int) -> None: ... + def generateMipMapsChanged(self, generateMipMaps: bool) -> None: ... + def statusChanged(self, status: 'QAbstractTexture.Status') -> None: ... + def formatChanged(self, format: 'QAbstractTexture.TextureFormat') -> None: ... def setSamples(self, samples: int) -> None: ... def setLayers(self, layers: int) -> None: ... def setComparisonMode(self, mode: 'QAbstractTexture.ComparisonMode') -> None: ... @@ -470,9 +471,9 @@ class QAbstractTextureImage(Qt3DCore.QNode): def dataGenerator(self) -> 'QTextureImageDataGenerator': ... def notifyDataGeneratorChanged(self) -> None: ... - faceChanged: typing.ClassVar[QtCore.pyqtSignal] - layerChanged: typing.ClassVar[QtCore.pyqtSignal] - mipLevelChanged: typing.ClassVar[QtCore.pyqtSignal] + def faceChanged(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... + def layerChanged(self, layer: int) -> None: ... + def mipLevelChanged(self, mipLevel: int) -> None: ... def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... def setLayer(self, layer: int) -> None: ... def setMipLevel(self, level: int) -> None: ... @@ -508,8 +509,9 @@ class QAlphaTest('QRenderState'): NotEqual = ... # type: QAlphaTest.AlphaFunction def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - referenceValueChanged: typing.ClassVar[QtCore.pyqtSignal] - alphaFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def referenceValueChanged(self, referenceValue: float) -> None: ... + def alphaFunctionChanged(self, alphaFunction: 'QAlphaTest.AlphaFunction') -> None: ... def setReferenceValue(self, referenceValue: float) -> None: ... def setAlphaFunction(self, alphaFunction: 'QAlphaTest.AlphaFunction') -> None: ... def referenceValue(self) -> float: ... @@ -553,17 +555,18 @@ class QAttribute(Qt3DCore.QNode): def __init__(self, buf: 'QBuffer', vertexBaseType: 'QAttribute.VertexBaseType', vertexSize: int, count: int, offset: int = ..., stride: int = ..., parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... @typing.overload def __init__(self, buf: 'QBuffer', name: str, vertexBaseType: 'QAttribute.VertexBaseType', vertexSize: int, count: int, offset: int = ..., stride: int = ..., parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - vertexSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - vertexBaseTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - attributeTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - divisorChanged: typing.ClassVar[QtCore.pyqtSignal] - byteOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] - byteStrideChanged: typing.ClassVar[QtCore.pyqtSignal] - countChanged: typing.ClassVar[QtCore.pyqtSignal] - dataSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - dataTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - nameChanged: typing.ClassVar[QtCore.pyqtSignal] - bufferChanged: typing.ClassVar[QtCore.pyqtSignal] + + def vertexSizeChanged(self, vertexSize: int) -> None: ... + def vertexBaseTypeChanged(self, vertexBaseType: 'QAttribute.VertexBaseType') -> None: ... + def attributeTypeChanged(self, attributeType: 'QAttribute.AttributeType') -> None: ... + def divisorChanged(self, divisor: int) -> None: ... + def byteOffsetChanged(self, byteOffset: int) -> None: ... + def byteStrideChanged(self, byteStride: int) -> None: ... + def countChanged(self, count: int) -> None: ... + def dataSizeChanged(self, vertexSize: int) -> None: ... + def dataTypeChanged(self, vertexBaseType: 'QAttribute.VertexBaseType') -> None: ... + def nameChanged(self, name: str) -> None: ... + def bufferChanged(self, buffer: 'QBuffer') -> None: ... def setVertexSize(self, size: int) -> None: ... def setVertexBaseType(self, type: 'QAttribute.VertexBaseType') -> None: ... def setAttributeType(self, attributeType: 'QAttribute.AttributeType') -> None: ... @@ -619,7 +622,8 @@ class QBlendEquation('QRenderState'): Max = ... # type: QBlendEquation.BlendFunction def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - blendFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def blendFunctionChanged(self, blendFunction: 'QBlendEquation.BlendFunction') -> None: ... def setBlendFunction(self, blendFunction: 'QBlendEquation.BlendFunction') -> None: ... def blendFunction(self) -> 'QBlendEquation.BlendFunction': ... @@ -669,13 +673,14 @@ class QBlendEquationArguments('QRenderState'): OneMinusSource1Color = ... # type: QBlendEquationArguments.Blending def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - bufferIndexChanged: typing.ClassVar[QtCore.pyqtSignal] - destinationRgbaChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceRgbaChanged: typing.ClassVar[QtCore.pyqtSignal] - destinationAlphaChanged: typing.ClassVar[QtCore.pyqtSignal] - destinationRgbChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceAlphaChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceRgbChanged: typing.ClassVar[QtCore.pyqtSignal] + + def bufferIndexChanged(self, index: int) -> None: ... + def destinationRgbaChanged(self, destinationRgba: 'QBlendEquationArguments.Blending') -> None: ... + def sourceRgbaChanged(self, sourceRgba: 'QBlendEquationArguments.Blending') -> None: ... + def destinationAlphaChanged(self, destinationAlpha: 'QBlendEquationArguments.Blending') -> None: ... + def destinationRgbChanged(self, destinationRgb: 'QBlendEquationArguments.Blending') -> None: ... + def sourceAlphaChanged(self, sourceAlpha: 'QBlendEquationArguments.Blending') -> None: ... + def sourceRgbChanged(self, sourceRgb: 'QBlendEquationArguments.Blending') -> None: ... def setBufferIndex(self, index: int) -> None: ... def setDestinationRgba(self, destinationRgba: 'QBlendEquationArguments.Blending') -> None: ... def setSourceRgba(self, sourceRgba: 'QBlendEquationArguments.Blending') -> None: ... @@ -705,13 +710,14 @@ class QBlitFramebuffer('QFrameGraphNode'): Linear = ... # type: QBlitFramebuffer.InterpolationMethod def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - interpolationMethodChanged: typing.ClassVar[QtCore.pyqtSignal] - destinationAttachmentPointChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceAttachmentPointChanged: typing.ClassVar[QtCore.pyqtSignal] - destinationRectChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceRectChanged: typing.ClassVar[QtCore.pyqtSignal] - destinationChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + + def interpolationMethodChanged(self) -> None: ... + def destinationAttachmentPointChanged(self) -> None: ... + def sourceAttachmentPointChanged(self) -> None: ... + def destinationRectChanged(self) -> None: ... + def sourceRectChanged(self) -> None: ... + def destinationChanged(self) -> None: ... + def sourceChanged(self) -> None: ... def setInterpolationMethod(self, interpolationMethod: 'QBlitFramebuffer.InterpolationMethod') -> None: ... def setDestinationAttachmentPoint(self, destinationAttachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... def setSourceAttachmentPoint(self, sourceAttachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... @@ -780,16 +786,17 @@ class QBuffer(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... @typing.overload def __init__(self, ty: 'QBuffer.BufferType', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - dataAvailable: typing.ClassVar[QtCore.pyqtSignal] - accessTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def dataAvailable(self) -> None: ... + def accessTypeChanged(self, access: 'QBuffer.AccessType') -> None: ... def setAccessType(self, access: 'QBuffer.AccessType') -> None: ... def accessType(self) -> 'QBuffer.AccessType': ... def updateData(self, offset: int, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - syncDataChanged: typing.ClassVar[QtCore.pyqtSignal] - usageChanged: typing.ClassVar[QtCore.pyqtSignal] - typeChanged: typing.ClassVar[QtCore.pyqtSignal] - dataChanged: typing.ClassVar[QtCore.pyqtSignal] + def syncDataChanged(self, syncData: bool) -> None: ... + def usageChanged(self, usage: 'QBuffer.UsageType') -> None: ... + def typeChanged(self, type: 'QBuffer.BufferType') -> None: ... + def dataChanged(self, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def setSyncData(self, syncData: bool) -> None: ... def setUsage(self, usage: 'QBuffer.UsageType') -> None: ... def setType(self, type: 'QBuffer.BufferType') -> None: ... @@ -819,24 +826,24 @@ class QCamera(Qt3DCore.QEntity): def viewEntity(self, entity: Qt3DCore.QEntity) -> None: ... def viewSphere(self, center: QtGui.QVector3D, radius: float) -> None: ... def viewAll(self) -> None: ... - exposureChanged: typing.ClassVar[QtCore.pyqtSignal] + def exposureChanged(self, exposure: float) -> None: ... def setExposure(self, exposure: float) -> None: ... def exposure(self) -> float: ... - viewMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] - viewVectorChanged: typing.ClassVar[QtCore.pyqtSignal] - viewCenterChanged: typing.ClassVar[QtCore.pyqtSignal] - upVectorChanged: typing.ClassVar[QtCore.pyqtSignal] - positionChanged: typing.ClassVar[QtCore.pyqtSignal] - projectionMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] - topChanged: typing.ClassVar[QtCore.pyqtSignal] - bottomChanged: typing.ClassVar[QtCore.pyqtSignal] - rightChanged: typing.ClassVar[QtCore.pyqtSignal] - leftChanged: typing.ClassVar[QtCore.pyqtSignal] - aspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] - fieldOfViewChanged: typing.ClassVar[QtCore.pyqtSignal] - farPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] - nearPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] - projectionTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + def viewMatrixChanged(self) -> None: ... + def viewVectorChanged(self, viewVector: QtGui.QVector3D) -> None: ... + def viewCenterChanged(self, viewCenter: QtGui.QVector3D) -> None: ... + def upVectorChanged(self, upVector: QtGui.QVector3D) -> None: ... + def positionChanged(self, position: QtGui.QVector3D) -> None: ... + def projectionMatrixChanged(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... + def topChanged(self, top: float) -> None: ... + def bottomChanged(self, bottom: float) -> None: ... + def rightChanged(self, right: float) -> None: ... + def leftChanged(self, left: float) -> None: ... + def aspectRatioChanged(self, aspectRatio: float) -> None: ... + def fieldOfViewChanged(self, fieldOfView: float) -> None: ... + def farPlaneChanged(self, farPlane: float) -> None: ... + def nearPlaneChanged(self, nearPlane: float) -> None: ... + def projectionTypeChanged(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... def setViewCenter(self, viewCenter: QtGui.QVector3D) -> None: ... def setUpVector(self, upVector: QtGui.QVector3D) -> None: ... def setPosition(self, position: QtGui.QVector3D) -> None: ... @@ -902,22 +909,23 @@ class QCameraLens(Qt3DCore.QComponent): CustomProjection = ... # type: QCameraLens.ProjectionType def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - viewSphere: typing.ClassVar[QtCore.pyqtSignal] + + def viewSphere(self, center: QtGui.QVector3D, radius: float) -> None: ... def viewEntity(self, entityId: Qt3DCore.QNodeId, cameraId: Qt3DCore.QNodeId) -> None: ... def viewAll(self, cameraId: Qt3DCore.QNodeId) -> None: ... - exposureChanged: typing.ClassVar[QtCore.pyqtSignal] + def exposureChanged(self, exposure: float) -> None: ... def setExposure(self, exposure: float) -> None: ... def exposure(self) -> float: ... - projectionMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] - topChanged: typing.ClassVar[QtCore.pyqtSignal] - bottomChanged: typing.ClassVar[QtCore.pyqtSignal] - rightChanged: typing.ClassVar[QtCore.pyqtSignal] - leftChanged: typing.ClassVar[QtCore.pyqtSignal] - aspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] - fieldOfViewChanged: typing.ClassVar[QtCore.pyqtSignal] - farPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] - nearPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] - projectionTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + def projectionMatrixChanged(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... + def topChanged(self, top: float) -> None: ... + def bottomChanged(self, bottom: float) -> None: ... + def rightChanged(self, right: float) -> None: ... + def leftChanged(self, left: float) -> None: ... + def aspectRatioChanged(self, aspectRatio: float) -> None: ... + def fieldOfViewChanged(self, fieldOfView: float) -> None: ... + def farPlaneChanged(self, farPlane: float) -> None: ... + def nearPlaneChanged(self, nearPlane: float) -> None: ... + def projectionTypeChanged(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... def setProjectionMatrix(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... def setTop(self, top: float) -> None: ... def setBottom(self, bottom: float) -> None: ... @@ -945,7 +953,8 @@ class QCameraLens(Qt3DCore.QComponent): class QCameraSelector('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - cameraChanged: typing.ClassVar[QtCore.pyqtSignal] + + def cameraChanged(self, camera: Qt3DCore.QEntity) -> None: ... def setCamera(self, camera: Qt3DCore.QEntity) -> None: ... def camera(self) -> Qt3DCore.QEntity: ... @@ -986,11 +995,12 @@ class QClearBuffers('QFrameGraphNode'): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - colorBufferChanged: typing.ClassVar[QtCore.pyqtSignal] - clearStencilValueChanged: typing.ClassVar[QtCore.pyqtSignal] - clearDepthValueChanged: typing.ClassVar[QtCore.pyqtSignal] - clearColorChanged: typing.ClassVar[QtCore.pyqtSignal] - buffersChanged: typing.ClassVar[QtCore.pyqtSignal] + + def colorBufferChanged(self, buffer: 'QRenderTargetOutput') -> None: ... + def clearStencilValueChanged(self, clearStencilValue: int) -> None: ... + def clearDepthValueChanged(self, clearDepthValue: float) -> None: ... + def clearColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def buffersChanged(self, buffers: 'QClearBuffers.BufferType') -> None: ... def setColorBuffer(self, buffer: 'QRenderTargetOutput') -> None: ... def setClearStencilValue(self, clearStencilValue: int) -> None: ... def setClearDepthValue(self, clearDepthValue: float) -> None: ... @@ -1005,9 +1015,10 @@ class QClearBuffers('QFrameGraphNode'): class QClipPlane('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - distanceChanged: typing.ClassVar[QtCore.pyqtSignal] - normalChanged: typing.ClassVar[QtCore.pyqtSignal] - planeIndexChanged: typing.ClassVar[QtCore.pyqtSignal] + + def distanceChanged(self, distance: float) -> None: ... + def normalChanged(self, normal: QtGui.QVector3D) -> None: ... + def planeIndexChanged(self, planeIndex: int) -> None: ... def setDistance(self, a0: float) -> None: ... def setNormal(self, a0: QtGui.QVector3D) -> None: ... def setPlaneIndex(self, a0: int) -> None: ... @@ -1025,16 +1036,17 @@ class QComputeCommand(Qt3DCore.QComponent): Manual = ... # type: QComputeCommand.RunType def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - runTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def runTypeChanged(self) -> None: ... @typing.overload def trigger(self, frameCount: int = ...) -> None: ... @typing.overload def trigger(self, workGroupX: int, workGroupY: int, workGroupZ: int, frameCount: int = ...) -> None: ... def setRunType(self, runType: 'QComputeCommand.RunType') -> None: ... def runType(self) -> 'QComputeCommand.RunType': ... - workGroupZChanged: typing.ClassVar[QtCore.pyqtSignal] - workGroupYChanged: typing.ClassVar[QtCore.pyqtSignal] - workGroupXChanged: typing.ClassVar[QtCore.pyqtSignal] + def workGroupZChanged(self) -> None: ... + def workGroupYChanged(self) -> None: ... + def workGroupXChanged(self) -> None: ... def setWorkGroupZ(self, workGroupZ: int) -> None: ... def setWorkGroupY(self, workGroupY: int) -> None: ... def setWorkGroupX(self, workGroupX: int) -> None: ... @@ -1045,10 +1057,11 @@ class QComputeCommand(Qt3DCore.QComponent): class QColorMask('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - alphaMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] - blueMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] - greenMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] - redMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] + + def alphaMaskedChanged(self, alphaMasked: bool) -> None: ... + def blueMaskedChanged(self, blueMasked: bool) -> None: ... + def greenMaskedChanged(self, greenMasked: bool) -> None: ... + def redMaskedChanged(self, redMasked: bool) -> None: ... def setAlphaMasked(self, alphaMasked: bool) -> None: ... def setBlueMasked(self, blueMasked: bool) -> None: ... def setGreenMasked(self, greenMasked: bool) -> None: ... @@ -1072,15 +1085,17 @@ class QCullFace('QRenderState'): FrontAndBack = ... # type: QCullFace.CullingMode def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - modeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def modeChanged(self, mode: 'QCullFace.CullingMode') -> None: ... def setMode(self, mode: 'QCullFace.CullingMode') -> None: ... def mode(self) -> 'QCullFace.CullingMode': ... class QDepthRange('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - farValueChanged: typing.ClassVar[QtCore.pyqtSignal] - nearValueChanged: typing.ClassVar[QtCore.pyqtSignal] + + def farValueChanged(self, farValue: float) -> None: ... + def nearValueChanged(self, nearValue: float) -> None: ... def setFarValue(self, value: float) -> None: ... def setNearValue(self, value: float) -> None: ... def farValue(self) -> float: ... @@ -1108,23 +1123,26 @@ class QDepthTest('QRenderState'): NotEqual = ... # type: QDepthTest.DepthFunction def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - depthFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def depthFunctionChanged(self, depthFunction: 'QDepthTest.DepthFunction') -> None: ... def setDepthFunction(self, depthFunction: 'QDepthTest.DepthFunction') -> None: ... def depthFunction(self) -> 'QDepthTest.DepthFunction': ... class QDirectionalLight('QAbstractLight'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - worldDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def worldDirectionChanged(self, worldDirection: QtGui.QVector3D) -> None: ... def setWorldDirection(self, worldDirection: QtGui.QVector3D) -> None: ... def worldDirection(self) -> QtGui.QVector3D: ... class QDispatchCompute('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - workGroupZChanged: typing.ClassVar[QtCore.pyqtSignal] - workGroupYChanged: typing.ClassVar[QtCore.pyqtSignal] - workGroupXChanged: typing.ClassVar[QtCore.pyqtSignal] + + def workGroupZChanged(self) -> None: ... + def workGroupYChanged(self) -> None: ... + def workGroupXChanged(self) -> None: ... def setWorkGroupZ(self, workGroupZ: int) -> None: ... def setWorkGroupY(self, workGroupY: int) -> None: ... def setWorkGroupX(self, workGroupX: int) -> None: ... @@ -1150,8 +1168,9 @@ class QEffect(Qt3DCore.QNode): class QEnvironmentLight(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - specularChanged: typing.ClassVar[QtCore.pyqtSignal] - irradianceChanged: typing.ClassVar[QtCore.pyqtSignal] + + def specularChanged(self, environmentSpecular: 'QAbstractTexture') -> None: ... + def irradianceChanged(self, environmentIrradiance: 'QAbstractTexture') -> None: ... def setSpecular(self, specular: 'QAbstractTexture') -> None: ... def setIrradiance(self, irradiance: 'QAbstractTexture') -> None: ... def specular(self) -> 'QAbstractTexture': ... @@ -1160,8 +1179,9 @@ class QEnvironmentLight(Qt3DCore.QComponent): class QFilterKey(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - valueChanged: typing.ClassVar[QtCore.pyqtSignal] - nameChanged: typing.ClassVar[QtCore.pyqtSignal] + + def valueChanged(self, value: typing.Any) -> None: ... + def nameChanged(self, name: str) -> None: ... def setName(self, customType: str) -> None: ... def setValue(self, value: typing.Any) -> None: ... def name(self) -> str: ... @@ -1177,7 +1197,8 @@ class QFrontFace('QRenderState'): CounterClockWise = ... # type: QFrontFace.WindingDirection def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - directionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def directionChanged(self, direction: 'QFrontFace.WindingDirection') -> None: ... def setDirection(self, direction: 'QFrontFace.WindingDirection') -> None: ... def direction(self) -> 'QFrontFace.WindingDirection': ... @@ -1190,11 +1211,11 @@ class QGeometry(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - maxExtentChanged: typing.ClassVar[QtCore.pyqtSignal] - minExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + def maxExtentChanged(self, maxExtent: QtGui.QVector3D) -> None: ... + def minExtentChanged(self, minExtent: QtGui.QVector3D) -> None: ... def maxExtent(self) -> QtGui.QVector3D: ... def minExtent(self) -> QtGui.QVector3D: ... - boundingVolumePositionAttributeChanged: typing.ClassVar[QtCore.pyqtSignal] + def boundingVolumePositionAttributeChanged(self, boundingVolumePositionAttribute: 'QAttribute') -> None: ... def setBoundingVolumePositionAttribute(self, boundingVolumePositionAttribute: 'QAttribute') -> None: ... def boundingVolumePositionAttribute(self) -> 'QAttribute': ... def removeAttribute(self, attribute: 'QAttribute') -> None: ... @@ -1237,19 +1258,19 @@ class QGeometryRenderer(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - indexBufferByteOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] + def indexBufferByteOffsetChanged(self, offset: int) -> None: ... def setIndexBufferByteOffset(self, offset: int) -> None: ... def indexBufferByteOffset(self) -> int: ... - primitiveTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - geometryChanged: typing.ClassVar[QtCore.pyqtSignal] - primitiveRestartEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - verticesPerPatchChanged: typing.ClassVar[QtCore.pyqtSignal] - restartIndexValueChanged: typing.ClassVar[QtCore.pyqtSignal] - firstVertexChanged: typing.ClassVar[QtCore.pyqtSignal] - firstInstanceChanged: typing.ClassVar[QtCore.pyqtSignal] - indexOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] - vertexCountChanged: typing.ClassVar[QtCore.pyqtSignal] - instanceCountChanged: typing.ClassVar[QtCore.pyqtSignal] + def primitiveTypeChanged(self, primitiveType: 'QGeometryRenderer.PrimitiveType') -> None: ... + def geometryChanged(self, geometry: 'QGeometry') -> None: ... + def primitiveRestartEnabledChanged(self, primitiveRestartEnabled: bool) -> None: ... + def verticesPerPatchChanged(self, verticesPerPatch: int) -> None: ... + def restartIndexValueChanged(self, restartIndexValue: int) -> None: ... + def firstVertexChanged(self, firstVertex: int) -> None: ... + def firstInstanceChanged(self, firstInstance: int) -> None: ... + def indexOffsetChanged(self, indexOffset: int) -> None: ... + def vertexCountChanged(self, vertexCount: int) -> None: ... + def instanceCountChanged(self, instanceCount: int) -> None: ... def setPrimitiveType(self, primitiveType: 'QGeometryRenderer.PrimitiveType') -> None: ... def setGeometry(self, geometry: 'QGeometry') -> None: ... def setPrimitiveRestartEnabled(self, enabled: bool) -> None: ... @@ -1298,13 +1319,14 @@ class QGraphicsApiFilter(QtCore.QObject): RHI = ... # type: QGraphicsApiFilter.Api def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - graphicsApiFilterChanged: typing.ClassVar[QtCore.pyqtSignal] - vendorChanged: typing.ClassVar[QtCore.pyqtSignal] - extensionsChanged: typing.ClassVar[QtCore.pyqtSignal] - majorVersionChanged: typing.ClassVar[QtCore.pyqtSignal] - minorVersionChanged: typing.ClassVar[QtCore.pyqtSignal] - profileChanged: typing.ClassVar[QtCore.pyqtSignal] - apiChanged: typing.ClassVar[QtCore.pyqtSignal] + + def graphicsApiFilterChanged(self) -> None: ... + def vendorChanged(self, vendor: str) -> None: ... + def extensionsChanged(self, extensions: typing.Iterable[str]) -> None: ... + def majorVersionChanged(self, majorVersion: int) -> None: ... + def minorVersionChanged(self, minorVersion: int) -> None: ... + def profileChanged(self, profile: 'QGraphicsApiFilter.OpenGLProfile') -> None: ... + def apiChanged(self, api: 'QGraphicsApiFilter.Api') -> None: ... def setVendor(self, vendor: str) -> None: ... def setExtensions(self, extensions: typing.Iterable[str]) -> None: ... def setMajorVersion(self, majorVersion: int) -> None: ... @@ -1321,7 +1343,8 @@ class QGraphicsApiFilter(QtCore.QObject): class QLayer(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - recursiveChanged: typing.ClassVar[QtCore.pyqtSignal] + + def recursiveChanged(self) -> None: ... def setRecursive(self, recursive: bool) -> None: ... def recursive(self) -> bool: ... @@ -1339,7 +1362,8 @@ class QLayerFilter('QFrameGraphNode'): DiscardAllMatchingLayers = ... # type: QLayerFilter.FilterMode def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - filterModeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def filterModeChanged(self, filterMode: 'QLayerFilter.FilterMode') -> None: ... def setFilterMode(self, filterMode: 'QLayerFilter.FilterMode') -> None: ... def filterMode(self) -> 'QLayerFilter.FilterMode': ... def layers(self) -> typing.List['QLayer']: ... @@ -1358,11 +1382,11 @@ class QLevelOfDetail(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - volumeOverrideChanged: typing.ClassVar[QtCore.pyqtSignal] - thresholdsChanged: typing.ClassVar[QtCore.pyqtSignal] - thresholdTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] - cameraChanged: typing.ClassVar[QtCore.pyqtSignal] + def volumeOverrideChanged(self, volumeOverride: 'QLevelOfDetailBoundingSphere') -> None: ... + def thresholdsChanged(self, thresholds: typing.Iterable[float]) -> None: ... + def thresholdTypeChanged(self, thresholdType: 'QLevelOfDetail.ThresholdType') -> None: ... + def currentIndexChanged(self, currentIndex: int) -> None: ... + def cameraChanged(self, camera: 'QCamera') -> None: ... def setVolumeOverride(self, volumeOverride: 'QLevelOfDetailBoundingSphere') -> None: ... def setThresholds(self, thresholds: typing.Iterable[float]) -> None: ... def setThresholdType(self, thresholdType: 'QLevelOfDetail.ThresholdType') -> None: ... @@ -1395,8 +1419,9 @@ class QLevelOfDetailSwitch('QLevelOfDetail'): class QLineWidth('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - smoothChanged: typing.ClassVar[QtCore.pyqtSignal] - valueChanged: typing.ClassVar[QtCore.pyqtSignal] + + def smoothChanged(self, enabled: bool) -> None: ... + def valueChanged(self, value: float) -> None: ... def setSmooth(self, enabled: bool) -> None: ... def setValue(self, value: float) -> None: ... def smooth(self) -> bool: ... @@ -1405,7 +1430,8 @@ class QLineWidth('QRenderState'): class QMaterial(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - effectChanged: typing.ClassVar[QtCore.pyqtSignal] + + def effectChanged(self, effect: 'QEffect') -> None: ... def setEffect(self, effect: 'QEffect') -> None: ... def parameters(self) -> typing.List['QParameter']: ... def removeParameter(self, parameter: 'QParameter') -> None: ... @@ -1465,7 +1491,8 @@ class QMemoryBarrier('QFrameGraphNode'): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - waitOperationsChanged: typing.ClassVar[QtCore.pyqtSignal] + + def waitOperationsChanged(self, barrierTypes: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... def setWaitOperations(self, operations: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... def waitOperations(self) -> 'QMemoryBarrier.Operations': ... @@ -1485,10 +1512,10 @@ class QMesh('QGeometryRenderer'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - statusChanged: typing.ClassVar[QtCore.pyqtSignal] + def statusChanged(self, status: 'QMesh.Status') -> None: ... def status(self) -> 'QMesh.Status': ... - meshNameChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + def meshNameChanged(self, meshName: str) -> None: ... + def sourceChanged(self, source: QtCore.QUrl) -> None: ... def setMeshName(self, meshName: str) -> None: ... def setSource(self, source: QtCore.QUrl) -> None: ... def meshName(self) -> str: ... @@ -1513,20 +1540,21 @@ class QNoPicking('QFrameGraphNode'): class QObjectPicker(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - priorityChanged: typing.ClassVar[QtCore.pyqtSignal] + + def priorityChanged(self, priority: int) -> None: ... def setPriority(self, priority: int) -> None: ... def priority(self) -> int: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - containsMouseChanged: typing.ClassVar[QtCore.pyqtSignal] - pressedChanged: typing.ClassVar[QtCore.pyqtSignal] - dragEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - hoverEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - exited: typing.ClassVar[QtCore.pyqtSignal] - entered: typing.ClassVar[QtCore.pyqtSignal] - moved: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] + def containsMouseChanged(self, containsMouse: bool) -> None: ... + def pressedChanged(self, pressed: bool) -> None: ... + def dragEnabledChanged(self, dragEnabled: bool) -> None: ... + def hoverEnabledChanged(self, hoverEnabled: bool) -> None: ... + def exited(self) -> None: ... + def entered(self) -> None: ... + def moved(self, pick: 'QPickEvent') -> None: ... + def clicked(self, pick: 'QPickEvent') -> None: ... + def released(self, pick: 'QPickEvent') -> None: ... + def pressed(self, pick: 'QPickEvent') -> None: ... def setDragEnabled(self, dragEnabled: bool) -> None: ... def setHoverEnabled(self, hoverEnabled: bool) -> None: ... def isPressed(self) -> bool: ... @@ -1539,9 +1567,9 @@ class QPaintedTextureImage('QAbstractTextureImage'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def paint(self, painter: QtGui.QPainter) -> None: ... - sizeChanged: typing.ClassVar[QtCore.pyqtSignal] - heightChanged: typing.ClassVar[QtCore.pyqtSignal] - widthChanged: typing.ClassVar[QtCore.pyqtSignal] + def sizeChanged(self, size: QtCore.QSize) -> None: ... + def heightChanged(self, w: int) -> None: ... + def widthChanged(self, w: int) -> None: ... def setSize(self, size: QtCore.QSize) -> None: ... def setHeight(self, h: int) -> None: ... def setWidth(self, w: int) -> None: ... @@ -1558,8 +1586,9 @@ class QParameter(Qt3DCore.QNode): def __init__(self, name: str, value: typing.Any, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... @typing.overload def __init__(self, name: str, texture: 'QAbstractTexture', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - nameChanged: typing.ClassVar[QtCore.pyqtSignal] - valueChanged: typing.ClassVar[QtCore.pyqtSignal] + + def nameChanged(self, name: str) -> None: ... + def valueChanged(self, value: typing.Any) -> None: ... def setValue(self, dv: typing.Any) -> None: ... def setName(self, name: str) -> None: ... def value(self) -> typing.Any: ... @@ -1607,7 +1636,7 @@ class QPickEvent(QtCore.QObject): def modifiers(self) -> int: ... def buttons(self) -> int: ... def button(self) -> 'QPickEvent.Buttons': ... - acceptedChanged: typing.ClassVar[QtCore.pyqtSignal] + def acceptedChanged(self, accepted: bool) -> None: ... def setAccepted(self, accepted: bool) -> None: ... def localIntersection(self) -> QtGui.QVector3D: ... def worldIntersection(self) -> QtGui.QVector3D: ... @@ -1649,14 +1678,15 @@ class QPickingSettings(Qt3DCore.QNode): PrimitivePicking = ... # type: QPickingSettings.PickMethod def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - worldSpaceToleranceChanged: typing.ClassVar[QtCore.pyqtSignal] + + def worldSpaceToleranceChanged(self, worldSpaceTolerance: float) -> None: ... def setWorldSpaceTolerance(self, worldSpaceTolerance: float) -> None: ... def worldSpaceTolerance(self) -> float: ... - faceOrientationPickingModeChanged: typing.ClassVar[QtCore.pyqtSignal] + def faceOrientationPickingModeChanged(self, faceOrientationPickingMode: 'QPickingSettings.FaceOrientationPickingMode') -> None: ... def setFaceOrientationPickingMode(self, faceOrientationPickingMode: 'QPickingSettings.FaceOrientationPickingMode') -> None: ... def faceOrientationPickingMode(self) -> 'QPickingSettings.FaceOrientationPickingMode': ... - pickResultModeChanged: typing.ClassVar[QtCore.pyqtSignal] - pickMethodChanged: typing.ClassVar[QtCore.pyqtSignal] + def pickResultModeChanged(self, pickResult: 'QPickingSettings.PickResultMode') -> None: ... + def pickMethodChanged(self, pickMethod: 'QPickingSettings.PickMethod') -> None: ... def setPickResultMode(self, pickResultMode: 'QPickingSettings.PickResultMode') -> None: ... def setPickMethod(self, pickMethod: 'QPickingSettings.PickMethod') -> None: ... def pickResultMode(self) -> 'QPickingSettings.PickResultMode': ... @@ -1700,9 +1730,10 @@ class QPickTriangleEvent('QPickEvent'): class QPointLight('QAbstractLight'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - quadraticAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] - linearAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] - constantAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] + + def quadraticAttenuationChanged(self, quadraticAttenuation: float) -> None: ... + def linearAttenuationChanged(self, linearAttenuation: float) -> None: ... + def constantAttenuationChanged(self, constantAttenuation: float) -> None: ... def setQuadraticAttenuation(self, value: float) -> None: ... def setLinearAttenuation(self, value: float) -> None: ... def setConstantAttenuation(self, value: float) -> None: ... @@ -1720,8 +1751,9 @@ class QPointSize('QRenderState'): Programmable = ... # type: QPointSize.SizeMode def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - valueChanged: typing.ClassVar[QtCore.pyqtSignal] - sizeModeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def valueChanged(self, value: float) -> None: ... + def sizeModeChanged(self, sizeMode: 'QPointSize.SizeMode') -> None: ... def setValue(self, value: float) -> None: ... def setSizeMode(self, sizeMode: 'QPointSize.SizeMode') -> None: ... def value(self) -> float: ... @@ -1730,8 +1762,9 @@ class QPointSize('QRenderState'): class QPolygonOffset('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - depthStepsChanged: typing.ClassVar[QtCore.pyqtSignal] - scaleFactorChanged: typing.ClassVar[QtCore.pyqtSignal] + + def depthStepsChanged(self, depthSteps: float) -> None: ... + def scaleFactorChanged(self, scaleFactor: float) -> None: ... def setDepthSteps(self, depthSteps: float) -> None: ... def setScaleFactor(self, scaleFactor: float) -> None: ... def depthSteps(self) -> float: ... @@ -1740,8 +1773,9 @@ class QPolygonOffset('QRenderState'): class QProximityFilter('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - distanceThresholdChanged: typing.ClassVar[QtCore.pyqtSignal] - entityChanged: typing.ClassVar[QtCore.pyqtSignal] + + def distanceThresholdChanged(self, distanceThreshold: float) -> None: ... + def entityChanged(self, entity: Qt3DCore.QEntity) -> None: ... def setDistanceThreshold(self, distanceThreshold: float) -> None: ... def setEntity(self, entity: Qt3DCore.QEntity) -> None: ... def distanceThreshold(self) -> float: ... @@ -1768,8 +1802,9 @@ class QRasterMode('QRenderState'): Fill = ... # type: QRasterMode.RasterMode def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - faceModeChanged: typing.ClassVar[QtCore.pyqtSignal] - rasterModeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def faceModeChanged(self, faceMode: 'QRasterMode.FaceMode') -> None: ... + def rasterModeChanged(self, rasterMode: 'QRasterMode.RasterMode') -> None: ... def setFaceMode(self, faceMode: 'QRasterMode.FaceMode') -> None: ... def setRasterMode(self, rasterMode: 'QRasterMode.RasterMode') -> None: ... def faceMode(self) -> 'QRasterMode.FaceMode': ... @@ -1778,9 +1813,10 @@ class QRasterMode('QRenderState'): class QRayCaster('QAbstractRayCaster'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - lengthChanged: typing.ClassVar[QtCore.pyqtSignal] - directionChanged: typing.ClassVar[QtCore.pyqtSignal] - originChanged: typing.ClassVar[QtCore.pyqtSignal] + + def lengthChanged(self, length: float) -> None: ... + def directionChanged(self, direction: QtGui.QVector3D) -> None: ... + def originChanged(self, origin: QtGui.QVector3D) -> None: ... @typing.overload def trigger(self) -> None: ... @typing.overload @@ -1898,9 +1934,10 @@ class QRenderCapabilities(QtCore.QObject): def isValid(self) -> bool: ... class QRenderCaptureReply(QtCore.QObject): - completed: typing.ClassVar[QtCore.pyqtSignal] + + def completed(self) -> None: ... def saveImage(self, fileName: str) -> bool: ... - completeChanged: typing.ClassVar[QtCore.pyqtSignal] + def completeChanged(self, isComplete: bool) -> None: ... def saveToFile(self, fileName: str) -> None: ... def isComplete(self) -> bool: ... def captureId(self) -> int: ... @@ -1921,7 +1958,8 @@ class QRenderCapture('QFrameGraphNode'): class QRenderPass(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - shaderProgramChanged: typing.ClassVar[QtCore.pyqtSignal] + + def shaderProgramChanged(self, shaderProgram: 'QShaderProgram') -> None: ... def setShaderProgram(self, shaderProgram: 'QShaderProgram') -> None: ... def parameters(self) -> typing.List['QParameter']: ... def removeParameter(self, p: 'QParameter') -> None: ... @@ -1955,8 +1993,9 @@ class QRenderSettings(Qt3DCore.QComponent): Always = ... # type: QRenderSettings.RenderPolicy def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - renderPolicyChanged: typing.ClassVar[QtCore.pyqtSignal] - activeFrameGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + + def renderPolicyChanged(self, renderPolicy: 'QRenderSettings.RenderPolicy') -> None: ... + def activeFrameGraphChanged(self, activeFrameGraph: 'QFrameGraphNode') -> None: ... def setRenderPolicy(self, renderPolicy: 'QRenderSettings.RenderPolicy') -> None: ... def setActiveFrameGraph(self, activeFrameGraph: 'QFrameGraphNode') -> None: ... def renderCapabilities(self) -> 'QRenderCapabilities': ... @@ -1975,9 +2014,10 @@ class QRenderStateSet('QFrameGraphNode'): class QRenderSurfaceSelector('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - surfacePixelRatioChanged: typing.ClassVar[QtCore.pyqtSignal] - externalRenderTargetSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - surfaceChanged: typing.ClassVar[QtCore.pyqtSignal] + + def surfacePixelRatioChanged(self, ratio: float) -> None: ... + def externalRenderTargetSizeChanged(self, size: QtCore.QSize) -> None: ... + def surfaceChanged(self, surface: QtCore.QObject) -> None: ... def setSurfacePixelRatio(self, ratio: float) -> None: ... def setSurface(self, surfaceObject: QtCore.QObject) -> None: ... def setExternalRenderTargetSize(self, size: QtCore.QSize) -> None: ... @@ -2037,11 +2077,12 @@ class QRenderTargetOutput(Qt3DCore.QNode): DepthStencil = ... # type: QRenderTargetOutput.AttachmentPoint def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - faceChanged: typing.ClassVar[QtCore.pyqtSignal] - layerChanged: typing.ClassVar[QtCore.pyqtSignal] - mipLevelChanged: typing.ClassVar[QtCore.pyqtSignal] - textureChanged: typing.ClassVar[QtCore.pyqtSignal] - attachmentPointChanged: typing.ClassVar[QtCore.pyqtSignal] + + def faceChanged(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... + def layerChanged(self, layer: int) -> None: ... + def mipLevelChanged(self, mipLevel: int) -> None: ... + def textureChanged(self, texture: 'QAbstractTexture') -> None: ... + def attachmentPointChanged(self, attachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... def setLayer(self, layer: int) -> None: ... def setMipLevel(self, level: int) -> None: ... @@ -2056,7 +2097,8 @@ class QRenderTargetOutput(Qt3DCore.QNode): class QRenderTargetSelector('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - targetChanged: typing.ClassVar[QtCore.pyqtSignal] + + def targetChanged(self, target: 'QRenderTarget') -> None: ... def setTarget(self, target: 'QRenderTarget') -> None: ... def target(self) -> 'QRenderTarget': ... def outputs(self) -> typing.List[QRenderTargetOutput.AttachmentPoint]: ... @@ -2094,8 +2136,8 @@ class QSceneLoader(Qt3DCore.QComponent): def component(self, entityName: str, componentType: 'QSceneLoader.ComponentType') -> Qt3DCore.QComponent: ... def entityNames(self) -> typing.List[str]: ... def entity(self, entityName: str) -> Qt3DCore.QEntity: ... - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + def statusChanged(self, status: 'QSceneLoader.Status') -> None: ... + def sourceChanged(self, source: QtCore.QUrl) -> None: ... def setSource(self, arg: QtCore.QUrl) -> None: ... def status(self) -> 'QSceneLoader.Status': ... def source(self) -> QtCore.QUrl: ... @@ -2104,10 +2146,11 @@ class QSceneLoader(Qt3DCore.QComponent): class QScissorTest('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - heightChanged: typing.ClassVar[QtCore.pyqtSignal] - widthChanged: typing.ClassVar[QtCore.pyqtSignal] - bottomChanged: typing.ClassVar[QtCore.pyqtSignal] - leftChanged: typing.ClassVar[QtCore.pyqtSignal] + + def heightChanged(self, height: int) -> None: ... + def widthChanged(self, width: int) -> None: ... + def bottomChanged(self, bottom: int) -> None: ... + def leftChanged(self, left: int) -> None: ... def setHeight(self, height: int) -> None: ... def setWidth(self, width: int) -> None: ... def setBottom(self, bottom: int) -> None: ... @@ -2120,7 +2163,8 @@ class QScissorTest('QRenderState'): class QScreenRayCaster('QAbstractRayCaster'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - positionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def positionChanged(self, position: QtCore.QPoint) -> None: ... @typing.overload def trigger(self) -> None: ... @typing.overload @@ -2144,8 +2188,8 @@ class QSetFence('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - handleChanged: typing.ClassVar[QtCore.pyqtSignal] - handleTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + def handleChanged(self, handle: typing.Any) -> None: ... + def handleTypeChanged(self, handleType: 'QSetFence.HandleType') -> None: ... def handle(self) -> typing.Any: ... def handleType(self) -> 'QSetFence.HandleType': ... @@ -2257,12 +2301,13 @@ class QShaderImage(Qt3DCore.QNode): ReadWrite = ... # type: QShaderImage.Access def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - formatChanged: typing.ClassVar[QtCore.pyqtSignal] - accessChanged: typing.ClassVar[QtCore.pyqtSignal] - layerChanged: typing.ClassVar[QtCore.pyqtSignal] - mipLevelChanged: typing.ClassVar[QtCore.pyqtSignal] - layeredChanged: typing.ClassVar[QtCore.pyqtSignal] - textureChanged: typing.ClassVar[QtCore.pyqtSignal] + + def formatChanged(self, format: 'QShaderImage.ImageFormat') -> None: ... + def accessChanged(self, access: 'QShaderImage.Access') -> None: ... + def layerChanged(self, layer: int) -> None: ... + def mipLevelChanged(self, mipLevel: int) -> None: ... + def layeredChanged(self, layered: bool) -> None: ... + def textureChanged(self, texture: 'QAbstractTexture') -> None: ... def setFormat(self, format: 'QShaderImage.ImageFormat') -> None: ... def setAccess(self, access: 'QShaderImage.Access') -> None: ... def setLayer(self, layer: int) -> None: ... @@ -2310,20 +2355,21 @@ class QShaderProgram(Qt3DCore.QNode): Compute = ... # type: QShaderProgram.ShaderType def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - formatChanged: typing.ClassVar[QtCore.pyqtSignal] + + def formatChanged(self, format: 'QShaderProgram.Format') -> None: ... def format(self) -> 'QShaderProgram.Format': ... def setFormat(self, format: 'QShaderProgram.Format') -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - logChanged: typing.ClassVar[QtCore.pyqtSignal] + def statusChanged(self, status: 'QShaderProgram.Status') -> None: ... + def logChanged(self, log: str) -> None: ... def status(self) -> 'QShaderProgram.Status': ... def log(self) -> str: ... - computeShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] - fragmentShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] - geometryShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] - tessellationEvaluationShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] - tessellationControlShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] - vertexShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + def computeShaderCodeChanged(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def fragmentShaderCodeChanged(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def geometryShaderCodeChanged(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def tessellationEvaluationShaderCodeChanged(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def tessellationControlShaderCodeChanged(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def vertexShaderCodeChanged(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def setComputeShaderCode(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def setFragmentShaderCode(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def setGeometryShaderCode(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... @@ -2346,26 +2392,26 @@ class QShaderProgramBuilder(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - computeShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] - fragmentShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] - geometryShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] - tessellationEvaluationShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] - tessellationControlShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] - vertexShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + def computeShaderCodeChanged(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def fragmentShaderCodeChanged(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def geometryShaderCodeChanged(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def tessellationEvaluationShaderCodeChanged(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def tessellationControlShaderCodeChanged(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def vertexShaderCodeChanged(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def computeShaderCode(self) -> QtCore.QByteArray: ... def fragmentShaderCode(self) -> QtCore.QByteArray: ... def geometryShaderCode(self) -> QtCore.QByteArray: ... def tessellationEvaluationShaderCode(self) -> QtCore.QByteArray: ... def tessellationControlShaderCode(self) -> QtCore.QByteArray: ... def vertexShaderCode(self) -> QtCore.QByteArray: ... - computeShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] - fragmentShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] - geometryShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] - tessellationEvaluationShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] - tessellationControlShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] - vertexShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] - enabledLayersChanged: typing.ClassVar[QtCore.pyqtSignal] - shaderProgramChanged: typing.ClassVar[QtCore.pyqtSignal] + def computeShaderGraphChanged(self, computeShaderGraph: QtCore.QUrl) -> None: ... + def fragmentShaderGraphChanged(self, fragmentShaderGraph: QtCore.QUrl) -> None: ... + def geometryShaderGraphChanged(self, geometryShaderGraph: QtCore.QUrl) -> None: ... + def tessellationEvaluationShaderGraphChanged(self, tessellationEvaluationShaderGraph: QtCore.QUrl) -> None: ... + def tessellationControlShaderGraphChanged(self, tessellationControlShaderGraph: QtCore.QUrl) -> None: ... + def vertexShaderGraphChanged(self, vertexShaderGraph: QtCore.QUrl) -> None: ... + def enabledLayersChanged(self, layers: typing.Iterable[str]) -> None: ... + def shaderProgramChanged(self, shaderProgram: 'QShaderProgram') -> None: ... def setComputeShaderGraph(self, computeShaderGraph: QtCore.QUrl) -> None: ... def setFragmentShaderGraph(self, fragmentShaderGraph: QtCore.QUrl) -> None: ... def setGeometryShaderGraph(self, geometryShaderGraph: QtCore.QUrl) -> None: ... @@ -2401,7 +2447,11 @@ class QSortPolicy('QFrameGraphNode'): Uniform = ... # type: QSortPolicy.SortType def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - sortTypesChanged: typing.ClassVar[QtCore.pyqtSignal] + + @typing.overload + def sortTypesChanged(self, sortTypes: typing.Iterable[QSortPolicy.SortType]) -> None: ... + @typing.overload + def sortTypesChanged(self, sortTypes: typing.Iterable[int]) -> None: ... @typing.overload def setSortTypes(self, sortTypes: typing.Iterable[QSortPolicy.SortType]) -> None: ... @typing.overload @@ -2412,11 +2462,12 @@ class QSortPolicy('QFrameGraphNode'): class QSpotLight('QAbstractLight'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - cutOffAngleChanged: typing.ClassVar[QtCore.pyqtSignal] - localDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] - quadraticAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] - linearAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] - constantAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] + + def cutOffAngleChanged(self, cutOffAngle: float) -> None: ... + def localDirectionChanged(self, localDirection: QtGui.QVector3D) -> None: ... + def quadraticAttenuationChanged(self, quadraticAttenuation: float) -> None: ... + def linearAttenuationChanged(self, linearAttenuation: float) -> None: ... + def constantAttenuationChanged(self, constantAttenuation: float) -> None: ... def setCutOffAngle(self, cutOffAngle: float) -> None: ... def setLocalDirection(self, localDirection: QtGui.QVector3D) -> None: ... def setQuadraticAttenuation(self, value: float) -> None: ... @@ -2431,8 +2482,9 @@ class QSpotLight('QAbstractLight'): class QStencilMask('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - backOutputMaskChanged: typing.ClassVar[QtCore.pyqtSignal] - frontOutputMaskChanged: typing.ClassVar[QtCore.pyqtSignal] + + def backOutputMaskChanged(self, backOutputMask: int) -> None: ... + def frontOutputMaskChanged(self, frontOutputMask: int) -> None: ... def setBackOutputMask(self, backOutputMask: int) -> None: ... def setFrontOutputMask(self, frontOutputMask: int) -> None: ... def backOutputMask(self) -> int: ... @@ -2474,10 +2526,11 @@ class QStencilOperationArguments(QtCore.QObject): Front = ... # type: QStencilOperationArguments.FaceMode Back = ... # type: QStencilOperationArguments.FaceMode FrontAndBack = ... # type: QStencilOperationArguments.FaceMode - faceModeChanged: typing.ClassVar[QtCore.pyqtSignal] - allTestsPassOperationChanged: typing.ClassVar[QtCore.pyqtSignal] - depthTestFailureOperationChanged: typing.ClassVar[QtCore.pyqtSignal] - stencilTestFailureOperationChanged: typing.ClassVar[QtCore.pyqtSignal] + + def faceModeChanged(self, faceMode: 'QStencilOperationArguments.FaceMode') -> None: ... + def allTestsPassOperationChanged(self, stencilDepthPass: 'QStencilOperationArguments.Operation') -> None: ... + def depthTestFailureOperationChanged(self, depthFail: 'QStencilOperationArguments.Operation') -> None: ... + def stencilTestFailureOperationChanged(self, stencilFail: 'QStencilOperationArguments.Operation') -> None: ... def setAllTestsPassOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... def setDepthTestFailureOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... def setStencilTestFailureOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... @@ -2522,10 +2575,11 @@ class QStencilTestArguments(QtCore.QObject): Front = ... # type: QStencilTestArguments.StencilFaceMode Back = ... # type: QStencilTestArguments.StencilFaceMode FrontAndBack = ... # type: QStencilTestArguments.StencilFaceMode - faceModeChanged: typing.ClassVar[QtCore.pyqtSignal] - referenceValueChanged: typing.ClassVar[QtCore.pyqtSignal] - stencilFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] - comparisonMaskChanged: typing.ClassVar[QtCore.pyqtSignal] + + def faceModeChanged(self, faceMode: 'QStencilTestArguments.StencilFaceMode') -> None: ... + def referenceValueChanged(self, referenceValue: int) -> None: ... + def stencilFunctionChanged(self, stencilFunction: 'QStencilTestArguments.StencilFunction') -> None: ... + def comparisonMaskChanged(self, comparisonMask: int) -> None: ... def setStencilFunction(self, stencilFunction: 'QStencilTestArguments.StencilFunction') -> None: ... def setReferenceValue(self, referenceValue: int) -> None: ... def setComparisonMask(self, comparisonMask: int) -> None: ... @@ -2544,7 +2598,8 @@ class QSubtreeEnabler('QFrameGraphNode'): SingleShot = ... # type: QSubtreeEnabler.Enablement def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - enablementChanged: typing.ClassVar[QtCore.pyqtSignal] + + def enablementChanged(self, enablement: 'QSubtreeEnabler.Enablement') -> None: ... def requestUpdate(self) -> None: ... def setEnablement(self, enablement: 'QSubtreeEnabler.Enablement') -> None: ... def enablement(self) -> 'QSubtreeEnabler.Enablement': ... @@ -2622,17 +2677,19 @@ class QTextureBuffer('QAbstractTexture'): class QTextureLoader('QAbstractTexture'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] + + def mirroredChanged(self, mirrored: bool) -> None: ... def setMirrored(self, mirrored: bool) -> None: ... def isMirrored(self) -> bool: ... - sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + def sourceChanged(self, source: QtCore.QUrl) -> None: ... def setSource(self, source: QtCore.QUrl) -> None: ... def source(self) -> QtCore.QUrl: ... class QSharedGLTexture('QAbstractTexture'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - textureIdChanged: typing.ClassVar[QtCore.pyqtSignal] + + def textureIdChanged(self, textureId: int) -> None: ... def setTextureId(self, id: int) -> None: ... def textureId(self) -> int: ... @@ -2717,13 +2774,14 @@ class QTextureImage('QAbstractTextureImage'): Error = ... # type: QTextureImage.Status def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] + + def mirroredChanged(self, mirrored: bool) -> None: ... def setMirrored(self, mirrored: bool) -> None: ... def isMirrored(self) -> bool: ... def setStatus(self, status: 'QTextureImage.Status') -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + def statusChanged(self, status: 'QTextureImage.Status') -> None: ... + def sourceChanged(self, source: QtCore.QUrl) -> None: ... def setSource(self, source: QtCore.QUrl) -> None: ... def status(self) -> 'QTextureImage.Status': ... def source(self) -> QtCore.QUrl: ... @@ -2782,9 +2840,10 @@ class QTextureWrapMode(QtCore.QObject): def __init__(self, wrapMode: 'QTextureWrapMode.WrapMode' = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, x: 'QTextureWrapMode.WrapMode', y: 'QTextureWrapMode.WrapMode', z: 'QTextureWrapMode.WrapMode', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - zChanged: typing.ClassVar[QtCore.pyqtSignal] - yChanged: typing.ClassVar[QtCore.pyqtSignal] - xChanged: typing.ClassVar[QtCore.pyqtSignal] + + def zChanged(self, z: 'QTextureWrapMode.WrapMode') -> None: ... + def yChanged(self, y: 'QTextureWrapMode.WrapMode') -> None: ... + def xChanged(self, x: 'QTextureWrapMode.WrapMode') -> None: ... def setZ(self, z: 'QTextureWrapMode.WrapMode') -> None: ... def setY(self, y: 'QTextureWrapMode.WrapMode') -> None: ... def setX(self, x: 'QTextureWrapMode.WrapMode') -> None: ... @@ -2795,10 +2854,11 @@ class QTextureWrapMode(QtCore.QObject): class QViewport('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - gammaChanged: typing.ClassVar[QtCore.pyqtSignal] + + def gammaChanged(self, gamma: float) -> None: ... def setGamma(self, gamma: float) -> None: ... def gamma(self) -> float: ... - normalizedRectChanged: typing.ClassVar[QtCore.pyqtSignal] + def normalizedRectChanged(self, normalizedRect: QtCore.QRectF) -> None: ... def setNormalizedRect(self, normalizedRect: QtCore.QRectF) -> None: ... def normalizedRect(self) -> QtCore.QRectF: ... @@ -2812,10 +2872,11 @@ class QWaitFence('QFrameGraphNode'): OpenGLFenceId = ... # type: QWaitFence.HandleType def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - handleChanged: typing.ClassVar[QtCore.pyqtSignal] - handleTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - timeoutChanged: typing.ClassVar[QtCore.pyqtSignal] - waitOnCPUChanged: typing.ClassVar[QtCore.pyqtSignal] + + def handleChanged(self, handle: typing.Any) -> None: ... + def handleTypeChanged(self, handleType: 'QWaitFence.HandleType') -> None: ... + def timeoutChanged(self, timeoutChanged: int) -> None: ... + def waitOnCPUChanged(self, waitOnCPU: bool) -> None: ... def setTimeout(self, timeout: int) -> None: ... def timeout(self) -> int: ... def setWaitOnCPU(self, waitOnCPU: bool) -> None: ... diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index a4b11401..b9bb57b5 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -163,10 +163,10 @@ class QBluetoothDeviceDiscoveryAgent(QtCore.QObject): def supportedDiscoveryMethods() -> 'QBluetoothDeviceDiscoveryAgent.DiscoveryMethods': ... def lowEnergyDiscoveryTimeout(self) -> int: ... def setLowEnergyDiscoveryTimeout(self, msTimeout: int) -> None: ... - deviceUpdated: typing.ClassVar[QtCore.pyqtSignal] - canceled: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] - deviceDiscovered: typing.ClassVar[QtCore.pyqtSignal] + def deviceUpdated(self, info: 'QBluetoothDeviceInfo', updatedFields: typing.Union['QBluetoothDeviceInfo.Fields', 'QBluetoothDeviceInfo.Field']) -> None: ... + def canceled(self) -> None: ... + def finished(self) -> None: ... + def deviceDiscovered(self, info: 'QBluetoothDeviceInfo') -> None: ... def stop(self) -> None: ... @typing.overload def start(self) -> None: ... @@ -174,7 +174,10 @@ class QBluetoothDeviceDiscoveryAgent(QtCore.QObject): def start(self, method: typing.Union['QBluetoothDeviceDiscoveryAgent.DiscoveryMethods', 'QBluetoothDeviceDiscoveryAgent.DiscoveryMethod']) -> None: ... def discoveredDevices(self) -> typing.List['QBluetoothDeviceInfo']: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QBluetoothDeviceDiscoveryAgent.Error': ... + @typing.overload + def error(self, error: 'QBluetoothDeviceDiscoveryAgent.Error') -> None: ... def isActive(self) -> bool: ... def setInquiryType(self, type: 'QBluetoothDeviceDiscoveryAgent.InquiryType') -> None: ... def inquiryType(self) -> 'QBluetoothDeviceDiscoveryAgent.InquiryType': ... @@ -571,13 +574,14 @@ class QBluetoothLocalDevice(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, address: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - deviceDisconnected: typing.ClassVar[QtCore.pyqtSignal] - deviceConnected: typing.ClassVar[QtCore.pyqtSignal] - error: typing.ClassVar[QtCore.pyqtSignal] - pairingDisplayConfirmation: typing.ClassVar[QtCore.pyqtSignal] - pairingDisplayPinCode: typing.ClassVar[QtCore.pyqtSignal] - pairingFinished: typing.ClassVar[QtCore.pyqtSignal] - hostModeStateChanged: typing.ClassVar[QtCore.pyqtSignal] + + def deviceDisconnected(self, address: QBluetoothAddress) -> None: ... + def deviceConnected(self, address: QBluetoothAddress) -> None: ... + def error(self, error: 'QBluetoothLocalDevice.Error') -> None: ... + def pairingDisplayConfirmation(self, address: QBluetoothAddress, pin: str) -> None: ... + def pairingDisplayPinCode(self, address: QBluetoothAddress, pin: str) -> None: ... + def pairingFinished(self, address: QBluetoothAddress, pairing: 'QBluetoothLocalDevice.Pairing') -> None: ... + def hostModeStateChanged(self, state: 'QBluetoothLocalDevice.HostMode') -> None: ... def pairingConfirmation(self, confirmation: bool) -> None: ... def connectedDevices(self) -> typing.List[QBluetoothAddress]: ... @staticmethod @@ -610,8 +614,12 @@ class QBluetoothServer(QtCore.QObject): UnsupportedProtocolError = ... # type: QBluetoothServer.Error def __init__(self, serverType: 'QBluetoothServiceInfo.Protocol', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - newConnection: typing.ClassVar[QtCore.pyqtSignal] - error: typing.ClassVar[QtCore.pyqtSignal] + + def newConnection(self) -> None: ... + @typing.overload + def error(self) -> 'QBluetoothServer.Error': ... + @typing.overload + def error(self, a0: 'QBluetoothServer.Error') -> None: ... def serverType(self) -> 'QBluetoothServiceInfo.Protocol': ... def securityFlags(self) -> QBluetooth.SecurityFlags: ... def setSecurityFlags(self, security: typing.Union[QBluetooth.SecurityFlags, QBluetooth.Security]) -> None: ... @@ -655,9 +663,10 @@ class QBluetoothServiceDiscoveryAgent(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, deviceAdapter: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - canceled: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] - serviceDiscovered: typing.ClassVar[QtCore.pyqtSignal] + + def canceled(self) -> None: ... + def finished(self) -> None: ... + def serviceDiscovered(self, info: 'QBluetoothServiceInfo') -> None: ... def clear(self) -> None: ... def stop(self) -> None: ... def start(self, mode: 'QBluetoothServiceDiscoveryAgent.DiscoveryMode' = ...) -> None: ... @@ -670,7 +679,10 @@ class QBluetoothServiceDiscoveryAgent(QtCore.QObject): def setUuidFilter(self, uuid: 'QBluetoothUuid') -> None: ... def discoveredServices(self) -> typing.List['QBluetoothServiceInfo']: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QBluetoothServiceDiscoveryAgent.Error': ... + @typing.overload + def error(self, error: 'QBluetoothServiceDiscoveryAgent.Error') -> None: ... def isActive(self) -> bool: ... @@ -813,11 +825,14 @@ class QBluetoothSocket(QtCore.QIODevice): def setSocketState(self, state: 'QBluetoothSocket.SocketState') -> None: ... def writeData(self, data: bytes) -> int: ... def readData(self, maxlen: int) -> bytes: ... - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - disconnected: typing.ClassVar[QtCore.pyqtSignal] - connected: typing.ClassVar[QtCore.pyqtSignal] + def stateChanged(self, state: 'QBluetoothSocket.SocketState') -> None: ... + def disconnected(self) -> None: ... + def connected(self) -> None: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QBluetoothSocket.SocketError': ... + @typing.overload + def error(self, error: 'QBluetoothSocket.SocketError') -> None: ... def state(self) -> 'QBluetoothSocket.SocketState': ... def socketType(self) -> QBluetoothServiceInfo.Protocol: ... def socketDescriptor(self) -> int: ... @@ -846,7 +861,8 @@ class QBluetoothSocket(QtCore.QIODevice): class QBluetoothTransferManager(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - finished: typing.ClassVar[QtCore.pyqtSignal] + + def finished(self, reply: 'QBluetoothTransferReply') -> None: ... def put(self, request: 'QBluetoothTransferRequest', data: QtCore.QIODevice) -> 'QBluetoothTransferReply': ... @@ -875,12 +891,15 @@ class QBluetoothTransferReply(QtCore.QObject): def setRequest(self, request: 'QBluetoothTransferRequest') -> None: ... def setManager(self, manager: QBluetoothTransferManager) -> None: ... - transferProgress: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + def transferProgress(self, bytesTransferred: int, bytesTotal: int) -> None: ... + def finished(self, a0: 'QBluetoothTransferReply') -> None: ... def abort(self) -> None: ... def request(self) -> 'QBluetoothTransferRequest': ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QBluetoothTransferReply.TransferError': ... + @typing.overload + def error(self, lastError: 'QBluetoothTransferReply.TransferError') -> None: ... def manager(self) -> QBluetoothTransferManager: ... def isRunning(self) -> bool: ... def isFinished(self) -> bool: ... @@ -1727,7 +1746,7 @@ class QLowEnergyController(QtCore.QObject): def __init__(self, remoteDevice: QBluetoothAddress, localDevice: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def remoteDeviceUuid(self) -> QBluetoothUuid: ... - connectionUpdated: typing.ClassVar[QtCore.pyqtSignal] + def connectionUpdated(self, parameters: QLowEnergyConnectionParameters) -> None: ... def role(self) -> 'QLowEnergyController.Role': ... def requestConnectionUpdate(self, parameters: QLowEnergyConnectionParameters) -> None: ... def addService(self, service: 'QLowEnergyServiceData', parent: typing.Optional[QtCore.QObject] = ...) -> 'QLowEnergyService': ... @@ -1741,14 +1760,17 @@ class QLowEnergyController(QtCore.QObject): @typing.overload @staticmethod def createCentral(remoteDevice: QBluetoothAddress, localDevice: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> 'QLowEnergyController': ... - discoveryFinished: typing.ClassVar[QtCore.pyqtSignal] - serviceDiscovered: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - disconnected: typing.ClassVar[QtCore.pyqtSignal] - connected: typing.ClassVar[QtCore.pyqtSignal] + def discoveryFinished(self) -> None: ... + def serviceDiscovered(self, newService: QBluetoothUuid) -> None: ... + def stateChanged(self, state: 'QLowEnergyController.ControllerState') -> None: ... + def disconnected(self) -> None: ... + def connected(self) -> None: ... def remoteName(self) -> str: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QLowEnergyController.Error': ... + @typing.overload + def error(self, newError: 'QLowEnergyController.Error') -> None: ... def createServiceObject(self, service: QBluetoothUuid, parent: typing.Optional[QtCore.QObject] = ...) -> 'QLowEnergyService': ... def services(self) -> typing.List[QBluetoothUuid]: ... def discoverServices(self) -> None: ... @@ -1861,21 +1883,25 @@ class QLowEnergyService(QtCore.QObject): def __invert__(self) -> 'QLowEnergyService.ServiceTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - descriptorRead: typing.ClassVar[QtCore.pyqtSignal] - characteristicRead: typing.ClassVar[QtCore.pyqtSignal] + + def descriptorRead(self, info: QLowEnergyDescriptor, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def characteristicRead(self, info: QLowEnergyCharacteristic, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def readDescriptor(self, descriptor: QLowEnergyDescriptor) -> None: ... def readCharacteristic(self, characteristic: QLowEnergyCharacteristic) -> None: ... - descriptorWritten: typing.ClassVar[QtCore.pyqtSignal] - characteristicWritten: typing.ClassVar[QtCore.pyqtSignal] - characteristicChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] + def descriptorWritten(self, info: QLowEnergyDescriptor, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def characteristicWritten(self, info: QLowEnergyCharacteristic, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def characteristicChanged(self, info: QLowEnergyCharacteristic, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def stateChanged(self, newState: 'QLowEnergyService.ServiceState') -> None: ... def writeDescriptor(self, descriptor: QLowEnergyDescriptor, newValue: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def writeCharacteristic(self, characteristic: QLowEnergyCharacteristic, newValue: typing.Union[QtCore.QByteArray, bytes, bytearray], mode: 'QLowEnergyService.WriteMode' = ...) -> None: ... @typing.overload def contains(self, characteristic: QLowEnergyCharacteristic) -> bool: ... @typing.overload def contains(self, descriptor: QLowEnergyDescriptor) -> bool: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QLowEnergyService.ServiceError': ... + @typing.overload + def error(self, error: 'QLowEnergyService.ServiceError') -> None: ... def discoverDetails(self) -> None: ... def serviceName(self) -> str: ... def serviceUuid(self) -> QBluetoothUuid: ... diff --git a/PyQt5-stubs/QtChart.pyi b/PyQt5-stubs/QtChart.pyi index a4bf36a9..5520a571 100644 --- a/PyQt5-stubs/QtChart.pyi +++ b/PyQt5-stubs/QtChart.pyi @@ -71,14 +71,15 @@ class QAbstractAxis(QtCore.QObject): def __invert__(self) -> 'QAbstractAxis.AxisTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - labelsEditableChanged: typing.ClassVar[QtCore.pyqtSignal] + + def labelsEditableChanged(self, editable: bool) -> None: ... def labelsEditable(self) -> bool: ... def setLabelsEditable(self, editable: bool = ...) -> None: ... - reverseChanged: typing.ClassVar[QtCore.pyqtSignal] - minorGridLineColorChanged: typing.ClassVar[QtCore.pyqtSignal] - gridLineColorChanged: typing.ClassVar[QtCore.pyqtSignal] - minorGridLinePenChanged: typing.ClassVar[QtCore.pyqtSignal] - minorGridVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + def reverseChanged(self, reverse: bool) -> None: ... + def minorGridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def gridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def minorGridLinePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def minorGridVisibleChanged(self, visible: bool) -> None: ... def isReverse(self) -> bool: ... def setReverse(self, reverse: bool = ...) -> None: ... def minorGridLineColor(self) -> QtGui.QColor: ... @@ -89,17 +90,17 @@ class QAbstractAxis(QtCore.QObject): def setMinorGridLinePen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setMinorGridLineVisible(self, visible: bool = ...) -> None: ... def isMinorGridLineVisible(self) -> bool: ... - shadesBrushChanged: typing.ClassVar[QtCore.pyqtSignal] - shadesPenChanged: typing.ClassVar[QtCore.pyqtSignal] - titleFontChanged: typing.ClassVar[QtCore.pyqtSignal] - titleVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] - titleBrushChanged: typing.ClassVar[QtCore.pyqtSignal] - titleTextChanged: typing.ClassVar[QtCore.pyqtSignal] - gridLinePenChanged: typing.ClassVar[QtCore.pyqtSignal] - labelsAngleChanged: typing.ClassVar[QtCore.pyqtSignal] - labelsFontChanged: typing.ClassVar[QtCore.pyqtSignal] - labelsBrushChanged: typing.ClassVar[QtCore.pyqtSignal] - linePenChanged: typing.ClassVar[QtCore.pyqtSignal] + def shadesBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def shadesPenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def titleFontChanged(self, font: QtGui.QFont) -> None: ... + def titleVisibleChanged(self, visible: bool) -> None: ... + def titleBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def titleTextChanged(self, title: str) -> None: ... + def gridLinePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def labelsAngleChanged(self, angle: int) -> None: ... + def labelsFontChanged(self, pen: QtGui.QFont) -> None: ... + def labelsBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def linePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def alignment(self) -> QtCore.Qt.Alignment: ... def titleText(self) -> str: ... def setTitleText(self, title: str) -> None: ... @@ -109,15 +110,15 @@ class QAbstractAxis(QtCore.QObject): def setTitleBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def setTitleVisible(self, visible: bool = ...) -> None: ... def isTitleVisible(self) -> bool: ... - shadesBorderColorChanged: typing.ClassVar[QtCore.pyqtSignal] - shadesColorChanged: typing.ClassVar[QtCore.pyqtSignal] - shadesVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] - labelsColorChanged: typing.ClassVar[QtCore.pyqtSignal] - colorChanged: typing.ClassVar[QtCore.pyqtSignal] - gridVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] - labelsVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] - lineVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] - visibleChanged: typing.ClassVar[QtCore.pyqtSignal] + def shadesBorderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def shadesColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def shadesVisibleChanged(self, visible: bool) -> None: ... + def labelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def gridVisibleChanged(self, visible: bool) -> None: ... + def labelsVisibleChanged(self, visible: bool) -> None: ... + def lineVisibleChanged(self, visible: bool) -> None: ... + def visibleChanged(self, visible: bool) -> None: ... def orientation(self) -> QtCore.Qt.Orientation: ... def hide(self) -> None: ... def show(self) -> None: ... @@ -188,17 +189,18 @@ class QAbstractSeries(QtCore.QObject): SeriesTypeHorizontalPercentBar = ... # type: QAbstractSeries.SeriesType SeriesTypeBoxPlot = ... # type: QAbstractSeries.SeriesType SeriesTypeCandlestick = ... # type: QAbstractSeries.SeriesType - useOpenGLChanged: typing.ClassVar[QtCore.pyqtSignal] + + def useOpenGLChanged(self) -> None: ... def useOpenGL(self) -> bool: ... def setUseOpenGL(self, enable: bool = ...) -> None: ... - opacityChanged: typing.ClassVar[QtCore.pyqtSignal] + def opacityChanged(self) -> None: ... def attachedAxes(self) -> typing.List['QAbstractAxis']: ... def detachAxis(self, axis: 'QAbstractAxis') -> bool: ... def attachAxis(self, axis: 'QAbstractAxis') -> bool: ... def setOpacity(self, opacity: float) -> None: ... def opacity(self) -> float: ... - visibleChanged: typing.ClassVar[QtCore.pyqtSignal] - nameChanged: typing.ClassVar[QtCore.pyqtSignal] + def visibleChanged(self) -> None: ... + def nameChanged(self) -> None: ... def hide(self) -> None: ... def show(self) -> None: ... def chart(self) -> 'QChart': ... @@ -220,27 +222,28 @@ class QAbstractBarSeries('QAbstractSeries'): LabelsInsideEnd = ... # type: QAbstractBarSeries.LabelsPosition LabelsInsideBase = ... # type: QAbstractBarSeries.LabelsPosition LabelsOutsideEnd = ... # type: QAbstractBarSeries.LabelsPosition - labelsPrecisionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def labelsPrecisionChanged(self, precision: int) -> None: ... def labelsPrecision(self) -> int: ... def setLabelsPrecision(self, precision: int) -> None: ... - labelsAngleChanged: typing.ClassVar[QtCore.pyqtSignal] + def labelsAngleChanged(self, angle: float) -> None: ... def labelsAngle(self) -> float: ... def setLabelsAngle(self, angle: float) -> None: ... - doubleClicked: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] - labelsPositionChanged: typing.ClassVar[QtCore.pyqtSignal] - labelsFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + def doubleClicked(self, index: int, barset: 'QBarSet') -> None: ... + def released(self, index: int, barset: 'QBarSet') -> None: ... + def pressed(self, index: int, barset: 'QBarSet') -> None: ... + def labelsPositionChanged(self, position: 'QAbstractBarSeries.LabelsPosition') -> None: ... + def labelsFormatChanged(self, format: str) -> None: ... def labelsPosition(self) -> 'QAbstractBarSeries.LabelsPosition': ... def setLabelsPosition(self, position: 'QAbstractBarSeries.LabelsPosition') -> None: ... def labelsFormat(self) -> str: ... def setLabelsFormat(self, format: str) -> None: ... - barsetsRemoved: typing.ClassVar[QtCore.pyqtSignal] - barsetsAdded: typing.ClassVar[QtCore.pyqtSignal] - labelsVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] - countChanged: typing.ClassVar[QtCore.pyqtSignal] - hovered: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] + def barsetsRemoved(self, sets: typing.Iterable['QBarSet']) -> None: ... + def barsetsAdded(self, sets: typing.Iterable['QBarSet']) -> None: ... + def labelsVisibleChanged(self) -> None: ... + def countChanged(self) -> None: ... + def hovered(self, status: bool, index: int, barset: 'QBarSet') -> None: ... + def clicked(self, index: int, barset: 'QBarSet') -> None: ... def take(self, set: 'QBarSet') -> bool: ... def isLabelsVisible(self) -> bool: ... def setLabelsVisible(self, visible: bool = ...) -> None: ... @@ -273,17 +276,18 @@ class QLegendMarker(QtCore.QObject): LegendMarkerTypeXY = ... # type: QLegendMarker.LegendMarkerType LegendMarkerTypeBoxPlot = ... # type: QLegendMarker.LegendMarkerType LegendMarkerTypeCandlestick = ... # type: QLegendMarker.LegendMarkerType - shapeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def shapeChanged(self) -> None: ... def setShape(self, shape: 'QLegend.MarkerShape') -> None: ... def shape(self) -> 'QLegend.MarkerShape': ... - visibleChanged: typing.ClassVar[QtCore.pyqtSignal] - brushChanged: typing.ClassVar[QtCore.pyqtSignal] - penChanged: typing.ClassVar[QtCore.pyqtSignal] - fontChanged: typing.ClassVar[QtCore.pyqtSignal] - labelBrushChanged: typing.ClassVar[QtCore.pyqtSignal] - labelChanged: typing.ClassVar[QtCore.pyqtSignal] - hovered: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] + def visibleChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def penChanged(self) -> None: ... + def fontChanged(self) -> None: ... + def labelBrushChanged(self) -> None: ... + def labelChanged(self) -> None: ... + def hovered(self, status: bool) -> None: ... + def clicked(self) -> None: ... def series(self) -> 'QAbstractSeries': ... def setVisible(self, visible: bool) -> None: ... def isVisible(self) -> bool: ... @@ -312,16 +316,17 @@ class QAreaSeries('QAbstractSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, upperSeries: 'QLineSeries', lowerSeries: typing.Optional['QLineSeries'] = ...) -> None: ... - pointLabelsClippingChanged: typing.ClassVar[QtCore.pyqtSignal] + + def pointLabelsClippingChanged(self, clipping: bool) -> None: ... def pointLabelsClipping(self) -> bool: ... def setPointLabelsClipping(self, enable: bool = ...) -> None: ... - doubleClicked: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] - pointLabelsColorChanged: typing.ClassVar[QtCore.pyqtSignal] - pointLabelsFontChanged: typing.ClassVar[QtCore.pyqtSignal] - pointLabelsVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] - pointLabelsFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + def doubleClicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def released(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def pressed(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def pointLabelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pointLabelsFontChanged(self, font: QtGui.QFont) -> None: ... + def pointLabelsVisibilityChanged(self, visible: bool) -> None: ... + def pointLabelsFormatChanged(self, format: str) -> None: ... def pointLabelsColor(self) -> QtGui.QColor: ... def setPointLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def pointLabelsFont(self) -> QtGui.QFont: ... @@ -330,11 +335,11 @@ class QAreaSeries('QAbstractSeries'): def setPointLabelsVisible(self, visible: bool = ...) -> None: ... def pointLabelsFormat(self) -> str: ... def setPointLabelsFormat(self, format: str) -> None: ... - hovered: typing.ClassVar[QtCore.pyqtSignal] - selected: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] - colorChanged: typing.ClassVar[QtCore.pyqtSignal] - borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] + def hovered(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint], state: bool) -> None: ... + def selected(self) -> None: ... + def clicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def borderColor(self) -> QtGui.QColor: ... def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def color(self) -> QtGui.QColor: ... @@ -354,11 +359,12 @@ class QAreaSeries('QAbstractSeries'): class QBarCategoryAxis('QAbstractAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - countChanged: typing.ClassVar[QtCore.pyqtSignal] - rangeChanged: typing.ClassVar[QtCore.pyqtSignal] - maxChanged: typing.ClassVar[QtCore.pyqtSignal] - minChanged: typing.ClassVar[QtCore.pyqtSignal] - categoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + + def countChanged(self) -> None: ... + def rangeChanged(self, min: str, max: str) -> None: ... + def maxChanged(self, max: str) -> None: ... + def minChanged(self, min: str) -> None: ... + def categoriesChanged(self) -> None: ... def setRange(self, minCategory: str, maxCategory: str) -> None: ... def max(self) -> str: ... def setMax(self, maxCategory: str) -> None: ... @@ -396,22 +402,23 @@ class QBarSeries('QAbstractBarSeries'): class QBarSet(QtCore.QObject): def __init__(self, name: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - doubleClicked: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] - labelColorChanged: typing.ClassVar[QtCore.pyqtSignal] - borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] - colorChanged: typing.ClassVar[QtCore.pyqtSignal] - hovered: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] - valueChanged: typing.ClassVar[QtCore.pyqtSignal] - valuesRemoved: typing.ClassVar[QtCore.pyqtSignal] - valuesAdded: typing.ClassVar[QtCore.pyqtSignal] - labelFontChanged: typing.ClassVar[QtCore.pyqtSignal] - labelBrushChanged: typing.ClassVar[QtCore.pyqtSignal] - labelChanged: typing.ClassVar[QtCore.pyqtSignal] - brushChanged: typing.ClassVar[QtCore.pyqtSignal] - penChanged: typing.ClassVar[QtCore.pyqtSignal] + + def doubleClicked(self, index: int) -> None: ... + def released(self, index: int) -> None: ... + def pressed(self, index: int) -> None: ... + def labelColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def hovered(self, status: bool, index: int) -> None: ... + def clicked(self, index: int) -> None: ... + def valueChanged(self, index: int) -> None: ... + def valuesRemoved(self, index: int, count: int) -> None: ... + def valuesAdded(self, index: int, count: int) -> None: ... + def labelFontChanged(self) -> None: ... + def labelBrushChanged(self) -> None: ... + def labelChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def penChanged(self) -> None: ... def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def labelColor(self) -> QtGui.QColor: ... def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... @@ -451,18 +458,19 @@ class QBoxPlotLegendMarker('QLegendMarker'): class QBoxPlotSeries('QAbstractSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - doubleClicked: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] - boxsetsRemoved: typing.ClassVar[QtCore.pyqtSignal] - boxsetsAdded: typing.ClassVar[QtCore.pyqtSignal] - boxWidthChanged: typing.ClassVar[QtCore.pyqtSignal] - boxOutlineVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] - brushChanged: typing.ClassVar[QtCore.pyqtSignal] - penChanged: typing.ClassVar[QtCore.pyqtSignal] - countChanged: typing.ClassVar[QtCore.pyqtSignal] - hovered: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] + + def doubleClicked(self, boxset: 'QBoxSet') -> None: ... + def released(self, boxset: 'QBoxSet') -> None: ... + def pressed(self, boxset: 'QBoxSet') -> None: ... + def boxsetsRemoved(self, sets: typing.Iterable['QBoxSet']) -> None: ... + def boxsetsAdded(self, sets: typing.Iterable['QBoxSet']) -> None: ... + def boxWidthChanged(self) -> None: ... + def boxOutlineVisibilityChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def penChanged(self) -> None: ... + def countChanged(self) -> None: ... + def hovered(self, status: bool, boxset: 'QBoxSet') -> None: ... + def clicked(self, boxset: 'QBoxSet') -> None: ... def pen(self) -> QtGui.QPen: ... def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def brush(self) -> QtGui.QBrush: ... @@ -503,16 +511,17 @@ class QBoxSet(QtCore.QObject): def __init__(self, label: str = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, le: float, lq: float, m: float, uq: float, ue: float, label: str = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - doubleClicked: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] - cleared: typing.ClassVar[QtCore.pyqtSignal] - valueChanged: typing.ClassVar[QtCore.pyqtSignal] - valuesChanged: typing.ClassVar[QtCore.pyqtSignal] - brushChanged: typing.ClassVar[QtCore.pyqtSignal] - penChanged: typing.ClassVar[QtCore.pyqtSignal] - hovered: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] + + def doubleClicked(self) -> None: ... + def released(self) -> None: ... + def pressed(self) -> None: ... + def cleared(self) -> None: ... + def valueChanged(self, index: int) -> None: ... + def valuesChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def penChanged(self) -> None: ... + def hovered(self, status: bool) -> None: ... + def clicked(self) -> None: ... def brush(self) -> QtGui.QBrush: ... def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def pen(self) -> QtGui.QPen: ... @@ -555,8 +564,8 @@ class QCandlestickModelMapper(QtCore.QObject): def setOpen(self, open: int) -> None: ... def timestamp(self) -> int: ... def setTimestamp(self, timestamp: int) -> None: ... - seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] - modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + def seriesReplaced(self) -> None: ... + def modelReplaced(self) -> None: ... def orientation(self) -> QtCore.Qt.Orientation: ... def series(self) -> 'QCandlestickSeries': ... def setSeries(self, series: 'QCandlestickSeries') -> None: ... @@ -566,24 +575,25 @@ class QCandlestickModelMapper(QtCore.QObject): class QCandlestickSeries('QAbstractSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - penChanged: typing.ClassVar[QtCore.pyqtSignal] - brushChanged: typing.ClassVar[QtCore.pyqtSignal] - decreasingColorChanged: typing.ClassVar[QtCore.pyqtSignal] - increasingColorChanged: typing.ClassVar[QtCore.pyqtSignal] - capsVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] - capsWidthChanged: typing.ClassVar[QtCore.pyqtSignal] - bodyOutlineVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] - bodyWidthChanged: typing.ClassVar[QtCore.pyqtSignal] - minimumColumnWidthChanged: typing.ClassVar[QtCore.pyqtSignal] - maximumColumnWidthChanged: typing.ClassVar[QtCore.pyqtSignal] - countChanged: typing.ClassVar[QtCore.pyqtSignal] - candlestickSetsRemoved: typing.ClassVar[QtCore.pyqtSignal] - candlestickSetsAdded: typing.ClassVar[QtCore.pyqtSignal] - doubleClicked: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] - hovered: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] + + def penChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def decreasingColorChanged(self) -> None: ... + def increasingColorChanged(self) -> None: ... + def capsVisibilityChanged(self) -> None: ... + def capsWidthChanged(self) -> None: ... + def bodyOutlineVisibilityChanged(self) -> None: ... + def bodyWidthChanged(self) -> None: ... + def minimumColumnWidthChanged(self) -> None: ... + def maximumColumnWidthChanged(self) -> None: ... + def countChanged(self) -> None: ... + def candlestickSetsRemoved(self, sets: typing.Iterable['QCandlestickSet']) -> None: ... + def candlestickSetsAdded(self, sets: typing.Iterable['QCandlestickSet']) -> None: ... + def doubleClicked(self, set: 'QCandlestickSet') -> None: ... + def released(self, set: 'QCandlestickSet') -> None: ... + def pressed(self, set: 'QCandlestickSet') -> None: ... + def hovered(self, status: bool, set: 'QCandlestickSet') -> None: ... + def clicked(self, set: 'QCandlestickSet') -> None: ... def pen(self) -> QtGui.QPen: ... def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def brush(self) -> QtGui.QBrush: ... @@ -626,18 +636,19 @@ class QCandlestickSet(QtCore.QObject): def __init__(self, timestamp: float = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, open: float, high: float, low: float, close: float, timestamp: float = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - penChanged: typing.ClassVar[QtCore.pyqtSignal] - brushChanged: typing.ClassVar[QtCore.pyqtSignal] - closeChanged: typing.ClassVar[QtCore.pyqtSignal] - lowChanged: typing.ClassVar[QtCore.pyqtSignal] - highChanged: typing.ClassVar[QtCore.pyqtSignal] - openChanged: typing.ClassVar[QtCore.pyqtSignal] - timestampChanged: typing.ClassVar[QtCore.pyqtSignal] - doubleClicked: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] - hovered: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] + + def penChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def closeChanged(self) -> None: ... + def lowChanged(self) -> None: ... + def highChanged(self) -> None: ... + def openChanged(self) -> None: ... + def timestampChanged(self) -> None: ... + def doubleClicked(self) -> None: ... + def released(self) -> None: ... + def pressed(self) -> None: ... + def hovered(self, status: bool) -> None: ... + def clicked(self) -> None: ... def pen(self) -> QtGui.QPen: ... def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def brush(self) -> QtGui.QBrush: ... @@ -663,23 +674,24 @@ class QValueAxis('QAbstractAxis'): TicksFixed = ... # type: QValueAxis.TickType def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - tickTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - tickAnchorChanged: typing.ClassVar[QtCore.pyqtSignal] - tickIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + + def tickTypeChanged(self, type: 'QValueAxis.TickType') -> None: ... + def tickAnchorChanged(self, anchor: float) -> None: ... + def tickIntervalChanged(self, interval: float) -> None: ... def tickType(self) -> 'QValueAxis.TickType': ... def setTickType(self, type: 'QValueAxis.TickType') -> None: ... def tickInterval(self) -> float: ... def setTickInterval(self, insterval: float) -> None: ... def tickAnchor(self) -> float: ... def setTickAnchor(self, anchor: float) -> None: ... - minorTickCountChanged: typing.ClassVar[QtCore.pyqtSignal] + def minorTickCountChanged(self, tickCount: int) -> None: ... def minorTickCount(self) -> int: ... def setMinorTickCount(self, count: int) -> None: ... - labelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] - tickCountChanged: typing.ClassVar[QtCore.pyqtSignal] - rangeChanged: typing.ClassVar[QtCore.pyqtSignal] - maxChanged: typing.ClassVar[QtCore.pyqtSignal] - minChanged: typing.ClassVar[QtCore.pyqtSignal] + def labelFormatChanged(self, format: str) -> None: ... + def tickCountChanged(self, tickCount: int) -> None: ... + def rangeChanged(self, min: float, max: float) -> None: ... + def maxChanged(self, max: float) -> None: ... + def minChanged(self, min: float) -> None: ... def applyNiceNumbers(self) -> None: ... def labelFormat(self) -> str: ... def setLabelFormat(self, format: str) -> None: ... @@ -702,10 +714,11 @@ class QCategoryAxis('QValueAxis'): AxisLabelsPositionOnValue = ... # type: QCategoryAxis.AxisLabelsPosition def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - labelsPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def labelsPositionChanged(self, position: 'QCategoryAxis.AxisLabelsPosition') -> None: ... def setLabelsPosition(self, position: 'QCategoryAxis.AxisLabelsPosition') -> None: ... def labelsPosition(self) -> 'QCategoryAxis.AxisLabelsPosition': ... - categoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + def categoriesChanged(self) -> None: ... def __len__(self) -> int: ... def count(self) -> int: ... def categoriesLabels(self) -> typing.List[str]: ... @@ -779,7 +792,7 @@ class QChart(QtWidgets.QGraphicsWidget): def setAnimationEasingCurve(self, curve: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... def animationDuration(self) -> int: ... def setAnimationDuration(self, msecs: int) -> None: ... - plotAreaChanged: typing.ClassVar[QtCore.pyqtSignal] + def plotAreaChanged(self, plotArea: QtCore.QRectF) -> None: ... def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def localizeNumbers(self) -> bool: ... @@ -886,11 +899,12 @@ class QChartView(QtWidgets.QGraphicsView): class QDateTimeAxis('QAbstractAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - tickCountChanged: typing.ClassVar[QtCore.pyqtSignal] - formatChanged: typing.ClassVar[QtCore.pyqtSignal] - rangeChanged: typing.ClassVar[QtCore.pyqtSignal] - maxChanged: typing.ClassVar[QtCore.pyqtSignal] - minChanged: typing.ClassVar[QtCore.pyqtSignal] + + def tickCountChanged(self, tick: int) -> None: ... + def formatChanged(self, format: str) -> None: ... + def rangeChanged(self, min: typing.Union[QtCore.QDateTime, datetime.datetime], max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... + def maxChanged(self, max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... + def minChanged(self, min: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... def tickCount(self) -> int: ... def setTickCount(self, count: int) -> None: ... def format(self) -> str: ... @@ -905,12 +919,13 @@ class QDateTimeAxis('QAbstractAxis'): class QHBarModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] - firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - lastBarSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] - firstBarSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] - modelReplaced: typing.ClassVar[QtCore.pyqtSignal] - seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] + + def columnCountChanged(self) -> None: ... + def firstColumnChanged(self) -> None: ... + def lastBarSetRowChanged(self) -> None: ... + def firstBarSetRowChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... def setColumnCount(self, columnCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -927,12 +942,13 @@ class QHBarModelMapper(QtCore.QObject): class QHBoxPlotModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] - firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - lastBoxSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] - firstBoxSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] - modelReplaced: typing.ClassVar[QtCore.pyqtSignal] - seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] + + def columnCountChanged(self) -> None: ... + def firstColumnChanged(self) -> None: ... + def lastBoxSetRowChanged(self) -> None: ... + def firstBoxSetRowChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... def setColumnCount(self, rowCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -949,13 +965,14 @@ class QHBoxPlotModelMapper(QtCore.QObject): class QHCandlestickModelMapper('QCandlestickModelMapper'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - lastSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] - firstSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] - closeColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - lowColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - highColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - openColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - timestampColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + + def lastSetRowChanged(self) -> None: ... + def firstSetRowChanged(self) -> None: ... + def closeColumnChanged(self) -> None: ... + def lowColumnChanged(self) -> None: ... + def highColumnChanged(self) -> None: ... + def openColumnChanged(self) -> None: ... + def timestampColumnChanged(self) -> None: ... def lastSetRow(self) -> int: ... def setLastSetRow(self, lastSetRow: int) -> None: ... def firstSetRow(self) -> int: ... @@ -993,12 +1010,13 @@ class QHorizontalStackedBarSeries('QAbstractBarSeries'): class QHPieModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] - firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - labelsRowChanged: typing.ClassVar[QtCore.pyqtSignal] - valuesRowChanged: typing.ClassVar[QtCore.pyqtSignal] - modelReplaced: typing.ClassVar[QtCore.pyqtSignal] - seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] + + def columnCountChanged(self) -> None: ... + def firstColumnChanged(self) -> None: ... + def labelsRowChanged(self) -> None: ... + def valuesRowChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... def setColumnCount(self, columnCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -1015,12 +1033,13 @@ class QHPieModelMapper(QtCore.QObject): class QHXYModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] - firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - yRowChanged: typing.ClassVar[QtCore.pyqtSignal] - xRowChanged: typing.ClassVar[QtCore.pyqtSignal] - modelReplaced: typing.ClassVar[QtCore.pyqtSignal] - seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] + + def columnCountChanged(self) -> None: ... + def firstColumnChanged(self) -> None: ... + def yRowChanged(self) -> None: ... + def xRowChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... def setColumnCount(self, columnCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -1046,22 +1065,23 @@ class QLegend(QtWidgets.QGraphicsWidget): MarkerShapeRectangle = ... # type: QLegend.MarkerShape MarkerShapeCircle = ... # type: QLegend.MarkerShape MarkerShapeFromSeries = ... # type: QLegend.MarkerShape - markerShapeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def markerShapeChanged(self, shape: 'QLegend.MarkerShape') -> None: ... def setMarkerShape(self, shape: 'QLegend.MarkerShape') -> None: ... def markerShape(self) -> 'QLegend.MarkerShape': ... - showToolTipsChanged: typing.ClassVar[QtCore.pyqtSignal] + def showToolTipsChanged(self, showToolTips: bool) -> None: ... def setShowToolTips(self, show: bool) -> None: ... def showToolTips(self) -> bool: ... - reverseMarkersChanged: typing.ClassVar[QtCore.pyqtSignal] + def reverseMarkersChanged(self, reverseMarkers: bool) -> None: ... def setReverseMarkers(self, reverseMarkers: bool = ...) -> None: ... def reverseMarkers(self) -> bool: ... def showEvent(self, event: QtGui.QShowEvent) -> None: ... def hideEvent(self, event: QtGui.QHideEvent) -> None: ... - labelColorChanged: typing.ClassVar[QtCore.pyqtSignal] - fontChanged: typing.ClassVar[QtCore.pyqtSignal] - borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] - colorChanged: typing.ClassVar[QtCore.pyqtSignal] - backgroundVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + def labelColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... + def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def backgroundVisibleChanged(self, visible: bool) -> None: ... def markers(self, series: typing.Optional['QAbstractSeries'] = ...) -> typing.List['QLegendMarker']: ... def labelColor(self) -> QtGui.QColor: ... def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... @@ -1087,20 +1107,21 @@ class QLegend(QtWidgets.QGraphicsWidget): def paint(self, painter: QtGui.QPainter, option: QtWidgets.QStyleOptionGraphicsItem, widget: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... class QXYSeries('QAbstractSeries'): - penChanged: typing.ClassVar[QtCore.pyqtSignal] - pointsRemoved: typing.ClassVar[QtCore.pyqtSignal] - pointLabelsClippingChanged: typing.ClassVar[QtCore.pyqtSignal] + + def penChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pointsRemoved(self, index: int, count: int) -> None: ... + def pointLabelsClippingChanged(self, clipping: bool) -> None: ... def pointLabelsClipping(self) -> bool: ... def setPointLabelsClipping(self, enable: bool = ...) -> None: ... def pointsVector(self) -> typing.List[QtCore.QPointF]: ... def removePoints(self, index: int, count: int) -> None: ... - doubleClicked: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] - pointLabelsColorChanged: typing.ClassVar[QtCore.pyqtSignal] - pointLabelsFontChanged: typing.ClassVar[QtCore.pyqtSignal] - pointLabelsVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] - pointLabelsFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + def doubleClicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def released(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def pressed(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def pointLabelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pointLabelsFontChanged(self, font: QtGui.QFont) -> None: ... + def pointLabelsVisibilityChanged(self, visible: bool) -> None: ... + def pointLabelsFormatChanged(self, format: str) -> None: ... def pointLabelsColor(self) -> QtGui.QColor: ... def setPointLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def pointLabelsFont(self) -> QtGui.QFont: ... @@ -1109,13 +1130,13 @@ class QXYSeries('QAbstractSeries'): def setPointLabelsVisible(self, visible: bool = ...) -> None: ... def pointLabelsFormat(self) -> str: ... def setPointLabelsFormat(self, format: str) -> None: ... - hovered: typing.ClassVar[QtCore.pyqtSignal] - pointsReplaced: typing.ClassVar[QtCore.pyqtSignal] - pointAdded: typing.ClassVar[QtCore.pyqtSignal] - pointRemoved: typing.ClassVar[QtCore.pyqtSignal] - pointReplaced: typing.ClassVar[QtCore.pyqtSignal] - colorChanged: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] + def hovered(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint], state: bool) -> None: ... + def pointsReplaced(self) -> None: ... + def pointAdded(self, index: int) -> None: ... + def pointRemoved(self, index: int) -> None: ... + def pointReplaced(self, index: int) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def clicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... def at(self, index: int) -> QtCore.QPointF: ... def pointsVisible(self) -> bool: ... def setPointsVisible(self, visible: bool = ...) -> None: ... @@ -1161,16 +1182,17 @@ class QLineSeries('QXYSeries'): class QLogValueAxis('QAbstractAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - minorTickCountChanged: typing.ClassVar[QtCore.pyqtSignal] - tickCountChanged: typing.ClassVar[QtCore.pyqtSignal] + + def minorTickCountChanged(self, minorTickCount: int) -> None: ... + def tickCountChanged(self, tickCount: int) -> None: ... def minorTickCount(self) -> int: ... def setMinorTickCount(self, minorTickCount: int) -> None: ... def tickCount(self) -> int: ... - baseChanged: typing.ClassVar[QtCore.pyqtSignal] - labelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] - rangeChanged: typing.ClassVar[QtCore.pyqtSignal] - maxChanged: typing.ClassVar[QtCore.pyqtSignal] - minChanged: typing.ClassVar[QtCore.pyqtSignal] + def baseChanged(self, base: float) -> None: ... + def labelFormatChanged(self, format: str) -> None: ... + def rangeChanged(self, min: float, max: float) -> None: ... + def maxChanged(self, max: float) -> None: ... + def minChanged(self, min: float) -> None: ... def base(self) -> float: ... def setBase(self, base: float) -> None: ... def labelFormat(self) -> str: ... @@ -1199,19 +1221,20 @@ class QPieLegendMarker('QLegendMarker'): class QPieSeries('QAbstractSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - doubleClicked: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] + + def doubleClicked(self, slice: 'QPieSlice') -> None: ... + def released(self, slice: 'QPieSlice') -> None: ... + def pressed(self, slice: 'QPieSlice') -> None: ... def setLabelsPosition(self, position: 'QPieSlice.LabelPosition') -> None: ... def holeSize(self) -> float: ... def setHoleSize(self, holeSize: float) -> None: ... def take(self, slice: 'QPieSlice') -> bool: ... - sumChanged: typing.ClassVar[QtCore.pyqtSignal] - countChanged: typing.ClassVar[QtCore.pyqtSignal] - hovered: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] - removed: typing.ClassVar[QtCore.pyqtSignal] - added: typing.ClassVar[QtCore.pyqtSignal] + def sumChanged(self) -> None: ... + def countChanged(self) -> None: ... + def hovered(self, slice: 'QPieSlice', state: bool) -> None: ... + def clicked(self, slice: 'QPieSlice') -> None: ... + def removed(self, slices: typing.Iterable['QPieSlice']) -> None: ... + def added(self, slices: typing.Iterable['QPieSlice']) -> None: ... def setLabelsVisible(self, visible: bool = ...) -> None: ... def pieEndAngle(self) -> float: ... def setPieEndAngle(self, endAngle: float) -> None: ... @@ -1256,25 +1279,26 @@ class QPieSlice(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, label: str, value: float, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - doubleClicked: typing.ClassVar[QtCore.pyqtSignal] - released: typing.ClassVar[QtCore.pyqtSignal] - pressed: typing.ClassVar[QtCore.pyqtSignal] - hovered: typing.ClassVar[QtCore.pyqtSignal] - clicked: typing.ClassVar[QtCore.pyqtSignal] - labelColorChanged: typing.ClassVar[QtCore.pyqtSignal] - borderWidthChanged: typing.ClassVar[QtCore.pyqtSignal] - borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] - colorChanged: typing.ClassVar[QtCore.pyqtSignal] - angleSpanChanged: typing.ClassVar[QtCore.pyqtSignal] - startAngleChanged: typing.ClassVar[QtCore.pyqtSignal] - percentageChanged: typing.ClassVar[QtCore.pyqtSignal] - labelFontChanged: typing.ClassVar[QtCore.pyqtSignal] - labelBrushChanged: typing.ClassVar[QtCore.pyqtSignal] - brushChanged: typing.ClassVar[QtCore.pyqtSignal] - penChanged: typing.ClassVar[QtCore.pyqtSignal] - labelVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] - valueChanged: typing.ClassVar[QtCore.pyqtSignal] - labelChanged: typing.ClassVar[QtCore.pyqtSignal] + + def doubleClicked(self) -> None: ... + def released(self) -> None: ... + def pressed(self) -> None: ... + def hovered(self, state: bool) -> None: ... + def clicked(self) -> None: ... + def labelColorChanged(self) -> None: ... + def borderWidthChanged(self) -> None: ... + def borderColorChanged(self) -> None: ... + def colorChanged(self) -> None: ... + def angleSpanChanged(self) -> None: ... + def startAngleChanged(self) -> None: ... + def percentageChanged(self) -> None: ... + def labelFontChanged(self) -> None: ... + def labelBrushChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def penChanged(self) -> None: ... + def labelVisibleChanged(self) -> None: ... + def valueChanged(self) -> None: ... + def labelChanged(self) -> None: ... def setLabelPosition(self, position: 'QPieSlice.LabelPosition') -> None: ... def labelPosition(self) -> 'QPieSlice.LabelPosition': ... def series(self) -> 'QPieSeries': ... @@ -1351,10 +1375,11 @@ class QScatterSeries('QXYSeries'): MarkerShapeRectangle = ... # type: QScatterSeries.MarkerShape def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - markerSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - markerShapeChanged: typing.ClassVar[QtCore.pyqtSignal] - borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] - colorChanged: typing.ClassVar[QtCore.pyqtSignal] + + def markerSizeChanged(self, size: float) -> None: ... + def markerShapeChanged(self, shape: 'QScatterSeries.MarkerShape') -> None: ... + def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def borderColor(self) -> QtGui.QColor: ... def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def color(self) -> QtGui.QColor: ... @@ -1383,12 +1408,13 @@ class QStackedBarSeries('QAbstractBarSeries'): class QVBarModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] - firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] - lastBarSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - firstBarSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - modelReplaced: typing.ClassVar[QtCore.pyqtSignal] - seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] + + def rowCountChanged(self) -> None: ... + def firstRowChanged(self) -> None: ... + def lastBarSetColumnChanged(self) -> None: ... + def firstBarSetColumnChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... @@ -1405,12 +1431,13 @@ class QVBarModelMapper(QtCore.QObject): class QVBoxPlotModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] - firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] - lastBoxSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - firstBoxSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - modelReplaced: typing.ClassVar[QtCore.pyqtSignal] - seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] + + def rowCountChanged(self) -> None: ... + def firstRowChanged(self) -> None: ... + def lastBoxSetColumnChanged(self) -> None: ... + def firstBoxSetColumnChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... @@ -1427,13 +1454,14 @@ class QVBoxPlotModelMapper(QtCore.QObject): class QVCandlestickModelMapper('QCandlestickModelMapper'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - lastSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - firstSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - closeRowChanged: typing.ClassVar[QtCore.pyqtSignal] - lowRowChanged: typing.ClassVar[QtCore.pyqtSignal] - highRowChanged: typing.ClassVar[QtCore.pyqtSignal] - openRowChanged: typing.ClassVar[QtCore.pyqtSignal] - timestampRowChanged: typing.ClassVar[QtCore.pyqtSignal] + + def lastSetColumnChanged(self) -> None: ... + def firstSetColumnChanged(self) -> None: ... + def closeRowChanged(self) -> None: ... + def lowRowChanged(self) -> None: ... + def highRowChanged(self) -> None: ... + def openRowChanged(self) -> None: ... + def timestampRowChanged(self) -> None: ... def lastSetColumn(self) -> int: ... def setLastSetColumn(self, lastSetColumn: int) -> None: ... def firstSetColumn(self) -> int: ... @@ -1453,12 +1481,13 @@ class QVCandlestickModelMapper('QCandlestickModelMapper'): class QVPieModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] - firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] - labelsColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - valuesColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - modelReplaced: typing.ClassVar[QtCore.pyqtSignal] - seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] + + def rowCountChanged(self) -> None: ... + def firstRowChanged(self) -> None: ... + def labelsColumnChanged(self) -> None: ... + def valuesColumnChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... @@ -1475,12 +1504,13 @@ class QVPieModelMapper(QtCore.QObject): class QVXYModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] - firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] - yColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - xColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - modelReplaced: typing.ClassVar[QtCore.pyqtSignal] - seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] + + def rowCountChanged(self) -> None: ... + def firstRowChanged(self) -> None: ... + def yColumnChanged(self) -> None: ... + def xColumnChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 8b89b18a..e430ea9a 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -3135,10 +3135,10 @@ class QAbstractAnimation(QObject): def resume(self) -> None: ... def pause(self) -> None: ... def start(self, policy: 'QAbstractAnimation.DeletionPolicy' = ...) -> None: ... - directionChanged: typing.ClassVar[QtCore.pyqtSignal] - currentLoopChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + def directionChanged(self, a0: 'QAbstractAnimation.Direction') -> None: ... + def currentLoopChanged(self, currentLoop: int) -> None: ... + def stateChanged(self, newState: 'QAbstractAnimation.State', oldState: 'QAbstractAnimation.State') -> None: ... + def finished(self) -> None: ... def totalDuration(self) -> int: ... def duration(self) -> int: ... def currentLoop(self) -> int: ... @@ -3166,8 +3166,9 @@ class QAbstractEventDispatcher(QObject): def __init__(self, a0: 'QAbstractEventDispatcher.TimerInfo') -> None: ... def __init__(self, parent: typing.Optional[QObject] = ...) -> None: ... - awake: typing.ClassVar[QtCore.pyqtSignal] - aboutToBlock: typing.ClassVar[QtCore.pyqtSignal] + + def awake(self) -> None: ... + def aboutToBlock(self) -> None: ... def filterNativeEvent(self, eventType: typing.Union['QByteArray', bytes, bytearray], message: sip.voidptr) -> typing.Tuple[bool, int]: ... def removeNativeEventFilter(self, filterObj: 'QAbstractNativeEventFilter') -> None: ... def installNativeEventFilter(self, filterObj: 'QAbstractNativeEventFilter') -> None: ... @@ -3291,10 +3292,10 @@ class QAbstractItemModel(QObject): def beginMoveColumns(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationColumn: int) -> bool: ... def endMoveRows(self) -> None: ... def beginMoveRows(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationRow: int) -> bool: ... - columnsMoved: typing.ClassVar[QtCore.pyqtSignal] - columnsAboutToBeMoved: typing.ClassVar[QtCore.pyqtSignal] - rowsMoved: typing.ClassVar[QtCore.pyqtSignal] - rowsAboutToBeMoved: typing.ClassVar[QtCore.pyqtSignal] + def columnsMoved(self, parent: QModelIndex, start: int, end: int, destination: QModelIndex, column: int) -> None: ... + def columnsAboutToBeMoved(self, sourceParent: QModelIndex, sourceStart: int, sourceEnd: int, destinationParent: QModelIndex, destinationColumn: int) -> None: ... + def rowsMoved(self, parent: QModelIndex, start: int, end: int, destination: QModelIndex, row: int) -> None: ... + def rowsAboutToBeMoved(self, sourceParent: QModelIndex, sourceStart: int, sourceEnd: int, destinationParent: QModelIndex, destinationRow: int) -> None: ... def createIndex(self, row: int, column: int, object: typing.Any = ...) -> QModelIndex: ... def roleNames(self) -> typing.Dict[int, 'QByteArray']: ... def supportedDragActions(self) -> Qt.DropActions: ... @@ -3317,19 +3318,19 @@ class QAbstractItemModel(QObject): def encodeData(self, indexes: typing.Iterable[QModelIndex], stream: 'QDataStream') -> None: ... def revert(self) -> None: ... def submit(self) -> bool: ... - modelReset: typing.ClassVar[QtCore.pyqtSignal] - modelAboutToBeReset: typing.ClassVar[QtCore.pyqtSignal] - columnsRemoved: typing.ClassVar[QtCore.pyqtSignal] - columnsAboutToBeRemoved: typing.ClassVar[QtCore.pyqtSignal] - columnsInserted: typing.ClassVar[QtCore.pyqtSignal] - columnsAboutToBeInserted: typing.ClassVar[QtCore.pyqtSignal] - rowsRemoved: typing.ClassVar[QtCore.pyqtSignal] - rowsAboutToBeRemoved: typing.ClassVar[QtCore.pyqtSignal] - rowsInserted: typing.ClassVar[QtCore.pyqtSignal] - rowsAboutToBeInserted: typing.ClassVar[QtCore.pyqtSignal] - layoutChanged: typing.ClassVar[QtCore.pyqtSignal] - layoutAboutToBeChanged: typing.ClassVar[QtCore.pyqtSignal] - headerDataChanged: typing.ClassVar[QtCore.pyqtSignal] + def modelReset(self) -> None: ... + def modelAboutToBeReset(self) -> None: ... + def columnsRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... + def columnsAboutToBeRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... + def columnsInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... + def columnsAboutToBeInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... + def rowsRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... + def rowsAboutToBeRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... + def rowsInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... + def rowsAboutToBeInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... + def layoutChanged(self, parents: typing.Iterable[QPersistentModelIndex] = ..., hint: 'QAbstractItemModel.LayoutChangeHint' = ...) -> None: ... + def layoutAboutToBeChanged(self, parents: typing.Iterable[QPersistentModelIndex] = ..., hint: 'QAbstractItemModel.LayoutChangeHint' = ...) -> None: ... + def headerDataChanged(self, orientation: Qt.Orientation, first: int, last: int) -> None: ... dataChanged: typing.ClassVar[pyqtSignal] def span(self, index: QModelIndex) -> 'QSize': ... def match(self, start: QModelIndex, role: int, value: typing.Any, hits: int = ..., flags: typing.Union[Qt.MatchFlags, Qt.MatchFlag] = ...) -> typing.List[QModelIndex]: ... @@ -3400,7 +3401,7 @@ class QAbstractProxyModel(QAbstractItemModel): def supportedDragActions(self) -> Qt.DropActions: ... def dropMimeData(self, data: 'QMimeData', action: Qt.DropAction, row: int, column: int, parent: QModelIndex) -> bool: ... def canDropMimeData(self, data: 'QMimeData', action: Qt.DropAction, row: int, column: int, parent: QModelIndex) -> bool: ... - sourceModelChanged: typing.ClassVar[QtCore.pyqtSignal] + def sourceModelChanged(self) -> None: ... def resetInternalData(self) -> None: ... def sibling(self, row: int, column: int, idx: QModelIndex) -> QModelIndex: ... def supportedDropActions(self) -> Qt.DropActions: ... @@ -3436,9 +3437,9 @@ class QAbstractState(QObject): def event(self, e: 'QEvent') -> bool: ... def onExit(self, event: 'QEvent') -> None: ... def onEntry(self, event: 'QEvent') -> None: ... - exited: typing.ClassVar[QtCore.pyqtSignal] - entered: typing.ClassVar[QtCore.pyqtSignal] - activeChanged: typing.ClassVar[QtCore.pyqtSignal] + def exited(self) -> None: ... + def entered(self) -> None: ... + def activeChanged(self, active: bool) -> None: ... def active(self) -> bool: ... def machine(self) -> 'QStateMachine': ... def parentState(self) -> 'QState': ... @@ -3460,9 +3461,9 @@ class QAbstractTransition(QObject): def event(self, e: 'QEvent') -> bool: ... def onTransition(self, event: 'QEvent') -> None: ... def eventTest(self, event: 'QEvent') -> bool: ... - targetStatesChanged: typing.ClassVar[QtCore.pyqtSignal] - targetStateChanged: typing.ClassVar[QtCore.pyqtSignal] - triggered: typing.ClassVar[QtCore.pyqtSignal] + def targetStatesChanged(self) -> None: ... + def targetStateChanged(self) -> None: ... + def triggered(self) -> None: ... def animations(self) -> typing.List[QAbstractAnimation]: ... def removeAnimation(self, animation: QAbstractAnimation) -> None: ... def addAnimation(self, animation: QAbstractAnimation) -> None: ... @@ -3603,8 +3604,8 @@ class QIODevice(QObject): def __init__(self, parent: QObject) -> None: ... def skip(self, maxSize: int) -> int: ... - channelBytesWritten: typing.ClassVar[QtCore.pyqtSignal] - channelReadyRead: typing.ClassVar[QtCore.pyqtSignal] + def channelBytesWritten(self, channel: int, bytes: int) -> None: ... + def channelReadyRead(self, channel: int) -> None: ... def isTransactionStarted(self) -> bool: ... def rollbackTransaction(self) -> None: ... def commitTransaction(self) -> None: ... @@ -3620,10 +3621,10 @@ class QIODevice(QObject): def writeData(self, data: bytes) -> int: ... def readLineData(self, maxlen: int) -> bytes: ... def readData(self, maxlen: int) -> bytes: ... - readChannelFinished: typing.ClassVar[QtCore.pyqtSignal] - aboutToClose: typing.ClassVar[QtCore.pyqtSignal] - bytesWritten: typing.ClassVar[QtCore.pyqtSignal] - readyRead: typing.ClassVar[QtCore.pyqtSignal] + def readChannelFinished(self) -> None: ... + def aboutToClose(self) -> None: ... + def bytesWritten(self, bytes: int) -> None: ... + def readyRead(self) -> None: ... def errorString(self) -> str: ... def getChar(self) -> typing.Tuple[bool, bytes]: ... def putChar(self, c: str) -> bool: ... @@ -6072,8 +6073,9 @@ class QFileSystemWatcher(QObject): def __init__(self, parent: typing.Optional[QObject] = ...) -> None: ... @typing.overload def __init__(self, paths: typing.Iterable[str], parent: typing.Optional[QObject] = ...) -> None: ... - fileChanged: typing.ClassVar[QtCore.pyqtSignal] - directoryChanged: typing.ClassVar[QtCore.pyqtSignal] + + def fileChanged(self, path: str) -> None: ... + def directoryChanged(self, path: str) -> None: ... def removePaths(self, files: typing.Iterable[str]) -> typing.List[str]: ... def removePath(self, file: str) -> bool: ... def files(self) -> typing.List[str]: ... @@ -6104,11 +6106,12 @@ class QHistoryState(QAbstractState): def __init__(self, parent: typing.Optional['QState'] = ...) -> None: ... @typing.overload def __init__(self, type: 'QHistoryState.HistoryType', parent: typing.Optional['QState'] = ...) -> None: ... - defaultTransitionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def defaultTransitionChanged(self) -> None: ... def setDefaultTransition(self, transition: QAbstractTransition) -> None: ... def defaultTransition(self) -> QAbstractTransition: ... - historyTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - defaultStateChanged: typing.ClassVar[QtCore.pyqtSignal] + def historyTypeChanged(self) -> None: ... + def defaultStateChanged(self) -> None: ... def event(self, e: QEvent) -> bool: ... def onExit(self, event: QEvent) -> None: ... def onEntry(self, event: QEvent) -> None: ... @@ -6223,15 +6226,16 @@ class QItemSelectionModel(QObject): def __init__(self, model: typing.Optional[QAbstractItemModel] = ...) -> None: ... @typing.overload def __init__(self, model: QAbstractItemModel, parent: QObject) -> None: ... - modelChanged: typing.ClassVar[QtCore.pyqtSignal] + + def modelChanged(self, model: QAbstractItemModel) -> None: ... def setModel(self, model: QAbstractItemModel) -> None: ... def selectedColumns(self, row: int = ...) -> typing.List[QModelIndex]: ... def selectedRows(self, column: int = ...) -> typing.List[QModelIndex]: ... def hasSelection(self) -> bool: ... def emitSelectionChanged(self, newSelection: 'QItemSelection', oldSelection: 'QItemSelection') -> None: ... - currentColumnChanged: typing.ClassVar[QtCore.pyqtSignal] - currentRowChanged: typing.ClassVar[QtCore.pyqtSignal] - currentChanged: typing.ClassVar[QtCore.pyqtSignal] + def currentColumnChanged(self, current: QModelIndex, previous: QModelIndex) -> None: ... + def currentRowChanged(self, current: QModelIndex, previous: QModelIndex) -> None: ... + def currentChanged(self, current: QModelIndex, previous: QModelIndex) -> None: ... selectionChanged: typing.ClassVar[pyqtSignal] def clearCurrentIndex(self) -> None: ... def setCurrentIndex(self, index: QModelIndex, command: typing.Union['QItemSelectionModel.SelectionFlags', 'QItemSelectionModel.SelectionFlag']) -> None: ... @@ -9298,7 +9302,7 @@ class QVariantAnimation(QAbstractAnimation): def updateState(self, newState: QAbstractAnimation.State, oldState: QAbstractAnimation.State) -> None: ... def updateCurrentTime(self, a0: int) -> None: ... def event(self, event: QEvent) -> bool: ... - valueChanged: typing.ClassVar[QtCore.pyqtSignal] + def valueChanged(self, value: typing.Any) -> None: ... def setEasingCurve(self, easing: typing.Union[QEasingCurve, QEasingCurve.Type]) -> None: ... def easingCurve(self) -> QEasingCurve: ... def setDuration(self, msecs: int) -> None: ... @@ -9536,7 +9540,10 @@ class QProcess(QIODevice): def waitForStarted(self, msecs: int = ...) -> bool: ... def pid(self) -> int: ... def state(self) -> 'QProcess.ProcessState': ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QProcess.ProcessError': ... + @typing.overload + def error(self, error: 'QProcess.ProcessError') -> None: ... def setWorkingDirectory(self, dir: str) -> None: ... def workingDirectory(self) -> str: ... def closeWriteChannel(self) -> None: ... @@ -10159,7 +10166,7 @@ class QSequentialAnimationGroup(QAnimationGroup): def updateState(self, newState: QAbstractAnimation.State, oldState: QAbstractAnimation.State) -> None: ... def updateCurrentTime(self, a0: int) -> None: ... def event(self, event: QEvent) -> bool: ... - currentAnimationChanged: typing.ClassVar[QtCore.pyqtSignal] + def currentAnimationChanged(self, current: QAbstractAnimation) -> None: ... def duration(self) -> int: ... def currentAnimation(self) -> QAbstractAnimation: ... def insertPause(self, index: int, msecs: int) -> QPauseAnimation: ... @@ -10307,10 +10314,10 @@ class QSignalMapper(QObject): def map(self) -> None: ... @typing.overload def map(self, sender: QObject) -> None: ... - mappedObject: typing.ClassVar[QtCore.pyqtSignal] - mappedWidget: typing.ClassVar[QtCore.pyqtSignal] - mappedString: typing.ClassVar[QtCore.pyqtSignal] - mappedInt: typing.ClassVar[QtCore.pyqtSignal] + def mappedObject(self, a0: QObject) -> None: ... + def mappedWidget(self, a0: QtWidgets.QWidget) -> None: ... + def mappedString(self, a0: str) -> None: ... + def mappedInt(self, a0: int) -> None: ... mapped: typing.ClassVar[pyqtSignal] @typing.overload def mapping(self, id: int) -> QObject: ... @@ -10337,8 +10344,9 @@ class QSignalTransition(QAbstractTransition): def __init__(self, sourceState: typing.Optional['QState'] = ...) -> None: ... @typing.overload def __init__(self, signal: pyqtBoundSignal, sourceState: typing.Optional['QState'] = ...) -> None: ... - signalChanged: typing.ClassVar[QtCore.pyqtSignal] - senderObjectChanged: typing.ClassVar[QtCore.pyqtSignal] + + def signalChanged(self) -> None: ... + def senderObjectChanged(self) -> None: ... def event(self, e: QEvent) -> bool: ... def onTransition(self, event: QEvent) -> None: ... def eventTest(self, event: QEvent) -> bool: ... @@ -10433,7 +10441,7 @@ class QSocketNotifier(QObject): def __init__(self, socket: sip.voidptr, a1: 'QSocketNotifier.Type', parent: typing.Optional[QObject] = ...) -> None: ... def event(self, a0: QEvent) -> bool: ... - activated: typing.ClassVar[QtCore.pyqtSignal] + def activated(self, socket: int) -> None: ... def setEnabled(self, a0: bool) -> None: ... def isEnabled(self) -> bool: ... def type(self) -> 'QSocketNotifier.Type': ... @@ -10443,13 +10451,14 @@ class QSocketNotifier(QObject): class QSortFilterProxyModel(QAbstractProxyModel): def __init__(self, parent: typing.Optional[QObject] = ...) -> None: ... - recursiveFilteringEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - filterRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - sortRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - sortLocaleAwareChanged: typing.ClassVar[QtCore.pyqtSignal] - sortCaseSensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] - filterCaseSensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] - dynamicSortFilterChanged: typing.ClassVar[QtCore.pyqtSignal] + + def recursiveFilteringEnabledChanged(self, recursiveFilteringEnabled: bool) -> None: ... + def filterRoleChanged(self, filterRole: int) -> None: ... + def sortRoleChanged(self, sortRole: int) -> None: ... + def sortLocaleAwareChanged(self, sortLocaleAware: bool) -> None: ... + def sortCaseSensitivityChanged(self, sortCaseSensitivity: Qt.CaseSensitivity) -> None: ... + def filterCaseSensitivityChanged(self, filterCaseSensitivity: Qt.CaseSensitivity) -> None: ... + def dynamicSortFilterChanged(self, dynamicSortFilter: bool) -> None: ... def invalidateFilter(self) -> None: ... def setRecursiveFilteringEnabled(self, recursive: bool) -> None: ... def isRecursiveFilteringEnabled(self) -> bool: ... @@ -10627,14 +10636,15 @@ class QState(QAbstractState): def __init__(self, parent: typing.Optional['QState'] = ...) -> None: ... @typing.overload def __init__(self, childMode: 'QState.ChildMode', parent: typing.Optional['QState'] = ...) -> None: ... - errorStateChanged: typing.ClassVar[QtCore.pyqtSignal] - initialStateChanged: typing.ClassVar[QtCore.pyqtSignal] - childModeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def errorStateChanged(self) -> None: ... + def initialStateChanged(self) -> None: ... + def childModeChanged(self) -> None: ... def event(self, e: QEvent) -> bool: ... def onExit(self, event: QEvent) -> None: ... def onEntry(self, event: QEvent) -> None: ... - propertiesAssigned: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + def propertiesAssigned(self) -> None: ... + def finished(self) -> None: ... def assignProperty(self, object: QObject, name: str, value: typing.Any) -> None: ... def setChildMode(self, mode: 'QState.ChildMode') -> None: ... def childMode(self) -> 'QState.ChildMode': ... @@ -10693,9 +10703,9 @@ class QStateMachine(QState): def event(self, e: QEvent) -> bool: ... def onExit(self, event: QEvent) -> None: ... def onEntry(self, event: QEvent) -> None: ... - runningChanged: typing.ClassVar[QtCore.pyqtSignal] - stopped: typing.ClassVar[QtCore.pyqtSignal] - started: typing.ClassVar[QtCore.pyqtSignal] + def runningChanged(self, running: bool) -> None: ... + def stopped(self) -> None: ... + def started(self) -> None: ... def setRunning(self, running: bool) -> None: ... def stop(self) -> None: ... def start(self) -> None: ... @@ -11263,10 +11273,10 @@ class QTimeLine(QObject): def setEasingCurve(self, curve: typing.Union[QEasingCurve, QEasingCurve.Type]) -> None: ... def easingCurve(self) -> QEasingCurve: ... def timerEvent(self, event: QTimerEvent) -> None: ... - valueChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - frameChanged: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + def valueChanged(self, x: float) -> None: ... + def stateChanged(self, newState: 'QTimeLine.State') -> None: ... + def frameChanged(self, a0: int) -> None: ... + def finished(self) -> None: ... def toggleDirection(self) -> None: ... def stop(self) -> None: ... def start(self) -> None: ... diff --git a/PyQt5-stubs/QtDBus.pyi b/PyQt5-stubs/QtDBus.pyi index c84f0755..ac26141b 100644 --- a/PyQt5-stubs/QtDBus.pyi +++ b/PyQt5-stubs/QtDBus.pyi @@ -282,10 +282,10 @@ class QDBusConnectionInterface(QDBusAbstractInterface): def disconnectNotify(self, a0: QtCore.QMetaMethod) -> None: ... def connectNotify(self, a0: QtCore.QMetaMethod) -> None: ... - callWithCallbackFailed: typing.ClassVar[QtCore.pyqtSignal] - serviceOwnerChanged: typing.ClassVar[QtCore.pyqtSignal] - serviceUnregistered: typing.ClassVar[QtCore.pyqtSignal] - serviceRegistered: typing.ClassVar[QtCore.pyqtSignal] + def callWithCallbackFailed(self, error: 'QDBusError', call: 'QDBusMessage') -> None: ... + def serviceOwnerChanged(self, name: str, oldOwner: str, newOwner: str) -> None: ... + def serviceUnregistered(self, service: str) -> None: ... + def serviceRegistered(self, service: str) -> None: ... def startService(self, name: str) -> QDBusReply: ... def serviceUid(self, serviceName: str) -> QDBusReply: ... def servicePid(self, serviceName: str) -> QDBusReply: ... @@ -497,7 +497,8 @@ class QDBusPendingCall(sip.simplewrapper): class QDBusPendingCallWatcher(QtCore.QObject, QDBusPendingCall): def __init__(self, call: QDBusPendingCall, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - finished: typing.ClassVar[QtCore.pyqtSignal] + + def finished(self, watcher: typing.Optional['QDBusPendingCallWatcher'] = ...) -> None: ... def waitForFinished(self) -> None: ... def isFinished(self) -> bool: ... @@ -532,9 +533,10 @@ class QDBusServiceWatcher(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, service: str, connection: QDBusConnection, watchMode: typing.Union['QDBusServiceWatcher.WatchMode', 'QDBusServiceWatcher.WatchModeFlag'] = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - serviceOwnerChanged: typing.ClassVar[QtCore.pyqtSignal] - serviceUnregistered: typing.ClassVar[QtCore.pyqtSignal] - serviceRegistered: typing.ClassVar[QtCore.pyqtSignal] + + def serviceOwnerChanged(self, service: str, oldOwner: str, newOwner: str) -> None: ... + def serviceUnregistered(self, service: str) -> None: ... + def serviceRegistered(self, service: str) -> None: ... def setConnection(self, connection: QDBusConnection) -> None: ... def connection(self) -> QDBusConnection: ... def setWatchMode(self, mode: typing.Union['QDBusServiceWatcher.WatchMode', 'QDBusServiceWatcher.WatchModeFlag']) -> None: ... diff --git a/PyQt5-stubs/QtDataVisualization.pyi b/PyQt5-stubs/QtDataVisualization.pyi index fcf79057..b4c86933 100644 --- a/PyQt5-stubs/QtDataVisualization.pyi +++ b/PyQt5-stubs/QtDataVisualization.pyi @@ -134,14 +134,14 @@ class QAbstract3DGraph(QtGui.QWindow): def __int__(self) -> int: ... def hasContext(self) -> bool: ... - marginChanged: typing.ClassVar[QtCore.pyqtSignal] - queriedGraphPositionChanged: typing.ClassVar[QtCore.pyqtSignal] - localeChanged: typing.ClassVar[QtCore.pyqtSignal] - reflectivityChanged: typing.ClassVar[QtCore.pyqtSignal] - reflectionChanged: typing.ClassVar[QtCore.pyqtSignal] - horizontalAspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] - radialLabelOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] - polarChanged: typing.ClassVar[QtCore.pyqtSignal] + def marginChanged(self, margin: float) -> None: ... + def queriedGraphPositionChanged(self, data: QtGui.QVector3D) -> None: ... + def localeChanged(self, locale: QtCore.QLocale) -> None: ... + def reflectivityChanged(self, reflectivity: float) -> None: ... + def reflectionChanged(self, enabled: bool) -> None: ... + def horizontalAspectRatioChanged(self, ratio: float) -> None: ... + def radialLabelOffsetChanged(self, offset: float) -> None: ... + def polarChanged(self, enabled: bool) -> None: ... def margin(self) -> float: ... def setMargin(self, margin: float) -> None: ... def queriedGraphPosition(self) -> QtGui.QVector3D: ... @@ -158,12 +158,12 @@ class QAbstract3DGraph(QtGui.QWindow): def isPolar(self) -> bool: ... def setPolar(self, enable: bool) -> None: ... def customItems(self) -> typing.List['QCustom3DItem']: ... - optimizationHintsChanged: typing.ClassVar[QtCore.pyqtSignal] - aspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] - orthoProjectionChanged: typing.ClassVar[QtCore.pyqtSignal] - currentFpsChanged: typing.ClassVar[QtCore.pyqtSignal] - measureFpsChanged: typing.ClassVar[QtCore.pyqtSignal] - selectedElementChanged: typing.ClassVar[QtCore.pyqtSignal] + def optimizationHintsChanged(self, hints: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... + def aspectRatioChanged(self, ratio: float) -> None: ... + def orthoProjectionChanged(self, enabled: bool) -> None: ... + def currentFpsChanged(self, fps: float) -> None: ... + def measureFpsChanged(self, enabled: bool) -> None: ... + def selectedElementChanged(self, type: 'QAbstract3DGraph.ElementType') -> None: ... def optimizationHints(self) -> 'QAbstract3DGraph.OptimizationHints': ... def setOptimizationHints(self, hints: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... def aspectRatio(self) -> float: ... @@ -193,10 +193,10 @@ class QAbstract3DGraph(QtGui.QWindow): def exposeEvent(self, event: QtGui.QExposeEvent) -> None: ... def resizeEvent(self, event: QtGui.QResizeEvent) -> None: ... def event(self, event: QtCore.QEvent) -> bool: ... - shadowQualityChanged: typing.ClassVar[QtCore.pyqtSignal] - selectionModeChanged: typing.ClassVar[QtCore.pyqtSignal] - activeThemeChanged: typing.ClassVar[QtCore.pyqtSignal] - activeInputHandlerChanged: typing.ClassVar[QtCore.pyqtSignal] + def shadowQualityChanged(self, quality: 'QAbstract3DGraph.ShadowQuality') -> None: ... + def selectionModeChanged(self, mode: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag']) -> None: ... + def activeThemeChanged(self, theme: 'Q3DTheme') -> None: ... + def activeInputHandlerChanged(self, inputHandler: 'QAbstract3DInputHandler') -> None: ... def shadowsSupported(self) -> bool: ... def activeInputHandler(self) -> 'QAbstract3DInputHandler': ... def clearSelection(self) -> None: ... @@ -218,18 +218,19 @@ class QAbstract3DGraph(QtGui.QWindow): class Q3DBars('QAbstract3DGraph'): def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - floorLevelChanged: typing.ClassVar[QtCore.pyqtSignal] + + def floorLevelChanged(self, level: float) -> None: ... def floorLevel(self) -> float: ... def setFloorLevel(self, level: float) -> None: ... - selectedSeriesChanged: typing.ClassVar[QtCore.pyqtSignal] - primarySeriesChanged: typing.ClassVar[QtCore.pyqtSignal] - valueAxisChanged: typing.ClassVar[QtCore.pyqtSignal] - columnAxisChanged: typing.ClassVar[QtCore.pyqtSignal] - rowAxisChanged: typing.ClassVar[QtCore.pyqtSignal] - barSpacingRelativeChanged: typing.ClassVar[QtCore.pyqtSignal] - barSpacingChanged: typing.ClassVar[QtCore.pyqtSignal] - barThicknessChanged: typing.ClassVar[QtCore.pyqtSignal] - multiSeriesUniformChanged: typing.ClassVar[QtCore.pyqtSignal] + def selectedSeriesChanged(self, series: 'QBar3DSeries') -> None: ... + def primarySeriesChanged(self, series: 'QBar3DSeries') -> None: ... + def valueAxisChanged(self, axis: 'QValue3DAxis') -> None: ... + def columnAxisChanged(self, axis: 'QCategory3DAxis') -> None: ... + def rowAxisChanged(self, axis: 'QCategory3DAxis') -> None: ... + def barSpacingRelativeChanged(self, relative: bool) -> None: ... + def barSpacingChanged(self, spacing: QtCore.QSizeF) -> None: ... + def barThicknessChanged(self, thicknessRatio: float) -> None: ... + def multiSeriesUniformChanged(self, uniform: bool) -> None: ... def selectedSeries(self) -> 'QBar3DSeries': ... def axes(self) -> typing.List['QAbstract3DAxis']: ... def releaseAxis(self, axis: 'QAbstract3DAxis') -> None: ... @@ -261,7 +262,7 @@ class Q3DObject(QtCore.QObject): def isDirty(self) -> bool: ... def setDirty(self, dirty: bool) -> None: ... - positionChanged: typing.ClassVar[QtCore.pyqtSignal] + def positionChanged(self, position: QtGui.QVector3D) -> None: ... def setPosition(self, position: QtGui.QVector3D) -> None: ... def position(self) -> QtGui.QVector3D: ... def parentScene(self) -> 'Q3DScene': ... @@ -323,21 +324,22 @@ class Q3DCamera('Q3DObject'): CameraPresetDirectlyBelow = ... # type: Q3DCamera.CameraPreset def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - targetChanged: typing.ClassVar[QtCore.pyqtSignal] - maxZoomLevelChanged: typing.ClassVar[QtCore.pyqtSignal] - minZoomLevelChanged: typing.ClassVar[QtCore.pyqtSignal] + + def targetChanged(self, target: QtGui.QVector3D) -> None: ... + def maxZoomLevelChanged(self, zoomLevel: float) -> None: ... + def minZoomLevelChanged(self, zoomLevel: float) -> None: ... def setTarget(self, target: QtGui.QVector3D) -> None: ... def target(self) -> QtGui.QVector3D: ... def setMaxZoomLevel(self, zoomLevel: float) -> None: ... def maxZoomLevel(self) -> float: ... def setMinZoomLevel(self, zoomLevel: float) -> None: ... def minZoomLevel(self) -> float: ... - wrapYRotationChanged: typing.ClassVar[QtCore.pyqtSignal] - wrapXRotationChanged: typing.ClassVar[QtCore.pyqtSignal] - cameraPresetChanged: typing.ClassVar[QtCore.pyqtSignal] - zoomLevelChanged: typing.ClassVar[QtCore.pyqtSignal] - yRotationChanged: typing.ClassVar[QtCore.pyqtSignal] - xRotationChanged: typing.ClassVar[QtCore.pyqtSignal] + def wrapYRotationChanged(self, isEnabled: bool) -> None: ... + def wrapXRotationChanged(self, isEnabled: bool) -> None: ... + def cameraPresetChanged(self, preset: 'Q3DCamera.CameraPreset') -> None: ... + def zoomLevelChanged(self, zoomLevel: float) -> None: ... + def yRotationChanged(self, rotation: float) -> None: ... + def xRotationChanged(self, rotation: float) -> None: ... def setZoomLevel(self, zoomLevel: float) -> None: ... def zoomLevel(self) -> float: ... def setCameraPosition(self, horizontal: float, vertical: float, zoom: float = ...) -> None: ... @@ -370,9 +372,9 @@ class QAbstract3DInputHandler(QtCore.QObject): def setPreviousInputPos(self, position: QtCore.QPoint) -> None: ... def prevDistance(self) -> int: ... def setPrevDistance(self, distance: int) -> None: ... - sceneChanged: typing.ClassVar[QtCore.pyqtSignal] - inputViewChanged: typing.ClassVar[QtCore.pyqtSignal] - positionChanged: typing.ClassVar[QtCore.pyqtSignal] + def sceneChanged(self, scene: 'Q3DScene') -> None: ... + def inputViewChanged(self, view: 'QAbstract3DInputHandler.InputView') -> None: ... + def positionChanged(self, position: QtCore.QPoint) -> None: ... def setScene(self, scene: 'Q3DScene') -> None: ... def scene(self) -> 'Q3DScene': ... def setInputPosition(self, position: QtCore.QPoint) -> None: ... @@ -389,10 +391,11 @@ class QAbstract3DInputHandler(QtCore.QObject): class Q3DInputHandler('QAbstract3DInputHandler'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - zoomAtTargetEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - selectionEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - zoomEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + + def zoomAtTargetEnabledChanged(self, enable: bool) -> None: ... + def selectionEnabledChanged(self, enable: bool) -> None: ... + def zoomEnabledChanged(self, enable: bool) -> None: ... + def rotationEnabledChanged(self, enable: bool) -> None: ... def isZoomAtTargetEnabled(self) -> bool: ... def setZoomAtTargetEnabled(self, enable: bool) -> None: ... def isSelectionEnabled(self) -> bool: ... @@ -409,17 +412,19 @@ class Q3DInputHandler('QAbstract3DInputHandler'): class Q3DLight('Q3DObject'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - autoPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def autoPositionChanged(self, autoPosition: bool) -> None: ... def isAutoPosition(self) -> bool: ... def setAutoPosition(self, enabled: bool) -> None: ... class Q3DScatter('QAbstract3DGraph'): def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - selectedSeriesChanged: typing.ClassVar[QtCore.pyqtSignal] - axisZChanged: typing.ClassVar[QtCore.pyqtSignal] - axisYChanged: typing.ClassVar[QtCore.pyqtSignal] - axisXChanged: typing.ClassVar[QtCore.pyqtSignal] + + def selectedSeriesChanged(self, series: 'QScatter3DSeries') -> None: ... + def axisZChanged(self, axis: 'QValue3DAxis') -> None: ... + def axisYChanged(self, axis: 'QValue3DAxis') -> None: ... + def axisXChanged(self, axis: 'QValue3DAxis') -> None: ... def selectedSeries(self) -> 'QScatter3DSeries': ... def axes(self) -> typing.List['QValue3DAxis']: ... def releaseAxis(self, axis: 'QValue3DAxis') -> None: ... @@ -437,18 +442,19 @@ class Q3DScatter('QAbstract3DGraph'): class Q3DScene(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - graphPositionQueryChanged: typing.ClassVar[QtCore.pyqtSignal] + + def graphPositionQueryChanged(self, position: QtCore.QPoint) -> None: ... def graphPositionQuery(self) -> QtCore.QPoint: ... def setGraphPositionQuery(self, point: QtCore.QPoint) -> None: ... - selectionQueryPositionChanged: typing.ClassVar[QtCore.pyqtSignal] - devicePixelRatioChanged: typing.ClassVar[QtCore.pyqtSignal] - activeLightChanged: typing.ClassVar[QtCore.pyqtSignal] - activeCameraChanged: typing.ClassVar[QtCore.pyqtSignal] - slicingActiveChanged: typing.ClassVar[QtCore.pyqtSignal] - secondarySubviewOnTopChanged: typing.ClassVar[QtCore.pyqtSignal] - secondarySubViewportChanged: typing.ClassVar[QtCore.pyqtSignal] - primarySubViewportChanged: typing.ClassVar[QtCore.pyqtSignal] - viewportChanged: typing.ClassVar[QtCore.pyqtSignal] + def selectionQueryPositionChanged(self, position: QtCore.QPoint) -> None: ... + def devicePixelRatioChanged(self, pixelRatio: float) -> None: ... + def activeLightChanged(self, light: 'Q3DLight') -> None: ... + def activeCameraChanged(self, camera: 'Q3DCamera') -> None: ... + def slicingActiveChanged(self, isSlicingActive: bool) -> None: ... + def secondarySubviewOnTopChanged(self, isSecondaryOnTop: bool) -> None: ... + def secondarySubViewportChanged(self, subViewport: QtCore.QRect) -> None: ... + def primarySubViewportChanged(self, subViewport: QtCore.QRect) -> None: ... + def viewportChanged(self, viewport: QtCore.QRect) -> None: ... def setDevicePixelRatio(self, pixelRatio: float) -> None: ... def devicePixelRatio(self) -> float: ... def setActiveLight(self, light: 'Q3DLight') -> None: ... @@ -474,13 +480,14 @@ class Q3DScene(QtCore.QObject): class Q3DSurface('QAbstract3DGraph'): def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - flipHorizontalGridChanged: typing.ClassVar[QtCore.pyqtSignal] + + def flipHorizontalGridChanged(self, flip: bool) -> None: ... def flipHorizontalGrid(self) -> bool: ... def setFlipHorizontalGrid(self, flip: bool) -> None: ... - selectedSeriesChanged: typing.ClassVar[QtCore.pyqtSignal] - axisZChanged: typing.ClassVar[QtCore.pyqtSignal] - axisYChanged: typing.ClassVar[QtCore.pyqtSignal] - axisXChanged: typing.ClassVar[QtCore.pyqtSignal] + def selectedSeriesChanged(self, series: 'QSurface3DSeries') -> None: ... + def axisZChanged(self, axis: 'QValue3DAxis') -> None: ... + def axisYChanged(self, axis: 'QValue3DAxis') -> None: ... + def axisXChanged(self, axis: 'QValue3DAxis') -> None: ... def selectedSeries(self) -> 'QSurface3DSeries': ... def axes(self) -> typing.List['QValue3DAxis']: ... def releaseAxis(self, axis: 'QValue3DAxis') -> None: ... @@ -531,28 +538,29 @@ class Q3DTheme(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, themeType: 'Q3DTheme.Theme', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - colorStyleChanged: typing.ClassVar[QtCore.pyqtSignal] - labelBackgroundEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - gridEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - backgroundEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - fontChanged: typing.ClassVar[QtCore.pyqtSignal] - labelBorderEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - highlightLightStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] - ambientLightStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] - lightStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] - multiHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] - singleHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] - baseGradientsChanged: typing.ClassVar[QtCore.pyqtSignal] - lightColorChanged: typing.ClassVar[QtCore.pyqtSignal] - multiHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] - singleHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] - gridLineColorChanged: typing.ClassVar[QtCore.pyqtSignal] - labelBackgroundColorChanged: typing.ClassVar[QtCore.pyqtSignal] - labelTextColorChanged: typing.ClassVar[QtCore.pyqtSignal] - windowColorChanged: typing.ClassVar[QtCore.pyqtSignal] - backgroundColorChanged: typing.ClassVar[QtCore.pyqtSignal] - baseColorsChanged: typing.ClassVar[QtCore.pyqtSignal] - typeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def colorStyleChanged(self, style: 'Q3DTheme.ColorStyle') -> None: ... + def labelBackgroundEnabledChanged(self, enabled: bool) -> None: ... + def gridEnabledChanged(self, enabled: bool) -> None: ... + def backgroundEnabledChanged(self, enabled: bool) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... + def labelBorderEnabledChanged(self, enabled: bool) -> None: ... + def highlightLightStrengthChanged(self, strength: float) -> None: ... + def ambientLightStrengthChanged(self, strength: float) -> None: ... + def lightStrengthChanged(self, strength: float) -> None: ... + def multiHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... + def singleHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... + def baseGradientsChanged(self, gradients: typing.Iterable[QtGui.QLinearGradient]) -> None: ... + def lightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def multiHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def singleHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def gridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def labelBackgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def labelTextColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def windowColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def backgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def baseColorsChanged(self, colors: typing.Iterable[typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]]) -> None: ... + def typeChanged(self, themeType: 'Q3DTheme.Theme') -> None: ... def colorStyle(self) -> 'Q3DTheme.ColorStyle': ... def setColorStyle(self, style: 'Q3DTheme.ColorStyle') -> None: ... def isLabelBackgroundEnabled(self) -> bool: ... @@ -619,22 +627,23 @@ class QAbstract3DAxis(QtCore.QObject): AxisOrientationX = ... # type: QAbstract3DAxis.AxisOrientation AxisOrientationY = ... # type: QAbstract3DAxis.AxisOrientation AxisOrientationZ = ... # type: QAbstract3DAxis.AxisOrientation - titleFixedChanged: typing.ClassVar[QtCore.pyqtSignal] - titleVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] - labelAutoRotationChanged: typing.ClassVar[QtCore.pyqtSignal] + + def titleFixedChanged(self, fixed: bool) -> None: ... + def titleVisibilityChanged(self, visible: bool) -> None: ... + def labelAutoRotationChanged(self, angle: float) -> None: ... def isTitleFixed(self) -> bool: ... def setTitleFixed(self, fixed: bool) -> None: ... def isTitleVisible(self) -> bool: ... def setTitleVisible(self, visible: bool) -> None: ... def labelAutoRotation(self) -> float: ... def setLabelAutoRotation(self, angle: float) -> None: ... - autoAdjustRangeChanged: typing.ClassVar[QtCore.pyqtSignal] - rangeChanged: typing.ClassVar[QtCore.pyqtSignal] - maxChanged: typing.ClassVar[QtCore.pyqtSignal] - minChanged: typing.ClassVar[QtCore.pyqtSignal] - orientationChanged: typing.ClassVar[QtCore.pyqtSignal] - labelsChanged: typing.ClassVar[QtCore.pyqtSignal] - titleChanged: typing.ClassVar[QtCore.pyqtSignal] + def autoAdjustRangeChanged(self, autoAdjust: bool) -> None: ... + def rangeChanged(self, min: float, max: float) -> None: ... + def maxChanged(self, value: float) -> None: ... + def minChanged(self, value: float) -> None: ... + def orientationChanged(self, orientation: 'QAbstract3DAxis.AxisOrientation') -> None: ... + def labelsChanged(self) -> None: ... + def titleChanged(self, newTitle: str) -> None: ... def setTitle(self, title: str) -> None: ... def setRange(self, min: float, max: float) -> None: ... def isAutoAdjustRange(self) -> bool: ... @@ -688,25 +697,26 @@ class QAbstract3DSeries(QtCore.QObject): SeriesTypeBar = ... # type: QAbstract3DSeries.SeriesType SeriesTypeScatter = ... # type: QAbstract3DSeries.SeriesType SeriesTypeSurface = ... # type: QAbstract3DSeries.SeriesType - itemLabelVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] - itemLabelChanged: typing.ClassVar[QtCore.pyqtSignal] + + def itemLabelVisibilityChanged(self, visible: bool) -> None: ... + def itemLabelChanged(self, label: str) -> None: ... def isItemLabelVisible(self) -> bool: ... def setItemLabelVisible(self, visible: bool) -> None: ... def itemLabel(self) -> str: ... - nameChanged: typing.ClassVar[QtCore.pyqtSignal] - multiHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] - multiHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] - singleHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] - singleHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] - baseGradientChanged: typing.ClassVar[QtCore.pyqtSignal] - baseColorChanged: typing.ClassVar[QtCore.pyqtSignal] - colorStyleChanged: typing.ClassVar[QtCore.pyqtSignal] - userDefinedMeshChanged: typing.ClassVar[QtCore.pyqtSignal] - meshRotationChanged: typing.ClassVar[QtCore.pyqtSignal] - meshSmoothChanged: typing.ClassVar[QtCore.pyqtSignal] - meshChanged: typing.ClassVar[QtCore.pyqtSignal] - visibilityChanged: typing.ClassVar[QtCore.pyqtSignal] - itemLabelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + def nameChanged(self, name: str) -> None: ... + def multiHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... + def multiHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def singleHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... + def singleHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def baseGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... + def baseColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def colorStyleChanged(self, style: 'Q3DTheme.ColorStyle') -> None: ... + def userDefinedMeshChanged(self, fileName: str) -> None: ... + def meshRotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... + def meshSmoothChanged(self, enabled: bool) -> None: ... + def meshChanged(self, mesh: 'QAbstract3DSeries.Mesh') -> None: ... + def visibilityChanged(self, visible: bool) -> None: ... + def itemLabelFormatChanged(self, format: str) -> None: ... def setMeshAxisAndAngle(self, axis: QtGui.QVector3D, angle: float) -> None: ... def name(self) -> str: ... def setName(self, name: str) -> None: ... @@ -759,9 +769,10 @@ class QBar3DSeries('QAbstract3DSeries'): def __init__(self, dataProxy: 'QBarDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - meshAngleChanged: typing.ClassVar[QtCore.pyqtSignal] - selectedBarChanged: typing.ClassVar[QtCore.pyqtSignal] - dataProxyChanged: typing.ClassVar[QtCore.pyqtSignal] + + def meshAngleChanged(self, angle: float) -> None: ... + def selectedBarChanged(self, position: QtCore.QPoint) -> None: ... + def dataProxyChanged(self, proxy: 'QBarDataProxy') -> None: ... def meshAngle(self) -> float: ... def setMeshAngle(self, angle: float) -> None: ... @staticmethod @@ -790,16 +801,17 @@ class QBarDataItem(sip.simplewrapper): class QBarDataProxy('QAbstractDataProxy'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - seriesChanged: typing.ClassVar[QtCore.pyqtSignal] - columnLabelsChanged: typing.ClassVar[QtCore.pyqtSignal] - rowLabelsChanged: typing.ClassVar[QtCore.pyqtSignal] - rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] - itemChanged: typing.ClassVar[QtCore.pyqtSignal] - rowsInserted: typing.ClassVar[QtCore.pyqtSignal] - rowsRemoved: typing.ClassVar[QtCore.pyqtSignal] - rowsChanged: typing.ClassVar[QtCore.pyqtSignal] - rowsAdded: typing.ClassVar[QtCore.pyqtSignal] - arrayReset: typing.ClassVar[QtCore.pyqtSignal] + + def seriesChanged(self, series: 'QBar3DSeries') -> None: ... + def columnLabelsChanged(self) -> None: ... + def rowLabelsChanged(self) -> None: ... + def rowCountChanged(self, count: int) -> None: ... + def itemChanged(self, rowIndex: int, columnIndex: int) -> None: ... + def rowsInserted(self, startIndex: int, count: int) -> None: ... + def rowsRemoved(self, startIndex: int, count: int) -> None: ... + def rowsChanged(self, startIndex: int, count: int) -> None: ... + def rowsAdded(self, startIndex: int, count: int) -> None: ... + def arrayReset(self) -> None: ... def series(self) -> 'QBar3DSeries': ... def removeRows(self, rowIndex: int, removeCount: int, removeLabels: bool = ...) -> None: ... @typing.overload @@ -851,7 +863,8 @@ class QBarDataProxy('QAbstractDataProxy'): class QCategory3DAxis('QAbstract3DAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - labelsChanged: typing.ClassVar[QtCore.pyqtSignal] + + def labelsChanged(self) -> None: ... def labels(self) -> typing.List[str]: ... def setLabels(self, labels: typing.Iterable[str]) -> None: ... @@ -861,17 +874,18 @@ class QCustom3DItem(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, meshFile: str, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, texture: QtGui.QImage, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - scalingAbsoluteChanged: typing.ClassVar[QtCore.pyqtSignal] + + def scalingAbsoluteChanged(self, scalingAbsolute: bool) -> None: ... def isScalingAbsolute(self) -> bool: ... def setScalingAbsolute(self, scalingAbsolute: bool) -> None: ... - shadowCastingChanged: typing.ClassVar[QtCore.pyqtSignal] - visibleChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationChanged: typing.ClassVar[QtCore.pyqtSignal] - scalingChanged: typing.ClassVar[QtCore.pyqtSignal] - positionAbsoluteChanged: typing.ClassVar[QtCore.pyqtSignal] - positionChanged: typing.ClassVar[QtCore.pyqtSignal] - textureFileChanged: typing.ClassVar[QtCore.pyqtSignal] - meshFileChanged: typing.ClassVar[QtCore.pyqtSignal] + def shadowCastingChanged(self, shadowCasting: bool) -> None: ... + def visibleChanged(self, visible: bool) -> None: ... + def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... + def scalingChanged(self, scaling: QtGui.QVector3D) -> None: ... + def positionAbsoluteChanged(self, positionAbsolute: bool) -> None: ... + def positionChanged(self, position: QtGui.QVector3D) -> None: ... + def textureFileChanged(self, textureFile: str) -> None: ... + def meshFileChanged(self, meshFile: str) -> None: ... def setTextureImage(self, textureImage: QtGui.QImage) -> None: ... def setRotationAxisAndAngle(self, axis: QtGui.QVector3D, angle: float) -> None: ... def isShadowCasting(self) -> bool: ... @@ -897,13 +911,14 @@ class QCustom3DLabel('QCustom3DItem'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, text: str, font: QtGui.QFont, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - facingCameraChanged: typing.ClassVar[QtCore.pyqtSignal] - backgroundEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - borderEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - backgroundColorChanged: typing.ClassVar[QtCore.pyqtSignal] - textColorChanged: typing.ClassVar[QtCore.pyqtSignal] - fontChanged: typing.ClassVar[QtCore.pyqtSignal] - textChanged: typing.ClassVar[QtCore.pyqtSignal] + + def facingCameraChanged(self, enabled: bool) -> None: ... + def backgroundEnabledChanged(self, enabled: bool) -> None: ... + def borderEnabledChanged(self, enabled: bool) -> None: ... + def backgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def textColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... + def textChanged(self, text: str) -> None: ... def isFacingCamera(self) -> bool: ... def setFacingCamera(self, enabled: bool) -> None: ... def isBackgroundEnabled(self) -> bool: ... @@ -925,24 +940,25 @@ class QCustom3DVolume('QCustom3DItem'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, textureWidth: int, textureHeight: int, textureDepth: int, textureData: sip.array[int], textureFormat: QtGui.QImage.Format, colorTable: typing.Iterable[int], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - sliceFrameThicknessesChanged: typing.ClassVar[QtCore.pyqtSignal] - sliceFrameGapsChanged: typing.ClassVar[QtCore.pyqtSignal] - sliceFrameWidthsChanged: typing.ClassVar[QtCore.pyqtSignal] - sliceFrameColorChanged: typing.ClassVar[QtCore.pyqtSignal] - drawSliceFramesChanged: typing.ClassVar[QtCore.pyqtSignal] - drawSlicesChanged: typing.ClassVar[QtCore.pyqtSignal] - useHighDefShaderChanged: typing.ClassVar[QtCore.pyqtSignal] - preserveOpacityChanged: typing.ClassVar[QtCore.pyqtSignal] - alphaMultiplierChanged: typing.ClassVar[QtCore.pyqtSignal] - textureFormatChanged: typing.ClassVar[QtCore.pyqtSignal] - textureDataChanged: typing.ClassVar[QtCore.pyqtSignal] - colorTableChanged: typing.ClassVar[QtCore.pyqtSignal] - sliceIndexZChanged: typing.ClassVar[QtCore.pyqtSignal] - sliceIndexYChanged: typing.ClassVar[QtCore.pyqtSignal] - sliceIndexXChanged: typing.ClassVar[QtCore.pyqtSignal] - textureDepthChanged: typing.ClassVar[QtCore.pyqtSignal] - textureHeightChanged: typing.ClassVar[QtCore.pyqtSignal] - textureWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + + def sliceFrameThicknessesChanged(self, values: QtGui.QVector3D) -> None: ... + def sliceFrameGapsChanged(self, values: QtGui.QVector3D) -> None: ... + def sliceFrameWidthsChanged(self, values: QtGui.QVector3D) -> None: ... + def sliceFrameColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def drawSliceFramesChanged(self, enabled: bool) -> None: ... + def drawSlicesChanged(self, enabled: bool) -> None: ... + def useHighDefShaderChanged(self, enabled: bool) -> None: ... + def preserveOpacityChanged(self, enabled: bool) -> None: ... + def alphaMultiplierChanged(self, mult: float) -> None: ... + def textureFormatChanged(self, format: QtGui.QImage.Format) -> None: ... + def textureDataChanged(self, data: sip.array[int]) -> None: ... + def colorTableChanged(self) -> None: ... + def sliceIndexZChanged(self, value: int) -> None: ... + def sliceIndexYChanged(self, value: int) -> None: ... + def sliceIndexXChanged(self, value: int) -> None: ... + def textureDepthChanged(self, value: int) -> None: ... + def textureHeightChanged(self, value: int) -> None: ... + def textureWidthChanged(self, value: int) -> None: ... def renderSlice(self, axis: QtCore.Qt.Axis, index: int) -> QtGui.QImage: ... def sliceFrameThicknesses(self) -> QtGui.QVector3D: ... def setSliceFrameThicknesses(self, values: QtGui.QVector3D) -> None: ... @@ -992,15 +1008,16 @@ class QCustom3DVolume('QCustom3DItem'): class QSurfaceDataProxy('QAbstractDataProxy'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - seriesChanged: typing.ClassVar[QtCore.pyqtSignal] - columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] - rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] - itemChanged: typing.ClassVar[QtCore.pyqtSignal] - rowsInserted: typing.ClassVar[QtCore.pyqtSignal] - rowsRemoved: typing.ClassVar[QtCore.pyqtSignal] - rowsChanged: typing.ClassVar[QtCore.pyqtSignal] - rowsAdded: typing.ClassVar[QtCore.pyqtSignal] - arrayReset: typing.ClassVar[QtCore.pyqtSignal] + + def seriesChanged(self, series: 'QSurface3DSeries') -> None: ... + def columnCountChanged(self, count: int) -> None: ... + def rowCountChanged(self, count: int) -> None: ... + def itemChanged(self, rowIndex: int, columnIndex: int) -> None: ... + def rowsInserted(self, startIndex: int, count: int) -> None: ... + def rowsRemoved(self, startIndex: int, count: int) -> None: ... + def rowsChanged(self, startIndex: int, count: int) -> None: ... + def rowsAdded(self, startIndex: int, count: int) -> None: ... + def arrayReset(self) -> None: ... @typing.overload def itemAt(self, rowIndex: int, columnIndex: int) -> 'QSurfaceDataItem': ... @typing.overload @@ -1030,12 +1047,13 @@ class QHeightMapSurfaceDataProxy('QSurfaceDataProxy'): def __init__(self, image: QtGui.QImage, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, filename: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - maxZValueChanged: typing.ClassVar[QtCore.pyqtSignal] - minZValueChanged: typing.ClassVar[QtCore.pyqtSignal] - maxXValueChanged: typing.ClassVar[QtCore.pyqtSignal] - minXValueChanged: typing.ClassVar[QtCore.pyqtSignal] - heightMapFileChanged: typing.ClassVar[QtCore.pyqtSignal] - heightMapChanged: typing.ClassVar[QtCore.pyqtSignal] + + def maxZValueChanged(self, value: float) -> None: ... + def minZValueChanged(self, value: float) -> None: ... + def maxXValueChanged(self, value: float) -> None: ... + def minXValueChanged(self, value: float) -> None: ... + def heightMapFileChanged(self, filename: str) -> None: ... + def heightMapChanged(self, image: QtGui.QImage) -> None: ... def maxZValue(self) -> float: ... def setMaxZValue(self, max: float) -> None: ... def minZValue(self) -> float: ... @@ -1077,15 +1095,16 @@ class QItemModelBarDataProxy('QBarDataProxy'): def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, valueRole: str, rotationRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - multiMatchBehaviorChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - valueRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - columnRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - rowRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] - valueRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] - columnRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] - rowRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + + def multiMatchBehaviorChanged(self, behavior: 'QItemModelBarDataProxy.MultiMatchBehavior') -> None: ... + def rotationRoleReplaceChanged(self, replace: str) -> None: ... + def valueRoleReplaceChanged(self, replace: str) -> None: ... + def columnRoleReplaceChanged(self, replace: str) -> None: ... + def rowRoleReplaceChanged(self, replace: str) -> None: ... + def rotationRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def valueRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def columnRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def rowRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... def multiMatchBehavior(self) -> 'QItemModelBarDataProxy.MultiMatchBehavior': ... def setMultiMatchBehavior(self, behavior: 'QItemModelBarDataProxy.MultiMatchBehavior') -> None: ... def rotationRoleReplace(self) -> str: ... @@ -1104,16 +1123,16 @@ class QItemModelBarDataProxy('QBarDataProxy'): def setColumnRolePattern(self, pattern: QtCore.QRegExp) -> None: ... def rowRolePattern(self) -> QtCore.QRegExp: ... def setRowRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - autoColumnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] - autoRowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] - useModelCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] - columnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] - rowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - valueRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - columnRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - rowRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - itemModelChanged: typing.ClassVar[QtCore.pyqtSignal] + def autoColumnCategoriesChanged(self, enable: bool) -> None: ... + def autoRowCategoriesChanged(self, enable: bool) -> None: ... + def useModelCategoriesChanged(self, enable: bool) -> None: ... + def columnCategoriesChanged(self) -> None: ... + def rowCategoriesChanged(self) -> None: ... + def rotationRoleChanged(self, role: str) -> None: ... + def valueRoleChanged(self, role: str) -> None: ... + def columnRoleChanged(self, role: str) -> None: ... + def rowRoleChanged(self, role: str) -> None: ... + def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... def remap(self, rowRole: str, columnRole: str, valueRole: str, rotationRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str]) -> None: ... def rotationRole(self) -> str: ... def setRotationRole(self, role: str) -> None: ... @@ -1141,13 +1160,14 @@ class QItemModelBarDataProxy('QBarDataProxy'): class QScatterDataProxy('QAbstractDataProxy'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - seriesChanged: typing.ClassVar[QtCore.pyqtSignal] - itemCountChanged: typing.ClassVar[QtCore.pyqtSignal] - itemsInserted: typing.ClassVar[QtCore.pyqtSignal] - itemsRemoved: typing.ClassVar[QtCore.pyqtSignal] - itemsChanged: typing.ClassVar[QtCore.pyqtSignal] - itemsAdded: typing.ClassVar[QtCore.pyqtSignal] - arrayReset: typing.ClassVar[QtCore.pyqtSignal] + + def seriesChanged(self, series: 'QScatter3DSeries') -> None: ... + def itemCountChanged(self, count: int) -> None: ... + def itemsInserted(self, startIndex: int, count: int) -> None: ... + def itemsRemoved(self, startIndex: int, count: int) -> None: ... + def itemsChanged(self, startIndex: int, count: int) -> None: ... + def itemsAdded(self, startIndex: int, count: int) -> None: ... + def arrayReset(self) -> None: ... def series(self) -> 'QScatter3DSeries': ... def removeItems(self, index: int, removeCount: int) -> None: ... def insertItems(self, index: int, items: typing.Iterable['QScatterDataItem']) -> None: ... @@ -1171,14 +1191,15 @@ class QItemModelScatterDataProxy('QScatterDataProxy'): def __init__(self, itemModel: QtCore.QAbstractItemModel, xPosRole: str, yPosRole: str, zPosRole: str, rotationRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - zPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - yPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - xPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - rotationRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] - zPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] - yPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] - xPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + + def zPosRoleReplaceChanged(self, replace: str) -> None: ... + def yPosRoleReplaceChanged(self, replace: str) -> None: ... + def xPosRoleReplaceChanged(self, replace: str) -> None: ... + def rotationRoleReplaceChanged(self, replace: str) -> None: ... + def rotationRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def zPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def yPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def xPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... def rotationRoleReplace(self) -> str: ... def setRotationRoleReplace(self, replace: str) -> None: ... def zPosRoleReplace(self) -> str: ... @@ -1195,11 +1216,11 @@ class QItemModelScatterDataProxy('QScatterDataProxy'): def setYPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... def xPosRolePattern(self) -> QtCore.QRegExp: ... def setXPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - rotationRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - zPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - yPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - xPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - itemModelChanged: typing.ClassVar[QtCore.pyqtSignal] + def rotationRoleChanged(self, role: str) -> None: ... + def zPosRoleChanged(self, role: str) -> None: ... + def yPosRoleChanged(self, role: str) -> None: ... + def xPosRoleChanged(self, role: str) -> None: ... + def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... def remap(self, xPosRole: str, yPosRole: str, zPosRole: str, rotationRole: str) -> None: ... def rotationRole(self) -> str: ... def setRotationRole(self, role: str) -> None: ... @@ -1239,17 +1260,18 @@ class QItemModelSurfaceDataProxy('QSurfaceDataProxy'): def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, xPosRole: str, yPosRole: str, zPosRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - multiMatchBehaviorChanged: typing.ClassVar[QtCore.pyqtSignal] - zPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - yPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - xPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - columnRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - rowRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] - zPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] - yPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] - xPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] - columnRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] - rowRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + + def multiMatchBehaviorChanged(self, behavior: 'QItemModelSurfaceDataProxy.MultiMatchBehavior') -> None: ... + def zPosRoleReplaceChanged(self, replace: str) -> None: ... + def yPosRoleReplaceChanged(self, replace: str) -> None: ... + def xPosRoleReplaceChanged(self, replace: str) -> None: ... + def columnRoleReplaceChanged(self, replace: str) -> None: ... + def rowRoleReplaceChanged(self, replace: str) -> None: ... + def zPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def yPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def xPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def columnRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def rowRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... def multiMatchBehavior(self) -> 'QItemModelSurfaceDataProxy.MultiMatchBehavior': ... def setMultiMatchBehavior(self, behavior: 'QItemModelSurfaceDataProxy.MultiMatchBehavior') -> None: ... def zPosRoleReplace(self) -> str: ... @@ -1272,17 +1294,17 @@ class QItemModelSurfaceDataProxy('QSurfaceDataProxy'): def setColumnRolePattern(self, pattern: QtCore.QRegExp) -> None: ... def rowRolePattern(self) -> QtCore.QRegExp: ... def setRowRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - autoColumnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] - autoRowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] - useModelCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] - columnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] - rowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] - zPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - yPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - xPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - columnRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - rowRoleChanged: typing.ClassVar[QtCore.pyqtSignal] - itemModelChanged: typing.ClassVar[QtCore.pyqtSignal] + def autoColumnCategoriesChanged(self, enable: bool) -> None: ... + def autoRowCategoriesChanged(self, enable: bool) -> None: ... + def useModelCategoriesChanged(self, enable: bool) -> None: ... + def columnCategoriesChanged(self) -> None: ... + def rowCategoriesChanged(self) -> None: ... + def zPosRoleChanged(self, role: str) -> None: ... + def yPosRoleChanged(self, role: str) -> None: ... + def xPosRoleChanged(self, role: str) -> None: ... + def columnRoleChanged(self, role: str) -> None: ... + def rowRoleChanged(self, role: str) -> None: ... + def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... def remap(self, rowRole: str, columnRole: str, xPosRole: str, yPosRole: str, zPosRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str]) -> None: ... def zPosRole(self) -> str: ... def setZPosRole(self, role: str) -> None: ... @@ -1341,9 +1363,9 @@ class QLogValue3DAxisFormatter('QValue3DAxisFormatter'): def positionAt(self, value: float) -> float: ... def recalculate(self) -> None: ... def createNewInstance(self) -> 'QValue3DAxisFormatter': ... - showEdgeLabelsChanged: typing.ClassVar[QtCore.pyqtSignal] - autoSubGridChanged: typing.ClassVar[QtCore.pyqtSignal] - baseChanged: typing.ClassVar[QtCore.pyqtSignal] + def showEdgeLabelsChanged(self, enabled: bool) -> None: ... + def autoSubGridChanged(self, enabled: bool) -> None: ... + def baseChanged(self, base: float) -> None: ... def showEdgeLabels(self) -> bool: ... def setShowEdgeLabels(self, enabled: bool) -> None: ... def autoSubGrid(self) -> bool: ... @@ -1357,9 +1379,10 @@ class QScatter3DSeries('QAbstract3DSeries'): def __init__(self, dataProxy: 'QScatterDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - itemSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - selectedItemChanged: typing.ClassVar[QtCore.pyqtSignal] - dataProxyChanged: typing.ClassVar[QtCore.pyqtSignal] + + def itemSizeChanged(self, size: float) -> None: ... + def selectedItemChanged(self, index: int) -> None: ... + def dataProxyChanged(self, proxy: 'QScatterDataProxy') -> None: ... def itemSize(self) -> float: ... def setItemSize(self, size: float) -> None: ... @staticmethod @@ -1421,17 +1444,18 @@ class QSurface3DSeries('QAbstract3DSeries'): def __init__(self, dataProxy: 'QSurfaceDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - textureFileChanged: typing.ClassVar[QtCore.pyqtSignal] - textureChanged: typing.ClassVar[QtCore.pyqtSignal] + + def textureFileChanged(self, filename: str) -> None: ... + def textureChanged(self, image: QtGui.QImage) -> None: ... def textureFile(self) -> str: ... def setTextureFile(self, filename: str) -> None: ... def texture(self) -> QtGui.QImage: ... def setTexture(self, texture: QtGui.QImage) -> None: ... - drawModeChanged: typing.ClassVar[QtCore.pyqtSignal] - flatShadingSupportedChanged: typing.ClassVar[QtCore.pyqtSignal] - flatShadingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - selectedPointChanged: typing.ClassVar[QtCore.pyqtSignal] - dataProxyChanged: typing.ClassVar[QtCore.pyqtSignal] + def drawModeChanged(self, mode: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... + def flatShadingSupportedChanged(self, enable: bool) -> None: ... + def flatShadingEnabledChanged(self, enable: bool) -> None: ... + def selectedPointChanged(self, position: QtCore.QPoint) -> None: ... + def dataProxyChanged(self, proxy: 'QSurfaceDataProxy') -> None: ... def isFlatShadingSupported(self) -> bool: ... def drawMode(self) -> 'QSurface3DSeries.DrawFlags': ... def setDrawMode(self, mode: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... @@ -1471,15 +1495,16 @@ class QTouch3DInputHandler('Q3DInputHandler'): class QValue3DAxis('QAbstract3DAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - reversedChanged: typing.ClassVar[QtCore.pyqtSignal] - formatterChanged: typing.ClassVar[QtCore.pyqtSignal] + + def reversedChanged(self, enable: bool) -> None: ... + def formatterChanged(self, formatter: 'QValue3DAxisFormatter') -> None: ... def reversed(self) -> bool: ... def setReversed(self, enable: bool) -> None: ... def formatter(self) -> 'QValue3DAxisFormatter': ... def setFormatter(self, formatter: 'QValue3DAxisFormatter') -> None: ... - labelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] - subSegmentCountChanged: typing.ClassVar[QtCore.pyqtSignal] - segmentCountChanged: typing.ClassVar[QtCore.pyqtSignal] + def labelFormatChanged(self, format: str) -> None: ... + def subSegmentCountChanged(self, count: int) -> None: ... + def segmentCountChanged(self, count: int) -> None: ... def labelFormat(self) -> str: ... def setLabelFormat(self, format: str) -> None: ... def subSegmentCount(self) -> int: ... diff --git a/PyQt5-stubs/QtDesigner.pyi b/PyQt5-stubs/QtDesigner.pyi index e24e8cf4..8bd1874d 100644 --- a/PyQt5-stubs/QtDesigner.pyi +++ b/PyQt5-stubs/QtDesigner.pyi @@ -112,19 +112,19 @@ class QDesignerFormWindowInterface(QtWidgets.QWidget): def formContainer(self) -> QtWidgets.QWidget: ... def activeResourceFilePaths(self) -> typing.List[str]: ... def checkContents(self) -> typing.List[str]: ... - objectRemoved: typing.ClassVar[QtCore.pyqtSignal] - widgetRemoved: typing.ClassVar[QtCore.pyqtSignal] - changed: typing.ClassVar[QtCore.pyqtSignal] - activated: typing.ClassVar[QtCore.pyqtSignal] - aboutToUnmanageWidget: typing.ClassVar[QtCore.pyqtSignal] - widgetUnmanaged: typing.ClassVar[QtCore.pyqtSignal] - widgetManaged: typing.ClassVar[QtCore.pyqtSignal] - resourceFilesChanged: typing.ClassVar[QtCore.pyqtSignal] - geometryChanged: typing.ClassVar[QtCore.pyqtSignal] - selectionChanged: typing.ClassVar[QtCore.pyqtSignal] - featureChanged: typing.ClassVar[QtCore.pyqtSignal] - fileNameChanged: typing.ClassVar[QtCore.pyqtSignal] - mainContainerChanged: typing.ClassVar[QtCore.pyqtSignal] + def objectRemoved(self, o: QtCore.QObject) -> None: ... + def widgetRemoved(self, w: QtWidgets.QWidget) -> None: ... + def changed(self) -> None: ... + def activated(self, widget: QtWidgets.QWidget) -> None: ... + def aboutToUnmanageWidget(self, widget: QtWidgets.QWidget) -> None: ... + def widgetUnmanaged(self, widget: QtWidgets.QWidget) -> None: ... + def widgetManaged(self, widget: QtWidgets.QWidget) -> None: ... + def resourceFilesChanged(self) -> None: ... + def geometryChanged(self) -> None: ... + def selectionChanged(self) -> None: ... + def featureChanged(self, f: typing.Union['QDesignerFormWindowInterface.Feature', 'QDesignerFormWindowInterface.FeatureFlag']) -> None: ... + def fileNameChanged(self, fileName: str) -> None: ... + def mainContainerChanged(self, mainContainer: QtWidgets.QWidget) -> None: ... def setFileName(self, fileName: str) -> None: ... def setGrid(self, grid: QtCore.QPoint) -> None: ... def selectWidget(self, widget: QtWidgets.QWidget, select: bool = ...) -> None: ... @@ -286,10 +286,10 @@ class QDesignerFormWindowManagerInterface(QtCore.QObject): def setActiveFormWindow(self, formWindow: QDesignerFormWindowInterface) -> None: ... def removeFormWindow(self, formWindow: QDesignerFormWindowInterface) -> None: ... def addFormWindow(self, formWindow: QDesignerFormWindowInterface) -> None: ... - formWindowSettingsChanged: typing.ClassVar[QtCore.pyqtSignal] - activeFormWindowChanged: typing.ClassVar[QtCore.pyqtSignal] - formWindowRemoved: typing.ClassVar[QtCore.pyqtSignal] - formWindowAdded: typing.ClassVar[QtCore.pyqtSignal] + def formWindowSettingsChanged(self, fw: QDesignerFormWindowInterface) -> None: ... + def activeFormWindowChanged(self, formWindow: QDesignerFormWindowInterface) -> None: ... + def formWindowRemoved(self, formWindow: QDesignerFormWindowInterface) -> None: ... + def formWindowAdded(self, formWindow: QDesignerFormWindowInterface) -> None: ... def core(self) -> QDesignerFormEditorInterface: ... def createFormWindow(self, parent: typing.Optional[QtWidgets.QWidget] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> QDesignerFormWindowInterface: ... def formWindow(self, index: int) -> QDesignerFormWindowInterface: ... @@ -314,7 +314,7 @@ class QDesignerPropertyEditorInterface(QtWidgets.QWidget): def setReadOnly(self, readOnly: bool) -> None: ... def setPropertyValue(self, name: str, value: typing.Any, changed: bool = ...) -> None: ... def setObject(self, object: QtCore.QObject) -> None: ... - propertyChanged: typing.ClassVar[QtCore.pyqtSignal] + def propertyChanged(self, name: str, value: typing.Any) -> None: ... def currentPropertyName(self) -> str: ... def object(self) -> QtCore.QObject: ... def isReadOnly(self) -> bool: ... diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index bc251f19..2dddd700 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -80,10 +80,10 @@ class QAbstractTextDocumentLayout(QtCore.QObject): def positionInlineObject(self, item: 'QTextInlineObject', posInDocument: int, format: 'QTextFormat') -> None: ... def resizeInlineObject(self, item: 'QTextInlineObject', posInDocument: int, format: 'QTextFormat') -> None: ... def documentChanged(self, from_: int, charsRemoved: int, charsAdded: int) -> None: ... - updateBlock: typing.ClassVar[QtCore.pyqtSignal] - pageCountChanged: typing.ClassVar[QtCore.pyqtSignal] - documentSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - update: typing.ClassVar[QtCore.pyqtSignal] + def updateBlock(self, block: 'QTextBlock') -> None: ... + def pageCountChanged(self, newPages: int) -> None: ... + def documentSizeChanged(self, newSize: QtCore.QSizeF) -> None: ... + def update(self, rect: QtCore.QRectF = ...) -> None: ... def handlerForObject(self, objectType: int) -> 'QTextObjectInterface': ... def unregisterHandler(self, objectType: int, component: typing.Optional[QtCore.QObject] = ...) -> None: ... def registerHandler(self, objectType: int, component: QtCore.QObject) -> None: ... @@ -1291,8 +1291,8 @@ class QDrag(QtCore.QObject): def defaultAction(self) -> QtCore.Qt.DropAction: ... def supportedActions(self) -> QtCore.Qt.DropActions: ... def dragCursor(self, action: QtCore.Qt.DropAction) -> QPixmap: ... - targetChanged: typing.ClassVar[QtCore.pyqtSignal] - actionChanged: typing.ClassVar[QtCore.pyqtSignal] + def targetChanged(self, newTarget: QtCore.QObject) -> None: ... + def actionChanged(self, action: QtCore.Qt.DropAction) -> None: ... def setDragCursor(self, cursor: QPixmap, action: QtCore.Qt.DropAction) -> None: ... def target(self) -> QtCore.QObject: ... def source(self) -> QtCore.QObject: ... @@ -2653,21 +2653,21 @@ class QGuiApplication(QtCore.QCoreApplication): def highDpiScaleFactorRoundingPolicy() -> QtCore.Qt.HighDpiScaleFactorRoundingPolicy: ... @staticmethod def setHighDpiScaleFactorRoundingPolicy(policy: QtCore.Qt.HighDpiScaleFactorRoundingPolicy) -> None: ... - fontChanged: typing.ClassVar[QtCore.pyqtSignal] + def fontChanged(self, font: QFont) -> None: ... @staticmethod def screenAt(point: QtCore.QPoint) -> 'QScreen': ... @staticmethod def desktopFileName() -> str: ... @staticmethod def setDesktopFileName(name: str) -> None: ... - primaryScreenChanged: typing.ClassVar[QtCore.pyqtSignal] + def primaryScreenChanged(self, screen: 'QScreen') -> None: ... @staticmethod def setFallbackSessionManagementEnabled(a0: bool) -> None: ... @staticmethod def isFallbackSessionManagementEnabled() -> bool: ... - paletteChanged: typing.ClassVar[QtCore.pyqtSignal] - layoutDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] - screenRemoved: typing.ClassVar[QtCore.pyqtSignal] + def paletteChanged(self, pal: 'QPalette') -> None: ... + def layoutDirectionChanged(self, direction: QtCore.Qt.LayoutDirection) -> None: ... + def screenRemoved(self, screen: 'QScreen') -> None: ... def event(self, a0: QtCore.QEvent) -> bool: ... @staticmethod def windowIcon() -> 'QIcon': ... @@ -2692,15 +2692,15 @@ class QGuiApplication(QtCore.QCoreApplication): def applicationDisplayName() -> str: ... @staticmethod def setApplicationDisplayName(name: str) -> None: ... - applicationDisplayNameChanged: typing.ClassVar[QtCore.pyqtSignal] - applicationStateChanged: typing.ClassVar[QtCore.pyqtSignal] - focusWindowChanged: typing.ClassVar[QtCore.pyqtSignal] - saveStateRequest: typing.ClassVar[QtCore.pyqtSignal] - commitDataRequest: typing.ClassVar[QtCore.pyqtSignal] - focusObjectChanged: typing.ClassVar[QtCore.pyqtSignal] + def applicationDisplayNameChanged(self) -> None: ... + def applicationStateChanged(self, state: QtCore.Qt.ApplicationState) -> None: ... + def focusWindowChanged(self, focusWindow: 'QWindow') -> None: ... + def saveStateRequest(self, sessionManager: 'QSessionManager') -> None: ... + def commitDataRequest(self, sessionManager: 'QSessionManager') -> None: ... + def focusObjectChanged(self, focusObject: QtCore.QObject) -> None: ... lastWindowClosed: typing.ClassVar[QtCore.pyqtSignal] - screenAdded: typing.ClassVar[QtCore.pyqtSignal] - fontDatabaseChanged: typing.ClassVar[QtCore.pyqtSignal] + def screenAdded(self, screen: 'QScreen') -> None: ... + def fontDatabaseChanged(self) -> None: ... def notify(self, a0: QtCore.QObject, a1: QtCore.QEvent) -> bool: ... @staticmethod def exec() -> int: ... @@ -3375,16 +3375,17 @@ class QInputMethod(QtCore.QObject): Click = ... # type: QInputMethod.Action ContextMenu = ... # type: QInputMethod.Action - inputItemClipRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] - anchorRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] + + def inputItemClipRectangleChanged(self) -> None: ... + def anchorRectangleChanged(self) -> None: ... def inputItemClipRectangle(self) -> QtCore.QRectF: ... def anchorRectangle(self) -> QtCore.QRectF: ... - inputDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] - localeChanged: typing.ClassVar[QtCore.pyqtSignal] - animatingChanged: typing.ClassVar[QtCore.pyqtSignal] - visibleChanged: typing.ClassVar[QtCore.pyqtSignal] - keyboardRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] - cursorRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] + def inputDirectionChanged(self, newDirection: QtCore.Qt.LayoutDirection) -> None: ... + def localeChanged(self) -> None: ... + def animatingChanged(self) -> None: ... + def visibleChanged(self) -> None: ... + def keyboardRectangleChanged(self) -> None: ... + def cursorRectangleChanged(self) -> None: ... def invokeAction(self, a: 'QInputMethod.Action', cursorPosition: int) -> None: ... def commit(self) -> None: ... def reset(self) -> None: ... @@ -3716,13 +3717,13 @@ class QMovie(QtCore.QObject): def setPaused(self, paused: bool) -> None: ... def jumpToNextFrame(self) -> bool: ... def start(self) -> None: ... - frameChanged: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] - error: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - updated: typing.ClassVar[QtCore.pyqtSignal] - resized: typing.ClassVar[QtCore.pyqtSignal] - started: typing.ClassVar[QtCore.pyqtSignal] + def frameChanged(self, frameNumber: int) -> None: ... + def finished(self) -> None: ... + def error(self, error: QImageReader.ImageReaderError) -> None: ... + def stateChanged(self, state: 'QMovie.MovieState') -> None: ... + def updated(self, rect: QtCore.QRect) -> None: ... + def resized(self, size: QtCore.QSize) -> None: ... + def started(self) -> None: ... def setCacheMode(self, mode: 'QMovie.CacheMode') -> None: ... def cacheMode(self) -> 'QMovie.CacheMode': ... def setScaledSize(self, size: QtCore.QSize) -> None: ... @@ -3796,7 +3797,7 @@ class QOffscreenSurface(QtCore.QObject, QSurface): def setNativeHandle(self, handle: sip.voidptr) -> None: ... def nativeHandle(self) -> sip.voidptr: ... - screenChanged: typing.ClassVar[QtCore.pyqtSignal] + def screenChanged(self, screen: 'QScreen') -> None: ... def setScreen(self, screen: 'QScreen') -> None: ... def screen(self) -> 'QScreen': ... def size(self) -> QtCore.QSize: ... @@ -3945,7 +3946,7 @@ class QOpenGLContext(QtCore.QObject): @staticmethod def openGLModuleHandle() -> sip.voidptr: ... def versionFunctions(self, versionProfile: typing.Optional['QOpenGLVersionProfile'] = ...) -> typing.Any: ... - aboutToBeDestroyed: typing.ClassVar[QtCore.pyqtSignal] + def aboutToBeDestroyed(self) -> None: ... def hasExtension(self, extension: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> bool: ... def extensions(self) -> typing.Set[QtCore.QByteArray]: ... @staticmethod @@ -4120,7 +4121,8 @@ class QOpenGLDebugLogger(QtCore.QObject): SynchronousLogging = ... # type: QOpenGLDebugLogger.LoggingMode def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - messageLogged: typing.ClassVar[QtCore.pyqtSignal] + + def messageLogged(self, debugMessage: QOpenGLDebugMessage) -> None: ... def stopLogging(self) -> None: ... def startLogging(self, loggingMode: 'QOpenGLDebugLogger.LoggingMode' = ...) -> None: ... def logMessage(self, debugMessage: QOpenGLDebugMessage) -> None: ... @@ -5546,7 +5548,7 @@ class QOpenGLWindow(QPaintDeviceWindow): def paintGL(self) -> None: ... def resizeGL(self, w: int, h: int) -> None: ... def initializeGL(self) -> None: ... - frameSwapped: typing.ClassVar[QtCore.pyqtSignal] + def frameSwapped(self) -> None: ... def shareContext(self) -> QOpenGLContext: ... def grabFramebuffer(self) -> QImage: ... def defaultFramebufferObject(self) -> int: ... @@ -8086,15 +8088,15 @@ class QScreen(QtCore.QObject): def serialNumber(self) -> str: ... def model(self) -> str: ... def manufacturer(self) -> str: ... - availableGeometryChanged: typing.ClassVar[QtCore.pyqtSignal] - virtualGeometryChanged: typing.ClassVar[QtCore.pyqtSignal] - physicalSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - refreshRateChanged: typing.ClassVar[QtCore.pyqtSignal] - orientationChanged: typing.ClassVar[QtCore.pyqtSignal] - primaryOrientationChanged: typing.ClassVar[QtCore.pyqtSignal] - logicalDotsPerInchChanged: typing.ClassVar[QtCore.pyqtSignal] - physicalDotsPerInchChanged: typing.ClassVar[QtCore.pyqtSignal] - geometryChanged: typing.ClassVar[QtCore.pyqtSignal] + def availableGeometryChanged(self, geometry: QtCore.QRect) -> None: ... + def virtualGeometryChanged(self, rect: QtCore.QRect) -> None: ... + def physicalSizeChanged(self, size: QtCore.QSizeF) -> None: ... + def refreshRateChanged(self, refreshRate: float) -> None: ... + def orientationChanged(self, orientation: QtCore.Qt.ScreenOrientation) -> None: ... + def primaryOrientationChanged(self, orientation: QtCore.Qt.ScreenOrientation) -> None: ... + def logicalDotsPerInchChanged(self, dpi: float) -> None: ... + def physicalDotsPerInchChanged(self, dpi: float) -> None: ... + def geometryChanged(self, geometry: QtCore.QRect) -> None: ... def devicePixelRatio(self) -> float: ... def refreshRate(self) -> float: ... def grabWindow(self, window: sip.voidptr, x: int = ..., y: int = ..., width: int = ..., height: int = ...) -> QPixmap: ... @@ -8169,7 +8171,7 @@ class QStandardItemModel(QtCore.QAbstractItemModel): def __init__(self, rows: int, columns: int, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def clearItemData(self, index: QtCore.QModelIndex) -> bool: ... - itemChanged: typing.ClassVar[QtCore.pyqtSignal] + def itemChanged(self, item: 'QStandardItem') -> None: ... def setItemRoleNames(self, roleNames: typing.Dict[int, typing.Union[QtCore.QByteArray, bytes, bytearray]]) -> None: ... def sibling(self, row: int, column: int, idx: QtCore.QModelIndex) -> QtCore.QModelIndex: ... def dropMimeData(self, data: QtCore.QMimeData, action: QtCore.Qt.DropAction, row: int, column: int, parent: QtCore.QModelIndex) -> bool: ... @@ -8390,24 +8392,24 @@ class QStyleHints(QtCore.QObject): def touchDoubleTapDistance(self) -> int: ... def mouseDoubleClickDistance(self) -> int: ... - showShortcutsInContextMenusChanged: typing.ClassVar[QtCore.pyqtSignal] + def showShortcutsInContextMenusChanged(self, a0: bool) -> None: ... def setShowShortcutsInContextMenus(self, showShortcutsInContextMenus: bool) -> None: ... - mouseQuickSelectionThresholdChanged: typing.ClassVar[QtCore.pyqtSignal] + def mouseQuickSelectionThresholdChanged(self, threshold: int) -> None: ... def mouseQuickSelectionThreshold(self) -> int: ... def showShortcutsInContextMenus(self) -> bool: ... - wheelScrollLinesChanged: typing.ClassVar[QtCore.pyqtSignal] + def wheelScrollLinesChanged(self, scrollLines: int) -> None: ... def wheelScrollLines(self) -> int: ... - useHoverEffectsChanged: typing.ClassVar[QtCore.pyqtSignal] + def useHoverEffectsChanged(self, useHoverEffects: bool) -> None: ... def setUseHoverEffects(self, useHoverEffects: bool) -> None: ... def useHoverEffects(self) -> bool: ... def showIsMaximized(self) -> bool: ... - tabFocusBehaviorChanged: typing.ClassVar[QtCore.pyqtSignal] - mousePressAndHoldIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] - startDragTimeChanged: typing.ClassVar[QtCore.pyqtSignal] - startDragDistanceChanged: typing.ClassVar[QtCore.pyqtSignal] - mouseDoubleClickIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] - keyboardInputIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] - cursorFlashTimeChanged: typing.ClassVar[QtCore.pyqtSignal] + def tabFocusBehaviorChanged(self, tabFocusBehavior: QtCore.Qt.TabFocusBehavior) -> None: ... + def mousePressAndHoldIntervalChanged(self, mousePressAndHoldInterval: int) -> None: ... + def startDragTimeChanged(self, startDragTime: int) -> None: ... + def startDragDistanceChanged(self, startDragDistance: int) -> None: ... + def mouseDoubleClickIntervalChanged(self, mouseDoubleClickInterval: int) -> None: ... + def keyboardInputIntervalChanged(self, keyboardInputInterval: int) -> None: ... + def cursorFlashTimeChanged(self, cursorFlashTime: int) -> None: ... def singleClickActivation(self) -> bool: ... def tabFocusBehavior(self) -> QtCore.Qt.TabFocusBehavior: ... def mousePressAndHoldInterval(self) -> int: ... @@ -8832,7 +8834,7 @@ class QTextDocument(QtCore.QObject): def setMarkdown(self, markdown: str, features: typing.Union['QTextDocument.MarkdownFeatures', 'QTextDocument.MarkdownFeature'] = ...) -> None: ... def toMarkdown(self, features: typing.Union['QTextDocument.MarkdownFeatures', 'QTextDocument.MarkdownFeature'] = ...) -> str: ... def toRawText(self) -> str: ... - baseUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + def baseUrlChanged(self, url: QtCore.QUrl) -> None: ... def setBaseUrl(self, url: QtCore.QUrl) -> None: ... def baseUrl(self) -> QtCore.QUrl: ... def setDefaultCursorMoveStyle(self, style: QtCore.Qt.CursorMoveStyle) -> None: ... @@ -8845,8 +8847,8 @@ class QTextDocument(QtCore.QObject): def setDocumentMargin(self, margin: float) -> None: ... def documentMargin(self) -> float: ... def characterAt(self, pos: int) -> str: ... - documentLayoutChanged: typing.ClassVar[QtCore.pyqtSignal] - undoCommandAdded: typing.ClassVar[QtCore.pyqtSignal] + def documentLayoutChanged(self) -> None: ... + def undoCommandAdded(self) -> None: ... def setIndentWidth(self, width: float) -> None: ... def indentWidth(self) -> float: ... def lastBlock(self) -> 'QTextBlock': ... @@ -8878,13 +8880,13 @@ class QTextDocument(QtCore.QObject): def undo(self) -> None: ... @typing.overload def undo(self, cursor: QTextCursor) -> None: ... - undoAvailable: typing.ClassVar[QtCore.pyqtSignal] - redoAvailable: typing.ClassVar[QtCore.pyqtSignal] - modificationChanged: typing.ClassVar[QtCore.pyqtSignal] - cursorPositionChanged: typing.ClassVar[QtCore.pyqtSignal] - contentsChanged: typing.ClassVar[QtCore.pyqtSignal] - contentsChange: typing.ClassVar[QtCore.pyqtSignal] - blockCountChanged: typing.ClassVar[QtCore.pyqtSignal] + def undoAvailable(self, a0: bool) -> None: ... + def redoAvailable(self, a0: bool) -> None: ... + def modificationChanged(self, m: bool) -> None: ... + def cursorPositionChanged(self, cursor: QTextCursor) -> None: ... + def contentsChanged(self) -> None: ... + def contentsChange(self, from_: int, charsRemoves: int, charsAdded: int) -> None: ... + def blockCountChanged(self, newBlockCount: int) -> None: ... def useDesignMetrics(self) -> bool: ... def setUseDesignMetrics(self, b: bool) -> None: ... def markContentsDirty(self, from_: int, length: int) -> None: ... @@ -10311,7 +10313,8 @@ class QValidator(QtCore.QObject): Acceptable = ... # type: QValidator.State def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - changed: typing.ClassVar[QtCore.pyqtSignal] + + def changed(self) -> None: ... def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def fixup(self, a0: str) -> str: ... diff --git a/PyQt5-stubs/QtHelp.pyi b/PyQt5-stubs/QtHelp.pyi index 4b2dca21..0b87c478 100644 --- a/PyQt5-stubs/QtHelp.pyi +++ b/PyQt5-stubs/QtHelp.pyi @@ -68,8 +68,9 @@ class QHelpContentItem(sip.simplewrapper): class QHelpContentModel(QtCore.QAbstractItemModel): - contentsCreated: typing.ClassVar[QtCore.pyqtSignal] - contentsCreationStarted: typing.ClassVar[QtCore.pyqtSignal] + + def contentsCreated(self) -> None: ... + def contentsCreationStarted(self) -> None: ... def isCreatingContents(self) -> bool: ... def columnCount(self, parent: QtCore.QModelIndex = ...) -> int: ... def rowCount(self, parent: QtCore.QModelIndex = ...) -> int: ... @@ -81,7 +82,8 @@ class QHelpContentModel(QtCore.QAbstractItemModel): class QHelpContentWidget(QtWidgets.QTreeView): - linkActivated: typing.ClassVar[QtCore.pyqtSignal] + + def linkActivated(self, link: QtCore.QUrl) -> None: ... def indexOf(self, link: QtCore.QUrl) -> QtCore.QModelIndex: ... @@ -100,11 +102,11 @@ class QHelpEngineCore(QtCore.QObject): def usesFilterEngine(self) -> bool: ... def setUsesFilterEngine(self, uses: bool) -> None: ... def filterEngine(self) -> 'QHelpFilterEngine': ... - readersAboutToBeInvalidated: typing.ClassVar[QtCore.pyqtSignal] - warning: typing.ClassVar[QtCore.pyqtSignal] - currentFilterChanged: typing.ClassVar[QtCore.pyqtSignal] - setupFinished: typing.ClassVar[QtCore.pyqtSignal] - setupStarted: typing.ClassVar[QtCore.pyqtSignal] + def readersAboutToBeInvalidated(self) -> None: ... + def warning(self, msg: str) -> None: ... + def currentFilterChanged(self, newFilter: str) -> None: ... + def setupFinished(self) -> None: ... + def setupStarted(self) -> None: ... def setAutoSaveFilter(self, save: bool) -> None: ... def autoSaveFilter(self) -> bool: ... def error(self) -> str: ... @@ -175,7 +177,7 @@ class QHelpFilterEngine(QtCore.QObject): @typing.overload def indices(self, filterName: str) -> typing.List[str]: ... def availableVersions(self) -> typing.List[QtCore.QVersionNumber]: ... - filterActivated: typing.ClassVar[QtCore.pyqtSignal] + def filterActivated(self, newFilter: str) -> None: ... def namespacesForFilter(self, filterName: str) -> typing.List[str]: ... def removeFilter(self, filterName: str) -> bool: ... def setFilterData(self, filterName: str, filterData: QHelpFilterData) -> bool: ... @@ -199,8 +201,9 @@ class QHelpFilterSettingsWidget(QtWidgets.QWidget): class QHelpIndexModel(QtCore.QStringListModel): - indexCreated: typing.ClassVar[QtCore.pyqtSignal] - indexCreationStarted: typing.ClassVar[QtCore.pyqtSignal] + + def indexCreated(self) -> None: ... + def indexCreationStarted(self) -> None: ... def isCreatingIndex(self) -> bool: ... def linksForKeyword(self, keyword: str) -> typing.Dict[str, QtCore.QUrl]: ... def filter(self, filter: str, wildcard: str = ...) -> QtCore.QModelIndex: ... @@ -209,12 +212,13 @@ class QHelpIndexModel(QtCore.QStringListModel): class QHelpIndexWidget(QtWidgets.QListView): - documentsActivated: typing.ClassVar[QtCore.pyqtSignal] - documentActivated: typing.ClassVar[QtCore.pyqtSignal] + + def documentsActivated(self, documents: typing.Iterable['QHelpLink'], keyword: str) -> None: ... + def documentActivated(self, document: 'QHelpLink', keyword: str) -> None: ... def activateCurrentItem(self) -> None: ... def filterIndices(self, filter: str, wildcard: str = ...) -> None: ... - linksActivated: typing.ClassVar[QtCore.pyqtSignal] - linkActivated: typing.ClassVar[QtCore.pyqtSignal] + def linksActivated(self, links: typing.Dict[str, QtCore.QUrl], keyword: str) -> None: ... + def linkActivated(self, link: QtCore.QUrl, keyword: str) -> None: ... class QHelpLink(sip.simplewrapper): @@ -260,10 +264,10 @@ class QHelpSearchEngine(QtCore.QObject): def searchInput(self) -> str: ... def searchResults(self, start: int, end: int) -> typing.List['QHelpSearchResult']: ... def searchResultCount(self) -> int: ... - searchingFinished: typing.ClassVar[QtCore.pyqtSignal] - searchingStarted: typing.ClassVar[QtCore.pyqtSignal] - indexingFinished: typing.ClassVar[QtCore.pyqtSignal] - indexingStarted: typing.ClassVar[QtCore.pyqtSignal] + def searchingFinished(self, hits: int) -> None: ... + def searchingStarted(self) -> None: ... + def indexingFinished(self) -> None: ... + def indexingStarted(self) -> None: ... def cancelSearching(self) -> None: ... @typing.overload def search(self, queryList: typing.Iterable[QHelpSearchQuery]) -> None: ... @@ -300,7 +304,7 @@ class QHelpSearchQueryWidget(QtWidgets.QWidget): def searchInput(self) -> str: ... def setCompactMode(self, on: bool) -> None: ... def isCompactMode(self) -> bool: ... - search: typing.ClassVar[QtCore.pyqtSignal] + def search(self) -> None: ... def collapseExtendedSearch(self) -> None: ... def expandExtendedSearch(self) -> None: ... def setQuery(self, queryList: typing.Iterable[QHelpSearchQuery]) -> None: ... @@ -308,5 +312,6 @@ class QHelpSearchQueryWidget(QtWidgets.QWidget): class QHelpSearchResultWidget(QtWidgets.QWidget): - requestShowLink: typing.ClassVar[QtCore.pyqtSignal] + + def requestShowLink(self, url: QtCore.QUrl) -> None: ... def linkAt(self, point: QtCore.QPoint) -> QtCore.QUrl: ... diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index 492c2180..3926f660 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -64,21 +64,25 @@ class QGeoCodeReply(QtCore.QObject): def setViewport(self, viewport: QtPositioning.QGeoShape) -> None: ... def setFinished(self, finished: bool) -> None: ... def setError(self, error: 'QGeoCodeReply.Error', errorString: str) -> None: ... - finished: typing.ClassVar[QtCore.pyqtSignal] - aborted: typing.ClassVar[QtCore.pyqtSignal] + def finished(self) -> None: ... + def aborted(self) -> None: ... def abort(self) -> None: ... def offset(self) -> int: ... def limit(self) -> int: ... def locations(self) -> typing.List[QtPositioning.QGeoLocation]: ... def viewport(self) -> QtPositioning.QGeoShape: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QGeoCodeReply.Error': ... + @typing.overload + def error(self, error: 'QGeoCodeReply.Error', errorString: str = ...) -> None: ... def isFinished(self) -> bool: ... class QGeoCodingManager(QtCore.QObject): - error: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + + def error(self, reply: QGeoCodeReply, error: QGeoCodeReply.Error, errorString: str = ...) -> None: ... + def finished(self, reply: QGeoCodeReply) -> None: ... def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def reverseGeocode(self, coordinate: QtPositioning.QGeoCoordinate, bounds: QtPositioning.QGeoShape = ...) -> QGeoCodeReply: ... @@ -93,8 +97,9 @@ class QGeoCodingManager(QtCore.QObject): class QGeoCodingManagerEngine(QtCore.QObject): def __init__(self, parameters: typing.Dict[str, typing.Any], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - error: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + + def error(self, reply: QGeoCodeReply, error: QGeoCodeReply.Error, errorString: str = ...) -> None: ... + def finished(self, reply: QGeoCodeReply) -> None: ... def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def reverseGeocode(self, coordinate: QtPositioning.QGeoCoordinate, bounds: QtPositioning.QGeoShape) -> QGeoCodeReply: ... @@ -225,13 +230,16 @@ class QGeoRouteReply(QtCore.QObject): def setRoutes(self, routes: typing.Iterable[QGeoRoute]) -> None: ... def setFinished(self, finished: bool) -> None: ... def setError(self, error: 'QGeoRouteReply.Error', errorString: str) -> None: ... - finished: typing.ClassVar[QtCore.pyqtSignal] - aborted: typing.ClassVar[QtCore.pyqtSignal] + def finished(self) -> None: ... + def aborted(self) -> None: ... def abort(self) -> None: ... def routes(self) -> typing.List[QGeoRoute]: ... def request(self) -> 'QGeoRouteRequest': ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QGeoRouteReply.Error': ... + @typing.overload + def error(self, error: 'QGeoRouteReply.Error', errorString: str = ...) -> None: ... def isFinished(self) -> bool: ... @@ -455,8 +463,9 @@ class QGeoRouteSegment(sip.simplewrapper): class QGeoRoutingManager(QtCore.QObject): - error: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + + def error(self, reply: QGeoRouteReply, error: QGeoRouteReply.Error, errorString: str = ...) -> None: ... + def finished(self, reply: QGeoRouteReply) -> None: ... def measurementSystem(self) -> QtCore.QLocale.MeasurementSystem: ... def setMeasurementSystem(self, system: QtCore.QLocale.MeasurementSystem) -> None: ... def locale(self) -> QtCore.QLocale: ... @@ -483,8 +492,8 @@ class QGeoRoutingManagerEngine(QtCore.QObject): def setSupportedFeatureWeights(self, featureWeights: typing.Union[QGeoRouteRequest.FeatureWeights, QGeoRouteRequest.FeatureWeight]) -> None: ... def setSupportedFeatureTypes(self, featureTypes: typing.Union[QGeoRouteRequest.FeatureTypes, QGeoRouteRequest.FeatureType]) -> None: ... def setSupportedTravelModes(self, travelModes: typing.Union[QGeoRouteRequest.TravelModes, QGeoRouteRequest.TravelMode]) -> None: ... - error: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + def error(self, reply: QGeoRouteReply, error: QGeoRouteReply.Error, errorString: str = ...) -> None: ... + def finished(self, reply: QGeoRouteReply) -> None: ... def measurementSystem(self) -> QtCore.QLocale.MeasurementSystem: ... def setMeasurementSystem(self, system: QtCore.QLocale.MeasurementSystem) -> None: ... def locale(self) -> QtCore.QLocale: ... @@ -921,11 +930,14 @@ class QPlaceReply(QtCore.QObject): def setError(self, error: 'QPlaceReply.Error', errorString: str) -> None: ... def setFinished(self, finished: bool) -> None: ... - contentUpdated: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] - aborted: typing.ClassVar[QtCore.pyqtSignal] + def contentUpdated(self) -> None: ... + def finished(self) -> None: ... + def aborted(self) -> None: ... def abort(self) -> None: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QPlaceReply.Error': ... + @typing.overload + def error(self, error: 'QPlaceReply.Error', errorString: str = ...) -> None: ... def errorString(self) -> str: ... def type(self) -> 'QPlaceReply.Type': ... def isFinished(self) -> bool: ... @@ -1048,15 +1060,16 @@ class QPlaceImage(QPlaceContent): class QPlaceManager(QtCore.QObject): - dataChanged: typing.ClassVar[QtCore.pyqtSignal] - categoryRemoved: typing.ClassVar[QtCore.pyqtSignal] - categoryUpdated: typing.ClassVar[QtCore.pyqtSignal] - categoryAdded: typing.ClassVar[QtCore.pyqtSignal] - placeRemoved: typing.ClassVar[QtCore.pyqtSignal] - placeUpdated: typing.ClassVar[QtCore.pyqtSignal] - placeAdded: typing.ClassVar[QtCore.pyqtSignal] - error: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + + def dataChanged(self) -> None: ... + def categoryRemoved(self, categoryId: str, parentId: str) -> None: ... + def categoryUpdated(self, category: QPlaceCategory, parentId: str) -> None: ... + def categoryAdded(self, category: QPlaceCategory, parentId: str) -> None: ... + def placeRemoved(self, placeId: str) -> None: ... + def placeUpdated(self, placeId: str) -> None: ... + def placeAdded(self, placeId: str) -> None: ... + def error(self, a0: QPlaceReply, error: QPlaceReply.Error, errorString: str = ...) -> None: ... + def finished(self, reply: QPlaceReply) -> None: ... def matchingPlaces(self, request: 'QPlaceMatchRequest') -> 'QPlaceMatchReply': ... def compatiblePlace(self, place: QPlace) -> QPlace: ... def setLocales(self, locale: typing.Iterable[QtCore.QLocale]) -> None: ... @@ -1084,15 +1097,15 @@ class QPlaceManagerEngine(QtCore.QObject): def __init__(self, parameters: typing.Dict[str, typing.Any], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def manager(self) -> QPlaceManager: ... - dataChanged: typing.ClassVar[QtCore.pyqtSignal] - categoryRemoved: typing.ClassVar[QtCore.pyqtSignal] - categoryUpdated: typing.ClassVar[QtCore.pyqtSignal] - categoryAdded: typing.ClassVar[QtCore.pyqtSignal] - placeRemoved: typing.ClassVar[QtCore.pyqtSignal] - placeUpdated: typing.ClassVar[QtCore.pyqtSignal] - placeAdded: typing.ClassVar[QtCore.pyqtSignal] - error: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + def dataChanged(self) -> None: ... + def categoryRemoved(self, categoryId: str, parentCategoryId: str) -> None: ... + def categoryUpdated(self, category: QPlaceCategory, parentCategoryId: str) -> None: ... + def categoryAdded(self, category: QPlaceCategory, parentCategoryId: str) -> None: ... + def placeRemoved(self, placeId: str) -> None: ... + def placeUpdated(self, placeId: str) -> None: ... + def placeAdded(self, placeId: str) -> None: ... + def error(self, a0: QPlaceReply, error: QPlaceReply.Error, errorString: str = ...) -> None: ... + def finished(self, reply: QPlaceReply) -> None: ... def matchingPlaces(self, request: 'QPlaceMatchRequest') -> 'QPlaceMatchReply': ... def compatiblePlace(self, original: QPlace) -> QPlace: ... def constructIconUrl(self, icon: QPlaceIcon, size: QtCore.QSize) -> QtCore.QUrl: ... diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index d57f1f63..e574b8cd 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -114,7 +114,8 @@ class QVideoFilterRunnable(sip.simplewrapper): class QAbstractVideoFilter(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - activeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def activeChanged(self) -> None: ... def createFilterRunnable(self) -> QVideoFilterRunnable: ... def isActive(self) -> bool: ... @@ -135,13 +136,14 @@ class QAbstractVideoSurface(QtCore.QObject): ResourceError = ... # type: QAbstractVideoSurface.Error def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - nativeResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + + def nativeResolutionChanged(self, a0: QtCore.QSize) -> None: ... def setNativeResolution(self, resolution: QtCore.QSize) -> None: ... def nativeResolution(self) -> QtCore.QSize: ... def setError(self, error: 'QAbstractVideoSurface.Error') -> None: ... - supportedFormatsChanged: typing.ClassVar[QtCore.pyqtSignal] - surfaceFormatChanged: typing.ClassVar[QtCore.pyqtSignal] - activeChanged: typing.ClassVar[QtCore.pyqtSignal] + def supportedFormatsChanged(self) -> None: ... + def surfaceFormatChanged(self, format: 'QVideoSurfaceFormat') -> None: ... + def activeChanged(self, active: bool) -> None: ... def error(self) -> 'QAbstractVideoSurface.Error': ... def present(self, frame: 'QVideoFrame') -> bool: ... def isActive(self) -> bool: ... @@ -255,10 +257,16 @@ class QMediaObject(QtCore.QObject): def removePropertyWatch(self, name: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def addPropertyWatch(self, name: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - availabilityChanged: typing.ClassVar[QtCore.pyqtSignal] - metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] - metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] - notifyIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def availabilityChanged(self, availability: 'QMultimedia.AvailabilityStatus') -> None: ... + @typing.overload + def availabilityChanged(self, available: bool) -> None: ... + @typing.overload + def metaDataChanged(self) -> None: ... + @typing.overload + def metaDataChanged(self, key: str, value: typing.Any) -> None: ... + def metaDataAvailableChanged(self, available: bool) -> None: ... + def notifyIntervalChanged(self, milliSeconds: int) -> None: ... def availableMetaData(self) -> typing.List[str]: ... def metaData(self, key: str) -> typing.Any: ... def isMetaDataAvailable(self) -> bool: ... @@ -297,14 +305,14 @@ class QAudioDecoder(QMediaObject): def unbind(self, a0: QtCore.QObject) -> None: ... def bind(self, a0: QtCore.QObject) -> bool: ... - durationChanged: typing.ClassVar[QtCore.pyqtSignal] - positionChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceChanged: typing.ClassVar[QtCore.pyqtSignal] - formatChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] - bufferReady: typing.ClassVar[QtCore.pyqtSignal] - bufferAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + def durationChanged(self, duration: int) -> None: ... + def positionChanged(self, position: int) -> None: ... + def sourceChanged(self) -> None: ... + def formatChanged(self, format: 'QAudioFormat') -> None: ... + def stateChanged(self, newState: 'QAudioDecoder.State') -> None: ... + def finished(self) -> None: ... + def bufferReady(self) -> None: ... + def bufferAvailableChanged(self, a0: bool) -> None: ... def stop(self) -> None: ... def start(self) -> None: ... def duration(self) -> int: ... @@ -312,7 +320,10 @@ class QAudioDecoder(QMediaObject): def bufferAvailable(self) -> bool: ... def read(self) -> QAudioBuffer: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QAudioDecoder.Error': ... + @typing.overload + def error(self, error: 'QAudioDecoder.Error') -> None: ... def setAudioFormat(self, format: 'QAudioFormat') -> None: ... def audioFormat(self) -> 'QAudioFormat': ... def setSourceDevice(self, device: QtCore.QIODevice) -> None: ... @@ -332,15 +343,16 @@ class QMediaControl(QtCore.QObject): class QAudioDecoderControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - durationChanged: typing.ClassVar[QtCore.pyqtSignal] - positionChanged: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] - bufferAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] - bufferReady: typing.ClassVar[QtCore.pyqtSignal] - error: typing.ClassVar[QtCore.pyqtSignal] - sourceChanged: typing.ClassVar[QtCore.pyqtSignal] - formatChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] + + def durationChanged(self, duration: int) -> None: ... + def positionChanged(self, position: int) -> None: ... + def finished(self) -> None: ... + def bufferAvailableChanged(self, available: bool) -> None: ... + def bufferReady(self) -> None: ... + def error(self, error: int, errorString: str) -> None: ... + def sourceChanged(self) -> None: ... + def formatChanged(self, format: 'QAudioFormat') -> None: ... + def stateChanged(self, newState: QAudioDecoder.State) -> None: ... def duration(self) -> int: ... def position(self) -> int: ... def bufferAvailable(self) -> bool: ... @@ -450,8 +462,8 @@ class QAudioInput(QtCore.QObject): def volume(self) -> float: ... def setVolume(self, volume: float) -> None: ... - notify: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] + def notify(self) -> None: ... + def stateChanged(self, a0: QAudio.State) -> None: ... def state(self) -> QAudio.State: ... def error(self) -> QAudio.Error: ... def elapsedUSecs(self) -> int: ... @@ -476,8 +488,9 @@ class QAudioInput(QtCore.QObject): class QAudioInputSelectorControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - availableInputsChanged: typing.ClassVar[QtCore.pyqtSignal] - activeInputChanged: typing.ClassVar[QtCore.pyqtSignal] + + def availableInputsChanged(self) -> None: ... + def activeInputChanged(self, name: str) -> None: ... def setActiveInput(self, name: str) -> None: ... def activeInput(self) -> str: ... def defaultInput(self) -> str: ... @@ -496,8 +509,8 @@ class QAudioOutput(QtCore.QObject): def category(self) -> str: ... def volume(self) -> float: ... def setVolume(self, a0: float) -> None: ... - notify: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] + def notify(self) -> None: ... + def stateChanged(self, a0: QAudio.State) -> None: ... def state(self) -> QAudio.State: ... def error(self) -> QAudio.Error: ... def elapsedUSecs(self) -> int: ... @@ -522,8 +535,9 @@ class QAudioOutput(QtCore.QObject): class QAudioOutputSelectorControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - availableOutputsChanged: typing.ClassVar[QtCore.pyqtSignal] - activeOutputChanged: typing.ClassVar[QtCore.pyqtSignal] + + def availableOutputsChanged(self) -> None: ... + def activeOutputChanged(self, name: str) -> None: ... def setActiveOutput(self, name: str) -> None: ... def activeOutput(self) -> str: ... def defaultOutput(self) -> str: ... @@ -534,8 +548,9 @@ class QAudioOutputSelectorControl(QMediaControl): class QAudioProbe(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - flush: typing.ClassVar[QtCore.pyqtSignal] - audioBufferProbed: typing.ClassVar[QtCore.pyqtSignal] + + def flush(self) -> None: ... + def audioBufferProbed(self, audioBuffer: QAudioBuffer) -> None: ... def isActive(self) -> bool: ... @typing.overload def setSource(self, source: QMediaObject) -> bool: ... @@ -598,16 +613,22 @@ class QMediaRecorder(QtCore.QObject, QMediaBindableInterface): def __init__(self, mediaObject: QMediaObject, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, object: QMediaObject) -> bool: ... - availabilityChanged: typing.ClassVar[QtCore.pyqtSignal] - metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] - metaDataWritableChanged: typing.ClassVar[QtCore.pyqtSignal] - metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] - actualLocationChanged: typing.ClassVar[QtCore.pyqtSignal] - volumeChanged: typing.ClassVar[QtCore.pyqtSignal] - mutedChanged: typing.ClassVar[QtCore.pyqtSignal] - durationChanged: typing.ClassVar[QtCore.pyqtSignal] - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def availabilityChanged(self, availability: 'QMultimedia.AvailabilityStatus') -> None: ... + @typing.overload + def availabilityChanged(self, available: bool) -> None: ... + @typing.overload + def metaDataChanged(self, key: str, value: typing.Any) -> None: ... + @typing.overload + def metaDataChanged(self) -> None: ... + def metaDataWritableChanged(self, writable: bool) -> None: ... + def metaDataAvailableChanged(self, available: bool) -> None: ... + def actualLocationChanged(self, location: QtCore.QUrl) -> None: ... + def volumeChanged(self, volume: float) -> None: ... + def mutedChanged(self, muted: bool) -> None: ... + def durationChanged(self, duration: int) -> None: ... + def statusChanged(self, status: 'QMediaRecorder.Status') -> None: ... + def stateChanged(self, state: 'QMediaRecorder.State') -> None: ... def setVolume(self, volume: float) -> None: ... def setMuted(self, muted: bool) -> None: ... def stop(self) -> None: ... @@ -638,7 +659,10 @@ class QMediaRecorder(QtCore.QObject, QMediaBindableInterface): def isMuted(self) -> bool: ... def duration(self) -> int: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QMediaRecorder.Error': ... + @typing.overload + def error(self, error: 'QMediaRecorder.Error') -> None: ... def status(self) -> 'QMediaRecorder.Status': ... def state(self) -> 'QMediaRecorder.State': ... def actualLocation(self) -> QtCore.QUrl: ... @@ -652,8 +676,9 @@ class QMediaRecorder(QtCore.QObject, QMediaBindableInterface): class QAudioRecorder(QMediaRecorder): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - availableAudioInputsChanged: typing.ClassVar[QtCore.pyqtSignal] - audioInputChanged: typing.ClassVar[QtCore.pyqtSignal] + + def availableAudioInputsChanged(self) -> None: ... + def audioInputChanged(self, name: str) -> None: ... def setAudioInput(self, name: str) -> None: ... def audioInput(self) -> str: ... def audioInputDescription(self, name: str) -> str: ... @@ -664,7 +689,8 @@ class QAudioRecorder(QMediaRecorder): class QAudioRoleControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - audioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + + def audioRoleChanged(self, role: QAudio.Role) -> None: ... def supportedAudioRoles(self) -> typing.List[QAudio.Role]: ... def setAudioRole(self, role: QAudio.Role) -> None: ... def audioRole(self) -> QAudio.Role: ... @@ -823,13 +849,16 @@ class QCamera(QMediaObject): def supportedViewfinderSettings(self, settings: 'QCameraViewfinderSettings' = ...) -> typing.List['QCameraViewfinderSettings']: ... def setViewfinderSettings(self, settings: 'QCameraViewfinderSettings') -> None: ... def viewfinderSettings(self) -> 'QCameraViewfinderSettings': ... - errorOccurred: typing.ClassVar[QtCore.pyqtSignal] - lockStatusChanged: typing.ClassVar[QtCore.pyqtSignal] - lockFailed: typing.ClassVar[QtCore.pyqtSignal] - locked: typing.ClassVar[QtCore.pyqtSignal] - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - captureModeChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] + def errorOccurred(self, a0: 'QCamera.Error') -> None: ... + @typing.overload + def lockStatusChanged(self, a0: 'QCamera.LockStatus', a1: 'QCamera.LockChangeReason') -> None: ... + @typing.overload + def lockStatusChanged(self, a0: 'QCamera.LockType', a1: 'QCamera.LockStatus', a2: 'QCamera.LockChangeReason') -> None: ... + def lockFailed(self) -> None: ... + def locked(self) -> None: ... + def statusChanged(self, a0: 'QCamera.Status') -> None: ... + def captureModeChanged(self, a0: typing.Union['QCamera.CaptureModes', 'QCamera.CaptureMode']) -> None: ... + def stateChanged(self, a0: 'QCamera.State') -> None: ... @typing.overload def unlock(self) -> None: ... @typing.overload @@ -850,7 +879,10 @@ class QCamera(QMediaObject): def requestedLocks(self) -> 'QCamera.LockTypes': ... def supportedLocks(self) -> 'QCamera.LockTypes': ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QCamera.Error': ... + @typing.overload + def error(self, a0: 'QCamera.Error') -> None: ... @typing.overload def setViewfinder(self, viewfinder: QtMultimediaWidgets.QVideoWidget) -> None: ... @typing.overload @@ -874,7 +906,8 @@ class QCamera(QMediaObject): class QCameraCaptureBufferFormatControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - bufferFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + + def bufferFormatChanged(self, format: 'QVideoFrame.PixelFormat') -> None: ... def setBufferFormat(self, format: 'QVideoFrame.PixelFormat') -> None: ... def bufferFormat(self) -> 'QVideoFrame.PixelFormat': ... def supportedBufferFormats(self) -> typing.List['QVideoFrame.PixelFormat']: ... @@ -883,7 +916,8 @@ class QCameraCaptureBufferFormatControl(QMediaControl): class QCameraCaptureDestinationControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - captureDestinationChanged: typing.ClassVar[QtCore.pyqtSignal] + + def captureDestinationChanged(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... def setCaptureDestination(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... def captureDestination(self) -> 'QCameraImageCapture.CaptureDestinations': ... def isCaptureDestinationSupported(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> bool: ... @@ -905,10 +939,11 @@ class QCameraControl(QMediaControl): ViewfinderSettings = ... # type: QCameraControl.PropertyChangeType def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - captureModeChanged: typing.ClassVar[QtCore.pyqtSignal] - error: typing.ClassVar[QtCore.pyqtSignal] - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] + + def captureModeChanged(self, mode: typing.Union[QCamera.CaptureModes, QCamera.CaptureMode]) -> None: ... + def error(self, error: int, errorString: str) -> None: ... + def statusChanged(self, a0: QCamera.Status) -> None: ... + def stateChanged(self, a0: QCamera.State) -> None: ... def canChangeProperty(self, changeType: 'QCameraControl.PropertyChangeType', status: QCamera.Status) -> bool: ... def isCaptureModeSupported(self, mode: typing.Union[QCamera.CaptureModes, QCamera.CaptureMode]) -> bool: ... def setCaptureMode(self, a0: typing.Union[QCamera.CaptureModes, QCamera.CaptureMode]) -> None: ... @@ -1013,13 +1048,14 @@ class QCameraExposure(QtCore.QObject): def __invert__(self) -> 'QCameraExposure.FlashModes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - exposureCompensationChanged: typing.ClassVar[QtCore.pyqtSignal] - isoSensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] - shutterSpeedRangeChanged: typing.ClassVar[QtCore.pyqtSignal] - shutterSpeedChanged: typing.ClassVar[QtCore.pyqtSignal] - apertureRangeChanged: typing.ClassVar[QtCore.pyqtSignal] - apertureChanged: typing.ClassVar[QtCore.pyqtSignal] - flashReady: typing.ClassVar[QtCore.pyqtSignal] + + def exposureCompensationChanged(self, a0: float) -> None: ... + def isoSensitivityChanged(self, a0: int) -> None: ... + def shutterSpeedRangeChanged(self) -> None: ... + def shutterSpeedChanged(self, a0: float) -> None: ... + def apertureRangeChanged(self) -> None: ... + def apertureChanged(self, a0: float) -> None: ... + def flashReady(self, a0: bool) -> None: ... def setAutoShutterSpeed(self) -> None: ... def setManualShutterSpeed(self, seconds: float) -> None: ... def setAutoAperture(self) -> None: ... @@ -1080,9 +1116,10 @@ class QCameraExposureControl(QMediaControl): ExtendedExposureParameter = ... # type: QCameraExposureControl.ExposureParameter def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - parameterRangeChanged: typing.ClassVar[QtCore.pyqtSignal] - actualValueChanged: typing.ClassVar[QtCore.pyqtSignal] - requestedValueChanged: typing.ClassVar[QtCore.pyqtSignal] + + def parameterRangeChanged(self, parameter: int) -> None: ... + def actualValueChanged(self, parameter: int) -> None: ... + def requestedValueChanged(self, parameter: int) -> None: ... def setValue(self, parameter: 'QCameraExposureControl.ExposureParameter', value: typing.Any) -> bool: ... def actualValue(self, parameter: 'QCameraExposureControl.ExposureParameter') -> typing.Any: ... def requestedValue(self, parameter: 'QCameraExposureControl.ExposureParameter') -> typing.Any: ... @@ -1129,7 +1166,8 @@ class QCameraFeedbackControl(QMediaControl): class QCameraFlashControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - flashReady: typing.ClassVar[QtCore.pyqtSignal] + + def flashReady(self, a0: bool) -> None: ... def isFlashReady(self) -> bool: ... def isFlashModeSupported(self, mode: typing.Union[QCameraExposure.FlashModes, QCameraExposure.FlashMode]) -> bool: ... def setFlashMode(self, mode: typing.Union[QCameraExposure.FlashModes, QCameraExposure.FlashMode]) -> None: ... @@ -1198,11 +1236,12 @@ class QCameraFocus(QtCore.QObject): def __invert__(self) -> 'QCameraFocus.FocusModes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - maximumDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] - maximumOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] - focusZonesChanged: typing.ClassVar[QtCore.pyqtSignal] - digitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] - opticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + + def maximumDigitalZoomChanged(self, a0: float) -> None: ... + def maximumOpticalZoomChanged(self, a0: float) -> None: ... + def focusZonesChanged(self) -> None: ... + def digitalZoomChanged(self, a0: float) -> None: ... + def opticalZoomChanged(self, a0: float) -> None: ... def zoomTo(self, opticalZoom: float, digitalZoom: float) -> None: ... def digitalZoom(self) -> float: ... def opticalZoom(self) -> float: ... @@ -1223,10 +1262,11 @@ class QCameraFocus(QtCore.QObject): class QCameraFocusControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - focusZonesChanged: typing.ClassVar[QtCore.pyqtSignal] - customFocusPointChanged: typing.ClassVar[QtCore.pyqtSignal] - focusPointModeChanged: typing.ClassVar[QtCore.pyqtSignal] - focusModeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def focusZonesChanged(self) -> None: ... + def customFocusPointChanged(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def focusPointModeChanged(self, mode: QCameraFocus.FocusPointMode) -> None: ... + def focusModeChanged(self, mode: typing.Union[QCameraFocus.FocusModes, QCameraFocus.FocusMode]) -> None: ... def focusZones(self) -> typing.List[QCameraFocusZone]: ... def setCustomFocusPoint(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... def customFocusPoint(self) -> QtCore.QPointF: ... @@ -1285,14 +1325,14 @@ class QCameraImageCapture(QtCore.QObject, QMediaBindableInterface): def __init__(self, mediaObject: QMediaObject, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, a0: QMediaObject) -> bool: ... - imageSaved: typing.ClassVar[QtCore.pyqtSignal] - imageAvailable: typing.ClassVar[QtCore.pyqtSignal] - imageMetadataAvailable: typing.ClassVar[QtCore.pyqtSignal] - imageCaptured: typing.ClassVar[QtCore.pyqtSignal] - imageExposed: typing.ClassVar[QtCore.pyqtSignal] - captureDestinationChanged: typing.ClassVar[QtCore.pyqtSignal] - bufferFormatChanged: typing.ClassVar[QtCore.pyqtSignal] - readyForCaptureChanged: typing.ClassVar[QtCore.pyqtSignal] + def imageSaved(self, id: int, fileName: str) -> None: ... + def imageAvailable(self, id: int, image: 'QVideoFrame') -> None: ... + def imageMetadataAvailable(self, id: int, key: str, value: typing.Any) -> None: ... + def imageCaptured(self, id: int, preview: QtGui.QImage) -> None: ... + def imageExposed(self, id: int) -> None: ... + def captureDestinationChanged(self, a0: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... + def bufferFormatChanged(self, a0: 'QVideoFrame.PixelFormat') -> None: ... + def readyForCaptureChanged(self, a0: bool) -> None: ... def cancelCapture(self) -> None: ... def capture(self, file: str = ...) -> int: ... def setCaptureDestination(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... @@ -1308,7 +1348,10 @@ class QCameraImageCapture(QtCore.QObject, QMediaBindableInterface): def supportedImageCodecs(self) -> typing.List[str]: ... def isReadyForCapture(self) -> bool: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QCameraImageCapture.Error': ... + @typing.overload + def error(self, id: int, error: 'QCameraImageCapture.Error', errorString: str) -> None: ... def mediaObject(self) -> QMediaObject: ... def availability(self) -> 'QMultimedia.AvailabilityStatus': ... def isAvailable(self) -> bool: ... @@ -1317,13 +1360,14 @@ class QCameraImageCapture(QtCore.QObject, QMediaBindableInterface): class QCameraImageCaptureControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - error: typing.ClassVar[QtCore.pyqtSignal] - imageSaved: typing.ClassVar[QtCore.pyqtSignal] - imageAvailable: typing.ClassVar[QtCore.pyqtSignal] - imageMetadataAvailable: typing.ClassVar[QtCore.pyqtSignal] - imageCaptured: typing.ClassVar[QtCore.pyqtSignal] - imageExposed: typing.ClassVar[QtCore.pyqtSignal] - readyForCaptureChanged: typing.ClassVar[QtCore.pyqtSignal] + + def error(self, id: int, error: int, errorString: str) -> None: ... + def imageSaved(self, requestId: int, fileName: str) -> None: ... + def imageAvailable(self, requestId: int, buffer: 'QVideoFrame') -> None: ... + def imageMetadataAvailable(self, id: int, key: str, value: typing.Any) -> None: ... + def imageCaptured(self, requestId: int, preview: QtGui.QImage) -> None: ... + def imageExposed(self, requestId: int) -> None: ... + def readyForCaptureChanged(self, ready: bool) -> None: ... def cancelCapture(self) -> None: ... def capture(self, fileName: str) -> int: ... def setDriveMode(self, mode: QCameraImageCapture.DriveMode) -> None: ... @@ -1472,7 +1516,8 @@ class QCameraInfoControl(QMediaControl): class QCameraLocksControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - lockStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + + def lockStatusChanged(self, type: QCamera.LockType, status: QCamera.LockStatus, reason: QCamera.LockChangeReason) -> None: ... def unlock(self, locks: typing.Union[QCamera.LockTypes, QCamera.LockType]) -> None: ... def searchAndLock(self, locks: typing.Union[QCamera.LockTypes, QCamera.LockType]) -> None: ... def lockStatus(self, lock: QCamera.LockType) -> QCamera.LockStatus: ... @@ -1542,12 +1587,13 @@ class QCameraViewfinderSettingsControl2(QMediaControl): class QCameraZoomControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - currentDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] - currentOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] - requestedDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] - requestedOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] - maximumDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] - maximumOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + + def currentDigitalZoomChanged(self, digitalZoom: float) -> None: ... + def currentOpticalZoomChanged(self, opticalZoom: float) -> None: ... + def requestedDigitalZoomChanged(self, digitalZoom: float) -> None: ... + def requestedOpticalZoomChanged(self, opticalZoom: float) -> None: ... + def maximumDigitalZoomChanged(self, a0: float) -> None: ... + def maximumOpticalZoomChanged(self, a0: float) -> None: ... def zoomTo(self, optical: float, digital: float) -> None: ... def currentDigitalZoom(self) -> float: ... def currentOpticalZoom(self) -> float: ... @@ -1560,7 +1606,8 @@ class QCameraZoomControl(QMediaControl): class QCustomAudioRoleControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - customAudioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + + def customAudioRoleChanged(self, role: str) -> None: ... def supportedCustomAudioRoles(self) -> typing.List[str]: ... def setCustomAudioRole(self, role: str) -> None: ... def customAudioRole(self) -> str: ... @@ -1580,14 +1627,16 @@ class QImageEncoderControl(QMediaControl): class QMediaAudioProbeControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - flush: typing.ClassVar[QtCore.pyqtSignal] - audioBufferProbed: typing.ClassVar[QtCore.pyqtSignal] + + def flush(self) -> None: ... + def audioBufferProbed(self, buffer: QAudioBuffer) -> None: ... class QMediaAvailabilityControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - availabilityChanged: typing.ClassVar[QtCore.pyqtSignal] + + def availabilityChanged(self, availability: 'QMultimedia.AvailabilityStatus') -> None: ... def availability(self) -> 'QMultimedia.AvailabilityStatus': ... @@ -1708,9 +1757,10 @@ class QImageEncoderSettings(sip.simplewrapper): class QMediaGaplessPlaybackControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - advancedToNextMedia: typing.ClassVar[QtCore.pyqtSignal] - nextMediaChanged: typing.ClassVar[QtCore.pyqtSignal] - crossfadeTimeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def advancedToNextMedia(self) -> None: ... + def nextMediaChanged(self, media: QMediaContent) -> None: ... + def crossfadeTimeChanged(self, crossfadeTime: float) -> None: ... def setCrossfadeTime(self, crossfadeTime: float) -> None: ... def crossfadeTime(self) -> float: ... def isCrossfadeSupported(self) -> bool: ... @@ -1816,7 +1866,8 @@ class QMediaMetaData(sip.simplewrapper): class QMediaNetworkAccessControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - configurationChanged: typing.ClassVar[QtCore.pyqtSignal] + + def configurationChanged(self, configuration: QtNetwork.QNetworkConfiguration) -> None: ... def currentConfiguration(self) -> QtNetwork.QNetworkConfiguration: ... def setConfigurations(self, configuration: typing.Iterable[QtNetwork.QNetworkConfiguration]) -> None: ... @@ -1893,30 +1944,31 @@ class QMediaPlayer(QMediaObject): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ..., flags: typing.Union['QMediaPlayer.Flags', 'QMediaPlayer.Flag'] = ...) -> None: ... - customAudioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + + def customAudioRoleChanged(self, role: str) -> None: ... def supportedCustomAudioRoles(self) -> typing.List[str]: ... def setCustomAudioRole(self, audioRole: str) -> None: ... def customAudioRole(self) -> str: ... - audioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + def audioRoleChanged(self, role: QAudio.Role) -> None: ... def supportedAudioRoles(self) -> typing.List[QAudio.Role]: ... def setAudioRole(self, audioRole: QAudio.Role) -> None: ... def audioRole(self) -> QAudio.Role: ... def unbind(self, a0: QtCore.QObject) -> None: ... def bind(self, a0: QtCore.QObject) -> bool: ... - networkConfigurationChanged: typing.ClassVar[QtCore.pyqtSignal] - playbackRateChanged: typing.ClassVar[QtCore.pyqtSignal] - seekableChanged: typing.ClassVar[QtCore.pyqtSignal] - bufferStatusChanged: typing.ClassVar[QtCore.pyqtSignal] - videoAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] - audioAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] - mutedChanged: typing.ClassVar[QtCore.pyqtSignal] - volumeChanged: typing.ClassVar[QtCore.pyqtSignal] - positionChanged: typing.ClassVar[QtCore.pyqtSignal] - durationChanged: typing.ClassVar[QtCore.pyqtSignal] - mediaStatusChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - currentMediaChanged: typing.ClassVar[QtCore.pyqtSignal] - mediaChanged: typing.ClassVar[QtCore.pyqtSignal] + def networkConfigurationChanged(self, configuration: QtNetwork.QNetworkConfiguration) -> None: ... + def playbackRateChanged(self, rate: float) -> None: ... + def seekableChanged(self, seekable: bool) -> None: ... + def bufferStatusChanged(self, percentFilled: int) -> None: ... + def videoAvailableChanged(self, videoAvailable: bool) -> None: ... + def audioAvailableChanged(self, available: bool) -> None: ... + def mutedChanged(self, muted: bool) -> None: ... + def volumeChanged(self, volume: int) -> None: ... + def positionChanged(self, position: int) -> None: ... + def durationChanged(self, duration: int) -> None: ... + def mediaStatusChanged(self, status: 'QMediaPlayer.MediaStatus') -> None: ... + def stateChanged(self, newState: 'QMediaPlayer.State') -> None: ... + def currentMediaChanged(self, media: QMediaContent) -> None: ... + def mediaChanged(self, media: QMediaContent) -> None: ... def setNetworkConfigurations(self, configurations: typing.Iterable[QtNetwork.QNetworkConfiguration]) -> None: ... def setPlaylist(self, playlist: 'QMediaPlaylist') -> None: ... def setMedia(self, media: QMediaContent, stream: typing.Optional[QtCore.QIODevice] = ...) -> None: ... @@ -1930,7 +1982,10 @@ class QMediaPlayer(QMediaObject): def availability(self) -> 'QMultimedia.AvailabilityStatus': ... def currentNetworkConfiguration(self) -> QtNetwork.QNetworkConfiguration: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QMediaPlayer.Error': ... + @typing.overload + def error(self, error: 'QMediaPlayer.Error') -> None: ... def playbackRate(self) -> float: ... def isSeekable(self) -> bool: ... def bufferStatus(self) -> int: ... @@ -1963,20 +2018,21 @@ class QMediaPlayer(QMediaObject): class QMediaPlayerControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - error: typing.ClassVar[QtCore.pyqtSignal] - playbackRateChanged: typing.ClassVar[QtCore.pyqtSignal] - availablePlaybackRangesChanged: typing.ClassVar[QtCore.pyqtSignal] - seekableChanged: typing.ClassVar[QtCore.pyqtSignal] - bufferStatusChanged: typing.ClassVar[QtCore.pyqtSignal] - videoAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] - audioAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] - mutedChanged: typing.ClassVar[QtCore.pyqtSignal] - volumeChanged: typing.ClassVar[QtCore.pyqtSignal] - mediaStatusChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - positionChanged: typing.ClassVar[QtCore.pyqtSignal] - durationChanged: typing.ClassVar[QtCore.pyqtSignal] - mediaChanged: typing.ClassVar[QtCore.pyqtSignal] + + def error(self, error: int, errorString: str) -> None: ... + def playbackRateChanged(self, rate: float) -> None: ... + def availablePlaybackRangesChanged(self, ranges: 'QMediaTimeRange') -> None: ... + def seekableChanged(self, seekable: bool) -> None: ... + def bufferStatusChanged(self, percentFilled: int) -> None: ... + def videoAvailableChanged(self, videoAvailable: bool) -> None: ... + def audioAvailableChanged(self, audioAvailable: bool) -> None: ... + def mutedChanged(self, mute: bool) -> None: ... + def volumeChanged(self, volume: int) -> None: ... + def mediaStatusChanged(self, status: QMediaPlayer.MediaStatus) -> None: ... + def stateChanged(self, newState: QMediaPlayer.State) -> None: ... + def positionChanged(self, position: int) -> None: ... + def durationChanged(self, duration: int) -> None: ... + def mediaChanged(self, content: QMediaContent) -> None: ... def stop(self) -> None: ... def pause(self) -> None: ... def play(self) -> None: ... @@ -2032,16 +2088,16 @@ class QMediaPlaylist(QtCore.QObject, QMediaBindableInterface): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, object: QMediaObject) -> bool: ... - loadFailed: typing.ClassVar[QtCore.pyqtSignal] - loaded: typing.ClassVar[QtCore.pyqtSignal] - mediaChanged: typing.ClassVar[QtCore.pyqtSignal] - mediaRemoved: typing.ClassVar[QtCore.pyqtSignal] - mediaAboutToBeRemoved: typing.ClassVar[QtCore.pyqtSignal] - mediaInserted: typing.ClassVar[QtCore.pyqtSignal] - mediaAboutToBeInserted: typing.ClassVar[QtCore.pyqtSignal] - currentMediaChanged: typing.ClassVar[QtCore.pyqtSignal] - playbackModeChanged: typing.ClassVar[QtCore.pyqtSignal] - currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] + def loadFailed(self) -> None: ... + def loaded(self) -> None: ... + def mediaChanged(self, start: int, end: int) -> None: ... + def mediaRemoved(self, start: int, end: int) -> None: ... + def mediaAboutToBeRemoved(self, start: int, end: int) -> None: ... + def mediaInserted(self, start: int, end: int) -> None: ... + def mediaAboutToBeInserted(self, start: int, end: int) -> None: ... + def currentMediaChanged(self, a0: QMediaContent) -> None: ... + def playbackModeChanged(self, mode: 'QMediaPlaylist.PlaybackMode') -> None: ... + def currentIndexChanged(self, index: int) -> None: ... def setCurrentIndex(self, index: int) -> None: ... def previous(self) -> None: ... def next(self) -> None: ... @@ -2092,13 +2148,13 @@ class QMediaRecorderControl(QMediaControl): def setVolume(self, volume: float) -> None: ... def setMuted(self, muted: bool) -> None: ... def setState(self, state: QMediaRecorder.State) -> None: ... - error: typing.ClassVar[QtCore.pyqtSignal] - actualLocationChanged: typing.ClassVar[QtCore.pyqtSignal] - volumeChanged: typing.ClassVar[QtCore.pyqtSignal] - mutedChanged: typing.ClassVar[QtCore.pyqtSignal] - durationChanged: typing.ClassVar[QtCore.pyqtSignal] - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] + def error(self, error: int, errorString: str) -> None: ... + def actualLocationChanged(self, location: QtCore.QUrl) -> None: ... + def volumeChanged(self, volume: float) -> None: ... + def mutedChanged(self, muted: bool) -> None: ... + def durationChanged(self, position: int) -> None: ... + def statusChanged(self, status: QMediaRecorder.Status) -> None: ... + def stateChanged(self, state: QMediaRecorder.State) -> None: ... def applySettings(self) -> None: ... def volume(self) -> float: ... def isMuted(self) -> bool: ... @@ -2171,8 +2227,9 @@ class QMediaStreamsControl(QMediaControl): DataStream = ... # type: QMediaStreamsControl.StreamType def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - activeStreamsChanged: typing.ClassVar[QtCore.pyqtSignal] - streamsChanged: typing.ClassVar[QtCore.pyqtSignal] + + def activeStreamsChanged(self) -> None: ... + def streamsChanged(self) -> None: ... def setActive(self, streamNumber: int, state: bool) -> None: ... def isActive(self, streamNumber: int) -> bool: ... def metaData(self, streamNumber: int, key: str) -> typing.Any: ... @@ -2230,15 +2287,20 @@ class QMediaTimeRange(sip.simplewrapper): class QMediaVideoProbeControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - flush: typing.ClassVar[QtCore.pyqtSignal] - videoFrameProbed: typing.ClassVar[QtCore.pyqtSignal] + + def flush(self) -> None: ... + def videoFrameProbed(self, frame: 'QVideoFrame') -> None: ... class QMetaDataReaderControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] - metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] + + def metaDataAvailableChanged(self, available: bool) -> None: ... + @typing.overload + def metaDataChanged(self) -> None: ... + @typing.overload + def metaDataChanged(self, key: str, value: typing.Any) -> None: ... def availableMetaData(self) -> typing.List[str]: ... def metaData(self, key: str) -> typing.Any: ... def isMetaDataAvailable(self) -> bool: ... @@ -2247,9 +2309,13 @@ class QMetaDataReaderControl(QMediaControl): class QMetaDataWriterControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] - writableChanged: typing.ClassVar[QtCore.pyqtSignal] - metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] + + def metaDataAvailableChanged(self, available: bool) -> None: ... + def writableChanged(self, writable: bool) -> None: ... + @typing.overload + def metaDataChanged(self) -> None: ... + @typing.overload + def metaDataChanged(self, key: str, value: typing.Any) -> None: ... def availableMetaData(self) -> typing.List[str]: ... def setMetaData(self, key: str, value: typing.Any) -> None: ... def metaData(self, key: str) -> typing.Any: ... @@ -2421,15 +2487,18 @@ class QRadioData(QtCore.QObject, QMediaBindableInterface): def __init__(self, mediaObject: QMediaObject, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, a0: QMediaObject) -> bool: ... - alternativeFrequenciesEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - radioTextChanged: typing.ClassVar[QtCore.pyqtSignal] - stationNameChanged: typing.ClassVar[QtCore.pyqtSignal] - programTypeNameChanged: typing.ClassVar[QtCore.pyqtSignal] - programTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - stationIdChanged: typing.ClassVar[QtCore.pyqtSignal] + def alternativeFrequenciesEnabledChanged(self, enabled: bool) -> None: ... + def radioTextChanged(self, radioText: str) -> None: ... + def stationNameChanged(self, stationName: str) -> None: ... + def programTypeNameChanged(self, programTypeName: str) -> None: ... + def programTypeChanged(self, programType: 'QRadioData.ProgramType') -> None: ... + def stationIdChanged(self, stationId: str) -> None: ... def setAlternativeFrequenciesEnabled(self, enabled: bool) -> None: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QRadioData.Error': ... + @typing.overload + def error(self, error: 'QRadioData.Error') -> None: ... def isAlternativeFrequenciesEnabled(self) -> bool: ... def radioText(self) -> str: ... def stationName(self) -> str: ... @@ -2443,14 +2512,18 @@ class QRadioData(QtCore.QObject, QMediaBindableInterface): class QRadioDataControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - alternativeFrequenciesEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - radioTextChanged: typing.ClassVar[QtCore.pyqtSignal] - stationNameChanged: typing.ClassVar[QtCore.pyqtSignal] - programTypeNameChanged: typing.ClassVar[QtCore.pyqtSignal] - programTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - stationIdChanged: typing.ClassVar[QtCore.pyqtSignal] + + def alternativeFrequenciesEnabledChanged(self, enabled: bool) -> None: ... + def radioTextChanged(self, radioText: str) -> None: ... + def stationNameChanged(self, stationName: str) -> None: ... + def programTypeNameChanged(self, programTypeName: str) -> None: ... + def programTypeChanged(self, programType: QRadioData.ProgramType) -> None: ... + def stationIdChanged(self, stationId: str) -> None: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> QRadioData.Error: ... + @typing.overload + def error(self, err: QRadioData.Error) -> None: ... def isAlternativeFrequenciesEnabled(self) -> bool: ... def setAlternativeFrequenciesEnabled(self, enabled: bool) -> None: ... def radioText(self) -> str: ... @@ -2510,16 +2583,17 @@ class QRadioTuner(QMediaObject): StoppedState = ... # type: QRadioTuner.State def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - antennaConnectedChanged: typing.ClassVar[QtCore.pyqtSignal] - stationFound: typing.ClassVar[QtCore.pyqtSignal] - mutedChanged: typing.ClassVar[QtCore.pyqtSignal] - volumeChanged: typing.ClassVar[QtCore.pyqtSignal] - signalStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] - searchingChanged: typing.ClassVar[QtCore.pyqtSignal] - stereoStatusChanged: typing.ClassVar[QtCore.pyqtSignal] - frequencyChanged: typing.ClassVar[QtCore.pyqtSignal] - bandChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] + + def antennaConnectedChanged(self, connectionStatus: bool) -> None: ... + def stationFound(self, frequency: int, stationId: str) -> None: ... + def mutedChanged(self, muted: bool) -> None: ... + def volumeChanged(self, volume: int) -> None: ... + def signalStrengthChanged(self, signalStrength: int) -> None: ... + def searchingChanged(self, searching: bool) -> None: ... + def stereoStatusChanged(self, stereo: bool) -> None: ... + def frequencyChanged(self, frequency: int) -> None: ... + def bandChanged(self, band: 'QRadioTuner.Band') -> None: ... + def stateChanged(self, state: 'QRadioTuner.State') -> None: ... def stop(self) -> None: ... def start(self) -> None: ... def setMuted(self, muted: bool) -> None: ... @@ -2532,7 +2606,10 @@ class QRadioTuner(QMediaObject): def searchForward(self) -> None: ... def radioData(self) -> QRadioData: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QRadioTuner.Error': ... + @typing.overload + def error(self, error: 'QRadioTuner.Error') -> None: ... def isAntennaConnected(self) -> bool: ... def isSearching(self) -> bool: ... def isMuted(self) -> bool: ... @@ -2553,18 +2630,22 @@ class QRadioTuner(QMediaObject): class QRadioTunerControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - antennaConnectedChanged: typing.ClassVar[QtCore.pyqtSignal] - stationFound: typing.ClassVar[QtCore.pyqtSignal] - mutedChanged: typing.ClassVar[QtCore.pyqtSignal] - volumeChanged: typing.ClassVar[QtCore.pyqtSignal] - signalStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] - searchingChanged: typing.ClassVar[QtCore.pyqtSignal] - stereoStatusChanged: typing.ClassVar[QtCore.pyqtSignal] - frequencyChanged: typing.ClassVar[QtCore.pyqtSignal] - bandChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] + + def antennaConnectedChanged(self, connectionStatus: bool) -> None: ... + def stationFound(self, frequency: int, stationId: str) -> None: ... + def mutedChanged(self, muted: bool) -> None: ... + def volumeChanged(self, volume: int) -> None: ... + def signalStrengthChanged(self, signalStrength: int) -> None: ... + def searchingChanged(self, searching: bool) -> None: ... + def stereoStatusChanged(self, stereo: bool) -> None: ... + def frequencyChanged(self, frequency: int) -> None: ... + def bandChanged(self, band: QRadioTuner.Band) -> None: ... + def stateChanged(self, state: QRadioTuner.State) -> None: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> QRadioTuner.Error: ... + @typing.overload + def error(self, err: QRadioTuner.Error) -> None: ... def stop(self) -> None: ... def start(self) -> None: ... def cancelSearch(self) -> None: ... @@ -2638,15 +2719,15 @@ class QSoundEffect(QtCore.QObject): def stop(self) -> None: ... def play(self) -> None: ... - categoryChanged: typing.ClassVar[QtCore.pyqtSignal] - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - playingChanged: typing.ClassVar[QtCore.pyqtSignal] - loadedChanged: typing.ClassVar[QtCore.pyqtSignal] - mutedChanged: typing.ClassVar[QtCore.pyqtSignal] - volumeChanged: typing.ClassVar[QtCore.pyqtSignal] - loopsRemainingChanged: typing.ClassVar[QtCore.pyqtSignal] - loopCountChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + def categoryChanged(self) -> None: ... + def statusChanged(self) -> None: ... + def playingChanged(self) -> None: ... + def loadedChanged(self) -> None: ... + def mutedChanged(self) -> None: ... + def volumeChanged(self) -> None: ... + def loopsRemainingChanged(self) -> None: ... + def loopCountChanged(self) -> None: ... + def sourceChanged(self) -> None: ... def setCategory(self, category: str) -> None: ... def category(self) -> str: ... def status(self) -> 'QSoundEffect.Status': ... @@ -2668,8 +2749,12 @@ class QSoundEffect(QtCore.QObject): class QVideoDeviceSelectorControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - devicesChanged: typing.ClassVar[QtCore.pyqtSignal] - selectedDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] + + def devicesChanged(self) -> None: ... + @typing.overload + def selectedDeviceChanged(self, index: int) -> None: ... + @typing.overload + def selectedDeviceChanged(self, name: str) -> None: ... def setSelectedDevice(self, index: int) -> None: ... def selectedDevice(self) -> int: ... def defaultDevice(self) -> int: ... @@ -2832,8 +2917,9 @@ class QVideoFrame(sip.simplewrapper): class QVideoProbe(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - flush: typing.ClassVar[QtCore.pyqtSignal] - videoFrameProbed: typing.ClassVar[QtCore.pyqtSignal] + + def flush(self) -> None: ... + def videoFrameProbed(self, videoFrame: QVideoFrame) -> None: ... def isActive(self) -> bool: ... @typing.overload def setSource(self, source: QMediaObject) -> bool: ... @@ -2914,12 +3000,13 @@ class QVideoSurfaceFormat(sip.simplewrapper): class QVideoWindowControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - nativeSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - saturationChanged: typing.ClassVar[QtCore.pyqtSignal] - hueChanged: typing.ClassVar[QtCore.pyqtSignal] - contrastChanged: typing.ClassVar[QtCore.pyqtSignal] - brightnessChanged: typing.ClassVar[QtCore.pyqtSignal] - fullScreenChanged: typing.ClassVar[QtCore.pyqtSignal] + + def nativeSizeChanged(self) -> None: ... + def saturationChanged(self, saturation: int) -> None: ... + def hueChanged(self, hue: int) -> None: ... + def contrastChanged(self, contrast: int) -> None: ... + def brightnessChanged(self, brightness: int) -> None: ... + def fullScreenChanged(self, fullScreen: bool) -> None: ... def setSaturation(self, saturation: int) -> None: ... def saturation(self) -> int: ... def setHue(self, hue: int) -> None: ... diff --git a/PyQt5-stubs/QtMultimediaWidgets.pyi b/PyQt5-stubs/QtMultimediaWidgets.pyi index d9b678fb..c7a0cc68 100644 --- a/PyQt5-stubs/QtMultimediaWidgets.pyi +++ b/PyQt5-stubs/QtMultimediaWidgets.pyi @@ -53,11 +53,11 @@ class QVideoWidget(QtWidgets.QWidget, QtMultimedia.QMediaBindableInterface): def hideEvent(self, event: QtGui.QHideEvent) -> None: ... def showEvent(self, event: QtGui.QShowEvent) -> None: ... def event(self, event: QtCore.QEvent) -> bool: ... - saturationChanged: typing.ClassVar[QtCore.pyqtSignal] - hueChanged: typing.ClassVar[QtCore.pyqtSignal] - contrastChanged: typing.ClassVar[QtCore.pyqtSignal] - brightnessChanged: typing.ClassVar[QtCore.pyqtSignal] - fullScreenChanged: typing.ClassVar[QtCore.pyqtSignal] + def saturationChanged(self, saturation: int) -> None: ... + def hueChanged(self, hue: int) -> None: ... + def contrastChanged(self, contrast: int) -> None: ... + def brightnessChanged(self, brightness: int) -> None: ... + def fullScreenChanged(self, fullScreen: bool) -> None: ... def setSaturation(self, saturation: int) -> None: ... def setHue(self, hue: int) -> None: ... def setContrast(self, contrast: int) -> None: ... @@ -89,7 +89,7 @@ class QGraphicsVideoItem(QtWidgets.QGraphicsObject, QtMultimedia.QMediaBindableI def setMediaObject(self, object: QtMultimedia.QMediaObject) -> bool: ... def itemChange(self, change: QtWidgets.QGraphicsItem.GraphicsItemChange, value: typing.Any) -> typing.Any: ... def timerEvent(self, event: QtCore.QTimerEvent) -> None: ... - nativeSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + def nativeSizeChanged(self, size: QtCore.QSizeF) -> None: ... def paint(self, painter: QtGui.QPainter, option: QtWidgets.QStyleOptionGraphicsItem, widget: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... def boundingRect(self) -> QtCore.QRectF: ... def nativeSize(self) -> QtCore.QSizeF: ... @@ -105,11 +105,12 @@ class QGraphicsVideoItem(QtWidgets.QGraphicsObject, QtMultimedia.QMediaBindableI class QVideoWidgetControl(QtMultimedia.QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - saturationChanged: typing.ClassVar[QtCore.pyqtSignal] - hueChanged: typing.ClassVar[QtCore.pyqtSignal] - contrastChanged: typing.ClassVar[QtCore.pyqtSignal] - brightnessChanged: typing.ClassVar[QtCore.pyqtSignal] - fullScreenChanged: typing.ClassVar[QtCore.pyqtSignal] + + def saturationChanged(self, saturation: int) -> None: ... + def hueChanged(self, hue: int) -> None: ... + def contrastChanged(self, contrast: int) -> None: ... + def brightnessChanged(self, brightness: int) -> None: ... + def fullScreenChanged(self, fullScreen: bool) -> None: ... def setSaturation(self, saturation: int) -> None: ... def saturation(self) -> int: ... def setHue(self, hue: int) -> None: ... diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index e7186771..4acd10cb 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -270,12 +270,12 @@ class QAbstractSocket(QtCore.QIODevice): def writeData(self, data: bytes) -> int: ... def readLineData(self, maxlen: int) -> bytes: ... def readData(self, maxlen: int) -> bytes: ... - proxyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] - errorOccurred: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - disconnected: typing.ClassVar[QtCore.pyqtSignal] - connected: typing.ClassVar[QtCore.pyqtSignal] - hostFound: typing.ClassVar[QtCore.pyqtSignal] + def proxyAuthenticationRequired(self, proxy: 'QNetworkProxy', authenticator: 'QAuthenticator') -> None: ... + def errorOccurred(self, a0: 'QAbstractSocket.SocketError') -> None: ... + def stateChanged(self, a0: 'QAbstractSocket.SocketState') -> None: ... + def disconnected(self) -> None: ... + def connected(self) -> None: ... + def hostFound(self) -> None: ... def proxy(self) -> 'QNetworkProxy': ... def setProxy(self, networkProxy: 'QNetworkProxy') -> None: ... def waitForDisconnected(self, msecs: int = ...) -> bool: ... @@ -286,7 +286,10 @@ class QAbstractSocket(QtCore.QIODevice): def atEnd(self) -> bool: ... def isSequential(self) -> bool: ... def close(self) -> None: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QAbstractSocket.SocketError': ... + @typing.overload + def error(self, a0: 'QAbstractSocket.SocketError') -> None: ... def state(self) -> 'QAbstractSocket.SocketState': ... def socketType(self) -> 'QAbstractSocket.SocketType': ... def socketDescriptor(self) -> sip.voidptr: ... @@ -445,12 +448,13 @@ class QDnsLookup(QtCore.QObject): def __init__(self, type: 'QDnsLookup.Type', name: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, type: 'QDnsLookup.Type', name: str, nameserver: typing.Union['QHostAddress', 'QHostAddress.SpecialAddress'], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - nameserverChanged: typing.ClassVar[QtCore.pyqtSignal] + + def nameserverChanged(self, nameserver: typing.Union['QHostAddress', 'QHostAddress.SpecialAddress']) -> None: ... def setNameserver(self, nameserver: typing.Union['QHostAddress', 'QHostAddress.SpecialAddress']) -> None: ... def nameserver(self) -> 'QHostAddress': ... - typeChanged: typing.ClassVar[QtCore.pyqtSignal] - nameChanged: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + def typeChanged(self, type: 'QDnsLookup.Type') -> None: ... + def nameChanged(self, name: str) -> None: ... + def finished(self) -> None: ... def lookup(self) -> None: ... def abort(self) -> None: ... def textRecords(self) -> typing.List[QDnsTextRecord]: ... @@ -735,7 +739,7 @@ class QLocalServer(QtCore.QObject): def socketOptions(self) -> 'QLocalServer.SocketOptions': ... def setSocketOptions(self, options: typing.Union['QLocalServer.SocketOptions', 'QLocalServer.SocketOption']) -> None: ... def incomingConnection(self, socketDescriptor: sip.voidptr) -> None: ... - newConnection: typing.ClassVar[QtCore.pyqtSignal] + def newConnection(self) -> None: ... @staticmethod def removeServer(name: str) -> bool: ... def waitForNewConnection(self, msecs: int = ...) -> typing.Tuple[bool, bool]: ... @@ -797,10 +801,10 @@ class QLocalSocket(QtCore.QIODevice): def writeData(self, a0: bytes) -> int: ... def readData(self, maxlen: int) -> bytes: ... - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - errorOccurred: typing.ClassVar[QtCore.pyqtSignal] - disconnected: typing.ClassVar[QtCore.pyqtSignal] - connected: typing.ClassVar[QtCore.pyqtSignal] + def stateChanged(self, socketState: 'QLocalSocket.LocalSocketState') -> None: ... + def errorOccurred(self, socketError: 'QLocalSocket.LocalSocketError') -> None: ... + def disconnected(self) -> None: ... + def connected(self) -> None: ... def waitForReadyRead(self, msecs: int = ...) -> bool: ... def waitForDisconnected(self, msecs: int = ...) -> bool: ... def waitForConnected(self, msecs: int = ...) -> bool: ... @@ -812,7 +816,10 @@ class QLocalSocket(QtCore.QIODevice): def readBufferSize(self) -> int: ... def isValid(self) -> bool: ... def flush(self) -> bool: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QLocalSocket.LocalSocketError': ... + @typing.overload + def error(self, socketError: 'QLocalSocket.LocalSocketError') -> None: ... def close(self) -> None: ... def canReadLine(self) -> bool: ... def bytesToWrite(self) -> int: ... @@ -958,11 +965,12 @@ class QNetworkConfigurationManager(QtCore.QObject): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - updateCompleted: typing.ClassVar[QtCore.pyqtSignal] - onlineStateChanged: typing.ClassVar[QtCore.pyqtSignal] - configurationChanged: typing.ClassVar[QtCore.pyqtSignal] - configurationRemoved: typing.ClassVar[QtCore.pyqtSignal] - configurationAdded: typing.ClassVar[QtCore.pyqtSignal] + + def updateCompleted(self) -> None: ... + def onlineStateChanged(self, isOnline: bool) -> None: ... + def configurationChanged(self, config: 'QNetworkConfiguration') -> None: ... + def configurationRemoved(self, config: 'QNetworkConfiguration') -> None: ... + def configurationAdded(self, config: 'QNetworkConfiguration') -> None: ... def isOnline(self) -> bool: ... def updateConfigurations(self) -> None: ... def configurationFromIdentifier(self, identifier: str) -> 'QNetworkConfiguration': ... @@ -1544,16 +1552,16 @@ class QNetworkReply(QtCore.QIODevice): def setRequest(self, request: 'QNetworkRequest') -> None: ... def setOperation(self, operation: QNetworkAccessManager.Operation) -> None: ... def writeData(self, data: bytes) -> int: ... - redirectAllowed: typing.ClassVar[QtCore.pyqtSignal] - redirected: typing.ClassVar[QtCore.pyqtSignal] - preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] - downloadProgress: typing.ClassVar[QtCore.pyqtSignal] - uploadProgress: typing.ClassVar[QtCore.pyqtSignal] - sslErrors: typing.ClassVar[QtCore.pyqtSignal] - errorOccurred: typing.ClassVar[QtCore.pyqtSignal] - encrypted: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] - metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] + def redirectAllowed(self) -> None: ... + def redirected(self, url: QtCore.QUrl) -> None: ... + def preSharedKeyAuthenticationRequired(self, authenticator: 'QSslPreSharedKeyAuthenticator') -> None: ... + def downloadProgress(self, bytesReceived: int, bytesTotal: int) -> None: ... + def uploadProgress(self, bytesSent: int, bytesTotal: int) -> None: ... + def sslErrors(self, errors: typing.Iterable['QSslError']) -> None: ... + def errorOccurred(self, a0: 'QNetworkReply.NetworkError') -> None: ... + def encrypted(self) -> None: ... + def finished(self) -> None: ... + def metaDataChanged(self) -> None: ... @typing.overload def ignoreSslErrors(self) -> None: ... @typing.overload @@ -1566,7 +1574,10 @@ class QNetworkReply(QtCore.QIODevice): def hasRawHeader(self, headerName: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> bool: ... def header(self, header: 'QNetworkRequest.KnownHeaders') -> typing.Any: ... def url(self) -> QtCore.QUrl: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QNetworkReply.NetworkError': ... + @typing.overload + def error(self, a0: 'QNetworkReply.NetworkError') -> None: ... def request(self) -> 'QNetworkRequest': ... def operation(self) -> QNetworkAccessManager.Operation: ... def manager(self) -> QNetworkAccessManager: ... @@ -1799,15 +1810,16 @@ class QNetworkSession(QtCore.QObject): def __int__(self) -> int: ... def __init__(self, connConfig: QNetworkConfiguration, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - usagePoliciesChanged: typing.ClassVar[QtCore.pyqtSignal] + + def usagePoliciesChanged(self, usagePolicies: typing.Union['QNetworkSession.UsagePolicies', 'QNetworkSession.UsagePolicy']) -> None: ... def usagePolicies(self) -> 'QNetworkSession.UsagePolicies': ... def disconnectNotify(self, signal: QtCore.QMetaMethod) -> None: ... def connectNotify(self, signal: QtCore.QMetaMethod) -> None: ... - newConfigurationActivated: typing.ClassVar[QtCore.pyqtSignal] - preferredConfigurationChanged: typing.ClassVar[QtCore.pyqtSignal] - closed: typing.ClassVar[QtCore.pyqtSignal] - opened: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] + def newConfigurationActivated(self) -> None: ... + def preferredConfigurationChanged(self, config: QNetworkConfiguration, isSeamless: bool) -> None: ... + def closed(self) -> None: ... + def opened(self) -> None: ... + def stateChanged(self, a0: 'QNetworkSession.State') -> None: ... def reject(self) -> None: ... def accept(self) -> None: ... def ignore(self) -> None: ... @@ -1822,7 +1834,10 @@ class QNetworkSession(QtCore.QObject): def setSessionProperty(self, key: str, value: typing.Any) -> None: ... def sessionProperty(self, key: str) -> typing.Any: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QNetworkSession.SessionError': ... + @typing.overload + def error(self, a0: 'QNetworkSession.SessionError') -> None: ... def state(self) -> 'QNetworkSession.State': ... def interface(self) -> QNetworkInterface: ... def configuration(self) -> QNetworkConfiguration: ... @@ -2376,7 +2391,8 @@ class QSslSocket(QTcpSocket): SslServerMode = ... # type: QSslSocket.SslMode def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - newSessionTicketReceived: typing.ClassVar[QtCore.pyqtSignal] + + def newSessionTicketReceived(self) -> None: ... def sslHandshakeErrors(self) -> typing.List[QSslError]: ... def ocspResponses(self) -> typing.List[QOcspResponse]: ... @staticmethod @@ -2397,8 +2413,8 @@ class QSslSocket(QTcpSocket): def peerVerifyName(self) -> str: ... def socketOption(self, option: QAbstractSocket.SocketOption) -> typing.Any: ... def setSocketOption(self, option: QAbstractSocket.SocketOption, value: typing.Any) -> None: ... - encryptedBytesWritten: typing.ClassVar[QtCore.pyqtSignal] - peerVerifyError: typing.ClassVar[QtCore.pyqtSignal] + def encryptedBytesWritten(self, totalBytes: int) -> None: ... + def peerVerifyError(self, error: QSslError) -> None: ... def setSslConfiguration(self, config: QSslConfiguration) -> None: ... def sslConfiguration(self) -> QSslConfiguration: ... def encryptedBytesToWrite(self) -> int: ... @@ -2410,9 +2426,9 @@ class QSslSocket(QTcpSocket): def peerVerifyMode(self) -> 'QSslSocket.PeerVerifyMode': ... def writeData(self, data: bytes) -> int: ... def readData(self, maxlen: int) -> bytes: ... - preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] - modeChanged: typing.ClassVar[QtCore.pyqtSignal] - encrypted: typing.ClassVar[QtCore.pyqtSignal] + def preSharedKeyAuthenticationRequired(self, authenticator: QSslPreSharedKeyAuthenticator) -> None: ... + def modeChanged(self, newMode: 'QSslSocket.SslMode') -> None: ... + def encrypted(self) -> None: ... @typing.overload def ignoreSslErrors(self) -> None: ... @typing.overload @@ -2421,7 +2437,10 @@ class QSslSocket(QTcpSocket): def startClientEncryption(self) -> None: ... @staticmethod def supportsSsl() -> bool: ... - sslErrors: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def sslErrors(self) -> typing.List[QSslError]: ... + @typing.overload + def sslErrors(self, errors: typing.Iterable[QSslError]) -> None: ... def waitForDisconnected(self, msecs: int = ...) -> bool: ... def waitForBytesWritten(self, msecs: int = ...) -> bool: ... def waitForReadyRead(self, msecs: int = ...) -> bool: ... @@ -2493,8 +2512,9 @@ class QSslSocket(QTcpSocket): class QTcpServer(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - acceptError: typing.ClassVar[QtCore.pyqtSignal] - newConnection: typing.ClassVar[QtCore.pyqtSignal] + + def acceptError(self, socketError: QAbstractSocket.SocketError) -> None: ... + def newConnection(self) -> None: ... def addPendingConnection(self, socket: QTcpSocket) -> None: ... def incomingConnection(self, handle: sip.voidptr) -> None: ... def resumeAccepting(self) -> None: ... diff --git a/PyQt5-stubs/QtNetworkAuth.pyi b/PyQt5-stubs/QtNetworkAuth.pyi index 6fb0f628..b9f650b4 100644 --- a/PyQt5-stubs/QtNetworkAuth.pyi +++ b/PyQt5-stubs/QtNetworkAuth.pyi @@ -64,17 +64,17 @@ class QAbstractOAuth(QtCore.QObject): def resourceOwnerAuthorization(self, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any]) -> None: ... def callback(self) -> str: ... def setStatus(self, status: 'QAbstractOAuth.Status') -> None: ... - replyDataReceived: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] - granted: typing.ClassVar[QtCore.pyqtSignal] - authorizeWithBrowser: typing.ClassVar[QtCore.pyqtSignal] - requestFailed: typing.ClassVar[QtCore.pyqtSignal] - contentTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - extraTokensChanged: typing.ClassVar[QtCore.pyqtSignal] - authorizationUrlChanged: typing.ClassVar[QtCore.pyqtSignal] - statusChanged: typing.ClassVar[QtCore.pyqtSignal] - tokenChanged: typing.ClassVar[QtCore.pyqtSignal] - clientIdentifierChanged: typing.ClassVar[QtCore.pyqtSignal] + def replyDataReceived(self, data: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def finished(self, reply: QtNetwork.QNetworkReply) -> None: ... + def granted(self) -> None: ... + def authorizeWithBrowser(self, url: QtCore.QUrl) -> None: ... + def requestFailed(self, error: 'QAbstractOAuth.Error') -> None: ... + def contentTypeChanged(self, contentType: 'QAbstractOAuth.ContentType') -> None: ... + def extraTokensChanged(self, tokens: typing.Dict[str, typing.Any]) -> None: ... + def authorizationUrlChanged(self, url: QtCore.QUrl) -> None: ... + def statusChanged(self, status: 'QAbstractOAuth.Status') -> None: ... + def tokenChanged(self, token: str) -> None: ... + def clientIdentifierChanged(self, clientIdentifier: str) -> None: ... def grant(self) -> None: ... def prepareRequest(self, request: QtNetwork.QNetworkRequest, verb: typing.Union[QtCore.QByteArray, bytes, bytearray], body: typing.Union[QtCore.QByteArray, bytes, bytearray] = ...) -> None: ... def setContentType(self, contentType: 'QAbstractOAuth.ContentType') -> None: ... @@ -108,15 +108,15 @@ class QAbstractOAuth2(QAbstractOAuth): def __init__(self, manager: QtNetwork.QNetworkAccessManager, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setResponseType(self, responseType: str) -> None: ... - authorizationCallbackReceived: typing.ClassVar[QtCore.pyqtSignal] - error: typing.ClassVar[QtCore.pyqtSignal] - expirationAtChanged: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - clientIdentifierSharedKeyChanged: typing.ClassVar[QtCore.pyqtSignal] - responseTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - refreshTokenChanged: typing.ClassVar[QtCore.pyqtSignal] - userAgentChanged: typing.ClassVar[QtCore.pyqtSignal] - scopeChanged: typing.ClassVar[QtCore.pyqtSignal] + def authorizationCallbackReceived(self, data: typing.Dict[str, typing.Any]) -> None: ... + def error(self, error: str, errorDescription: str, uri: QtCore.QUrl) -> None: ... + def expirationAtChanged(self, expiration: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... + def stateChanged(self, state: str) -> None: ... + def clientIdentifierSharedKeyChanged(self, clientIdentifierSharedKey: str) -> None: ... + def responseTypeChanged(self, responseType: str) -> None: ... + def refreshTokenChanged(self, refreshToken: str) -> None: ... + def userAgentChanged(self, userAgent: str) -> None: ... + def scopeChanged(self, scope: str) -> None: ... def setRefreshToken(self, refreshToken: str) -> None: ... def refreshToken(self) -> str: ... def expirationAt(self) -> QtCore.QDateTime: ... @@ -150,10 +150,11 @@ class QAbstractOAuth2(QAbstractOAuth): class QAbstractOAuthReplyHandler(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - callbackDataReceived: typing.ClassVar[QtCore.pyqtSignal] - replyDataReceived: typing.ClassVar[QtCore.pyqtSignal] - tokensReceived: typing.ClassVar[QtCore.pyqtSignal] - callbackReceived: typing.ClassVar[QtCore.pyqtSignal] + + def callbackDataReceived(self, data: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def replyDataReceived(self, data: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def tokensReceived(self, tokens: typing.Dict[str, typing.Any]) -> None: ... + def callbackReceived(self, values: typing.Dict[str, typing.Any]) -> None: ... def networkReplyFinished(self, reply: QtNetwork.QNetworkReply) -> None: ... def callback(self) -> str: ... @@ -182,11 +183,11 @@ class QOAuth1(QAbstractOAuth): def setup(self, request: QtNetwork.QNetworkRequest, signingParameters: typing.Dict[str, typing.Any], operationVerb: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def requestTokenCredentials(self, operation: QtNetwork.QNetworkAccessManager.Operation, url: QtCore.QUrl, temporaryToken: typing.Tuple[str, str], parameters: typing.Dict[str, typing.Any] = ...) -> QtNetwork.QNetworkReply: ... def requestTemporaryCredentials(self, operation: QtNetwork.QNetworkAccessManager.Operation, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any] = ...) -> QtNetwork.QNetworkReply: ... - tokenCredentialsUrlChanged: typing.ClassVar[QtCore.pyqtSignal] - temporaryCredentialsUrlChanged: typing.ClassVar[QtCore.pyqtSignal] - tokenSecretChanged: typing.ClassVar[QtCore.pyqtSignal] - clientSharedSecretChanged: typing.ClassVar[QtCore.pyqtSignal] - signatureMethodChanged: typing.ClassVar[QtCore.pyqtSignal] + def tokenCredentialsUrlChanged(self, url: QtCore.QUrl) -> None: ... + def temporaryCredentialsUrlChanged(self, url: QtCore.QUrl) -> None: ... + def tokenSecretChanged(self, token: str) -> None: ... + def clientSharedSecretChanged(self, credential: str) -> None: ... + def signatureMethodChanged(self, method: 'QOAuth1.SignatureMethod') -> None: ... def continueGrantWithVerifier(self, verifier: str) -> None: ... def grant(self) -> None: ... def deleteResource(self, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any] = ...) -> QtNetwork.QNetworkReply: ... @@ -277,7 +278,7 @@ class QOAuth2AuthorizationCodeFlow(QAbstractOAuth2): def resourceOwnerAuthorization(self, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any] = ...) -> None: ... def requestAccessToken(self, code: str) -> None: ... def buildAuthenticateUrl(self, parameters: typing.Dict[str, typing.Any] = ...) -> QtCore.QUrl: ... - accessTokenUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + def accessTokenUrlChanged(self, accessTokenUrl: QtCore.QUrl) -> None: ... def refreshAccessToken(self) -> None: ... def grant(self) -> None: ... def setAccessTokenUrl(self, accessTokenUrl: QtCore.QUrl) -> None: ... diff --git a/PyQt5-stubs/QtNfc.pyi b/PyQt5-stubs/QtNfc.pyi index caaa56c0..669afa27 100644 --- a/PyQt5-stubs/QtNfc.pyi +++ b/PyQt5-stubs/QtNfc.pyi @@ -273,10 +273,11 @@ class QNearFieldManager(QtCore.QObject): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - adapterStateChanged: typing.ClassVar[QtCore.pyqtSignal] + + def adapterStateChanged(self, state: 'QNearFieldManager.AdapterState') -> None: ... def isSupported(self) -> bool: ... - targetLost: typing.ClassVar[QtCore.pyqtSignal] - targetDetected: typing.ClassVar[QtCore.pyqtSignal] + def targetLost(self, target: 'QNearFieldTarget') -> None: ... + def targetDetected(self, target: 'QNearFieldTarget') -> None: ... def unregisterNdefMessageHandler(self, handlerId: int) -> bool: ... @typing.overload def registerNdefMessageHandler(self, slot: PYQT_SLOT) -> int: ... @@ -339,9 +340,10 @@ class QNearFieldShareManager(QtCore.QObject): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - error: typing.ClassVar[QtCore.pyqtSignal] - shareModesChanged: typing.ClassVar[QtCore.pyqtSignal] - targetDetected: typing.ClassVar[QtCore.pyqtSignal] + + def error(self, error: 'QNearFieldShareManager.ShareError') -> None: ... + def shareModesChanged(self, modes: typing.Union['QNearFieldShareManager.ShareModes', 'QNearFieldShareManager.ShareMode']) -> None: ... + def targetDetected(self, shareTarget: 'QNearFieldShareTarget') -> None: ... def shareError(self) -> 'QNearFieldShareManager.ShareError': ... def shareModes(self) -> 'QNearFieldShareManager.ShareModes': ... def setShareModes(self, modes: typing.Union['QNearFieldShareManager.ShareModes', 'QNearFieldShareManager.ShareMode']) -> None: ... @@ -350,8 +352,9 @@ class QNearFieldShareManager(QtCore.QObject): class QNearFieldShareTarget(QtCore.QObject): - shareFinished: typing.ClassVar[QtCore.pyqtSignal] - error: typing.ClassVar[QtCore.pyqtSignal] + + def shareFinished(self) -> None: ... + def error(self, error: QNearFieldShareManager.ShareError) -> None: ... def shareError(self) -> QNearFieldShareManager.ShareError: ... def isShareInProgress(self) -> bool: ... def cancel(self) -> None: ... @@ -444,11 +447,11 @@ class QNearFieldTarget(QtCore.QObject): def disconnect(self) -> bool: ... # type: ignore[override] def setKeepConnection(self, isPersistent: bool) -> bool: ... def keepConnection(self) -> bool: ... - error: typing.ClassVar[QtCore.pyqtSignal] - requestCompleted: typing.ClassVar[QtCore.pyqtSignal] - ndefMessagesWritten: typing.ClassVar[QtCore.pyqtSignal] - ndefMessageRead: typing.ClassVar[QtCore.pyqtSignal] - disconnected: typing.ClassVar[QtCore.pyqtSignal] + def error(self, error: 'QNearFieldTarget.Error', id: 'QNearFieldTarget.RequestId') -> None: ... + def requestCompleted(self, id: 'QNearFieldTarget.RequestId') -> None: ... + def ndefMessagesWritten(self) -> None: ... + def ndefMessageRead(self, message: QNdefMessage) -> None: ... + def disconnected(self) -> None: ... def reportError(self, error: 'QNearFieldTarget.Error', id: 'QNearFieldTarget.RequestId') -> None: ... def handleResponse(self, id: 'QNearFieldTarget.RequestId', response: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> bool: ... def setResponseForRequest(self, id: 'QNearFieldTarget.RequestId', response: typing.Any, emitRequestCompleted: bool = ...) -> None: ... @@ -487,9 +490,10 @@ class QQmlNdefRecord(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, record: QNdefRecord, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - recordChanged: typing.ClassVar[QtCore.pyqtSignal] - typeNameFormatChanged: typing.ClassVar[QtCore.pyqtSignal] - typeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def recordChanged(self) -> None: ... + def typeNameFormatChanged(self) -> None: ... + def typeChanged(self) -> None: ... def setRecord(self, record: QNdefRecord) -> None: ... def record(self) -> QNdefRecord: ... def typeNameFormat(self) -> 'QQmlNdefRecord.TypeNameFormat': ... diff --git a/PyQt5-stubs/QtPositioning.pyi b/PyQt5-stubs/QtPositioning.pyi index d4914699..de57e255 100644 --- a/PyQt5-stubs/QtPositioning.pyi +++ b/PyQt5-stubs/QtPositioning.pyi @@ -119,9 +119,10 @@ class QGeoAreaMonitorSource(QtCore.QObject): def __int__(self) -> int: ... def __init__(self, parent: QtCore.QObject) -> None: ... - monitorExpired: typing.ClassVar[QtCore.pyqtSignal] - areaExited: typing.ClassVar[QtCore.pyqtSignal] - areaEntered: typing.ClassVar[QtCore.pyqtSignal] + + def monitorExpired(self, monitor: QGeoAreaMonitorInfo) -> None: ... + def areaExited(self, monitor: QGeoAreaMonitorInfo, update: 'QGeoPositionInfo') -> None: ... + def areaEntered(self, monitor: QGeoAreaMonitorInfo, update: 'QGeoPositionInfo') -> None: ... @typing.overload def activeMonitors(self) -> typing.List[QGeoAreaMonitorInfo]: ... @typing.overload @@ -130,7 +131,10 @@ class QGeoAreaMonitorSource(QtCore.QObject): def stopMonitoring(self, monitor: QGeoAreaMonitorInfo) -> bool: ... def startMonitoring(self, monitor: QGeoAreaMonitorInfo) -> bool: ... def supportedAreaMonitorFeatures(self) -> 'QGeoAreaMonitorSource.AreaMonitorFeatures': ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QGeoAreaMonitorSource.Error': ... + @typing.overload + def error(self, error: 'QGeoAreaMonitorSource.Error') -> None: ... def sourceName(self) -> str: ... def positionInfoSource(self) -> 'QGeoPositionInfoSource': ... def setPositionInfoSource(self, source: 'QGeoPositionInfoSource') -> None: ... @@ -410,13 +414,14 @@ class QGeoPositionInfoSource(QtCore.QObject): def backendProperty(self, name: str) -> typing.Any: ... def setBackendProperty(self, name: str, value: typing.Any) -> bool: ... - supportedPositioningMethodsChanged: typing.ClassVar[QtCore.pyqtSignal] - updateTimeout: typing.ClassVar[QtCore.pyqtSignal] - positionUpdated: typing.ClassVar[QtCore.pyqtSignal] + def supportedPositioningMethodsChanged(self) -> None: ... + def updateTimeout(self) -> None: ... + def positionUpdated(self, update: QGeoPositionInfo) -> None: ... def requestUpdate(self, timeout: int = ...) -> None: ... def stopUpdates(self) -> None: ... def startUpdates(self) -> None: ... - error: typing.ClassVar[QtCore.pyqtSignal] + # If the error signal is real, it isn't accessible in PyQt 5.15.1 + def error(self) -> 'QGeoPositionInfoSource.Error': ... @staticmethod def availableSources() -> typing.List[str]: ... @typing.overload @@ -528,13 +533,17 @@ class QGeoSatelliteInfoSource(QtCore.QObject): UnknownSourceError = ... # type: QGeoSatelliteInfoSource.Error def __init__(self, parent: QtCore.QObject) -> None: ... - requestTimeout: typing.ClassVar[QtCore.pyqtSignal] - satellitesInUseUpdated: typing.ClassVar[QtCore.pyqtSignal] - satellitesInViewUpdated: typing.ClassVar[QtCore.pyqtSignal] + + def requestTimeout(self) -> None: ... + def satellitesInUseUpdated(self, satellites: typing.Iterable[QGeoSatelliteInfo]) -> None: ... + def satellitesInViewUpdated(self, satellites: typing.Iterable[QGeoSatelliteInfo]) -> None: ... def requestUpdate(self, timeout: int = ...) -> None: ... def stopUpdates(self) -> None: ... def startUpdates(self) -> None: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QGeoSatelliteInfoSource.Error': ... + @typing.overload + def error(self, a0: 'QGeoSatelliteInfoSource.Error') -> None: ... def minimumUpdateInterval(self) -> int: ... def updateInterval(self) -> int: ... def setUpdateInterval(self, msec: int) -> None: ... diff --git a/PyQt5-stubs/QtPrintSupport.pyi b/PyQt5-stubs/QtPrintSupport.pyi index 4c6c6977..c49a0efa 100644 --- a/PyQt5-stubs/QtPrintSupport.pyi +++ b/PyQt5-stubs/QtPrintSupport.pyi @@ -128,7 +128,11 @@ class QPrintDialog(QAbstractPrintDialog): def __init__(self, printer: 'QPrinter', parent: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... @typing.overload def __init__(self, parent: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... - accepted: typing.ClassVar[QtCore.pyqtSignal] + + @typing.overload # type: ignore[override] + def accepted(self) -> None: ... + @typing.overload + def accepted(self, printer: 'QPrinter') -> None: ... @typing.overload def open(self) -> None: ... @typing.overload diff --git a/PyQt5-stubs/QtPurchasing.pyi b/PyQt5-stubs/QtPurchasing.pyi index 45707d83..5dc2605a 100644 --- a/PyQt5-stubs/QtPurchasing.pyi +++ b/PyQt5-stubs/QtPurchasing.pyi @@ -52,9 +52,10 @@ class QInAppProduct(QtCore.QObject): class QInAppStore(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - transactionReady: typing.ClassVar[QtCore.pyqtSignal] - productUnknown: typing.ClassVar[QtCore.pyqtSignal] - productRegistered: typing.ClassVar[QtCore.pyqtSignal] + + def transactionReady(self, transaction: 'QInAppTransaction') -> None: ... + def productUnknown(self, productType: QInAppProduct.ProductType, identifier: str) -> None: ... + def productRegistered(self, product: QInAppProduct) -> None: ... def setPlatformProperty(self, propertyName: str, value: str) -> None: ... def registeredProduct(self, identifier: str) -> QInAppProduct: ... def registerProduct(self, productType: QInAppProduct.ProductType, identifier: str) -> None: ... diff --git a/PyQt5-stubs/QtQml.pyi b/PyQt5-stubs/QtQml.pyi index c285e435..78e530bd 100644 --- a/PyQt5-stubs/QtQml.pyi +++ b/PyQt5-stubs/QtQml.pyi @@ -65,7 +65,8 @@ class QJSEngine(QtCore.QObject): def __init__(self) -> None: ... @typing.overload def __init__(self, parent: QtCore.QObject) -> None: ... - uiLanguageChanged: typing.ClassVar[QtCore.pyqtSignal] + + def uiLanguageChanged(self) -> None: ... def setUiLanguage(self, language: str) -> None: ... def uiLanguage(self) -> str: ... def isInterrupted(self) -> bool: ... @@ -298,8 +299,8 @@ class QQmlComponent(QtCore.QObject): def setInitialProperties(self, component: QtCore.QObject, properties: typing.Dict[str, typing.Any]) -> None: ... def engine(self) -> QQmlEngine: ... - progressChanged: typing.ClassVar[QtCore.pyqtSignal] - statusChanged: typing.ClassVar[QtCore.pyqtSignal] + def progressChanged(self, a0: float) -> None: ... + def statusChanged(self, a0: 'QQmlComponent.Status') -> None: ... def setData(self, a0: typing.Union[QtCore.QByteArray, bytes, bytearray], baseUrl: QtCore.QUrl) -> None: ... @typing.overload def loadUrl(self, url: QtCore.QUrl) -> None: ... @@ -427,7 +428,8 @@ class QQmlExpression(QtCore.QObject): def __init__(self, a0: QQmlContext, a1: QtCore.QObject, a2: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, a0: 'QQmlScriptString', context: typing.Optional[QQmlContext] = ..., scope: typing.Optional[QtCore.QObject] = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - valueChanged: typing.ClassVar[QtCore.pyqtSignal] + + def valueChanged(self) -> None: ... def evaluate(self) -> typing.Tuple[typing.Any, bool]: ... def error(self) -> QQmlError: ... def clearError(self) -> None: ... @@ -661,7 +663,7 @@ class QQmlPropertyMap(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def updateValue(self, key: str, input: typing.Any) -> typing.Any: ... - valueChanged: typing.ClassVar[QtCore.pyqtSignal] + def valueChanged(self, key: str, value: typing.Any) -> None: ... def __getitem__(self, key: str) -> typing.Any: ... def contains(self, key: str) -> bool: ... def isEmpty(self) -> bool: ... diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 662e8c63..0f9ea248 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -141,7 +141,8 @@ class QQuickItem(QtCore.QObject, QtQml.QQmlParserStatus): def __init__(self, a0: 'QQuickItem.UpdatePaintNodeData') -> None: ... def __init__(self, parent: typing.Optional['QQuickItem'] = ...) -> None: ... - containmentMaskChanged: typing.ClassVar[QtCore.pyqtSignal] + + def containmentMaskChanged(self) -> None: ... def setContainmentMask(self, mask: QtCore.QObject) -> None: ... def containmentMask(self) -> QtCore.QObject: ... def setAcceptTouchEvents(self, accept: bool) -> None: ... @@ -152,7 +153,7 @@ class QQuickItem(QtCore.QObject, QtQml.QQmlParserStatus): def isAncestorOf(self, child: 'QQuickItem') -> bool: ... def grabToImage(self, targetSize: QtCore.QSize = ...) -> 'QQuickItemGrabResult': ... def resetAntialiasing(self) -> None: ... - windowChanged: typing.ClassVar[QtCore.pyqtSignal] + def windowChanged(self, window: 'QQuickWindow') -> None: ... def nextItemInFocusChain(self, forward: bool = ...) -> 'QQuickItem': ... def setActiveFocusOnTab(self, a0: bool) -> None: ... def activeFocusOnTab(self) -> bool: ... @@ -300,13 +301,14 @@ class QQuickFramebufferObject(QQuickItem): def render(self) -> None: ... def __init__(self, parent: typing.Optional[QQuickItem] = ...) -> None: ... - mirrorVerticallyChanged: typing.ClassVar[QtCore.pyqtSignal] + + def mirrorVerticallyChanged(self, a0: bool) -> None: ... def setMirrorVertically(self, enable: bool) -> None: ... def mirrorVertically(self) -> bool: ... def releaseResources(self) -> None: ... def textureProvider(self) -> 'QSGTextureProvider': ... def isTextureProvider(self) -> bool: ... - textureFollowsItemSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + def textureFollowsItemSizeChanged(self, a0: bool) -> None: ... def updatePaintNode(self, a0: 'QSGNode', a1: QQuickItem.UpdatePaintNodeData) -> 'QSGNode': ... def geometryChanged(self, newGeometry: QtCore.QRectF, oldGeometry: QtCore.QRectF) -> None: ... def createRenderer(self) -> 'QQuickFramebufferObject.Renderer': ... @@ -343,7 +345,8 @@ class QQuickImageProvider(QtQml.QQmlImageProviderBase): class QQuickImageResponse(QtCore.QObject): def __init__(self) -> None: ... - finished: typing.ClassVar[QtCore.pyqtSignal] + + def finished(self) -> None: ... def cancel(self) -> None: ... def errorString(self) -> str: ... def textureFactory(self) -> QQuickTextureFactory: ... @@ -360,7 +363,8 @@ class QQuickAsyncImageProvider(QQuickImageProvider): class QQuickItemGrabResult(QtCore.QObject): - ready: typing.ClassVar[QtCore.pyqtSignal] + + def ready(self) -> None: ... def event(self, a0: QtCore.QEvent) -> bool: ... def saveToFile(self, fileName: str) -> bool: ... def url(self) -> QtCore.QUrl: ... @@ -399,7 +403,8 @@ class QQuickPaintedItem(QQuickItem): def __int__(self) -> int: ... def __init__(self, parent: typing.Optional[QQuickItem] = ...) -> None: ... - textureSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def textureSizeChanged(self) -> None: ... def setTextureSize(self, size: QtCore.QSize) -> None: ... def textureSize(self) -> QtCore.QSize: ... def itemChange(self, a0: QQuickItem.ItemChange, a1: QQuickItem.ItemChangeData) -> None: ... @@ -407,10 +412,10 @@ class QQuickPaintedItem(QQuickItem): def textureProvider(self) -> 'QSGTextureProvider': ... def isTextureProvider(self) -> bool: ... def updatePaintNode(self, a0: 'QSGNode', a1: QQuickItem.UpdatePaintNodeData) -> 'QSGNode': ... - renderTargetChanged: typing.ClassVar[QtCore.pyqtSignal] - contentsScaleChanged: typing.ClassVar[QtCore.pyqtSignal] - contentsSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - fillColorChanged: typing.ClassVar[QtCore.pyqtSignal] + def renderTargetChanged(self) -> None: ... + def contentsScaleChanged(self) -> None: ... + def contentsSizeChanged(self) -> None: ... + def fillColorChanged(self) -> None: ... def paint(self, painter: QtGui.QPainter) -> None: ... def setRenderTarget(self, target: 'QQuickPaintedItem.RenderTarget') -> None: ... def renderTarget(self) -> 'QQuickPaintedItem.RenderTarget': ... @@ -437,8 +442,9 @@ class QQuickPaintedItem(QQuickItem): class QQuickRenderControl(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - sceneChanged: typing.ClassVar[QtCore.pyqtSignal] - renderRequested: typing.ClassVar[QtCore.pyqtSignal] + + def sceneChanged(self) -> None: ... + def renderRequested(self) -> None: ... def prepareThread(self, targetThread: QtCore.QThread) -> None: ... def renderWindow(self, offset: QtCore.QPoint) -> QtGui.QWindow: ... @staticmethod @@ -645,7 +651,7 @@ class QQuickView(QQuickWindow): def keyPressEvent(self, a0: QtGui.QKeyEvent) -> None: ... def timerEvent(self, a0: QtCore.QTimerEvent) -> None: ... def resizeEvent(self, a0: QtGui.QResizeEvent) -> None: ... - statusChanged: typing.ClassVar[QtCore.pyqtSignal] + def statusChanged(self, a0: 'QQuickView.Status') -> None: ... def setInitialProperties(self, initialProperties: typing.Dict[str, typing.Any]) -> None: ... def setSource(self, a0: QtCore.QUrl) -> None: ... def initialSize(self) -> QtCore.QSize: ... @@ -707,7 +713,8 @@ class QSGAbstractRenderer(QtCore.QObject): def __invert__(self) -> 'QSGAbstractRenderer.MatrixTransformFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - sceneGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + + def sceneGraphChanged(self) -> None: ... def renderScene(self, fboId: int = ...) -> None: ... def clearMode(self) -> 'QSGAbstractRenderer.ClearMode': ... def setClearMode(self, mode: typing.Union['QSGAbstractRenderer.ClearMode', 'QSGAbstractRenderer.ClearModeBit']) -> None: ... @@ -1797,7 +1804,8 @@ class QSGTextureMaterial(QSGOpaqueTextureMaterial): class QSGTextureProvider(QtCore.QObject): def __init__(self) -> None: ... - textureChanged: typing.ClassVar[QtCore.pyqtSignal] + + def textureChanged(self) -> None: ... def texture(self) -> QSGTexture: ... diff --git a/PyQt5-stubs/QtQuickWidgets.pyi b/PyQt5-stubs/QtQuickWidgets.pyi index 62c14f4b..e3cc6b57 100644 --- a/PyQt5-stubs/QtQuickWidgets.pyi +++ b/PyQt5-stubs/QtQuickWidgets.pyi @@ -92,8 +92,8 @@ class QQuickWidget(QtWidgets.QWidget): def keyPressEvent(self, a0: QtGui.QKeyEvent) -> None: ... def timerEvent(self, a0: QtCore.QTimerEvent) -> None: ... def resizeEvent(self, a0: QtGui.QResizeEvent) -> None: ... - sceneGraphError: typing.ClassVar[QtCore.pyqtSignal] - statusChanged: typing.ClassVar[QtCore.pyqtSignal] + def sceneGraphError(self, error: QtQuick.QQuickWindow.SceneGraphError, message: str) -> None: ... + def statusChanged(self, a0: 'QQuickWidget.Status') -> None: ... def setSource(self, a0: QtCore.QUrl) -> None: ... def format(self) -> QtGui.QSurfaceFormat: ... def setFormat(self, format: QtGui.QSurfaceFormat) -> None: ... diff --git a/PyQt5-stubs/QtRemoteObjects.pyi b/PyQt5-stubs/QtRemoteObjects.pyi index 142f600d..8ae155b2 100644 --- a/PyQt5-stubs/QtRemoteObjects.pyi +++ b/PyQt5-stubs/QtRemoteObjects.pyi @@ -33,7 +33,8 @@ PYQT_SLOT = typing.Union[typing.Callable[..., None], QtCore.pyqtBoundSignal] class QAbstractItemModelReplica(QtCore.QAbstractItemModel): - initialized: typing.ClassVar[QtCore.pyqtSignal] + + def initialized(self) -> None: ... def setRootCacheSize(self, rootCacheSize: int) -> None: ... def rootCacheSize(self) -> int: ... def hasData(self, index: QtCore.QModelIndex, role: int) -> bool: ... @@ -66,9 +67,10 @@ class QRemoteObjectReplica(QtCore.QObject): Valid = ... # type: QRemoteObjectReplica.State Suspect = ... # type: QRemoteObjectReplica.State SignatureMismatch = ... # type: QRemoteObjectReplica.State - notified: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - initialized: typing.ClassVar[QtCore.pyqtSignal] + + def notified(self) -> None: ... + def stateChanged(self, state: 'QRemoteObjectReplica.State', oldState: 'QRemoteObjectReplica.State') -> None: ... + def initialized(self) -> None: ... def setNode(self, node: 'QRemoteObjectNode') -> None: ... def node(self) -> 'QRemoteObjectNode': ... def state(self) -> 'QRemoteObjectReplica.State': ... @@ -123,10 +125,10 @@ class QRemoteObjectNode(QtCore.QObject): def __init__(self, registryAddress: QtCore.QUrl, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def timerEvent(self, a0: QtCore.QTimerEvent) -> None: ... - heartbeatIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] - error: typing.ClassVar[QtCore.pyqtSignal] - remoteObjectRemoved: typing.ClassVar[QtCore.pyqtSignal] - remoteObjectAdded: typing.ClassVar[QtCore.pyqtSignal] + def heartbeatIntervalChanged(self, heartbeatInterval: int) -> None: ... + def error(self, errorCode: 'QRemoteObjectNode.ErrorCode') -> None: ... + def remoteObjectRemoved(self, a0: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... + def remoteObjectAdded(self, a0: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... def setHeartbeatInterval(self, interval: int) -> None: ... def heartbeatInterval(self) -> int: ... def lastError(self) -> 'QRemoteObjectNode.ErrorCode': ... @@ -172,7 +174,8 @@ class QRemoteObjectHost(QRemoteObjectHostBase): def __init__(self, address: QtCore.QUrl, registryAddress: QtCore.QUrl = ..., allowedSchemas: QRemoteObjectHostBase.AllowedSchemas = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, address: QtCore.QUrl, parent: QtCore.QObject) -> None: ... - hostUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + + def hostUrlChanged(self) -> None: ... def setHostUrl(self, hostAddress: QtCore.QUrl, allowedSchemas: QRemoteObjectHostBase.AllowedSchemas = ...) -> bool: ... def hostUrl(self) -> QtCore.QUrl: ... @@ -185,8 +188,9 @@ class QRemoteObjectRegistryHost(QRemoteObjectHostBase): class QRemoteObjectRegistry(QRemoteObjectReplica): - remoteObjectRemoved: typing.ClassVar[QtCore.pyqtSignal] - remoteObjectAdded: typing.ClassVar[QtCore.pyqtSignal] + + def remoteObjectRemoved(self, entry: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... + def remoteObjectAdded(self, entry: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... def sourceLocations(self) -> typing.Dict[str, 'QRemoteObjectSourceLocationInfo']: ... diff --git a/PyQt5-stubs/QtSensors.pyi b/PyQt5-stubs/QtSensors.pyi index b94922ec..017cbd80 100644 --- a/PyQt5-stubs/QtSensors.pyi +++ b/PyQt5-stubs/QtSensors.pyi @@ -101,20 +101,21 @@ class QSensor(QtCore.QObject): PressureSensorTemperature = ... # type: QSensor.Feature def __init__(self, type: typing.Union[QtCore.QByteArray, bytes, bytearray], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - bufferSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - efficientBufferSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - maxBufferSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - userOrientationChanged: typing.ClassVar[QtCore.pyqtSignal] - currentOrientationChanged: typing.ClassVar[QtCore.pyqtSignal] - axesOrientationModeChanged: typing.ClassVar[QtCore.pyqtSignal] - skipDuplicatesChanged: typing.ClassVar[QtCore.pyqtSignal] - dataRateChanged: typing.ClassVar[QtCore.pyqtSignal] - alwaysOnChanged: typing.ClassVar[QtCore.pyqtSignal] - availableSensorsChanged: typing.ClassVar[QtCore.pyqtSignal] - sensorError: typing.ClassVar[QtCore.pyqtSignal] - readingChanged: typing.ClassVar[QtCore.pyqtSignal] - activeChanged: typing.ClassVar[QtCore.pyqtSignal] - busyChanged: typing.ClassVar[QtCore.pyqtSignal] + + def bufferSizeChanged(self, bufferSize: int) -> None: ... + def efficientBufferSizeChanged(self, efficientBufferSize: int) -> None: ... + def maxBufferSizeChanged(self, maxBufferSize: int) -> None: ... + def userOrientationChanged(self, userOrientation: int) -> None: ... + def currentOrientationChanged(self, currentOrientation: int) -> None: ... + def axesOrientationModeChanged(self, axesOrientationMode: 'QSensor.AxesOrientationMode') -> None: ... + def skipDuplicatesChanged(self, skipDuplicates: bool) -> None: ... + def dataRateChanged(self) -> None: ... + def alwaysOnChanged(self) -> None: ... + def availableSensorsChanged(self) -> None: ... + def sensorError(self, error: int) -> None: ... + def readingChanged(self) -> None: ... + def activeChanged(self) -> None: ... + def busyChanged(self) -> None: ... def stop(self) -> None: ... def start(self) -> bool: ... def setBufferSize(self, bufferSize: int) -> None: ... @@ -174,7 +175,8 @@ class QAccelerometer(QSensor): User = ... # type: QAccelerometer.AccelerationMode def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - accelerationModeChanged: typing.ClassVar[QtCore.pyqtSignal] + + def accelerationModeChanged(self, accelerationMode: 'QAccelerometer.AccelerationMode') -> None: ... def reading(self) -> QAccelerometerReading: ... def setAccelerationMode(self, accelerationMode: 'QAccelerometer.AccelerationMode') -> None: ... def accelerationMode(self) -> 'QAccelerometer.AccelerationMode': ... @@ -411,8 +413,9 @@ class QIRProximitySensor(QSensor): class QLidReading(QSensorReading): - frontLidChanged: typing.ClassVar[QtCore.pyqtSignal] - backLidChanged: typing.ClassVar[QtCore.pyqtSignal] + + def frontLidChanged(self, closed: bool) -> None: ... + def backLidChanged(self, closed: bool) -> None: ... def setFrontLidClosed(self, closed: bool) -> None: ... def frontLidClosed(self) -> bool: ... def setBackLidClosed(self, closed: bool) -> None: ... @@ -455,7 +458,8 @@ class QLightFilter(QSensorFilter): class QLightSensor(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - fieldOfViewChanged: typing.ClassVar[QtCore.pyqtSignal] + + def fieldOfViewChanged(self, fieldOfView: float) -> None: ... def setFieldOfView(self, fieldOfView: float) -> None: ... def fieldOfView(self) -> float: ... def reading(self) -> QLightReading: ... @@ -486,7 +490,8 @@ class QMagnetometerFilter(QSensorFilter): class QMagnetometer(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - returnGeoValuesChanged: typing.ClassVar[QtCore.pyqtSignal] + + def returnGeoValuesChanged(self, returnGeoValues: bool) -> None: ... def setReturnGeoValues(self, returnGeoValues: bool) -> None: ... def returnGeoValues(self) -> bool: ... def reading(self) -> QMagnetometerReading: ... @@ -642,7 +647,8 @@ class QTapFilter(QSensorFilter): class QTapSensor(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - returnDoubleTapEventsChanged: typing.ClassVar[QtCore.pyqtSignal] + + def returnDoubleTapEventsChanged(self, returnDoubleTapEvents: bool) -> None: ... def setReturnDoubleTapEvents(self, returnDoubleTapEvents: bool) -> None: ... def returnDoubleTapEvents(self) -> bool: ... def reading(self) -> QTapReading: ... @@ -695,7 +701,8 @@ class QRotationFilter(QSensorFilter): class QRotationSensor(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - hasZChanged: typing.ClassVar[QtCore.pyqtSignal] + + def hasZChanged(self, hasZ: bool) -> None: ... def setHasZ(self, hasZ: bool) -> None: ... def hasZ(self) -> bool: ... def reading(self) -> QRotationReading: ... diff --git a/PyQt5-stubs/QtSerialPort.pyi b/PyQt5-stubs/QtSerialPort.pyi index aea12ea3..607e7f50 100644 --- a/PyQt5-stubs/QtSerialPort.pyi +++ b/PyQt5-stubs/QtSerialPort.pyi @@ -219,22 +219,23 @@ class QSerialPort(QtCore.QIODevice): def __init__(self, name: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, info: 'QSerialPortInfo', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - errorOccurred: typing.ClassVar[QtCore.pyqtSignal] - breakEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + + def errorOccurred(self, error: 'QSerialPort.SerialPortError') -> None: ... + def breakEnabledChanged(self, set: bool) -> None: ... def isBreakEnabled(self) -> bool: ... def handle(self) -> int: ... def writeData(self, data: bytes) -> int: ... def readLineData(self, maxlen: int) -> bytes: ... def readData(self, maxlen: int) -> bytes: ... - settingsRestoredOnCloseChanged: typing.ClassVar[QtCore.pyqtSignal] - requestToSendChanged: typing.ClassVar[QtCore.pyqtSignal] - dataTerminalReadyChanged: typing.ClassVar[QtCore.pyqtSignal] - dataErrorPolicyChanged: typing.ClassVar[QtCore.pyqtSignal] - flowControlChanged: typing.ClassVar[QtCore.pyqtSignal] - stopBitsChanged: typing.ClassVar[QtCore.pyqtSignal] - parityChanged: typing.ClassVar[QtCore.pyqtSignal] - dataBitsChanged: typing.ClassVar[QtCore.pyqtSignal] - baudRateChanged: typing.ClassVar[QtCore.pyqtSignal] + def settingsRestoredOnCloseChanged(self, restore: bool) -> None: ... + def requestToSendChanged(self, set: bool) -> None: ... + def dataTerminalReadyChanged(self, set: bool) -> None: ... + def dataErrorPolicyChanged(self, policy: 'QSerialPort.DataErrorPolicy') -> None: ... + def flowControlChanged(self, flow: 'QSerialPort.FlowControl') -> None: ... + def stopBitsChanged(self, stopBits: 'QSerialPort.StopBits') -> None: ... + def parityChanged(self, parity: 'QSerialPort.Parity') -> None: ... + def dataBitsChanged(self, dataBits: 'QSerialPort.DataBits') -> None: ... + def baudRateChanged(self, baudRate: int, directions: typing.Union['QSerialPort.Directions', 'QSerialPort.Direction']) -> None: ... def setBreakEnabled(self, enabled: bool = ...) -> bool: ... def sendBreak(self, duration: int = ...) -> bool: ... def waitForBytesWritten(self, msecs: int = ...) -> bool: ... @@ -246,7 +247,10 @@ class QSerialPort(QtCore.QIODevice): def setReadBufferSize(self, size: int) -> None: ... def readBufferSize(self) -> int: ... def clearError(self) -> None: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> 'QSerialPort.SerialPortError': ... + @typing.overload + def error(self, serialPortError: 'QSerialPort.SerialPortError') -> None: ... def dataErrorPolicy(self) -> 'QSerialPort.DataErrorPolicy': ... def setDataErrorPolicy(self, policy: 'QSerialPort.DataErrorPolicy' = ...) -> bool: ... def atEnd(self) -> bool: ... diff --git a/PyQt5-stubs/QtSql.pyi b/PyQt5-stubs/QtSql.pyi index 558e4ea9..160fcf4e 100644 --- a/PyQt5-stubs/QtSql.pyi +++ b/PyQt5-stubs/QtSql.pyi @@ -213,7 +213,10 @@ class QSqlDriver(QtCore.QObject): def setNumericalPrecisionPolicy(self, precisionPolicy: 'QSql.NumericalPrecisionPolicy') -> None: ... def stripDelimiters(self, identifier: str, type: 'QSqlDriver.IdentifierType') -> str: ... def isIdentifierEscaped(self, identifier: str, type: 'QSqlDriver.IdentifierType') -> bool: ... - notification: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def notification(self, name: str) -> None: ... + @typing.overload + def notification(self, name: str, source: 'QSqlDriver.NotificationSource', payload: typing.Any) -> None: ... def subscribedToNotifications(self) -> typing.List[str]: ... def unsubscribeFromNotification(self, name: str) -> bool: ... def subscribeToNotification(self, name: str) -> bool: ... @@ -557,10 +560,10 @@ class QSqlTableModel(QSqlQueryModel): def deleteRowFromTable(self, row: int) -> bool: ... def insertRowIntoTable(self, values: QSqlRecord) -> bool: ... def updateRowInTable(self, row: int, values: QSqlRecord) -> bool: ... - beforeDelete: typing.ClassVar[QtCore.pyqtSignal] - beforeUpdate: typing.ClassVar[QtCore.pyqtSignal] - beforeInsert: typing.ClassVar[QtCore.pyqtSignal] - primeInsert: typing.ClassVar[QtCore.pyqtSignal] + def beforeDelete(self, row: int) -> None: ... + def beforeUpdate(self, row: int, record: QSqlRecord) -> None: ... + def beforeInsert(self, record: QSqlRecord) -> None: ... + def primeInsert(self, row: int, record: QSqlRecord) -> None: ... def revertAll(self) -> None: ... def submitAll(self) -> bool: ... def revert(self) -> None: ... diff --git a/PyQt5-stubs/QtSvg.pyi b/PyQt5-stubs/QtSvg.pyi index 608b3393..97d2b50b 100644 --- a/PyQt5-stubs/QtSvg.pyi +++ b/PyQt5-stubs/QtSvg.pyi @@ -98,7 +98,7 @@ class QSvgRenderer(QtCore.QObject): def transformForElement(self, id: str) -> QtGui.QTransform: ... def setAspectRatioMode(self, mode: QtCore.Qt.AspectRatioMode) -> None: ... def aspectRatioMode(self) -> QtCore.Qt.AspectRatioMode: ... - repaintNeeded: typing.ClassVar[QtCore.pyqtSignal] + def repaintNeeded(self) -> None: ... @typing.overload def render(self, p: QtGui.QPainter) -> None: ... @typing.overload diff --git a/PyQt5-stubs/QtWebChannel.pyi b/PyQt5-stubs/QtWebChannel.pyi index 2a5bd122..4ff9b336 100644 --- a/PyQt5-stubs/QtWebChannel.pyi +++ b/PyQt5-stubs/QtWebChannel.pyi @@ -38,7 +38,7 @@ class QWebChannel(QtCore.QObject): def disconnectFrom(self, transport: 'QWebChannelAbstractTransport') -> None: ... def connectTo(self, transport: 'QWebChannelAbstractTransport') -> None: ... - blockUpdatesChanged: typing.ClassVar[QtCore.pyqtSignal] + def blockUpdatesChanged(self, block: bool) -> None: ... def setBlockUpdates(self, block: bool) -> None: ... def blockUpdates(self) -> bool: ... def deregisterObject(self, object: QtCore.QObject) -> None: ... @@ -50,5 +50,6 @@ class QWebChannel(QtCore.QObject): class QWebChannelAbstractTransport(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - messageReceived: typing.ClassVar[QtCore.pyqtSignal] + + def messageReceived(self, message: typing.Dict[str, typing.Union[QtCore.QJsonValue, QtCore.QJsonValue.Type, typing.Iterable[QtCore.QJsonValue], bool, int, float, None, str]], transport: 'QWebChannelAbstractTransport') -> None: ... def sendMessage(self, message: typing.Dict[str, typing.Union[QtCore.QJsonValue, QtCore.QJsonValue.Type, typing.Iterable[QtCore.QJsonValue], bool, int, float, None, str]]) -> None: ... diff --git a/PyQt5-stubs/QtWebEngine.pyi b/PyQt5-stubs/QtWebEngine.pyi index 2b78da94..7b3c7fe0 100644 --- a/PyQt5-stubs/QtWebEngine.pyi +++ b/PyQt5-stubs/QtWebEngine.pyi @@ -60,29 +60,30 @@ class QQuickWebEngineProfile(QtCore.QObject): NoCache = ... # type: QQuickWebEngineProfile.HttpCacheType def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - presentNotification: typing.ClassVar[QtCore.pyqtSignal] - downloadPathChanged: typing.ClassVar[QtCore.pyqtSignal] - useForGlobalCertificateVerificationChanged: typing.ClassVar[QtCore.pyqtSignal] + + def presentNotification(self, notification: QtWebEngineCore.QWebEngineNotification) -> None: ... + def downloadPathChanged(self) -> None: ... + def useForGlobalCertificateVerificationChanged(self) -> None: ... def clientCertificateStore(self) -> QtWebEngineCore.QWebEngineClientCertificateStore: ... def setDownloadPath(self, path: str) -> None: ... def downloadPath(self) -> str: ... def isUsedForGlobalCertificateVerification(self) -> bool: ... def setUseForGlobalCertificateVerification(self, b: bool) -> None: ... - spellCheckEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] - spellCheckLanguagesChanged: typing.ClassVar[QtCore.pyqtSignal] + def spellCheckEnabledChanged(self) -> None: ... + def spellCheckLanguagesChanged(self) -> None: ... def isSpellCheckEnabled(self) -> bool: ... def setSpellCheckEnabled(self, enabled: bool) -> None: ... def spellCheckLanguages(self) -> typing.List[str]: ... def setSpellCheckLanguages(self, languages: typing.Iterable[str]) -> None: ... - httpAcceptLanguageChanged: typing.ClassVar[QtCore.pyqtSignal] - httpCacheMaximumSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - persistentCookiesPolicyChanged: typing.ClassVar[QtCore.pyqtSignal] - httpCacheTypeChanged: typing.ClassVar[QtCore.pyqtSignal] - httpUserAgentChanged: typing.ClassVar[QtCore.pyqtSignal] - cachePathChanged: typing.ClassVar[QtCore.pyqtSignal] - persistentStoragePathChanged: typing.ClassVar[QtCore.pyqtSignal] - offTheRecordChanged: typing.ClassVar[QtCore.pyqtSignal] - storageNameChanged: typing.ClassVar[QtCore.pyqtSignal] + def httpAcceptLanguageChanged(self) -> None: ... + def httpCacheMaximumSizeChanged(self) -> None: ... + def persistentCookiesPolicyChanged(self) -> None: ... + def httpCacheTypeChanged(self) -> None: ... + def httpUserAgentChanged(self) -> None: ... + def cachePathChanged(self) -> None: ... + def persistentStoragePathChanged(self) -> None: ... + def offTheRecordChanged(self) -> None: ... + def storageNameChanged(self) -> None: ... @staticmethod def defaultProfile() -> 'QQuickWebEngineProfile': ... def clearHttpCache(self) -> None: ... @@ -137,12 +138,12 @@ class QQuickWebEngineScript(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def timerEvent(self, e: QtCore.QTimerEvent) -> None: ... - runOnSubframesChanged: typing.ClassVar[QtCore.pyqtSignal] - worldIdChanged: typing.ClassVar[QtCore.pyqtSignal] - injectionPointChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceCodeChanged: typing.ClassVar[QtCore.pyqtSignal] - sourceUrlChanged: typing.ClassVar[QtCore.pyqtSignal] - nameChanged: typing.ClassVar[QtCore.pyqtSignal] + def runOnSubframesChanged(self, on: bool) -> None: ... + def worldIdChanged(self, scriptWorldId: 'QQuickWebEngineScript.ScriptWorldId') -> None: ... + def injectionPointChanged(self, injectionPoint: 'QQuickWebEngineScript.InjectionPoint') -> None: ... + def sourceCodeChanged(self, code: str) -> None: ... + def sourceUrlChanged(self, url: QtCore.QUrl) -> None: ... + def nameChanged(self, name: str) -> None: ... def setRunOnSubframes(self, on: bool) -> None: ... def setWorldId(self, scriptWorldId: 'QQuickWebEngineScript.ScriptWorldId') -> None: ... def setInjectionPoint(self, injectionPoint: 'QQuickWebEngineScript.InjectionPoint') -> None: ... diff --git a/PyQt5-stubs/QtWebEngineCore.pyi b/PyQt5-stubs/QtWebEngineCore.pyi index 8b60c11b..4fd28480 100644 --- a/PyQt5-stubs/QtWebEngineCore.pyi +++ b/PyQt5-stubs/QtWebEngineCore.pyi @@ -65,8 +65,8 @@ class QWebEngineCookieStore(QtCore.QObject): def __init__(self, a0: 'QWebEngineCookieStore.FilterRequest') -> None: ... def setCookieFilter(self, filterCallback: typing.Optional[typing.Callable[[FilterRequest], bool]] = ...) -> None: ... - cookieRemoved: typing.ClassVar[QtCore.pyqtSignal] - cookieAdded: typing.ClassVar[QtCore.pyqtSignal] + def cookieRemoved(self, cookie: QtNetwork.QNetworkCookie) -> None: ... + def cookieAdded(self, cookie: QtNetwork.QNetworkCookie) -> None: ... def loadAllCookies(self) -> None: ... def deleteAllCookies(self) -> None: ... def deleteSessionCookies(self) -> None: ... @@ -116,7 +116,8 @@ class QWebEngineHttpRequest(sip.simplewrapper): class QWebEngineNotification(QtCore.QObject): - closed: typing.ClassVar[QtCore.pyqtSignal] + + def closed(self) -> None: ... def close(self) -> None: ... def click(self) -> None: ... def show(self) -> None: ... diff --git a/PyQt5-stubs/QtWebEngineWidgets.pyi b/PyQt5-stubs/QtWebEngineWidgets.pyi index f7cda7ee..fe699fc7 100644 --- a/PyQt5-stubs/QtWebEngineWidgets.pyi +++ b/PyQt5-stubs/QtWebEngineWidgets.pyi @@ -312,7 +312,7 @@ class QWebEngineDownloadItem(QtCore.QObject): def suggestedFileName(self) -> str: ... def page(self) -> 'QWebEnginePage': ... def isSavePageDownload(self) -> bool: ... - isPausedChanged: typing.ClassVar[QtCore.pyqtSignal] + def isPausedChanged(self, isPaused: bool) -> None: ... def resume(self) -> None: ... def pause(self) -> None: ... def isPaused(self) -> bool: ... @@ -322,9 +322,9 @@ class QWebEngineDownloadItem(QtCore.QObject): def setSavePageFormat(self, format: 'QWebEngineDownloadItem.SavePageFormat') -> None: ... def savePageFormat(self) -> 'QWebEngineDownloadItem.SavePageFormat': ... def mimeType(self) -> str: ... - downloadProgress: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - finished: typing.ClassVar[QtCore.pyqtSignal] + def downloadProgress(self, bytesReceived: int, bytesTotal: int) -> None: ... + def stateChanged(self, state: 'QWebEngineDownloadItem.DownloadState') -> None: ... + def finished(self) -> None: ... def cancel(self) -> None: ... def accept(self) -> None: ... def isFinished(self) -> bool: ... @@ -593,22 +593,23 @@ class QWebEnginePage(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, profile: 'QWebEngineProfile', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - renderProcessPidChanged: typing.ClassVar[QtCore.pyqtSignal] + + def renderProcessPidChanged(self, pid: int) -> None: ... def renderProcessPid(self) -> int: ... - findTextFinished: typing.ClassVar[QtCore.pyqtSignal] - recommendedStateChanged: typing.ClassVar[QtCore.pyqtSignal] - lifecycleStateChanged: typing.ClassVar[QtCore.pyqtSignal] - visibleChanged: typing.ClassVar[QtCore.pyqtSignal] + def findTextFinished(self, result: QtWebEngineCore.QWebEngineFindTextResult) -> None: ... + def recommendedStateChanged(self, state: 'QWebEnginePage.LifecycleState') -> None: ... + def lifecycleStateChanged(self, state: 'QWebEnginePage.LifecycleState') -> None: ... + def visibleChanged(self, visible: bool) -> None: ... def setVisible(self, visible: bool) -> None: ... def isVisible(self) -> bool: ... def recommendedState(self) -> 'QWebEnginePage.LifecycleState': ... def setLifecycleState(self, state: 'QWebEnginePage.LifecycleState') -> None: ... def lifecycleState(self) -> 'QWebEnginePage.LifecycleState': ... def setUrlRequestInterceptor(self, interceptor: QtWebEngineCore.QWebEngineUrlRequestInterceptor) -> None: ... - printRequested: typing.ClassVar[QtCore.pyqtSignal] - selectClientCertificate: typing.ClassVar[QtCore.pyqtSignal] - registerProtocolHandlerRequested: typing.ClassVar[QtCore.pyqtSignal] - quotaRequested: typing.ClassVar[QtCore.pyqtSignal] + def printRequested(self) -> None: ... + def selectClientCertificate(self, clientCertSelection: QWebEngineClientCertificateSelection) -> None: ... + def registerProtocolHandlerRequested(self, request: QtWebEngineCore.QWebEngineRegisterProtocolHandlerRequest) -> None: ... + def quotaRequested(self, quotaRequest: QtWebEngineCore.QWebEngineQuotaRequest) -> None: ... def devToolsPage(self) -> 'QWebEnginePage': ... def setDevToolsPage(self, page: 'QWebEnginePage') -> None: ... def inspectedPage(self) -> 'QWebEnginePage': ... @@ -617,12 +618,12 @@ class QWebEnginePage(QtCore.QObject): def print(self, printer: QtPrintSupport.QPrinter, resultCallback: typing.Callable[[bool], None]) -> None: ... def save(self, filePath: str, format: QWebEngineDownloadItem.SavePageFormat = ...) -> None: ... def replaceMisspelledWord(self, replacement: str) -> None: ... - pdfPrintingFinished: typing.ClassVar[QtCore.pyqtSignal] - recentlyAudibleChanged: typing.ClassVar[QtCore.pyqtSignal] - audioMutedChanged: typing.ClassVar[QtCore.pyqtSignal] - contentsSizeChanged: typing.ClassVar[QtCore.pyqtSignal] - scrollPositionChanged: typing.ClassVar[QtCore.pyqtSignal] - iconChanged: typing.ClassVar[QtCore.pyqtSignal] + def pdfPrintingFinished(self, filePath: str, success: bool) -> None: ... + def recentlyAudibleChanged(self, recentlyAudible: bool) -> None: ... + def audioMutedChanged(self, muted: bool) -> None: ... + def contentsSizeChanged(self, size: QtCore.QSizeF) -> None: ... + def scrollPositionChanged(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def iconChanged(self, icon: QtGui.QIcon) -> None: ... def contextMenuData(self) -> QWebEngineContextMenuData: ... @typing.overload def printToPdf(self, filePath: str, pageLayout: QtGui.QPageLayout = ...) -> None: ... @@ -634,8 +635,8 @@ class QWebEnginePage(QtCore.QObject): def contentsSize(self) -> QtCore.QSizeF: ... def scrollPosition(self) -> QtCore.QPointF: ... def icon(self) -> QtGui.QIcon: ... - renderProcessTerminated: typing.ClassVar[QtCore.pyqtSignal] - fullScreenRequested: typing.ClassVar[QtCore.pyqtSignal] + def renderProcessTerminated(self, terminationStatus: 'QWebEnginePage.RenderProcessTerminationStatus', exitCode: int) -> None: ... + def fullScreenRequested(self, fullScreenRequest: QWebEngineFullScreenRequest) -> None: ... def setBackgroundColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def backgroundColor(self) -> QtGui.QColor: ... def acceptNavigationRequest(self, url: QtCore.QUrl, type: 'QWebEnginePage.NavigationType', isMainFrame: bool) -> bool: ... @@ -653,20 +654,20 @@ class QWebEnginePage(QtCore.QObject): def javaScriptAlert(self, securityOrigin: QtCore.QUrl, msg: str) -> None: ... def chooseFiles(self, mode: 'QWebEnginePage.FileSelectionMode', oldFiles: typing.Iterable[str], acceptedMimeTypes: typing.Iterable[str]) -> typing.List[str]: ... def createWindow(self, type: 'QWebEnginePage.WebWindowType') -> 'QWebEnginePage': ... - iconUrlChanged: typing.ClassVar[QtCore.pyqtSignal] - urlChanged: typing.ClassVar[QtCore.pyqtSignal] - titleChanged: typing.ClassVar[QtCore.pyqtSignal] - proxyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] - authenticationRequired: typing.ClassVar[QtCore.pyqtSignal] - featurePermissionRequestCanceled: typing.ClassVar[QtCore.pyqtSignal] - featurePermissionRequested: typing.ClassVar[QtCore.pyqtSignal] - windowCloseRequested: typing.ClassVar[QtCore.pyqtSignal] - geometryChangeRequested: typing.ClassVar[QtCore.pyqtSignal] - selectionChanged: typing.ClassVar[QtCore.pyqtSignal] - linkHovered: typing.ClassVar[QtCore.pyqtSignal] - loadFinished: typing.ClassVar[QtCore.pyqtSignal] - loadProgress: typing.ClassVar[QtCore.pyqtSignal] - loadStarted: typing.ClassVar[QtCore.pyqtSignal] + def iconUrlChanged(self, url: QtCore.QUrl) -> None: ... + def urlChanged(self, url: QtCore.QUrl) -> None: ... + def titleChanged(self, title: str) -> None: ... + def proxyAuthenticationRequired(self, requestUrl: QtCore.QUrl, authenticator: QtNetwork.QAuthenticator, proxyHost: str) -> None: ... + def authenticationRequired(self, requestUrl: QtCore.QUrl, authenticator: QtNetwork.QAuthenticator) -> None: ... + def featurePermissionRequestCanceled(self, securityOrigin: QtCore.QUrl, feature: 'QWebEnginePage.Feature') -> None: ... + def featurePermissionRequested(self, securityOrigin: QtCore.QUrl, feature: 'QWebEnginePage.Feature') -> None: ... + def windowCloseRequested(self) -> None: ... + def geometryChangeRequested(self, geom: QtCore.QRect) -> None: ... + def selectionChanged(self) -> None: ... + def linkHovered(self, url: str) -> None: ... + def loadFinished(self, ok: bool) -> None: ... + def loadProgress(self, progress: int) -> None: ... + def loadStarted(self) -> None: ... def settings(self) -> 'QWebEngineSettings': ... @typing.overload def runJavaScript(self, scriptSource: str, worldId: int) -> None: ... @@ -750,7 +751,7 @@ class QWebEngineProfile(QtCore.QObject): def cookieStore(self) -> QtWebEngineCore.QWebEngineCookieStore: ... def httpAcceptLanguage(self) -> str: ... def setHttpAcceptLanguage(self, httpAcceptLanguage: str) -> None: ... - downloadRequested: typing.ClassVar[QtCore.pyqtSignal] + def downloadRequested(self, download: QWebEngineDownloadItem) -> None: ... @staticmethod def defaultProfile() -> 'QWebEngineProfile': ... def scripts(self) -> 'QWebEngineScriptCollection': ... @@ -963,21 +964,21 @@ class QWebEngineView(QtWidgets.QWidget): def dragMoveEvent(self, e: QtGui.QDragMoveEvent) -> None: ... def dragLeaveEvent(self, e: QtGui.QDragLeaveEvent) -> None: ... def dragEnterEvent(self, e: QtGui.QDragEnterEvent) -> None: ... - iconChanged: typing.ClassVar[QtCore.pyqtSignal] + def iconChanged(self, a0: QtGui.QIcon) -> None: ... def icon(self) -> QtGui.QIcon: ... def hideEvent(self, a0: QtGui.QHideEvent) -> None: ... def showEvent(self, a0: QtGui.QShowEvent) -> None: ... def event(self, a0: QtCore.QEvent) -> bool: ... def contextMenuEvent(self, a0: QtGui.QContextMenuEvent) -> None: ... def createWindow(self, type: QWebEnginePage.WebWindowType) -> 'QWebEngineView': ... - renderProcessTerminated: typing.ClassVar[QtCore.pyqtSignal] - iconUrlChanged: typing.ClassVar[QtCore.pyqtSignal] - urlChanged: typing.ClassVar[QtCore.pyqtSignal] - selectionChanged: typing.ClassVar[QtCore.pyqtSignal] - titleChanged: typing.ClassVar[QtCore.pyqtSignal] - loadFinished: typing.ClassVar[QtCore.pyqtSignal] - loadProgress: typing.ClassVar[QtCore.pyqtSignal] - loadStarted: typing.ClassVar[QtCore.pyqtSignal] + def renderProcessTerminated(self, terminationStatus: QWebEnginePage.RenderProcessTerminationStatus, exitCode: int) -> None: ... + def iconUrlChanged(self, a0: QtCore.QUrl) -> None: ... + def urlChanged(self, a0: QtCore.QUrl) -> None: ... + def selectionChanged(self) -> None: ... + def titleChanged(self, title: str) -> None: ... + def loadFinished(self, a0: bool) -> None: ... + def loadProgress(self, progress: int) -> None: ... + def loadStarted(self) -> None: ... def reload(self) -> None: ... def forward(self) -> None: ... def back(self) -> None: ... diff --git a/PyQt5-stubs/QtWebSockets.pyi b/PyQt5-stubs/QtWebSockets.pyi index b331369a..bdb0d168 100644 --- a/PyQt5-stubs/QtWebSockets.pyi +++ b/PyQt5-stubs/QtWebSockets.pyi @@ -58,20 +58,20 @@ class QWebSocket(QtCore.QObject): def maxAllowedIncomingFrameSize(self) -> int: ... def setMaxAllowedIncomingFrameSize(self, maxAllowedIncomingFrameSize: int) -> None: ... def bytesToWrite(self) -> int: ... - preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] - sslErrors: typing.ClassVar[QtCore.pyqtSignal] - bytesWritten: typing.ClassVar[QtCore.pyqtSignal] - pong: typing.ClassVar[QtCore.pyqtSignal] - binaryMessageReceived: typing.ClassVar[QtCore.pyqtSignal] - textMessageReceived: typing.ClassVar[QtCore.pyqtSignal] - binaryFrameReceived: typing.ClassVar[QtCore.pyqtSignal] - textFrameReceived: typing.ClassVar[QtCore.pyqtSignal] - readChannelFinished: typing.ClassVar[QtCore.pyqtSignal] - proxyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] - stateChanged: typing.ClassVar[QtCore.pyqtSignal] - disconnected: typing.ClassVar[QtCore.pyqtSignal] - connected: typing.ClassVar[QtCore.pyqtSignal] - aboutToClose: typing.ClassVar[QtCore.pyqtSignal] + def preSharedKeyAuthenticationRequired(self, authenticator: QtNetwork.QSslPreSharedKeyAuthenticator) -> None: ... + def sslErrors(self, errors: typing.Iterable[QtNetwork.QSslError]) -> None: ... + def bytesWritten(self, bytes: int) -> None: ... + def pong(self, elapsedTime: int, payload: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def binaryMessageReceived(self, message: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def textMessageReceived(self, message: str) -> None: ... + def binaryFrameReceived(self, frame: typing.Union[QtCore.QByteArray, bytes, bytearray], isLastFrame: bool) -> None: ... + def textFrameReceived(self, frame: str, isLastFrame: bool) -> None: ... + def readChannelFinished(self) -> None: ... + def proxyAuthenticationRequired(self, proxy: QtNetwork.QNetworkProxy, pAuthenticator: QtNetwork.QAuthenticator) -> None: ... + def stateChanged(self, state: QtNetwork.QAbstractSocket.SocketState) -> None: ... + def disconnected(self) -> None: ... + def connected(self) -> None: ... + def aboutToClose(self) -> None: ... def ping(self, payload: typing.Union[QtCore.QByteArray, bytes, bytearray] = ...) -> None: ... @typing.overload def open(self, url: QtCore.QUrl) -> None: ... @@ -111,7 +111,10 @@ class QWebSocket(QtCore.QObject): def isValid(self) -> bool: ... def flush(self) -> bool: ... def errorString(self) -> str: ... - error: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def error(self) -> QtNetwork.QAbstractSocket.SocketError: ... + @typing.overload + def error(self, error: QtNetwork.QAbstractSocket.SocketError) -> None: ... def abort(self) -> None: ... @@ -196,14 +199,14 @@ class QWebSocketServer(QtCore.QObject): def setHandshakeTimeout(self, msec: int) -> None: ... def nativeDescriptor(self) -> sip.voidptr: ... def setNativeDescriptor(self, descriptor: sip.voidptr) -> bool: ... - preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] - closed: typing.ClassVar[QtCore.pyqtSignal] - sslErrors: typing.ClassVar[QtCore.pyqtSignal] - peerVerifyError: typing.ClassVar[QtCore.pyqtSignal] - newConnection: typing.ClassVar[QtCore.pyqtSignal] - originAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] - serverError: typing.ClassVar[QtCore.pyqtSignal] - acceptError: typing.ClassVar[QtCore.pyqtSignal] + def preSharedKeyAuthenticationRequired(self, authenticator: QtNetwork.QSslPreSharedKeyAuthenticator) -> None: ... + def closed(self) -> None: ... + def sslErrors(self, errors: typing.Iterable[QtNetwork.QSslError]) -> None: ... + def peerVerifyError(self, error: QtNetwork.QSslError) -> None: ... + def newConnection(self) -> None: ... + def originAuthenticationRequired(self, pAuthenticator: QWebSocketCorsAuthenticator) -> None: ... + def serverError(self, closeCode: QWebSocketProtocol.CloseCode) -> None: ... + def acceptError(self, socketError: QtNetwork.QAbstractSocket.SocketError) -> None: ... def handleConnection(self, socket: QtNetwork.QTcpSocket) -> None: ... def serverUrl(self) -> QtCore.QUrl: ... def supportedVersions(self) -> typing.List[QWebSocketProtocol.Version]: ... diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 284bf8ba..92d28ffb 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -1514,10 +1514,11 @@ class QVBoxLayout(QBoxLayout): class QButtonGroup(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - idToggled: typing.ClassVar[QtCore.pyqtSignal] - idReleased: typing.ClassVar[QtCore.pyqtSignal] - idPressed: typing.ClassVar[QtCore.pyqtSignal] - idClicked: typing.ClassVar[QtCore.pyqtSignal] + + def idToggled(self, a0: int, a1: bool) -> None: ... + def idReleased(self, a0: int) -> None: ... + def idPressed(self, a0: int) -> None: ... + def idClicked(self, a0: int) -> None: ... buttonToggled: typing.ClassVar[QtCore.pyqtSignal] buttonReleased: typing.ClassVar[QtCore.pyqtSignal] buttonPressed: typing.ClassVar[QtCore.pyqtSignal] @@ -1809,8 +1810,8 @@ class QComboBox(QWidget): def placeholderText(self) -> str: ... def setPlaceholderText(self, placeholderText: str) -> None: ... - textHighlighted: typing.ClassVar[QtCore.pyqtSignal] - textActivated: typing.ClassVar[QtCore.pyqtSignal] + def textHighlighted(self, a0: str) -> None: ... + def textActivated(self, a0: str) -> None: ... def currentData(self, role: int = ...) -> typing.Any: ... @typing.overload def inputMethodQuery(self, a0: QtCore.Qt.InputMethodQuery) -> typing.Any: ... @@ -1831,7 +1832,10 @@ class QComboBox(QWidget): def focusOutEvent(self, e: QtGui.QFocusEvent) -> None: ... def focusInEvent(self, e: QtGui.QFocusEvent) -> None: ... def initStyleOption(self, option: 'QStyleOptionComboBox') -> None: ... - highlighted: typing.ClassVar[QtCore.pyqtSignal] + @typing.overload + def highlighted(self, index: int) -> None: ... + @typing.overload + def highlighted(self, a0: str) -> None: ... currentTextChanged: typing.ClassVar[QtCore.pyqtSignal] currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] activated: typing.ClassVar[QtCore.pyqtSignal] @@ -3474,10 +3478,10 @@ class QDesktopWidget(QWidget): def __init__(self) -> None: ... def resizeEvent(self, e: QtGui.QResizeEvent) -> None: ... - primaryScreenChanged: typing.ClassVar[QtCore.pyqtSignal] - screenCountChanged: typing.ClassVar[QtCore.pyqtSignal] - workAreaResized: typing.ClassVar[QtCore.pyqtSignal] - resized: typing.ClassVar[QtCore.pyqtSignal] + def primaryScreenChanged(self) -> None: ... + def screenCountChanged(self, a0: int) -> None: ... + def workAreaResized(self, a0: int) -> None: ... + def resized(self, a0: int) -> None: ... @typing.overload def availableGeometry(self, screen: int = ...) -> QtCore.QRect: ... @typing.overload @@ -5744,7 +5748,7 @@ class QGraphicsScene(QtCore.QObject): def setFocusOnTouch(self, enabled: bool) -> None: ... focusOnTouch: typing.ClassVar[QtCore.pyqtSignal] - focusItemChanged: typing.ClassVar[QtCore.pyqtSignal] + def focusItemChanged(self, newFocus: QGraphicsItem, oldFocus: QGraphicsItem, reason: QtCore.Qt.FocusReason) -> None: ... def setMinimumRenderSize(self, minSize: float) -> None: ... def minimumRenderSize(self) -> float: ... def sendEvent(self, item: QGraphicsItem, event: QtCore.QEvent) -> bool: ... @@ -5987,7 +5991,7 @@ class QGraphicsScale(QGraphicsTransform): yScaleChanged: typing.ClassVar[QtCore.pyqtSignal] xScaleChanged: typing.ClassVar[QtCore.pyqtSignal] scaleChanged: typing.ClassVar[QtCore.pyqtSignal] - originChanged: typing.ClassVar[QtCore.pyqtSignal] + def originChanged(self) -> None: ... def applyTo(self, matrix: QtGui.QMatrix4x4) -> None: ... def setZScale(self, a0: float) -> None: ... def zScale(self) -> float: ... @@ -6834,7 +6838,8 @@ class QLineEdit(QWidget): def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... @typing.overload def __init__(self, contents: str, parent: typing.Optional[QWidget] = ...) -> None: ... - inputRejected: typing.ClassVar[QtCore.pyqtSignal] + + def inputRejected(self) -> None: ... def selectionLength(self) -> int: ... def selectionEnd(self) -> int: ... @typing.overload @@ -7697,7 +7702,7 @@ class QMessageBox(QDialog): def setCheckBox(self, cb: QCheckBox) -> None: ... def textInteractionFlags(self) -> QtCore.Qt.TextInteractionFlags: ... def setTextInteractionFlags(self, flags: typing.Union[QtCore.Qt.TextInteractionFlags, QtCore.Qt.TextInteractionFlag]) -> None: ... - buttonClicked: typing.ClassVar[QtCore.pyqtSignal] + def buttonClicked(self, button: QAbstractButton) -> None: ... def buttonRole(self, button: QAbstractButton) -> 'QMessageBox.ButtonRole': ... def buttons(self) -> typing.List[QAbstractButton]: ... @typing.overload @@ -8531,7 +8536,7 @@ class QSpinBox(QAbstractSpinBox): def stepType(self) -> QAbstractSpinBox.StepType: ... def setDisplayIntegerBase(self, base: int) -> None: ... def displayIntegerBase(self) -> int: ... - textChanged: typing.ClassVar[QtCore.pyqtSignal] + def textChanged(self, a0: str) -> None: ... valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, val: int) -> None: ... def event(self, e: QtCore.QEvent) -> bool: ... @@ -8560,7 +8565,7 @@ class QDoubleSpinBox(QAbstractSpinBox): def setStepType(self, stepType: QAbstractSpinBox.StepType) -> None: ... def stepType(self) -> QAbstractSpinBox.StepType: ... - textChanged: typing.ClassVar[QtCore.pyqtSignal] + def textChanged(self, a0: str) -> None: ... valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, val: float) -> None: ... def fixup(self, str: str) -> str: ... From f1f54c5ce7291b5124e7d8257d0d0f29903835fa Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 24 Aug 2021 16:31:25 +0200 Subject: [PATCH 046/421] improvements --- tests/qflags/adjust_qflags.py | 83 ++++++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 6 deletions(-) diff --git a/tests/qflags/adjust_qflags.py b/tests/qflags/adjust_qflags.py index 2a7e0685..bd97c472 100644 --- a/tests/qflags/adjust_qflags.py +++ b/tests/qflags/adjust_qflags.py @@ -1,3 +1,6 @@ +from typing import List, Tuple + +import functools import pprint, collections # command-line to generate the file: all_qflags.txt @@ -5,8 +8,12 @@ # note add something to make re at word-boundary DECLARED_QFLAGS_FNAME = 'all-flags.txt' QFLAG_SRC='src\\corelib\\global\\qflags.h' +SOURCE_QFLAGS_TESTS = 'qflags_windowFlags.py' +MARKER_SPECIFIC_START = '### Specific part' +MARKER_SPECIFIC_END = '### End of specific part' + -MODULES = [ +QTBASE_MODULES = [ ['QtCore', '../../PyQt5-stubs/QtCore.pyi'], ['QtWidgets', '../../PyQt5-stubs/QtWidgets.pyi'], ['QtGui', '../../PyQt5-stubs/QtGui.pyi'], @@ -19,8 +26,17 @@ ['QtXml', '../../PyQt5-stubs/QtXml.pyi'], ] -def parse_declared_qflags(fname: str) -> None: - parsed_qflags = [] # type: List[Tuple[str, str, str]] -> fname, qflags, enum +def parse_declared_qflags(fname: str) -> List[Tuple[str, str, str, List[str]]]: + '''Parses the list of modules from QTBASE_MODULES and look for the qflags declated in QFLAG_SRC + + Sort the result into 4 cases: + - qflag present once in only one module: we are sure that these can be safely replaced by a better version + - qflag present multiple times in one module: probably some extra module parsing might be needed to + understand which version is the qflag which we want to modify + - qflag present multiple times in multiples modules: we can not infer which module the flag is in + - qflag not present anywhere: these are probably not exported to PyQt + ''' + parsed_qflags = [] # type: List[Tuple[str, str, str, List[str]]] # -> fname, qflags, enum with open(fname) as f: for l in f.readlines()[:]: if len(l.strip()) == 0: @@ -38,7 +54,7 @@ def parse_declared_qflags(fname: str) -> None: # print('->', qflag_class, enum_class) # fill up modules with content - for mod_info in MODULES: + for mod_info in QTBASE_MODULES: mod_name, mod_stub_path = mod_info mod_info.append(open(mod_stub_path).read()) @@ -49,7 +65,7 @@ def parse_declared_qflags(fname: str) -> None: decl_qflag_class = 'class %s(' % qflag_class decl_enum_class = 'class %s(' % enum_class - for mod_name, mod_stub_path, mod_content in MODULES: + for mod_name, mod_stub_path, mod_content in QTBASE_MODULES: if decl_qflag_class in mod_content and decl_enum_class in mod_content: # we have found one module @@ -103,6 +119,60 @@ def parse_declared_qflags(fname: str) -> None: return qflags_with_one_module_single +@functools.lru_cache(maxsize=1) +def read_qflag_test_template() -> Tuple[List[str], List[str], List[str]]: + '''Return the source of template for generating qflags test. + + Return 3 parts: + - the first part should be unmodified + - the second part should be replaced for a specific QFlag class + - the third part should be unmodified + ''' + with open(SOURCE_QFLAGS_TESTS) as f: + lines = f.readlines() + + sourcePart1, sourcePart2, sourcePart3 = [], [], [] + fillPart2, fillPart3 = False, False + for l in lines: + if fillPart3: + sourcePart3.append(l) + continue + + if fillPart2: + if MARKER_SPECIFIC_END in l: + fillPart3 = True + sourcePart3.append(l) + continue + + sourcePart2.append(l) + continue + + sourcePart1.append(l) + if MARKER_SPECIFIC_START in l: + fillPart2 = True + + return sourcePart1, sourcePart2, sourcePart3 + + +def generate_one_qflag_file(qflag_fname: str, multiFlagName: str, oneFlagName: str, oneFlagValue1: str, oneFlagValue2: str) -> None: + sourcePart1, sourcePart2, sourcePart3 = read_qflag_test_template() + + with open(qflag_fname, 'w') as f: + f.writelines(sourcePart1) + f.write('''# file generated from {source} for QFlags class "{multiFlagName}" and flag class "{oneFlagName}" + +OneFlagClass = {oneFlagName} +MultiFlagClass = {multiFlagName} + +oneFlagRefValue1 = {oneFlagValue1} +oneFlagRefValue2 = {oneFlagValue2} +'''.format(source=SOURCE_QFLAGS_TESTS, multiFlagName=multiFlagName, oneFlagName=oneFlagName, + oneFlagValue1=oneFlagValue1, oneFlagValue2=oneFlagValue2 + )) + f.writelines(sourcePart3) + print('File %s generated' % qflag_fname) + + # TODO: @@ -124,4 +194,5 @@ def parse_declared_qflags(fname: str) -> None: if __name__ == '__main__': qflags_with_module = parse_declared_qflags(DECLARED_QFLAGS_FNAME) for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_module: - generate_test_file(qflag_class, enum_class, qflag_fname) + # generate_test_file(qflag_class, enum_class, qflag_fname) + pass From 17e4270d6a3d26698e21385a9470c0fdebb30778 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 24 Aug 2021 16:30:55 +0200 Subject: [PATCH 047/421] Can locate QFlag into pyqt module --- ....py => generate_qflags_stubs_and_tests.py} | 150 ++++++++--- tests/qflags/qflags_windowflags.py | 232 ++++++++++++++++++ ...all-flags.txt => qt-qflag-grep-result.txt} | 0 3 files changed, 347 insertions(+), 35 deletions(-) rename tests/qflags/{adjust_qflags.py => generate_qflags_stubs_and_tests.py} (57%) create mode 100644 tests/qflags/qflags_windowflags.py rename tests/qflags/{all-flags.txt => qt-qflag-grep-result.txt} (100%) diff --git a/tests/qflags/adjust_qflags.py b/tests/qflags/generate_qflags_stubs_and_tests.py similarity index 57% rename from tests/qflags/adjust_qflags.py rename to tests/qflags/generate_qflags_stubs_and_tests.py index bd97c472..bc2a7dd0 100644 --- a/tests/qflags/adjust_qflags.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -1,14 +1,26 @@ -from typing import List, Tuple +from typing import List, Tuple, Dict +import dataclasses import functools +import json import pprint, collections -# command-line to generate the file: all_qflags.txt -# qt-src\qt5\qtbase>rg --type-add "headers:*.h" -t headers Q_DECLARE_FLAGS --no-heading > all-flags.txt -# note add something to make re at word-boundary -DECLARED_QFLAGS_FNAME = 'all-flags.txt' +'''How to use this generator script: + +1. Grep Qt sources, looking for all QFlag based classes. The command-line to use is: + + qt-src\qt5\qtbase>rg --type-add "headers:*.h" -t headers Q_DECLARE_FLAGS --no-heading > qt-qflag-grep-result.txt + +2. Run the script to identify where each QFlag is located in PyQt. +''' + +# the file defining the qflag implementation, to be skipped QFLAG_SRC='src\\corelib\\global\\qflags.h' + +# the template after which we model all generated qflag tests SOURCE_QFLAGS_TESTS = 'qflags_windowFlags.py' + +# the markers inside the above template to identify the parts to replace MARKER_SPECIFIC_START = '### Specific part' MARKER_SPECIFIC_END = '### End of specific part' @@ -26,8 +38,28 @@ ['QtXml', '../../PyQt5-stubs/QtXml.pyi'], ] -def parse_declared_qflags(fname: str) -> List[Tuple[str, str, str, List[str]]]: - '''Parses the list of modules from QTBASE_MODULES and look for the qflags declated in QFLAG_SRC +@dataclasses.dataclass +class QFlagLocationInfo: + grep_line: str + qflag_class: str + qflag_enum: str + + # list of (module_name, module_path) + module_info: List[ Tuple[str, str] ] + +def json_encode_qflaglocationinfo(flag_loc_info: object) -> object: + if not isinstance(flag_loc_info, QFlagLocationInfo): + # oups, we don't know how to encode that + return flag_loc_info + + return dataclasses.asdict(flag_loc_info) + + +def identify_qflag_location(fname_grep_result: str, + qt_modules: List[Tuple[str, str]] + ) -> List[ QFlagLocationInfo ]: + '''Parses the grep results to extract each qflag, and then look into all Qt modules + to see where the flag is located. Sort the result into 4 cases: - qflag present once in only one module: we are sure that these can be safely replaced by a better version @@ -36,44 +68,82 @@ def parse_declared_qflags(fname: str) -> List[Tuple[str, str, str, List[str]]]: - qflag present multiple times in multiples modules: we can not infer which module the flag is in - qflag not present anywhere: these are probably not exported to PyQt ''' - parsed_qflags = [] # type: List[Tuple[str, str, str, List[str]]] # -> fname, qflags, enum - with open(fname) as f: + parsed_qflags = [] # type: List[ QFlagLocationInfo ] + with open(fname_grep_result) as f: for l in f.readlines()[:]: - if len(l.strip()) == 0: + grep_line = l.strip() + if len(grep_line) == 0: continue - qflag_fname, qflag_declare_stmt = [s.strip(' \t\n') for s in l.split(':')] + qflag_fname, qflag_declare_stmt = [s.strip(' \t\n') for s in grep_line.split(':')] if qflag_fname == QFLAG_SRC: # do not include actual implementation of qflags continue assert 'Q_DECLARE_FLAGS' in qflag_declare_stmt - print(qflag_declare_stmt) s = qflag_declare_stmt[qflag_declare_stmt.index('(')+1:qflag_declare_stmt.index(')')] qflag_class, enum_class = [v.strip(' ') for v in s.split(',')] - parsed_qflags.append((qflag_fname, qflag_class, enum_class, [])) - # print(qflag_fname) - # print('->', qflag_class, enum_class) + parsed_qflags.append( + QFlagLocationInfo(grep_line, qflag_class, enum_class, []) + ) # fill up modules with content - for mod_info in QTBASE_MODULES: - mod_name, mod_stub_path = mod_info - mod_info.append(open(mod_stub_path).read()) - - mod_qflags = collections.defaultdict(lambda: collections.defaultdict(int)) - - for qflag_info in parsed_qflags: - qflag_fname, qflag_class, enum_class, qflag_modules = qflag_info + qt_modules_content = [ (mod_name, mod_stub_path, open(mod_stub_path, encoding='utf8').read()) + for (mod_name, mod_stub_path) in qt_modules] - decl_qflag_class = 'class %s(' % qflag_class - decl_enum_class = 'class %s(' % enum_class - for mod_name, mod_stub_path, mod_content in QTBASE_MODULES: + for qflag_loc_info in parsed_qflags: + decl_qflag_class = 'class %s(' % qflag_loc_info.qflag_class + decl_enum_class = 'class %s(' % qflag_loc_info.qflag_enum + for mod_name, mod_stub_path, mod_content in qt_modules_content: if decl_qflag_class in mod_content and decl_enum_class in mod_content: # we have found one module - print('Adding QFlags %s to module %s' % (qflag_class, mod_name)) - qflag_modules.append(mod_name) - mod_qflags[mod_name][qflag_class] += 1 - - + print('Adding QFlags %s to module %s' % (qflag_loc_info.qflag_class, mod_name)) + qflag_loc_info.module_info.append((mod_name, mod_stub_path)) + + count_qflag_class = mod_content.count(decl_qflag_class) + count_enum_class = mod_content.count(decl_enum_class) + if count_qflag_class > 1 and count_enum_class > 1: + print('QFlag present more than once, adding it more than once') + extra_add = min(count_qflag_class, count_enum_class) - 1 + for _ in range(extra_add): + qflag_loc_info.module_info.append((mod_name, mod_stub_path)) + + return parsed_qflags + +def group_qflags(qflag_location: List[QFlagLocationInfo] ) -> Dict[str, List[QFlagLocationInfo]]: + '''Group the QFlags into the following groups: + * one_flag_one_module: this flag is present once in one module exactly. + * one_flag_many_modules: this flag is present once or multiple times in one or multiple modules + * one_flag_no_module: this flag is not present in any modules at all. + + The first group is suitable for automatic processing. + The second group requires human verification + The last group reflects the non exported QFlags + ''' + d = { + 'one_flag_one_module': [ + qflag_loc_info for qflag_loc_info in qflag_location + if len(qflag_loc_info.module_info) == 1 + ], + 'one_flag_many_modules': [ + qflag_loc_info for qflag_loc_info in qflag_location + if len(qflag_loc_info.module_info) > 1 + ], + 'one_flag_no_module': [ + qflag_loc_info for qflag_loc_info in qflag_location + if len(qflag_loc_info.module_info) == 0 + ], + } + + return d + +def extract_qflags_to_process(qflags_modules_analysis_json: str) -> None: + '''Take the json file as input describing qflags and their location in modules. + + The qflags which are located in a single module will be selected for further processing. + + The others are marked as skipped. + ''' + return qflags_with_one_module_single = [ qflag_info for qflag_info in parsed_qflags if (len(qflag_info[-1]) == 1) and (mod_qflags[qflag_info[-1][0]][qflag_info[1]] == 1) ] qflags_with_one_module_multiple = [ qflag_info for qflag_info in parsed_qflags @@ -192,7 +262,17 @@ def generate_one_qflag_file(qflag_fname: str, multiFlagName: str, oneFlagName: s # analyse the result if __name__ == '__main__': - qflags_with_module = parse_declared_qflags(DECLARED_QFLAGS_FNAME) - for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_module: - # generate_test_file(qflag_class, enum_class, qflag_fname) - pass + qt_qflag_grep_result_fname = 'qt-qflag-grep-result.txt' + location_qflags = identify_qflag_location(qt_qflag_grep_result_fname, QTBASE_MODULES) + print('%d qflags extracted from grep file' % len(location_qflags)) + qflags_groups = group_qflags(location_qflags) + print('%d qflags ready to be processed' % len(qflags_groups['one_flag_one_module'])) + + qflags_modules_analysis_json = 'qflags_modules_analysis.json' + # put our intermediate classification into a json file for human review + with open(qflags_modules_analysis_json, 'w') as f: + json.dump(qflags_groups, f, indent=4, default=json_encode_qflaglocationinfo) + print('QFlag analysis saved to: %s' % qflags_modules_analysis_json) + + qflags_to_process = extract_qflags_to_process(qflags_modules_analysis_json) + # diff --git a/tests/qflags/qflags_windowflags.py b/tests/qflags/qflags_windowflags.py new file mode 100644 index 00000000..18c1fcd1 --- /dev/null +++ b/tests/qflags/qflags_windowflags.py @@ -0,0 +1,232 @@ +from typing import Union, TypeVar, Type +import pytest +from PyQt5 import QtCore, QtWidgets + +### Specific part +# This file is used as a source to generate all qflags related tests. The specific part +# changes for each test but the rest of the file is totally identical + +OneFlagClass = QtCore.Qt.WindowType +MultiFlagClass = QtCore.Qt.WindowFlags + +oneFlagRefValue1 = QtCore.Qt.WindowContextHelpButtonHint +oneFlagRefValue2 = QtCore.Qt.WindowMaximizeButtonHint +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + diff --git a/tests/qflags/all-flags.txt b/tests/qflags/qt-qflag-grep-result.txt similarity index 100% rename from tests/qflags/all-flags.txt rename to tests/qflags/qt-qflag-grep-result.txt From 8949a286afb266fbfcceae1d901b7562795c6cfc Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 24 Aug 2021 16:30:10 +0200 Subject: [PATCH 048/421] Work in progress for testing qflags --- .../qflags/generate_qflags_stubs_and_tests.py | 160 ++++++++++++------ 1 file changed, 108 insertions(+), 52 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index bc2a7dd0..e21834ff 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -2,8 +2,9 @@ import dataclasses import functools +import itertools import json -import pprint, collections +import collections '''How to use this generator script: @@ -136,58 +137,99 @@ def group_qflags(qflag_location: List[QFlagLocationInfo] ) -> Dict[str, List[QFl return d -def extract_qflags_to_process(qflags_modules_analysis_json: str) -> None: - '''Take the json file as input describing qflags and their location in modules. +def extract_qflags_to_process(qflags_modules_analysis_json: str, + qflags_to_process_json: str, + ) -> None: + '''Take the json file as input describing qflags and their modules and output a json file of qflags planned to be processed. The qflags which are located in a single module will be selected for further processing. + The others are marked as skipped with a proper reason. + ''' + with open(qflags_modules_analysis_json) as f: + d = json.load(f) + + result = { + '__': 'This file can be adjusted manually by a human prior to being processed by the tool', + 'qflags_to_process': [], + 'qflags_to_skip': [], + } + + for qflag_info in d['one_flag_many_modules']: + result['qflags_to_skip'].append( + { + 'qflag_class': qflag_info['qflag_class'], + 'qflag_enum': qflag_info['qflag_enum'], + 'skipReason': 'QFlag present more than once or in multiple modules' + } + ) + + for qflag_info in d['one_flag_no_module']: + result['qflags_to_skip'].append( + { + 'qflag_class': qflag_info['qflag_class'], + 'qflag_enum': qflag_info['qflag_enum'], + 'skipReason': 'QFlag not found', + } + ) + + for qflag_info in d['one_flag_one_module']: + result['qflags_to_process'].append( qflag_info ) + + with open(qflags_to_process_json, 'w') as f: + json.dump(result, f, indent=4) + - The others are marked as skipped. +def process_qflag(qflag_to_process_json: str, qflag_result_json: str) -> bool: + '''Read the qflags to process from the json file + + Process one qflag, by either: + * identifying that this flag is already processed and moving the flag to qflags_done + * identifying a reason why this flag can't be processed and moving the flag to qflags_error + * performing the qflag ajustment process: + * generate a test file for this qflag usage + * change the .pyi module for this qflag for supporting all the qflag operations + * run pytest on the result + * run mypy on the result + * run the tox on result + + Return True when all flags have been processed ''' - return - qflags_with_one_module_single = [ qflag_info for qflag_info in parsed_qflags - if (len(qflag_info[-1]) == 1) and (mod_qflags[qflag_info[-1][0]][qflag_info[1]] == 1) ] - qflags_with_one_module_multiple = [ qflag_info for qflag_info in parsed_qflags - if (len(qflag_info[-1]) == 1) and (mod_qflags[qflag_info[-1][0]][qflag_info[1]] != 1) ] - qflags_with_no_module = [ qflag_info for qflag_info in parsed_qflags if len(qflag_info[-1]) == 0] - qflags_with_many_module = [ qflag_info for qflag_info in parsed_qflags if len(qflag_info[-1]) > 1] - - qflags_with_one_module_single.sort(key=lambda v: (v[-1], v[1])) - qflags_with_one_module_multiple.sort(key=lambda v: (v[-1], v[1])) - qflags_with_no_module.sort(key=lambda v: (v[-1], v[1])) - qflags_with_many_module.sort(key=lambda v: (v[-1], v[1])) - - DISP_RESULTS = True - if DISP_RESULTS: - print('\nFlags identified with one module, unique in the module') - last_mod_name = '' - for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_one_module_single: - mod_name = qflag_modules[0] - if mod_name != last_mod_name: - print('\t%s:' % mod_name) - last_mod_name = mod_name - print('\t\t"%s" "%s" \t\t%s' % (qflag_class, enum_class, qflag_fname)) - - - print('\nFlags identified with one module, multiples in the module') - last_mod_name = '' - for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_one_module_multiple: - mod_name = qflag_modules[0] - if mod_name != last_mod_name: - print('\t%s:' % mod_name) - last_mod_name = mod_name - print('\t\t"%s" "%s" \t\t%s' % (qflag_class, enum_class, qflag_fname)) - - - print('\nqflags without module:') - for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_no_module: - print('\t\t"%s" "%s" \t\t%s []' % (qflag_class, enum_class, qflag_fname)) - - - print('\nqflags with many module:') - for qflag_fname, qflag_class, enum_class, qflag_modules in qflags_with_many_module: - print('\t\t"%s" "%s" \t\t%s [%s]' % (qflag_class, enum_class, qflag_fname, ' '.join(qflag_modules))) - - return qflags_with_one_module_single + with open(qflag_to_process_json) as f: + d = json.load(f) + + result = { + 'qflag_already_done': [], + 'qflag_processed_done': [], + 'qflag_process_error': [], + } + + if len(d['qflags_to_process']) == 0: + return True + + try: + flag_info_dict = d['qflags_to_process'].pop(0) + + # check if qflag has already been processed. If so move to the next one + # if all qflags have been processed, return True + + flag_info = QFlagLocationInfo(**flag_info_dict) + print('Processing qflag: %s / %s in module %s ' % + (flag_info.qflag_class, + flag_info.qflag_enum, + flag_info.module_info[0][0] if len(flag_info.module_info) else '' + )) + + with open(flag_info.module_info[0][1], encoding='utf8') as f: + mod_content = f.read() + + assert mod_content.count('class %s(' % flag_info.qflag_class) == 1 + assert mod_content.count('class %s(' % flag_info.qflag_enum) == 1 + + return False + finally: + with open(qflag_result_json, 'w') as f: + json.dump(result, f, indent=4) + @functools.lru_cache(maxsize=1) def read_qflag_test_template() -> Tuple[List[str], List[str], List[str]]: @@ -261,7 +303,8 @@ def generate_one_qflag_file(qflag_fname: str, multiFlagName: str, oneFlagName: s # # analyse the result -if __name__ == '__main__': +def generate_qflags_to_process(): + '''Run the generation process from the grep output parsing to the generation of json file listing the flags to process''' qt_qflag_grep_result_fname = 'qt-qflag-grep-result.txt' location_qflags = identify_qflag_location(qt_qflag_grep_result_fname, QTBASE_MODULES) print('%d qflags extracted from grep file' % len(location_qflags)) @@ -274,5 +317,18 @@ def generate_one_qflag_file(qflag_fname: str, multiFlagName: str, oneFlagName: s json.dump(qflags_groups, f, indent=4, default=json_encode_qflaglocationinfo) print('QFlag analysis saved to: %s' % qflags_modules_analysis_json) - qflags_to_process = extract_qflags_to_process(qflags_modules_analysis_json) - # + qflags_to_process_json = 'qflags_to_process.json' + extract_qflags_to_process(qflags_modules_analysis_json, qflags_to_process_json) + + +if __name__ == '__main__': + # generate_qflags_to_process() + + qflags_to_process_json = 'qflags_to_process.json' + # here we have the opportunity for human modification of the json file + + qflag_result_json = 'qflag_process_result.json' + + process_qflag(qflags_to_process_json, qflag_result_json) + + From cba2436a1ab4998c7f4ee51f440385484b39e739 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 24 Aug 2021 10:41:37 +0200 Subject: [PATCH 049/421] work in progress --- .../qflags/generate_qflags_stubs_and_tests.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index e21834ff..a8e2b576 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -225,6 +225,46 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str) -> bool: assert mod_content.count('class %s(' % flag_info.qflag_class) == 1 assert mod_content.count('class %s(' % flag_info.qflag_enum) == 1 + mod_lines = mod_content.split('\n') + + # find fqn of the class + qflag_class_lines = simple_class_finder(mod_lines, flag_info.qflag_class) + qflag_enum_lines = simple_class_finder(mod_lines, flag_info.qflag_enum) + + ''' +Operation to perform: + +On the enum class, add two methods: + class KeyboardModifier(int): ++ def __or__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... # type: ignore[override] ++ def __ror__ (self, other: int) -> 'Qt.KeyboardModifiers': ... # type: ignore[override, misc] + +On the qflag class, add one more argument to __init__() +- def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: ... ++ def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ... + +Possibly, remove the __init__() with only int argument if it exists + +Add more methods: + def __or__ (self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __and__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __xor__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __ror__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... +''' + # find the method content of the class + + # check that the mandatory operators are present or missing + # generate the filename + # if all conditions are met, declare the flag as already done + # if not, create the missing methods + # generate the test file + # run tox + # mark the test as done + + # if there are more flags to process, return False + # if all flags are processed, return True return False finally: with open(qflag_result_json, 'w') as f: From 6cf4838960a16c5ce7e922725909a1841aad938c Mon Sep 17 00:00:00 2001 From: TilmanK Date: Tue, 24 Aug 2021 20:40:36 +0200 Subject: [PATCH 050/421] Fixed handling of empty lines. --- PyQt5-stubs/Qt3DAnimation.pyi | 104 ++--- PyQt5-stubs/Qt3DCore.pyi | 62 +-- PyQt5-stubs/Qt3DExtras.pyi | 328 ++++++++-------- PyQt5-stubs/Qt3DInput.pyi | 156 ++++---- PyQt5-stubs/Qt3DLogic.pyi | 2 +- PyQt5-stubs/Qt3DRender.pyi | 541 +++++++++++++------------- PyQt5-stubs/QtBluetooth.pyi | 101 ++--- PyQt5-stubs/QtChart.pyi | 566 ++++++++++++++-------------- PyQt5-stubs/QtCore.pyi | 151 ++++---- PyQt5-stubs/QtDBus.pyi | 16 +- PyQt5-stubs/QtDataVisualization.pyi | 510 ++++++++++++------------- PyQt5-stubs/QtDesigner.pyi | 36 +- PyQt5-stubs/QtGui.pyi | 140 +++---- PyQt5-stubs/QtHelp.pyi | 42 +-- PyQt5-stubs/QtLocation.pyi | 81 ++-- PyQt5-stubs/QtMultimedia.pyi | 507 +++++++++++-------------- PyQt5-stubs/QtMultimediaWidgets.pyi | 22 +- PyQt5-stubs/QtNetwork.pyi | 113 +++--- PyQt5-stubs/QtNetworkAuth.pyi | 60 +-- PyQt5-stubs/QtNfc.pyi | 32 +- PyQt5-stubs/QtPositioning.pyi | 30 +- PyQt5-stubs/QtPrintSupport.pyi | 5 +- PyQt5-stubs/QtPurchasing.pyi | 6 +- PyQt5-stubs/QtQml.pyi | 10 +- PyQt5-stubs/QtQuick.pyi | 32 +- PyQt5-stubs/QtQuickWidgets.pyi | 4 +- PyQt5-stubs/QtRemoteObjects.pyi | 22 +- PyQt5-stubs/QtSensors.pyi | 42 +-- PyQt5-stubs/QtSerialPort.pyi | 27 +- PyQt5-stubs/QtSql.pyi | 13 +- PyQt5-stubs/QtSvg.pyi | 2 +- PyQt5-stubs/QtWebChannel.pyi | 4 +- PyQt5-stubs/QtWebEngine.pyi | 40 +- PyQt5-stubs/QtWebEngineCore.pyi | 6 +- PyQt5-stubs/QtWebEngineWidgets.pyi | 90 ++--- PyQt5-stubs/QtWebSockets.pyi | 49 ++- PyQt5-stubs/QtWidgets.pyi | 37 +- signal_fixer.py | 48 ++- 38 files changed, 1971 insertions(+), 2066 deletions(-) diff --git a/PyQt5-stubs/Qt3DAnimation.pyi b/PyQt5-stubs/Qt3DAnimation.pyi index 90a0c766..0c0c0a9f 100644 --- a/PyQt5-stubs/Qt3DAnimation.pyi +++ b/PyQt5-stubs/Qt3DAnimation.pyi @@ -52,9 +52,9 @@ class QAbstractAnimation(QtCore.QObject): MorphingAnimation = ... # type: QAbstractAnimation.AnimationType VertexBlendAnimation = ... # type: QAbstractAnimation.AnimationType - def durationChanged(self, duration: float) -> None: ... - def positionChanged(self, position: float) -> None: ... - def animationNameChanged(self, name: str) -> None: ... + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + animationNameChanged: typing.ClassVar[QtCore.pyqtSignal] def setDuration(self, duration: float) -> None: ... def setPosition(self, position: float) -> None: ... def setAnimationName(self, name: str) -> None: ... @@ -66,7 +66,7 @@ class QAbstractAnimation(QtCore.QObject): class QAbstractAnimationClip(Qt3DCore.QNode): def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def durationChanged(self, duration: float) -> None: ... + durationChanged: typing.ClassVar[QtCore.pyqtSignal] def duration(self) -> float: ... class QAbstractChannelMapping(Qt3DCore.QNode): ... @@ -81,11 +81,11 @@ class QAbstractClipAnimator(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def normalizedTimeChanged(self, index: float) -> None: ... - def clockChanged(self, clock: 'QClock') -> None: ... - def loopCountChanged(self, loops: int) -> None: ... - def channelMapperChanged(self, channelMapper: 'QChannelMapper') -> None: ... - def runningChanged(self, running: bool) -> None: ... + normalizedTimeChanged: typing.ClassVar[QtCore.pyqtSignal] + clockChanged: typing.ClassVar[QtCore.pyqtSignal] + loopCountChanged: typing.ClassVar[QtCore.pyqtSignal] + channelMapperChanged: typing.ClassVar[QtCore.pyqtSignal] + runningChanged: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def start(self) -> None: ... def setNormalizedTime(self, timeFraction: float) -> None: ... @@ -107,9 +107,9 @@ class QAdditiveClipBlend('QAbstractClipBlendNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def additiveClipChanged(self, additiveClip: 'QAbstractClipBlendNode') -> None: ... - def baseClipChanged(self, baseClip: 'QAbstractClipBlendNode') -> None: ... - def additiveFactorChanged(self, additiveFactor: float) -> None: ... + additiveClipChanged: typing.ClassVar[QtCore.pyqtSignal] + baseClipChanged: typing.ClassVar[QtCore.pyqtSignal] + additiveFactorChanged: typing.ClassVar[QtCore.pyqtSignal] def setAdditiveClip(self, additiveClip: 'QAbstractClipBlendNode') -> None: ... def setBaseClip(self, baseClip: 'QAbstractClipBlendNode') -> None: ... def setAdditiveFactor(self, additiveFactor: float) -> None: ... @@ -125,7 +125,7 @@ class QAnimationClip('QAbstractAnimationClip'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def clipDataChanged(self, clipData: 'QAnimationClipData') -> None: ... + clipDataChanged: typing.ClassVar[QtCore.pyqtSignal] def setClipData(self, clipData: 'QAnimationClipData') -> None: ... def clipData(self) -> 'QAnimationClipData': ... @@ -162,8 +162,8 @@ class QAnimationClipLoader('QAbstractAnimationClip'): def __init__(self, source: QtCore.QUrl, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QAnimationClipLoader.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSource(self, source: QtCore.QUrl) -> None: ... def status(self) -> 'QAnimationClipLoader.Status': ... def source(self) -> QtCore.QUrl: ... @@ -172,12 +172,12 @@ class QAnimationController(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def recursiveChanged(self, recursive: bool) -> None: ... - def entityChanged(self, entity: Qt3DCore.QEntity) -> None: ... - def positionOffsetChanged(self, offset: float) -> None: ... - def positionScaleChanged(self, scale: float) -> None: ... - def positionChanged(self, position: float) -> None: ... - def activeAnimationGroupChanged(self, index: int) -> None: ... + recursiveChanged: typing.ClassVar[QtCore.pyqtSignal] + entityChanged: typing.ClassVar[QtCore.pyqtSignal] + positionOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] + positionScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + activeAnimationGroupChanged: typing.ClassVar[QtCore.pyqtSignal] def setRecursive(self, recursive: bool) -> None: ... def setEntity(self, entity: Qt3DCore.QEntity) -> None: ... def setPositionOffset(self, offset: float) -> None: ... @@ -201,9 +201,9 @@ class QAnimationGroup(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def durationChanged(self, duration: float) -> None: ... - def positionChanged(self, position: float) -> None: ... - def nameChanged(self, name: str) -> None: ... + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] def setPosition(self, position: float) -> None: ... def setName(self, name: str) -> None: ... def removeAnimation(self, animation: 'QAbstractAnimation') -> None: ... @@ -218,7 +218,7 @@ class QBlendedClipAnimator('QAbstractClipAnimator'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def blendTreeChanged(self, blendTree: 'QAbstractClipBlendNode') -> None: ... + blendTreeChanged: typing.ClassVar[QtCore.pyqtSignal] def setBlendTree(self, blendTree: 'QAbstractClipBlendNode') -> None: ... def blendTree(self) -> 'QAbstractClipBlendNode': ... @@ -270,9 +270,9 @@ class QChannelMapping('QAbstractChannelMapping'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def propertyChanged(self, property: str) -> None: ... - def targetChanged(self, target: Qt3DCore.QNode) -> None: ... - def channelNameChanged(self, channelName: str) -> None: ... + propertyChanged: typing.ClassVar[QtCore.pyqtSignal] + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + channelNameChanged: typing.ClassVar[QtCore.pyqtSignal] def setProperty(self, property: str) -> None: ... # type: ignore[override] def setTarget(self, target: Qt3DCore.QNode) -> None: ... def setChannelName(self, channelName: str) -> None: ... @@ -284,7 +284,7 @@ class QClipAnimator('QAbstractClipAnimator'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def clipChanged(self, clip: 'QAbstractAnimationClip') -> None: ... + clipChanged: typing.ClassVar[QtCore.pyqtSignal] def setClip(self, clip: 'QAbstractAnimationClip') -> None: ... def clip(self) -> 'QAbstractAnimationClip': ... @@ -299,7 +299,7 @@ class QClipBlendValue('QAbstractClipBlendNode'): @typing.overload def __init__(self, clip: 'QAbstractAnimationClip', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def clipChanged(self, clip: 'QAbstractAnimationClip') -> None: ... + clipChanged: typing.ClassVar[QtCore.pyqtSignal] def setClip(self, clip: 'QAbstractAnimationClip') -> None: ... def clip(self) -> 'QAbstractAnimationClip': ... @@ -307,7 +307,7 @@ class QClock(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def playbackRateChanged(self, playbackRate: float) -> None: ... + playbackRateChanged: typing.ClassVar[QtCore.pyqtSignal] def setPlaybackRate(self, playbackRate: float) -> None: ... def playbackRate(self) -> float: ... @@ -353,12 +353,12 @@ class QKeyframeAnimation('QAbstractAnimation'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def endModeChanged(self, endMode: 'QKeyframeAnimation.RepeatMode') -> None: ... - def startModeChanged(self, startMode: 'QKeyframeAnimation.RepeatMode') -> None: ... - def targetNameChanged(self, name: str) -> None: ... - def easingChanged(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... - def targetChanged(self, target: Qt3DCore.QTransform) -> None: ... - def framePositionsChanged(self, positions: typing.Iterable[float]) -> None: ... + endModeChanged: typing.ClassVar[QtCore.pyqtSignal] + startModeChanged: typing.ClassVar[QtCore.pyqtSignal] + targetNameChanged: typing.ClassVar[QtCore.pyqtSignal] + easingChanged: typing.ClassVar[QtCore.pyqtSignal] + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + framePositionsChanged: typing.ClassVar[QtCore.pyqtSignal] def setEndMode(self, mode: 'QKeyframeAnimation.RepeatMode') -> None: ... def setStartMode(self, mode: 'QKeyframeAnimation.RepeatMode') -> None: ... def setTargetName(self, name: str) -> None: ... @@ -380,9 +380,9 @@ class QLerpClipBlend('QAbstractClipBlendNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def endClipChanged(self, endClip: 'QAbstractClipBlendNode') -> None: ... - def startClipChanged(self, startClip: 'QAbstractClipBlendNode') -> None: ... - def blendFactorChanged(self, blendFactor: float) -> None: ... + endClipChanged: typing.ClassVar[QtCore.pyqtSignal] + startClipChanged: typing.ClassVar[QtCore.pyqtSignal] + blendFactorChanged: typing.ClassVar[QtCore.pyqtSignal] def setEndClip(self, endClip: 'QAbstractClipBlendNode') -> None: ... def setStartClip(self, startClip: 'QAbstractClipBlendNode') -> None: ... def setBlendFactor(self, blendFactor: float) -> None: ... @@ -401,12 +401,12 @@ class QMorphingAnimation('QAbstractAnimation'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def easingChanged(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... - def methodChanged(self, method: 'QMorphingAnimation.Method') -> None: ... - def targetNameChanged(self, name: str) -> None: ... - def targetChanged(self, target: Qt3DRender.QGeometryRenderer) -> None: ... - def interpolatorChanged(self, interpolator: float) -> None: ... - def targetPositionsChanged(self, targetPositions: typing.Iterable[float]) -> None: ... + easingChanged: typing.ClassVar[QtCore.pyqtSignal] + methodChanged: typing.ClassVar[QtCore.pyqtSignal] + targetNameChanged: typing.ClassVar[QtCore.pyqtSignal] + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + interpolatorChanged: typing.ClassVar[QtCore.pyqtSignal] + targetPositionsChanged: typing.ClassVar[QtCore.pyqtSignal] def setEasing(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... def setMethod(self, method: 'QMorphingAnimation.Method') -> None: ... def setTargetName(self, name: str) -> None: ... @@ -429,7 +429,7 @@ class QMorphTarget(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def attributeNamesChanged(self, attributeNames: typing.Iterable[str]) -> None: ... + attributeNamesChanged: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def fromGeometry(geometry: Qt3DRender.QGeometry, attributes: typing.Iterable[str]) -> 'QMorphTarget': ... def removeAttribute(self, attribute: Qt3DRender.QAttribute) -> None: ... @@ -442,7 +442,7 @@ class QSkeletonMapping('QAbstractChannelMapping'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def skeletonChanged(self, skeleton: Qt3DCore.QAbstractSkeleton) -> None: ... + skeletonChanged: typing.ClassVar[QtCore.pyqtSignal] def setSkeleton(self, skeleton: Qt3DCore.QAbstractSkeleton) -> None: ... def skeleton(self) -> Qt3DCore.QAbstractSkeleton: ... @@ -450,10 +450,10 @@ class QVertexBlendAnimation('QAbstractAnimation'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def targetNameChanged(self, name: str) -> None: ... - def targetChanged(self, target: Qt3DRender.QGeometryRenderer) -> None: ... - def interpolatorChanged(self, interpolator: float) -> None: ... - def targetPositionsChanged(self, targetPositions: typing.Iterable[float]) -> None: ... + targetNameChanged: typing.ClassVar[QtCore.pyqtSignal] + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + interpolatorChanged: typing.ClassVar[QtCore.pyqtSignal] + targetPositionsChanged: typing.ClassVar[QtCore.pyqtSignal] def setTargetName(self, name: str) -> None: ... def setTarget(self, target: Qt3DRender.QGeometryRenderer) -> None: ... def setTargetPositions(self, targetPositions: typing.Iterable[float]) -> None: ... diff --git a/PyQt5-stubs/Qt3DCore.pyi b/PyQt5-stubs/Qt3DCore.pyi index 66970665..76b4ed67 100644 --- a/PyQt5-stubs/Qt3DCore.pyi +++ b/PyQt5-stubs/Qt3DCore.pyi @@ -115,7 +115,7 @@ class QNode(QtCore.QObject): def sendReply(self, command: 'QNodeCommand') -> None: ... def sendCommand(self, name: str, data: typing.Any = ..., replyTo: int = ...) -> int: ... - def defaultPropertyTrackingModeChanged(self, mode: 'QNode.PropertyTrackingMode') -> None: ... + defaultPropertyTrackingModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setDefaultPropertyTrackingMode(self, mode: 'QNode.PropertyTrackingMode') -> None: ... def clearPropertyTrackings(self) -> None: ... def clearPropertyTracking(self, propertyName: str) -> None: ... @@ -124,9 +124,9 @@ class QNode(QtCore.QObject): def defaultPropertyTrackingMode(self) -> 'QNode.PropertyTrackingMode': ... def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... def notifyObservers(self, change: 'QSceneChange') -> None: ... - def nodeDestroyed(self) -> None: ... - def enabledChanged(self, enabled: bool) -> None: ... - def parentChanged(self, parent: QtCore.QObject) -> None: ... + nodeDestroyed: typing.ClassVar[QtCore.pyqtSignal] + enabledChanged: typing.ClassVar[QtCore.pyqtSignal] + parentChanged: typing.ClassVar[QtCore.pyqtSignal] def setEnabled(self, isEnabled: bool) -> None: ... def setParent(self, parent: 'QNode') -> None: ... # type: ignore[override] def isEnabled(self) -> bool: ... @@ -139,16 +139,16 @@ class QNode(QtCore.QObject): class QAbstractSkeleton('QNode'): def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - def jointCountChanged(self, jointCount: int) -> None: ... + jointCountChanged: typing.ClassVar[QtCore.pyqtSignal] def jointCount(self) -> int: ... class QComponent('QNode'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - def removedFromEntity(self, entity: 'QEntity') -> None: ... - def addedToEntity(self, entity: 'QEntity') -> None: ... - def shareableChanged(self, isShareable: bool) -> None: ... + removedFromEntity: typing.ClassVar[QtCore.pyqtSignal] + addedToEntity: typing.ClassVar[QtCore.pyqtSignal] + shareableChanged: typing.ClassVar[QtCore.pyqtSignal] def setShareable(self, isShareable: bool) -> None: ... def entities(self) -> typing.List['QEntity']: ... def isShareable(self) -> bool: ... @@ -157,7 +157,7 @@ class QArmature('QComponent'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - def skeletonChanged(self, skeleton: 'QAbstractSkeleton') -> None: ... + skeletonChanged: typing.ClassVar[QtCore.pyqtSignal] def setSkeleton(self, skeleton: 'QAbstractSkeleton') -> None: ... def skeleton(self) -> 'QAbstractSkeleton': ... @@ -273,14 +273,14 @@ class QJoint('QNode'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - def nameChanged(self, name: str) -> None: ... - def rotationZChanged(self, rotationZ: float) -> None: ... - def rotationYChanged(self, rotationY: float) -> None: ... - def rotationXChanged(self, rotationX: float) -> None: ... - def inverseBindMatrixChanged(self, inverseBindMatrix: QtGui.QMatrix4x4) -> None: ... - def translationChanged(self, translation: QtGui.QVector3D) -> None: ... - def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def scaleChanged(self, scale: QtGui.QVector3D) -> None: ... + nameChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationZChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationYChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationXChanged: typing.ClassVar[QtCore.pyqtSignal] + inverseBindMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] + translationChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationChanged: typing.ClassVar[QtCore.pyqtSignal] + scaleChanged: typing.ClassVar[QtCore.pyqtSignal] def setToIdentity(self) -> None: ... def setName(self, name: str) -> None: ... def setRotationZ(self, rotationZ: float) -> None: ... @@ -437,7 +437,7 @@ class QSkeleton('QAbstractSkeleton'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - def rootJointChanged(self, rootJoint: 'QJoint') -> None: ... + rootJointChanged: typing.ClassVar[QtCore.pyqtSignal] def setRootJoint(self, rootJoint: 'QJoint') -> None: ... def rootJoint(self) -> 'QJoint': ... @@ -458,10 +458,10 @@ class QSkeletonLoader('QAbstractSkeleton'): def __init__(self, source: QtCore.QUrl, parent: typing.Optional['QNode'] = ...) -> None: ... def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - def rootJointChanged(self, rootJoint: 'QJoint') -> None: ... - def createJointsEnabledChanged(self, createJointsEnabled: bool) -> None: ... - def statusChanged(self, status: 'QSkeletonLoader.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + rootJointChanged: typing.ClassVar[QtCore.pyqtSignal] + createJointsEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setCreateJointsEnabled(self, enabled: bool) -> None: ... def setSource(self, source: QtCore.QUrl) -> None: ... def rootJoint(self) -> 'QJoint': ... @@ -474,16 +474,16 @@ class QTransform('QComponent'): def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - def worldMatrixChanged(self, worldMatrix: QtGui.QMatrix4x4) -> None: ... + worldMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] def worldMatrix(self) -> QtGui.QMatrix4x4: ... - def rotationZChanged(self, rotationZ: float) -> None: ... - def rotationYChanged(self, rotationY: float) -> None: ... - def rotationXChanged(self, rotationX: float) -> None: ... - def matrixChanged(self) -> None: ... - def translationChanged(self, translation: QtGui.QVector3D) -> None: ... - def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def scale3DChanged(self, scale: QtGui.QVector3D) -> None: ... - def scaleChanged(self, scale: float) -> None: ... + rotationZChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationYChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationXChanged: typing.ClassVar[QtCore.pyqtSignal] + matrixChanged: typing.ClassVar[QtCore.pyqtSignal] + translationChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationChanged: typing.ClassVar[QtCore.pyqtSignal] + scale3DChanged: typing.ClassVar[QtCore.pyqtSignal] + scaleChanged: typing.ClassVar[QtCore.pyqtSignal] def setRotationZ(self, rotationZ: float) -> None: ... def setRotationY(self, rotationY: float) -> None: ... def setRotationX(self, rotationX: float) -> None: ... diff --git a/PyQt5-stubs/Qt3DExtras.pyi b/PyQt5-stubs/Qt3DExtras.pyi index 1c3d4358..84b7bb4b 100644 --- a/PyQt5-stubs/Qt3DExtras.pyi +++ b/PyQt5-stubs/Qt3DExtras.pyi @@ -48,11 +48,11 @@ class QAbstractCameraController(Qt3DCore.QEntity): def mouseDevice(self) -> Qt3DInput.QMouseDevice: ... def keyboardDevice(self) -> Qt3DInput.QKeyboardDevice: ... - def decelerationChanged(self, deceleration: float) -> None: ... - def accelerationChanged(self, acceleration: float) -> None: ... - def lookSpeedChanged(self) -> None: ... - def linearSpeedChanged(self) -> None: ... - def cameraChanged(self) -> None: ... + decelerationChanged: typing.ClassVar[QtCore.pyqtSignal] + accelerationChanged: typing.ClassVar[QtCore.pyqtSignal] + lookSpeedChanged: typing.ClassVar[QtCore.pyqtSignal] + linearSpeedChanged: typing.ClassVar[QtCore.pyqtSignal] + cameraChanged: typing.ClassVar[QtCore.pyqtSignal] def setDeceleration(self, deceleration: float) -> None: ... def setAcceleration(self, acceleration: float) -> None: ... def setLookSpeed(self, lookSpeed: float) -> None: ... @@ -66,9 +66,9 @@ class QAbstractCameraController(Qt3DCore.QEntity): class QAbstractSpriteSheet(Qt3DCore.QNode): - def currentIndexChanged(self, currentIndex: int) -> None: ... - def textureTransformChanged(self, textureTransform: QtGui.QMatrix3x3) -> None: ... - def textureChanged(self, texture: Qt3DRender.QAbstractTexture) -> None: ... + currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] + textureTransformChanged: typing.ClassVar[QtCore.pyqtSignal] + textureChanged: typing.ClassVar[QtCore.pyqtSignal] def setCurrentIndex(self, currentIndex: int) -> None: ... def setTexture(self, texture: Qt3DRender.QAbstractTexture) -> None: ... def currentIndex(self) -> int: ... @@ -79,13 +79,13 @@ class QConeGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def bottomRadiusChanged(self, bottomRadius: float) -> None: ... - def topRadiusChanged(self, topRadius: float) -> None: ... - def hasBottomEndcapChanged(self, hasBottomEndcap: bool) -> None: ... - def hasTopEndcapChanged(self, hasTopEndcap: bool) -> None: ... + lengthChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + bottomRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + topRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + hasBottomEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] + hasTopEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] def setLength(self, length: float) -> None: ... def setSlices(self, slices: int) -> None: ... def setRings(self, rings: int) -> None: ... @@ -111,13 +111,13 @@ class QConeMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def bottomRadiusChanged(self, bottomRadius: float) -> None: ... - def topRadiusChanged(self, topRadius: float) -> None: ... - def hasBottomEndcapChanged(self, hasBottomEndcap: bool) -> None: ... - def hasTopEndcapChanged(self, hasTopEndcap: bool) -> None: ... + lengthChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + bottomRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + topRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + hasBottomEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] + hasTopEndcapChanged: typing.ClassVar[QtCore.pyqtSignal] def setLength(self, length: float) -> None: ... def setSlices(self, slices: int) -> None: ... def setRings(self, rings: int) -> None: ... @@ -137,12 +137,12 @@ class QCuboidGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def xyMeshResolutionChanged(self, xyMeshResolution: QtCore.QSize) -> None: ... - def xzMeshResolutionChanged(self, xzMeshResolution: QtCore.QSize) -> None: ... - def yzMeshResolutionChanged(self, yzMeshResolution: QtCore.QSize) -> None: ... - def zExtentChanged(self, zExtent: float) -> None: ... - def yExtentChanged(self, yExtent: float) -> None: ... - def xExtentChanged(self, xExtent: float) -> None: ... + xyMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + xzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + yzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + zExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + yExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + xExtentChanged: typing.ClassVar[QtCore.pyqtSignal] def setXYMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setXZMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setYZMeshResolution(self, resolution: QtCore.QSize) -> None: ... @@ -167,12 +167,12 @@ class QCuboidMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def xyMeshResolutionChanged(self, xyMeshResolution: QtCore.QSize) -> None: ... - def xzMeshResolutionChanged(self, xzMeshResolution: QtCore.QSize) -> None: ... - def yzMeshResolutionChanged(self, yzMeshResolution: QtCore.QSize) -> None: ... - def zExtentChanged(self, zExtent: float) -> None: ... - def yExtentChanged(self, yExtent: float) -> None: ... - def xExtentChanged(self, xExtent: float) -> None: ... + xyMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + xzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + yzMeshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] + zExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + yExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + xExtentChanged: typing.ClassVar[QtCore.pyqtSignal] def setXYMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setXZMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setYZMeshResolution(self, resolution: QtCore.QSize) -> None: ... @@ -190,10 +190,10 @@ class QCylinderGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + lengthChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setLength(self, length: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -213,10 +213,10 @@ class QCylinderMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + lengthChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setLength(self, length: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -230,11 +230,11 @@ class QDiffuseMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureScale(self, textureScale: float) -> None: ... def setDiffuse(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... def setShininess(self, shininess: float) -> None: ... @@ -250,11 +250,11 @@ class QDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: Qt3DRender.QAbstractTexture) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureScale(self, textureScale: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: Qt3DRender.QAbstractTexture) -> None: ... @@ -270,13 +270,13 @@ class QDiffuseSpecularMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def alphaBlendingEnabledChanged(self, enabled: bool) -> None: ... - def textureScaleChanged(self, textureScale: float) -> None: ... - def normalChanged(self, normal: typing.Any) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Any) -> None: ... - def diffuseChanged(self, diffuse: typing.Any) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + alphaBlendingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setAlphaBlendingEnabled(self, enabled: bool) -> None: ... def setTextureScale(self, textureScale: float) -> None: ... def setNormal(self, normal: typing.Any) -> None: ... @@ -296,9 +296,9 @@ class QExtrudedTextGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def depthChanged(self, extrusionLength: float) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def textChanged(self, text: str) -> None: ... + depthChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + textChanged: typing.ClassVar[QtCore.pyqtSignal] def setDepth(self, extrusionLength: float) -> None: ... def setFont(self, font: QtGui.QFont) -> None: ... def setText(self, text: str) -> None: ... @@ -313,9 +313,9 @@ class QExtrudedTextMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def depthChanged(self, depth: float) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def textChanged(self, text: str) -> None: ... + depthChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + textChanged: typing.ClassVar[QtCore.pyqtSignal] def setDepth(self, depth: float) -> None: ... def setFont(self, font: QtGui.QFont) -> None: ... def setText(self, text: str) -> None: ... @@ -331,23 +331,23 @@ class QForwardRenderer(Qt3DRender.QTechniqueFilter): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def showDebugOverlayChanged(self, showDebugOverlay: bool) -> None: ... + showDebugOverlayChanged: typing.ClassVar[QtCore.pyqtSignal] def setShowDebugOverlay(self, showDebugOverlay: bool) -> None: ... def showDebugOverlay(self) -> bool: ... - def buffersToClearChanged(self, a0: Qt3DRender.QClearBuffers.BufferType) -> None: ... + buffersToClearChanged: typing.ClassVar[QtCore.pyqtSignal] def setBuffersToClear(self, a0: Qt3DRender.QClearBuffers.BufferType) -> None: ... def buffersToClear(self) -> Qt3DRender.QClearBuffers.BufferType: ... - def gammaChanged(self, gamma: float) -> None: ... - def frustumCullingEnabledChanged(self, enabled: bool) -> None: ... + gammaChanged: typing.ClassVar[QtCore.pyqtSignal] + frustumCullingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] def setGamma(self, gamma: float) -> None: ... def setFrustumCullingEnabled(self, enabled: bool) -> None: ... def gamma(self) -> float: ... def isFrustumCullingEnabled(self) -> bool: ... - def externalRenderTargetSizeChanged(self, size: QtCore.QSize) -> None: ... - def surfaceChanged(self, surface: QtCore.QObject) -> None: ... - def cameraChanged(self, camera: Qt3DCore.QEntity) -> None: ... - def clearColorChanged(self, clearColor: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def viewportRectChanged(self, viewportRect: QtCore.QRectF) -> None: ... + externalRenderTargetSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + surfaceChanged: typing.ClassVar[QtCore.pyqtSignal] + cameraChanged: typing.ClassVar[QtCore.pyqtSignal] + clearColorChanged: typing.ClassVar[QtCore.pyqtSignal] + viewportRectChanged: typing.ClassVar[QtCore.pyqtSignal] def setExternalRenderTargetSize(self, size: QtCore.QSize) -> None: ... def setSurface(self, surface: QtCore.QObject) -> None: ... def setCamera(self, camera: Qt3DCore.QEntity) -> None: ... @@ -363,13 +363,13 @@ class QGoochMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def betaChanged(self, beta: float) -> None: ... - def alphaChanged(self, alpha: float) -> None: ... - def warmChanged(self, warm: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def coolChanged(self, cool: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + betaChanged: typing.ClassVar[QtCore.pyqtSignal] + alphaChanged: typing.ClassVar[QtCore.pyqtSignal] + warmChanged: typing.ClassVar[QtCore.pyqtSignal] + coolChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] def setShininess(self, shininess: float) -> None: ... def setBeta(self, beta: float) -> None: ... def setAlpha(self, alpha: float) -> None: ... @@ -389,12 +389,12 @@ class QMetalRoughMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def textureScaleChanged(self, textureScale: float) -> None: ... - def normalChanged(self, normal: typing.Any) -> None: ... - def ambientOcclusionChanged(self, ambientOcclusion: typing.Any) -> None: ... - def roughnessChanged(self, roughness: typing.Any) -> None: ... - def metalnessChanged(self, metalness: typing.Any) -> None: ... - def baseColorChanged(self, baseColor: typing.Any) -> None: ... + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientOcclusionChanged: typing.ClassVar[QtCore.pyqtSignal] + roughnessChanged: typing.ClassVar[QtCore.pyqtSignal] + metalnessChanged: typing.ClassVar[QtCore.pyqtSignal] + baseColorChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureScale(self, textureScale: float) -> None: ... def setNormal(self, normal: typing.Any) -> None: ... def setAmbientOcclusion(self, ambientOcclusion: typing.Any) -> None: ... @@ -412,11 +412,11 @@ class QMorphPhongMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def interpolatorChanged(self, interpolator: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + interpolatorChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setInterpolator(self, interpolator: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... @@ -432,12 +432,12 @@ class QNormalDiffuseMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def normalChanged(self, normal: Qt3DRender.QAbstractTexture) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureScale(self, textureScale: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setNormal(self, normal: Qt3DRender.QAbstractTexture) -> None: ... @@ -459,12 +459,12 @@ class QNormalDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: Qt3DRender.QAbstractTexture) -> None: ... - def normalChanged(self, normal: Qt3DRender.QAbstractTexture) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + textureScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureScale(self, textureScale: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: Qt3DRender.QAbstractTexture) -> None: ... @@ -482,7 +482,7 @@ class QOrbitCameraController('QAbstractCameraController'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def zoomInLimitChanged(self) -> None: ... + zoomInLimitChanged: typing.ClassVar[QtCore.pyqtSignal] def setZoomInLimit(self, zoomInLimit: float) -> None: ... def zoomInLimit(self) -> float: ... @@ -494,11 +494,11 @@ class QPhongAlphaMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def blendFunctionArgChanged(self, blendFunctionArg: Qt3DRender.QBlendEquation.BlendFunction) -> None: ... - def destinationAlphaArgChanged(self, destinationAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def sourceAlphaArgChanged(self, sourceAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def destinationRgbArgChanged(self, destinationRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def sourceRgbArgChanged(self, sourceRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + blendFunctionArgChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationAlphaArgChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceAlphaArgChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationRgbArgChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceRgbArgChanged: typing.ClassVar[QtCore.pyqtSignal] def setBlendFunctionArg(self, blendFunctionArg: Qt3DRender.QBlendEquation.BlendFunction) -> None: ... def setDestinationAlphaArg(self, destinationAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... def setSourceAlphaArg(self, sourceAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... @@ -509,11 +509,11 @@ class QPhongAlphaMaterial(Qt3DRender.QMaterial): def sourceAlphaArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... def destinationRgbArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... def sourceRgbArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... - def alphaChanged(self, alpha: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + alphaChanged: typing.ClassVar[QtCore.pyqtSignal] + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setAlpha(self, alpha: float) -> None: ... def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... @@ -529,10 +529,10 @@ class QPhongMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + shininessChanged: typing.ClassVar[QtCore.pyqtSignal] + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + diffuseChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientChanged: typing.ClassVar[QtCore.pyqtSignal] def setShininess(self, shininess: float) -> None: ... def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setDiffuse(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... @@ -546,12 +546,12 @@ class QPlaneGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def mirroredChanged(self, mirrored: bool) -> None: ... + mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] def setMirrored(self, mirrored: bool) -> None: ... def mirrored(self) -> bool: ... - def heightChanged(self, height: float) -> None: ... - def widthChanged(self, width: float) -> None: ... - def resolutionChanged(self, resolution: QtCore.QSize) -> None: ... + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + resolutionChanged: typing.ClassVar[QtCore.pyqtSignal] def setHeight(self, height: float) -> None: ... def setWidth(self, width: float) -> None: ... def setResolution(self, resolution: QtCore.QSize) -> None: ... @@ -570,12 +570,12 @@ class QPlaneMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def mirroredChanged(self, mirrored: bool) -> None: ... + mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] def setMirrored(self, mirrored: bool) -> None: ... def mirrored(self) -> bool: ... - def heightChanged(self, height: float) -> None: ... - def widthChanged(self, width: float) -> None: ... - def meshResolutionChanged(self, meshResolution: QtCore.QSize) -> None: ... + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + meshResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] def setMeshResolution(self, resolution: QtCore.QSize) -> None: ... def setHeight(self, height: float) -> None: ... def setWidth(self, width: float) -> None: ... @@ -587,11 +587,11 @@ class QSkyboxEntity(Qt3DCore.QEntity): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def gammaCorrectEnabledChanged(self, enabled: bool) -> None: ... - def baseNameChanged(self, path: str) -> None: ... + gammaCorrectEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + baseNameChanged: typing.ClassVar[QtCore.pyqtSignal] def setGammaCorrectEnabled(self, enabled: bool) -> None: ... def isGammaCorrectEnabled(self) -> bool: ... - def extensionChanged(self, extension: str) -> None: ... + extensionChanged: typing.ClassVar[QtCore.pyqtSignal] def extension(self) -> str: ... def setExtension(self, extension: str) -> None: ... def baseName(self) -> str: ... @@ -601,10 +601,10 @@ class QSphereGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def generateTangentsChanged(self, generateTangents: bool) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + generateTangentsChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setGenerateTangents(self, gen: bool) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -625,10 +625,10 @@ class QSphereMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def generateTangentsChanged(self, generateTangents: bool) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + generateTangentsChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setGenerateTangents(self, gen: bool) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -642,8 +642,8 @@ class QSpriteGrid('QAbstractSpriteSheet'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def columnsChanged(self, columns: int) -> None: ... - def rowsChanged(self, rows: int) -> None: ... + columnsChanged: typing.ClassVar[QtCore.pyqtSignal] + rowsChanged: typing.ClassVar[QtCore.pyqtSignal] def setColumns(self, columns: int) -> None: ... def setRows(self, rows: int) -> None: ... def columns(self) -> int: ... @@ -653,7 +653,7 @@ class QSpriteSheet('QAbstractSpriteSheet'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def spritesChanged(self, sprites: typing.Iterable['QSpriteSheetItem']) -> None: ... + spritesChanged: typing.ClassVar[QtCore.pyqtSignal] def setSprites(self, sprites: typing.Iterable['QSpriteSheetItem']) -> None: ... def removeSprite(self, sprite: 'QSpriteSheetItem') -> None: ... @typing.overload @@ -666,10 +666,10 @@ class QSpriteSheetItem(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def heightChanged(self, height: int) -> None: ... - def widthChanged(self, width: int) -> None: ... - def yChanged(self, y: int) -> None: ... - def xChanged(self, x: int) -> None: ... + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + yChanged: typing.ClassVar[QtCore.pyqtSignal] + xChanged: typing.ClassVar[QtCore.pyqtSignal] def setHeight(self, height: int) -> None: ... def setWidth(self, width: int) -> None: ... def setY(self, y: int) -> None: ... @@ -701,11 +701,11 @@ class QText2DEntity(Qt3DCore.QEntity): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def heightChanged(self, height: float) -> None: ... - def widthChanged(self, width: float) -> None: ... - def textChanged(self, text: str) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + textChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] def setHeight(self, height: float) -> None: ... def setWidth(self, width: float) -> None: ... def height(self) -> float: ... @@ -721,17 +721,17 @@ class QTexturedMetalRoughMaterial('QMetalRoughMaterial'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def normalChanged(self, normal: typing.Any) -> None: ... - def ambientOcclusionChanged(self, ambientOcclusion: typing.Any) -> None: ... + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientOcclusionChanged: typing.ClassVar[QtCore.pyqtSignal] class QTextureMaterial(Qt3DRender.QMaterial): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def alphaBlendingEnabledChanged(self, enabled: bool) -> None: ... - def textureTransformChanged(self, textureTransform: QtGui.QMatrix3x3) -> None: ... - def textureOffsetChanged(self, textureOffset: QtGui.QVector2D) -> None: ... - def textureChanged(self, texture: Qt3DRender.QAbstractTexture) -> None: ... + alphaBlendingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + textureTransformChanged: typing.ClassVar[QtCore.pyqtSignal] + textureOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] + textureChanged: typing.ClassVar[QtCore.pyqtSignal] def setAlphaBlendingEnabled(self, enabled: bool) -> None: ... def setTextureTransform(self, matrix: QtGui.QMatrix3x3) -> None: ... def setTextureOffset(self, textureOffset: QtGui.QVector2D) -> None: ... @@ -745,10 +745,10 @@ class QTorusGeometry(Qt3DRender.QGeometry): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def minorRadiusChanged(self, minorRadius: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + minorRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setMinorRadius(self, minorRadius: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... @@ -768,10 +768,10 @@ class QTorusMesh(Qt3DRender.QGeometryRenderer): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def minorRadiusChanged(self, minorRadius: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... + minorRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] + slicesChanged: typing.ClassVar[QtCore.pyqtSignal] + ringsChanged: typing.ClassVar[QtCore.pyqtSignal] + radiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setMinorRadius(self, minorRadius: float) -> None: ... def setRadius(self, radius: float) -> None: ... def setSlices(self, slices: int) -> None: ... diff --git a/PyQt5-stubs/Qt3DInput.pyi b/PyQt5-stubs/Qt3DInput.pyi index 5c6a8256..7d089687 100644 --- a/PyQt5-stubs/Qt3DInput.pyi +++ b/PyQt5-stubs/Qt3DInput.pyi @@ -44,7 +44,7 @@ class QAbstractActionInput(Qt3DCore.QNode): ... class QAbstractAxisInput(Qt3DCore.QNode): - def sourceDeviceChanged(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... + sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSourceDevice(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... def sourceDevice(self) -> 'QAbstractPhysicalDevice': ... @@ -67,7 +67,7 @@ class QAction(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def activeChanged(self, isActive: bool) -> None: ... + activeChanged: typing.ClassVar[QtCore.pyqtSignal] def inputs(self) -> typing.List['QAbstractActionInput']: ... def removeInput(self, input: 'QAbstractActionInput') -> None: ... def addInput(self, input: 'QAbstractActionInput') -> None: ... @@ -77,8 +77,8 @@ class QActionInput('QAbstractActionInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def buttonsChanged(self, buttons: typing.Iterable[int]) -> None: ... - def sourceDeviceChanged(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... + buttonsChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] def setButtons(self, buttons: typing.Iterable[int]) -> None: ... def setSourceDevice(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... def buttons(self) -> typing.List[int]: ... @@ -88,7 +88,7 @@ class QAnalogAxisInput('QAbstractAxisInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def axisChanged(self, axis: int) -> None: ... + axisChanged: typing.ClassVar[QtCore.pyqtSignal] def setAxis(self, axis: int) -> None: ... def axis(self) -> int: ... @@ -97,7 +97,7 @@ class QAxis(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def valueChanged(self, value: float) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def value(self) -> float: ... def inputs(self) -> typing.List['QAbstractAxisInput']: ... def removeInput(self, input: 'QAbstractAxisInput') -> None: ... @@ -115,11 +115,11 @@ class QAxisAccumulator(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def scaleChanged(self, scale: float) -> None: ... - def velocityChanged(self, value: float) -> None: ... - def valueChanged(self, value: float) -> None: ... - def sourceAxisTypeChanged(self, sourceAxisType: 'QAxisAccumulator.SourceAxisType') -> None: ... - def sourceAxisChanged(self, sourceAxis: 'QAxis') -> None: ... + scaleChanged: typing.ClassVar[QtCore.pyqtSignal] + velocityChanged: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceAxisTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceAxisChanged: typing.ClassVar[QtCore.pyqtSignal] def setScale(self, scale: float) -> None: ... def setSourceAxisType(self, sourceAxisType: 'QAxisAccumulator.SourceAxisType') -> None: ... def setSourceAxis(self, sourceAxis: 'QAxis') -> None: ... @@ -133,9 +133,9 @@ class QAxisSetting(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def smoothChanged(self, smooth: bool) -> None: ... - def axesChanged(self, axes: typing.Iterable[int]) -> None: ... - def deadZoneRadiusChanged(self, deadZoneRadius: float) -> None: ... + smoothChanged: typing.ClassVar[QtCore.pyqtSignal] + axesChanged: typing.ClassVar[QtCore.pyqtSignal] + deadZoneRadiusChanged: typing.ClassVar[QtCore.pyqtSignal] def setSmoothEnabled(self, enabled: bool) -> None: ... def setAxes(self, axes: typing.Iterable[int]) -> None: ... def setDeadZoneRadius(self, deadZoneRadius: float) -> None: ... @@ -147,10 +147,10 @@ class QButtonAxisInput('QAbstractAxisInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def decelerationChanged(self, deceleration: float) -> None: ... - def accelerationChanged(self, acceleration: float) -> None: ... - def buttonsChanged(self, buttons: typing.Iterable[int]) -> None: ... - def scaleChanged(self, scale: float) -> None: ... + decelerationChanged: typing.ClassVar[QtCore.pyqtSignal] + accelerationChanged: typing.ClassVar[QtCore.pyqtSignal] + buttonsChanged: typing.ClassVar[QtCore.pyqtSignal] + scaleChanged: typing.ClassVar[QtCore.pyqtSignal] def setDeceleration(self, deceleration: float) -> None: ... def setAcceleration(self, acceleration: float) -> None: ... def setButtons(self, buttons: typing.Iterable[int]) -> None: ... @@ -171,7 +171,7 @@ class QInputChord('QAbstractActionInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def timeoutChanged(self, timeout: int) -> None: ... + timeoutChanged: typing.ClassVar[QtCore.pyqtSignal] def setTimeout(self, timeout: int) -> None: ... def chords(self) -> typing.List['QAbstractActionInput']: ... def removeChord(self, input: 'QAbstractActionInput') -> None: ... @@ -182,8 +182,8 @@ class QInputSequence('QAbstractActionInput'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def buttonIntervalChanged(self, buttonInterval: int) -> None: ... - def timeoutChanged(self, timeout: int) -> None: ... + buttonIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + timeoutChanged: typing.ClassVar[QtCore.pyqtSignal] def setButtonInterval(self, buttonInterval: int) -> None: ... def setTimeout(self, timeout: int) -> None: ... def sequences(self) -> typing.List['QAbstractActionInput']: ... @@ -196,7 +196,7 @@ class QInputSettings(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def eventSourceChanged(self, a0: QtCore.QObject) -> None: ... + eventSourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setEventSource(self, eventSource: QtCore.QObject) -> None: ... def eventSource(self) -> QtCore.QObject: ... @@ -204,7 +204,7 @@ class QKeyboardDevice('QAbstractPhysicalDevice'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def activeInputChanged(self, activeInput: 'QKeyboardHandler') -> None: ... + activeInputChanged: typing.ClassVar[QtCore.pyqtSignal] def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... def buttonIdentifier(self, name: str) -> int: ... def axisIdentifier(self, name: str) -> int: ... @@ -219,48 +219,48 @@ class QKeyboardHandler(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def released(self, event: 'QKeyEvent') -> None: ... - def pressed(self, event: 'QKeyEvent') -> None: ... - def volumeDownPressed(self, event: 'QKeyEvent') -> None: ... - def volumeUpPressed(self, event: 'QKeyEvent') -> None: ... - def menuPressed(self, event: 'QKeyEvent') -> None: ... - def flipPressed(self, event: 'QKeyEvent') -> None: ... - def hangupPressed(self, event: 'QKeyEvent') -> None: ... - def callPressed(self, event: 'QKeyEvent') -> None: ... - def context4Pressed(self, event: 'QKeyEvent') -> None: ... - def context3Pressed(self, event: 'QKeyEvent') -> None: ... - def context2Pressed(self, event: 'QKeyEvent') -> None: ... - def context1Pressed(self, event: 'QKeyEvent') -> None: ... - def noPressed(self, event: 'QKeyEvent') -> None: ... - def yesPressed(self, event: 'QKeyEvent') -> None: ... - def selectPressed(self, event: 'QKeyEvent') -> None: ... - def cancelPressed(self, event: 'QKeyEvent') -> None: ... - def backPressed(self, event: 'QKeyEvent') -> None: ... - def spacePressed(self, event: 'QKeyEvent') -> None: ... - def deletePressed(self, event: 'QKeyEvent') -> None: ... - def enterPressed(self, event: 'QKeyEvent') -> None: ... - def returnPressed(self, event: 'QKeyEvent') -> None: ... - def escapePressed(self, event: 'QKeyEvent') -> None: ... - def numberSignPressed(self, event: 'QKeyEvent') -> None: ... - def asteriskPressed(self, event: 'QKeyEvent') -> None: ... - def backtabPressed(self, event: 'QKeyEvent') -> None: ... - def tabPressed(self, event: 'QKeyEvent') -> None: ... - def downPressed(self, event: 'QKeyEvent') -> None: ... - def upPressed(self, event: 'QKeyEvent') -> None: ... - def rightPressed(self, event: 'QKeyEvent') -> None: ... - def leftPressed(self, event: 'QKeyEvent') -> None: ... - def digit9Pressed(self, event: 'QKeyEvent') -> None: ... - def digit8Pressed(self, event: 'QKeyEvent') -> None: ... - def digit7Pressed(self, event: 'QKeyEvent') -> None: ... - def digit6Pressed(self, event: 'QKeyEvent') -> None: ... - def digit5Pressed(self, event: 'QKeyEvent') -> None: ... - def digit4Pressed(self, event: 'QKeyEvent') -> None: ... - def digit3Pressed(self, event: 'QKeyEvent') -> None: ... - def digit2Pressed(self, event: 'QKeyEvent') -> None: ... - def digit1Pressed(self, event: 'QKeyEvent') -> None: ... - def digit0Pressed(self, event: 'QKeyEvent') -> None: ... - def focusChanged(self, focus: bool) -> None: ... - def sourceDeviceChanged(self, keyboardDevice: 'QKeyboardDevice') -> None: ... + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + volumeDownPressed: typing.ClassVar[QtCore.pyqtSignal] + volumeUpPressed: typing.ClassVar[QtCore.pyqtSignal] + menuPressed: typing.ClassVar[QtCore.pyqtSignal] + flipPressed: typing.ClassVar[QtCore.pyqtSignal] + hangupPressed: typing.ClassVar[QtCore.pyqtSignal] + callPressed: typing.ClassVar[QtCore.pyqtSignal] + context4Pressed: typing.ClassVar[QtCore.pyqtSignal] + context3Pressed: typing.ClassVar[QtCore.pyqtSignal] + context2Pressed: typing.ClassVar[QtCore.pyqtSignal] + context1Pressed: typing.ClassVar[QtCore.pyqtSignal] + noPressed: typing.ClassVar[QtCore.pyqtSignal] + yesPressed: typing.ClassVar[QtCore.pyqtSignal] + selectPressed: typing.ClassVar[QtCore.pyqtSignal] + cancelPressed: typing.ClassVar[QtCore.pyqtSignal] + backPressed: typing.ClassVar[QtCore.pyqtSignal] + spacePressed: typing.ClassVar[QtCore.pyqtSignal] + deletePressed: typing.ClassVar[QtCore.pyqtSignal] + enterPressed: typing.ClassVar[QtCore.pyqtSignal] + returnPressed: typing.ClassVar[QtCore.pyqtSignal] + escapePressed: typing.ClassVar[QtCore.pyqtSignal] + numberSignPressed: typing.ClassVar[QtCore.pyqtSignal] + asteriskPressed: typing.ClassVar[QtCore.pyqtSignal] + backtabPressed: typing.ClassVar[QtCore.pyqtSignal] + tabPressed: typing.ClassVar[QtCore.pyqtSignal] + downPressed: typing.ClassVar[QtCore.pyqtSignal] + upPressed: typing.ClassVar[QtCore.pyqtSignal] + rightPressed: typing.ClassVar[QtCore.pyqtSignal] + leftPressed: typing.ClassVar[QtCore.pyqtSignal] + digit9Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit8Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit7Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit6Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit5Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit4Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit3Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit2Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit1Pressed: typing.ClassVar[QtCore.pyqtSignal] + digit0Pressed: typing.ClassVar[QtCore.pyqtSignal] + focusChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] def setFocus(self, focus: bool) -> None: ... def setSourceDevice(self, keyboardDevice: 'QKeyboardDevice') -> None: ... def focus(self) -> bool: ... @@ -310,11 +310,11 @@ class QMouseDevice('QAbstractPhysicalDevice'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def updateAxesContinuouslyChanged(self, updateAxesContinuously: bool) -> None: ... + updateAxesContinuouslyChanged: typing.ClassVar[QtCore.pyqtSignal] def setUpdateAxesContinuously(self, updateAxesContinuously: bool) -> None: ... def updateAxesContinuously(self) -> bool: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def sensitivityChanged(self, value: float) -> None: ... + sensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] def setSensitivity(self, value: float) -> None: ... def sensitivity(self) -> float: ... def buttonIdentifier(self, name: str) -> int: ... @@ -412,17 +412,17 @@ class QMouseHandler(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def wheel(self, wheel: 'QWheelEvent') -> None: ... - def positionChanged(self, mouse: 'QMouseEvent') -> None: ... - def pressAndHold(self, mouse: 'QMouseEvent') -> None: ... - def released(self, mouse: 'QMouseEvent') -> None: ... - def pressed(self, mouse: 'QMouseEvent') -> None: ... - def exited(self) -> None: ... - def entered(self) -> None: ... - def doubleClicked(self, mouse: 'QMouseEvent') -> None: ... - def clicked(self, mouse: 'QMouseEvent') -> None: ... - def containsMouseChanged(self, containsMouse: bool) -> None: ... - def sourceDeviceChanged(self, mouseDevice: 'QMouseDevice') -> None: ... + wheel: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + pressAndHold: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + exited: typing.ClassVar[QtCore.pyqtSignal] + entered: typing.ClassVar[QtCore.pyqtSignal] + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + containsMouseChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSourceDevice(self, mouseDevice: 'QMouseDevice') -> None: ... def containsMouse(self) -> bool: ... def sourceDevice(self) -> 'QMouseDevice': ... diff --git a/PyQt5-stubs/Qt3DLogic.pyi b/PyQt5-stubs/Qt3DLogic.pyi index dd8cabb8..98fdddcc 100644 --- a/PyQt5-stubs/Qt3DLogic.pyi +++ b/PyQt5-stubs/Qt3DLogic.pyi @@ -43,7 +43,7 @@ class QFrameAction(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def triggered(self, dt: float) -> None: ... + triggered: typing.ClassVar[QtCore.pyqtSignal] class QLogicAspect(Qt3DCore.QAbstractAspect): diff --git a/PyQt5-stubs/Qt3DRender.pyi b/PyQt5-stubs/Qt3DRender.pyi index 43b9e810..4083ea6f 100644 --- a/PyQt5-stubs/Qt3DRender.pyi +++ b/PyQt5-stubs/Qt3DRender.pyi @@ -55,8 +55,8 @@ class QAbstractLight(Qt3DCore.QComponent): DirectionalLight = ... # type: QAbstractLight.Type SpotLight = ... # type: QAbstractLight.Type - def intensityChanged(self, intensity: float) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + intensityChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] def setIntensity(self, intensity: float) -> None: ... def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def intensity(self) -> float: ... @@ -86,9 +86,9 @@ class QAbstractRayCaster(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def filterModeChanged(self, filterMode: 'QAbstractRayCaster.FilterMode') -> None: ... - def hitsChanged(self, hits: typing.Iterable['QRayCasterHit']) -> None: ... - def runModeChanged(self, runMode: 'QAbstractRayCaster.RunMode') -> None: ... + filterModeChanged: typing.ClassVar[QtCore.pyqtSignal] + hitsChanged: typing.ClassVar[QtCore.pyqtSignal] + runModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setFilterMode(self, filterMode: 'QAbstractRayCaster.FilterMode') -> None: ... def setRunMode(self, runMode: 'QAbstractRayCaster.RunMode') -> None: ... def layers(self) -> typing.List['QLayer']: ... @@ -412,25 +412,25 @@ class QAbstractTexture(Qt3DCore.QNode): def __init__(self, target: 'QAbstractTexture.Target', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def updateData(self, update: 'QTextureDataUpdate') -> None: ... - def handleChanged(self, handle: typing.Any) -> None: ... - def handleTypeChanged(self, handleType: 'QAbstractTexture.HandleType') -> None: ... + handleChanged: typing.ClassVar[QtCore.pyqtSignal] + handleTypeChanged: typing.ClassVar[QtCore.pyqtSignal] def handle(self) -> typing.Any: ... def handleType(self) -> 'QAbstractTexture.HandleType': ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... def setStatus(self, status: 'QAbstractTexture.Status') -> None: ... - def samplesChanged(self, samples: int) -> None: ... - def layersChanged(self, layers: int) -> None: ... - def comparisonModeChanged(self, comparisonMode: 'QAbstractTexture.ComparisonMode') -> None: ... - def comparisonFunctionChanged(self, comparisonFunction: 'QAbstractTexture.ComparisonFunction') -> None: ... - def maximumAnisotropyChanged(self, maximumAnisotropy: float) -> None: ... - def minificationFilterChanged(self, minificationFilter: 'QAbstractTexture.Filter') -> None: ... - def magnificationFilterChanged(self, magnificationFilter: 'QAbstractTexture.Filter') -> None: ... - def depthChanged(self, depth: int) -> None: ... - def heightChanged(self, height: int) -> None: ... - def widthChanged(self, width: int) -> None: ... - def generateMipMapsChanged(self, generateMipMaps: bool) -> None: ... - def statusChanged(self, status: 'QAbstractTexture.Status') -> None: ... - def formatChanged(self, format: 'QAbstractTexture.TextureFormat') -> None: ... + samplesChanged: typing.ClassVar[QtCore.pyqtSignal] + layersChanged: typing.ClassVar[QtCore.pyqtSignal] + comparisonModeChanged: typing.ClassVar[QtCore.pyqtSignal] + comparisonFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] + maximumAnisotropyChanged: typing.ClassVar[QtCore.pyqtSignal] + minificationFilterChanged: typing.ClassVar[QtCore.pyqtSignal] + magnificationFilterChanged: typing.ClassVar[QtCore.pyqtSignal] + depthChanged: typing.ClassVar[QtCore.pyqtSignal] + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + generateMipMapsChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + formatChanged: typing.ClassVar[QtCore.pyqtSignal] def setSamples(self, samples: int) -> None: ... def setLayers(self, layers: int) -> None: ... def setComparisonMode(self, mode: 'QAbstractTexture.ComparisonMode') -> None: ... @@ -471,9 +471,9 @@ class QAbstractTextureImage(Qt3DCore.QNode): def dataGenerator(self) -> 'QTextureImageDataGenerator': ... def notifyDataGeneratorChanged(self) -> None: ... - def faceChanged(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... - def layerChanged(self, layer: int) -> None: ... - def mipLevelChanged(self, mipLevel: int) -> None: ... + faceChanged: typing.ClassVar[QtCore.pyqtSignal] + layerChanged: typing.ClassVar[QtCore.pyqtSignal] + mipLevelChanged: typing.ClassVar[QtCore.pyqtSignal] def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... def setLayer(self, layer: int) -> None: ... def setMipLevel(self, level: int) -> None: ... @@ -510,8 +510,8 @@ class QAlphaTest('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def referenceValueChanged(self, referenceValue: float) -> None: ... - def alphaFunctionChanged(self, alphaFunction: 'QAlphaTest.AlphaFunction') -> None: ... + referenceValueChanged: typing.ClassVar[QtCore.pyqtSignal] + alphaFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] def setReferenceValue(self, referenceValue: float) -> None: ... def setAlphaFunction(self, alphaFunction: 'QAlphaTest.AlphaFunction') -> None: ... def referenceValue(self) -> float: ... @@ -556,17 +556,17 @@ class QAttribute(Qt3DCore.QNode): @typing.overload def __init__(self, buf: 'QBuffer', name: str, vertexBaseType: 'QAttribute.VertexBaseType', vertexSize: int, count: int, offset: int = ..., stride: int = ..., parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def vertexSizeChanged(self, vertexSize: int) -> None: ... - def vertexBaseTypeChanged(self, vertexBaseType: 'QAttribute.VertexBaseType') -> None: ... - def attributeTypeChanged(self, attributeType: 'QAttribute.AttributeType') -> None: ... - def divisorChanged(self, divisor: int) -> None: ... - def byteOffsetChanged(self, byteOffset: int) -> None: ... - def byteStrideChanged(self, byteStride: int) -> None: ... - def countChanged(self, count: int) -> None: ... - def dataSizeChanged(self, vertexSize: int) -> None: ... - def dataTypeChanged(self, vertexBaseType: 'QAttribute.VertexBaseType') -> None: ... - def nameChanged(self, name: str) -> None: ... - def bufferChanged(self, buffer: 'QBuffer') -> None: ... + vertexSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + vertexBaseTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + attributeTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + divisorChanged: typing.ClassVar[QtCore.pyqtSignal] + byteOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] + byteStrideChanged: typing.ClassVar[QtCore.pyqtSignal] + countChanged: typing.ClassVar[QtCore.pyqtSignal] + dataSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + dataTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] + bufferChanged: typing.ClassVar[QtCore.pyqtSignal] def setVertexSize(self, size: int) -> None: ... def setVertexBaseType(self, type: 'QAttribute.VertexBaseType') -> None: ... def setAttributeType(self, attributeType: 'QAttribute.AttributeType') -> None: ... @@ -623,7 +623,7 @@ class QBlendEquation('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def blendFunctionChanged(self, blendFunction: 'QBlendEquation.BlendFunction') -> None: ... + blendFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] def setBlendFunction(self, blendFunction: 'QBlendEquation.BlendFunction') -> None: ... def blendFunction(self) -> 'QBlendEquation.BlendFunction': ... @@ -674,13 +674,13 @@ class QBlendEquationArguments('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def bufferIndexChanged(self, index: int) -> None: ... - def destinationRgbaChanged(self, destinationRgba: 'QBlendEquationArguments.Blending') -> None: ... - def sourceRgbaChanged(self, sourceRgba: 'QBlendEquationArguments.Blending') -> None: ... - def destinationAlphaChanged(self, destinationAlpha: 'QBlendEquationArguments.Blending') -> None: ... - def destinationRgbChanged(self, destinationRgb: 'QBlendEquationArguments.Blending') -> None: ... - def sourceAlphaChanged(self, sourceAlpha: 'QBlendEquationArguments.Blending') -> None: ... - def sourceRgbChanged(self, sourceRgb: 'QBlendEquationArguments.Blending') -> None: ... + bufferIndexChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationRgbaChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceRgbaChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationAlphaChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationRgbChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceAlphaChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceRgbChanged: typing.ClassVar[QtCore.pyqtSignal] def setBufferIndex(self, index: int) -> None: ... def setDestinationRgba(self, destinationRgba: 'QBlendEquationArguments.Blending') -> None: ... def setSourceRgba(self, sourceRgba: 'QBlendEquationArguments.Blending') -> None: ... @@ -711,13 +711,13 @@ class QBlitFramebuffer('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def interpolationMethodChanged(self) -> None: ... - def destinationAttachmentPointChanged(self) -> None: ... - def sourceAttachmentPointChanged(self) -> None: ... - def destinationRectChanged(self) -> None: ... - def sourceRectChanged(self) -> None: ... - def destinationChanged(self) -> None: ... - def sourceChanged(self) -> None: ... + interpolationMethodChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationAttachmentPointChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceAttachmentPointChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationRectChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceRectChanged: typing.ClassVar[QtCore.pyqtSignal] + destinationChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setInterpolationMethod(self, interpolationMethod: 'QBlitFramebuffer.InterpolationMethod') -> None: ... def setDestinationAttachmentPoint(self, destinationAttachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... def setSourceAttachmentPoint(self, sourceAttachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... @@ -787,16 +787,16 @@ class QBuffer(Qt3DCore.QNode): @typing.overload def __init__(self, ty: 'QBuffer.BufferType', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def dataAvailable(self) -> None: ... - def accessTypeChanged(self, access: 'QBuffer.AccessType') -> None: ... + dataAvailable: typing.ClassVar[QtCore.pyqtSignal] + accessTypeChanged: typing.ClassVar[QtCore.pyqtSignal] def setAccessType(self, access: 'QBuffer.AccessType') -> None: ... def accessType(self) -> 'QBuffer.AccessType': ... def updateData(self, offset: int, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def syncDataChanged(self, syncData: bool) -> None: ... - def usageChanged(self, usage: 'QBuffer.UsageType') -> None: ... - def typeChanged(self, type: 'QBuffer.BufferType') -> None: ... - def dataChanged(self, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + syncDataChanged: typing.ClassVar[QtCore.pyqtSignal] + usageChanged: typing.ClassVar[QtCore.pyqtSignal] + typeChanged: typing.ClassVar[QtCore.pyqtSignal] + dataChanged: typing.ClassVar[QtCore.pyqtSignal] def setSyncData(self, syncData: bool) -> None: ... def setUsage(self, usage: 'QBuffer.UsageType') -> None: ... def setType(self, type: 'QBuffer.BufferType') -> None: ... @@ -826,24 +826,24 @@ class QCamera(Qt3DCore.QEntity): def viewEntity(self, entity: Qt3DCore.QEntity) -> None: ... def viewSphere(self, center: QtGui.QVector3D, radius: float) -> None: ... def viewAll(self) -> None: ... - def exposureChanged(self, exposure: float) -> None: ... + exposureChanged: typing.ClassVar[QtCore.pyqtSignal] def setExposure(self, exposure: float) -> None: ... def exposure(self) -> float: ... - def viewMatrixChanged(self) -> None: ... - def viewVectorChanged(self, viewVector: QtGui.QVector3D) -> None: ... - def viewCenterChanged(self, viewCenter: QtGui.QVector3D) -> None: ... - def upVectorChanged(self, upVector: QtGui.QVector3D) -> None: ... - def positionChanged(self, position: QtGui.QVector3D) -> None: ... - def projectionMatrixChanged(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... - def topChanged(self, top: float) -> None: ... - def bottomChanged(self, bottom: float) -> None: ... - def rightChanged(self, right: float) -> None: ... - def leftChanged(self, left: float) -> None: ... - def aspectRatioChanged(self, aspectRatio: float) -> None: ... - def fieldOfViewChanged(self, fieldOfView: float) -> None: ... - def farPlaneChanged(self, farPlane: float) -> None: ... - def nearPlaneChanged(self, nearPlane: float) -> None: ... - def projectionTypeChanged(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... + viewMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] + viewVectorChanged: typing.ClassVar[QtCore.pyqtSignal] + viewCenterChanged: typing.ClassVar[QtCore.pyqtSignal] + upVectorChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + projectionMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] + topChanged: typing.ClassVar[QtCore.pyqtSignal] + bottomChanged: typing.ClassVar[QtCore.pyqtSignal] + rightChanged: typing.ClassVar[QtCore.pyqtSignal] + leftChanged: typing.ClassVar[QtCore.pyqtSignal] + aspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + fieldOfViewChanged: typing.ClassVar[QtCore.pyqtSignal] + farPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] + nearPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] + projectionTypeChanged: typing.ClassVar[QtCore.pyqtSignal] def setViewCenter(self, viewCenter: QtGui.QVector3D) -> None: ... def setUpVector(self, upVector: QtGui.QVector3D) -> None: ... def setPosition(self, position: QtGui.QVector3D) -> None: ... @@ -910,22 +910,22 @@ class QCameraLens(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def viewSphere(self, center: QtGui.QVector3D, radius: float) -> None: ... + viewSphere: typing.ClassVar[QtCore.pyqtSignal] def viewEntity(self, entityId: Qt3DCore.QNodeId, cameraId: Qt3DCore.QNodeId) -> None: ... def viewAll(self, cameraId: Qt3DCore.QNodeId) -> None: ... - def exposureChanged(self, exposure: float) -> None: ... + exposureChanged: typing.ClassVar[QtCore.pyqtSignal] def setExposure(self, exposure: float) -> None: ... def exposure(self) -> float: ... - def projectionMatrixChanged(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... - def topChanged(self, top: float) -> None: ... - def bottomChanged(self, bottom: float) -> None: ... - def rightChanged(self, right: float) -> None: ... - def leftChanged(self, left: float) -> None: ... - def aspectRatioChanged(self, aspectRatio: float) -> None: ... - def fieldOfViewChanged(self, fieldOfView: float) -> None: ... - def farPlaneChanged(self, farPlane: float) -> None: ... - def nearPlaneChanged(self, nearPlane: float) -> None: ... - def projectionTypeChanged(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... + projectionMatrixChanged: typing.ClassVar[QtCore.pyqtSignal] + topChanged: typing.ClassVar[QtCore.pyqtSignal] + bottomChanged: typing.ClassVar[QtCore.pyqtSignal] + rightChanged: typing.ClassVar[QtCore.pyqtSignal] + leftChanged: typing.ClassVar[QtCore.pyqtSignal] + aspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + fieldOfViewChanged: typing.ClassVar[QtCore.pyqtSignal] + farPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] + nearPlaneChanged: typing.ClassVar[QtCore.pyqtSignal] + projectionTypeChanged: typing.ClassVar[QtCore.pyqtSignal] def setProjectionMatrix(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... def setTop(self, top: float) -> None: ... def setBottom(self, bottom: float) -> None: ... @@ -954,7 +954,7 @@ class QCameraSelector('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def cameraChanged(self, camera: Qt3DCore.QEntity) -> None: ... + cameraChanged: typing.ClassVar[QtCore.pyqtSignal] def setCamera(self, camera: Qt3DCore.QEntity) -> None: ... def camera(self) -> Qt3DCore.QEntity: ... @@ -996,11 +996,11 @@ class QClearBuffers('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def colorBufferChanged(self, buffer: 'QRenderTargetOutput') -> None: ... - def clearStencilValueChanged(self, clearStencilValue: int) -> None: ... - def clearDepthValueChanged(self, clearDepthValue: float) -> None: ... - def clearColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def buffersChanged(self, buffers: 'QClearBuffers.BufferType') -> None: ... + colorBufferChanged: typing.ClassVar[QtCore.pyqtSignal] + clearStencilValueChanged: typing.ClassVar[QtCore.pyqtSignal] + clearDepthValueChanged: typing.ClassVar[QtCore.pyqtSignal] + clearColorChanged: typing.ClassVar[QtCore.pyqtSignal] + buffersChanged: typing.ClassVar[QtCore.pyqtSignal] def setColorBuffer(self, buffer: 'QRenderTargetOutput') -> None: ... def setClearStencilValue(self, clearStencilValue: int) -> None: ... def setClearDepthValue(self, clearDepthValue: float) -> None: ... @@ -1016,9 +1016,9 @@ class QClipPlane('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def distanceChanged(self, distance: float) -> None: ... - def normalChanged(self, normal: QtGui.QVector3D) -> None: ... - def planeIndexChanged(self, planeIndex: int) -> None: ... + distanceChanged: typing.ClassVar[QtCore.pyqtSignal] + normalChanged: typing.ClassVar[QtCore.pyqtSignal] + planeIndexChanged: typing.ClassVar[QtCore.pyqtSignal] def setDistance(self, a0: float) -> None: ... def setNormal(self, a0: QtGui.QVector3D) -> None: ... def setPlaneIndex(self, a0: int) -> None: ... @@ -1037,16 +1037,16 @@ class QComputeCommand(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def runTypeChanged(self) -> None: ... + runTypeChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def trigger(self, frameCount: int = ...) -> None: ... @typing.overload def trigger(self, workGroupX: int, workGroupY: int, workGroupZ: int, frameCount: int = ...) -> None: ... def setRunType(self, runType: 'QComputeCommand.RunType') -> None: ... def runType(self) -> 'QComputeCommand.RunType': ... - def workGroupZChanged(self) -> None: ... - def workGroupYChanged(self) -> None: ... - def workGroupXChanged(self) -> None: ... + workGroupZChanged: typing.ClassVar[QtCore.pyqtSignal] + workGroupYChanged: typing.ClassVar[QtCore.pyqtSignal] + workGroupXChanged: typing.ClassVar[QtCore.pyqtSignal] def setWorkGroupZ(self, workGroupZ: int) -> None: ... def setWorkGroupY(self, workGroupY: int) -> None: ... def setWorkGroupX(self, workGroupX: int) -> None: ... @@ -1058,10 +1058,10 @@ class QColorMask('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def alphaMaskedChanged(self, alphaMasked: bool) -> None: ... - def blueMaskedChanged(self, blueMasked: bool) -> None: ... - def greenMaskedChanged(self, greenMasked: bool) -> None: ... - def redMaskedChanged(self, redMasked: bool) -> None: ... + alphaMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] + blueMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] + greenMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] + redMaskedChanged: typing.ClassVar[QtCore.pyqtSignal] def setAlphaMasked(self, alphaMasked: bool) -> None: ... def setBlueMasked(self, blueMasked: bool) -> None: ... def setGreenMasked(self, greenMasked: bool) -> None: ... @@ -1086,7 +1086,7 @@ class QCullFace('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def modeChanged(self, mode: 'QCullFace.CullingMode') -> None: ... + modeChanged: typing.ClassVar[QtCore.pyqtSignal] def setMode(self, mode: 'QCullFace.CullingMode') -> None: ... def mode(self) -> 'QCullFace.CullingMode': ... @@ -1094,8 +1094,8 @@ class QDepthRange('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def farValueChanged(self, farValue: float) -> None: ... - def nearValueChanged(self, nearValue: float) -> None: ... + farValueChanged: typing.ClassVar[QtCore.pyqtSignal] + nearValueChanged: typing.ClassVar[QtCore.pyqtSignal] def setFarValue(self, value: float) -> None: ... def setNearValue(self, value: float) -> None: ... def farValue(self) -> float: ... @@ -1124,7 +1124,7 @@ class QDepthTest('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def depthFunctionChanged(self, depthFunction: 'QDepthTest.DepthFunction') -> None: ... + depthFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] def setDepthFunction(self, depthFunction: 'QDepthTest.DepthFunction') -> None: ... def depthFunction(self) -> 'QDepthTest.DepthFunction': ... @@ -1132,7 +1132,7 @@ class QDirectionalLight('QAbstractLight'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def worldDirectionChanged(self, worldDirection: QtGui.QVector3D) -> None: ... + worldDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] def setWorldDirection(self, worldDirection: QtGui.QVector3D) -> None: ... def worldDirection(self) -> QtGui.QVector3D: ... @@ -1140,9 +1140,9 @@ class QDispatchCompute('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def workGroupZChanged(self) -> None: ... - def workGroupYChanged(self) -> None: ... - def workGroupXChanged(self) -> None: ... + workGroupZChanged: typing.ClassVar[QtCore.pyqtSignal] + workGroupYChanged: typing.ClassVar[QtCore.pyqtSignal] + workGroupXChanged: typing.ClassVar[QtCore.pyqtSignal] def setWorkGroupZ(self, workGroupZ: int) -> None: ... def setWorkGroupY(self, workGroupY: int) -> None: ... def setWorkGroupX(self, workGroupX: int) -> None: ... @@ -1169,8 +1169,8 @@ class QEnvironmentLight(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def specularChanged(self, environmentSpecular: 'QAbstractTexture') -> None: ... - def irradianceChanged(self, environmentIrradiance: 'QAbstractTexture') -> None: ... + specularChanged: typing.ClassVar[QtCore.pyqtSignal] + irradianceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSpecular(self, specular: 'QAbstractTexture') -> None: ... def setIrradiance(self, irradiance: 'QAbstractTexture') -> None: ... def specular(self) -> 'QAbstractTexture': ... @@ -1180,8 +1180,8 @@ class QFilterKey(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def valueChanged(self, value: typing.Any) -> None: ... - def nameChanged(self, name: str) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] def setName(self, customType: str) -> None: ... def setValue(self, value: typing.Any) -> None: ... def name(self) -> str: ... @@ -1198,7 +1198,7 @@ class QFrontFace('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def directionChanged(self, direction: 'QFrontFace.WindingDirection') -> None: ... + directionChanged: typing.ClassVar[QtCore.pyqtSignal] def setDirection(self, direction: 'QFrontFace.WindingDirection') -> None: ... def direction(self) -> 'QFrontFace.WindingDirection': ... @@ -1211,11 +1211,11 @@ class QGeometry(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def maxExtentChanged(self, maxExtent: QtGui.QVector3D) -> None: ... - def minExtentChanged(self, minExtent: QtGui.QVector3D) -> None: ... + maxExtentChanged: typing.ClassVar[QtCore.pyqtSignal] + minExtentChanged: typing.ClassVar[QtCore.pyqtSignal] def maxExtent(self) -> QtGui.QVector3D: ... def minExtent(self) -> QtGui.QVector3D: ... - def boundingVolumePositionAttributeChanged(self, boundingVolumePositionAttribute: 'QAttribute') -> None: ... + boundingVolumePositionAttributeChanged: typing.ClassVar[QtCore.pyqtSignal] def setBoundingVolumePositionAttribute(self, boundingVolumePositionAttribute: 'QAttribute') -> None: ... def boundingVolumePositionAttribute(self) -> 'QAttribute': ... def removeAttribute(self, attribute: 'QAttribute') -> None: ... @@ -1258,19 +1258,19 @@ class QGeometryRenderer(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def indexBufferByteOffsetChanged(self, offset: int) -> None: ... + indexBufferByteOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] def setIndexBufferByteOffset(self, offset: int) -> None: ... def indexBufferByteOffset(self) -> int: ... - def primitiveTypeChanged(self, primitiveType: 'QGeometryRenderer.PrimitiveType') -> None: ... - def geometryChanged(self, geometry: 'QGeometry') -> None: ... - def primitiveRestartEnabledChanged(self, primitiveRestartEnabled: bool) -> None: ... - def verticesPerPatchChanged(self, verticesPerPatch: int) -> None: ... - def restartIndexValueChanged(self, restartIndexValue: int) -> None: ... - def firstVertexChanged(self, firstVertex: int) -> None: ... - def firstInstanceChanged(self, firstInstance: int) -> None: ... - def indexOffsetChanged(self, indexOffset: int) -> None: ... - def vertexCountChanged(self, vertexCount: int) -> None: ... - def instanceCountChanged(self, instanceCount: int) -> None: ... + primitiveTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryChanged: typing.ClassVar[QtCore.pyqtSignal] + primitiveRestartEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + verticesPerPatchChanged: typing.ClassVar[QtCore.pyqtSignal] + restartIndexValueChanged: typing.ClassVar[QtCore.pyqtSignal] + firstVertexChanged: typing.ClassVar[QtCore.pyqtSignal] + firstInstanceChanged: typing.ClassVar[QtCore.pyqtSignal] + indexOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] + vertexCountChanged: typing.ClassVar[QtCore.pyqtSignal] + instanceCountChanged: typing.ClassVar[QtCore.pyqtSignal] def setPrimitiveType(self, primitiveType: 'QGeometryRenderer.PrimitiveType') -> None: ... def setGeometry(self, geometry: 'QGeometry') -> None: ... def setPrimitiveRestartEnabled(self, enabled: bool) -> None: ... @@ -1320,13 +1320,13 @@ class QGraphicsApiFilter(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def graphicsApiFilterChanged(self) -> None: ... - def vendorChanged(self, vendor: str) -> None: ... - def extensionsChanged(self, extensions: typing.Iterable[str]) -> None: ... - def majorVersionChanged(self, majorVersion: int) -> None: ... - def minorVersionChanged(self, minorVersion: int) -> None: ... - def profileChanged(self, profile: 'QGraphicsApiFilter.OpenGLProfile') -> None: ... - def apiChanged(self, api: 'QGraphicsApiFilter.Api') -> None: ... + graphicsApiFilterChanged: typing.ClassVar[QtCore.pyqtSignal] + vendorChanged: typing.ClassVar[QtCore.pyqtSignal] + extensionsChanged: typing.ClassVar[QtCore.pyqtSignal] + majorVersionChanged: typing.ClassVar[QtCore.pyqtSignal] + minorVersionChanged: typing.ClassVar[QtCore.pyqtSignal] + profileChanged: typing.ClassVar[QtCore.pyqtSignal] + apiChanged: typing.ClassVar[QtCore.pyqtSignal] def setVendor(self, vendor: str) -> None: ... def setExtensions(self, extensions: typing.Iterable[str]) -> None: ... def setMajorVersion(self, majorVersion: int) -> None: ... @@ -1344,7 +1344,7 @@ class QLayer(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def recursiveChanged(self) -> None: ... + recursiveChanged: typing.ClassVar[QtCore.pyqtSignal] def setRecursive(self, recursive: bool) -> None: ... def recursive(self) -> bool: ... @@ -1363,7 +1363,7 @@ class QLayerFilter('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def filterModeChanged(self, filterMode: 'QLayerFilter.FilterMode') -> None: ... + filterModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setFilterMode(self, filterMode: 'QLayerFilter.FilterMode') -> None: ... def filterMode(self) -> 'QLayerFilter.FilterMode': ... def layers(self) -> typing.List['QLayer']: ... @@ -1382,11 +1382,11 @@ class QLevelOfDetail(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def volumeOverrideChanged(self, volumeOverride: 'QLevelOfDetailBoundingSphere') -> None: ... - def thresholdsChanged(self, thresholds: typing.Iterable[float]) -> None: ... - def thresholdTypeChanged(self, thresholdType: 'QLevelOfDetail.ThresholdType') -> None: ... - def currentIndexChanged(self, currentIndex: int) -> None: ... - def cameraChanged(self, camera: 'QCamera') -> None: ... + volumeOverrideChanged: typing.ClassVar[QtCore.pyqtSignal] + thresholdsChanged: typing.ClassVar[QtCore.pyqtSignal] + thresholdTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] + cameraChanged: typing.ClassVar[QtCore.pyqtSignal] def setVolumeOverride(self, volumeOverride: 'QLevelOfDetailBoundingSphere') -> None: ... def setThresholds(self, thresholds: typing.Iterable[float]) -> None: ... def setThresholdType(self, thresholdType: 'QLevelOfDetail.ThresholdType') -> None: ... @@ -1420,8 +1420,8 @@ class QLineWidth('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def smoothChanged(self, enabled: bool) -> None: ... - def valueChanged(self, value: float) -> None: ... + smoothChanged: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setSmooth(self, enabled: bool) -> None: ... def setValue(self, value: float) -> None: ... def smooth(self) -> bool: ... @@ -1431,7 +1431,7 @@ class QMaterial(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def effectChanged(self, effect: 'QEffect') -> None: ... + effectChanged: typing.ClassVar[QtCore.pyqtSignal] def setEffect(self, effect: 'QEffect') -> None: ... def parameters(self) -> typing.List['QParameter']: ... def removeParameter(self, parameter: 'QParameter') -> None: ... @@ -1492,7 +1492,7 @@ class QMemoryBarrier('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def waitOperationsChanged(self, barrierTypes: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... + waitOperationsChanged: typing.ClassVar[QtCore.pyqtSignal] def setWaitOperations(self, operations: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... def waitOperations(self) -> 'QMemoryBarrier.Operations': ... @@ -1512,10 +1512,10 @@ class QMesh('QGeometryRenderer'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QMesh.Status') -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] def status(self) -> 'QMesh.Status': ... - def meshNameChanged(self, meshName: str) -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + meshNameChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setMeshName(self, meshName: str) -> None: ... def setSource(self, source: QtCore.QUrl) -> None: ... def meshName(self) -> str: ... @@ -1541,20 +1541,20 @@ class QObjectPicker(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def priorityChanged(self, priority: int) -> None: ... + priorityChanged: typing.ClassVar[QtCore.pyqtSignal] def setPriority(self, priority: int) -> None: ... def priority(self) -> int: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def containsMouseChanged(self, containsMouse: bool) -> None: ... - def pressedChanged(self, pressed: bool) -> None: ... - def dragEnabledChanged(self, dragEnabled: bool) -> None: ... - def hoverEnabledChanged(self, hoverEnabled: bool) -> None: ... - def exited(self) -> None: ... - def entered(self) -> None: ... - def moved(self, pick: 'QPickEvent') -> None: ... - def clicked(self, pick: 'QPickEvent') -> None: ... - def released(self, pick: 'QPickEvent') -> None: ... - def pressed(self, pick: 'QPickEvent') -> None: ... + containsMouseChanged: typing.ClassVar[QtCore.pyqtSignal] + pressedChanged: typing.ClassVar[QtCore.pyqtSignal] + dragEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + hoverEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + exited: typing.ClassVar[QtCore.pyqtSignal] + entered: typing.ClassVar[QtCore.pyqtSignal] + moved: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] def setDragEnabled(self, dragEnabled: bool) -> None: ... def setHoverEnabled(self, hoverEnabled: bool) -> None: ... def isPressed(self) -> bool: ... @@ -1567,9 +1567,9 @@ class QPaintedTextureImage('QAbstractTextureImage'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def paint(self, painter: QtGui.QPainter) -> None: ... - def sizeChanged(self, size: QtCore.QSize) -> None: ... - def heightChanged(self, w: int) -> None: ... - def widthChanged(self, w: int) -> None: ... + sizeChanged: typing.ClassVar[QtCore.pyqtSignal] + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] def setSize(self, size: QtCore.QSize) -> None: ... def setHeight(self, h: int) -> None: ... def setWidth(self, w: int) -> None: ... @@ -1587,8 +1587,8 @@ class QParameter(Qt3DCore.QNode): @typing.overload def __init__(self, name: str, texture: 'QAbstractTexture', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def nameChanged(self, name: str) -> None: ... - def valueChanged(self, value: typing.Any) -> None: ... + nameChanged: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, dv: typing.Any) -> None: ... def setName(self, name: str) -> None: ... def value(self) -> typing.Any: ... @@ -1636,7 +1636,7 @@ class QPickEvent(QtCore.QObject): def modifiers(self) -> int: ... def buttons(self) -> int: ... def button(self) -> 'QPickEvent.Buttons': ... - def acceptedChanged(self, accepted: bool) -> None: ... + acceptedChanged: typing.ClassVar[QtCore.pyqtSignal] def setAccepted(self, accepted: bool) -> None: ... def localIntersection(self) -> QtGui.QVector3D: ... def worldIntersection(self) -> QtGui.QVector3D: ... @@ -1679,14 +1679,14 @@ class QPickingSettings(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def worldSpaceToleranceChanged(self, worldSpaceTolerance: float) -> None: ... + worldSpaceToleranceChanged: typing.ClassVar[QtCore.pyqtSignal] def setWorldSpaceTolerance(self, worldSpaceTolerance: float) -> None: ... def worldSpaceTolerance(self) -> float: ... - def faceOrientationPickingModeChanged(self, faceOrientationPickingMode: 'QPickingSettings.FaceOrientationPickingMode') -> None: ... + faceOrientationPickingModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setFaceOrientationPickingMode(self, faceOrientationPickingMode: 'QPickingSettings.FaceOrientationPickingMode') -> None: ... def faceOrientationPickingMode(self) -> 'QPickingSettings.FaceOrientationPickingMode': ... - def pickResultModeChanged(self, pickResult: 'QPickingSettings.PickResultMode') -> None: ... - def pickMethodChanged(self, pickMethod: 'QPickingSettings.PickMethod') -> None: ... + pickResultModeChanged: typing.ClassVar[QtCore.pyqtSignal] + pickMethodChanged: typing.ClassVar[QtCore.pyqtSignal] def setPickResultMode(self, pickResultMode: 'QPickingSettings.PickResultMode') -> None: ... def setPickMethod(self, pickMethod: 'QPickingSettings.PickMethod') -> None: ... def pickResultMode(self) -> 'QPickingSettings.PickResultMode': ... @@ -1731,9 +1731,9 @@ class QPointLight('QAbstractLight'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def quadraticAttenuationChanged(self, quadraticAttenuation: float) -> None: ... - def linearAttenuationChanged(self, linearAttenuation: float) -> None: ... - def constantAttenuationChanged(self, constantAttenuation: float) -> None: ... + quadraticAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] + linearAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] + constantAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] def setQuadraticAttenuation(self, value: float) -> None: ... def setLinearAttenuation(self, value: float) -> None: ... def setConstantAttenuation(self, value: float) -> None: ... @@ -1752,8 +1752,8 @@ class QPointSize('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def valueChanged(self, value: float) -> None: ... - def sizeModeChanged(self, sizeMode: 'QPointSize.SizeMode') -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + sizeModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, value: float) -> None: ... def setSizeMode(self, sizeMode: 'QPointSize.SizeMode') -> None: ... def value(self) -> float: ... @@ -1763,8 +1763,8 @@ class QPolygonOffset('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def depthStepsChanged(self, depthSteps: float) -> None: ... - def scaleFactorChanged(self, scaleFactor: float) -> None: ... + depthStepsChanged: typing.ClassVar[QtCore.pyqtSignal] + scaleFactorChanged: typing.ClassVar[QtCore.pyqtSignal] def setDepthSteps(self, depthSteps: float) -> None: ... def setScaleFactor(self, scaleFactor: float) -> None: ... def depthSteps(self) -> float: ... @@ -1774,8 +1774,8 @@ class QProximityFilter('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def distanceThresholdChanged(self, distanceThreshold: float) -> None: ... - def entityChanged(self, entity: Qt3DCore.QEntity) -> None: ... + distanceThresholdChanged: typing.ClassVar[QtCore.pyqtSignal] + entityChanged: typing.ClassVar[QtCore.pyqtSignal] def setDistanceThreshold(self, distanceThreshold: float) -> None: ... def setEntity(self, entity: Qt3DCore.QEntity) -> None: ... def distanceThreshold(self) -> float: ... @@ -1803,8 +1803,8 @@ class QRasterMode('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def faceModeChanged(self, faceMode: 'QRasterMode.FaceMode') -> None: ... - def rasterModeChanged(self, rasterMode: 'QRasterMode.RasterMode') -> None: ... + faceModeChanged: typing.ClassVar[QtCore.pyqtSignal] + rasterModeChanged: typing.ClassVar[QtCore.pyqtSignal] def setFaceMode(self, faceMode: 'QRasterMode.FaceMode') -> None: ... def setRasterMode(self, rasterMode: 'QRasterMode.RasterMode') -> None: ... def faceMode(self) -> 'QRasterMode.FaceMode': ... @@ -1814,9 +1814,9 @@ class QRayCaster('QAbstractRayCaster'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def lengthChanged(self, length: float) -> None: ... - def directionChanged(self, direction: QtGui.QVector3D) -> None: ... - def originChanged(self, origin: QtGui.QVector3D) -> None: ... + lengthChanged: typing.ClassVar[QtCore.pyqtSignal] + directionChanged: typing.ClassVar[QtCore.pyqtSignal] + originChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def trigger(self) -> None: ... @typing.overload @@ -1935,9 +1935,9 @@ class QRenderCapabilities(QtCore.QObject): class QRenderCaptureReply(QtCore.QObject): - def completed(self) -> None: ... + completed: typing.ClassVar[QtCore.pyqtSignal] def saveImage(self, fileName: str) -> bool: ... - def completeChanged(self, isComplete: bool) -> None: ... + completeChanged: typing.ClassVar[QtCore.pyqtSignal] def saveToFile(self, fileName: str) -> None: ... def isComplete(self) -> bool: ... def captureId(self) -> int: ... @@ -1959,7 +1959,7 @@ class QRenderPass(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def shaderProgramChanged(self, shaderProgram: 'QShaderProgram') -> None: ... + shaderProgramChanged: typing.ClassVar[QtCore.pyqtSignal] def setShaderProgram(self, shaderProgram: 'QShaderProgram') -> None: ... def parameters(self) -> typing.List['QParameter']: ... def removeParameter(self, p: 'QParameter') -> None: ... @@ -1994,8 +1994,8 @@ class QRenderSettings(Qt3DCore.QComponent): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def renderPolicyChanged(self, renderPolicy: 'QRenderSettings.RenderPolicy') -> None: ... - def activeFrameGraphChanged(self, activeFrameGraph: 'QFrameGraphNode') -> None: ... + renderPolicyChanged: typing.ClassVar[QtCore.pyqtSignal] + activeFrameGraphChanged: typing.ClassVar[QtCore.pyqtSignal] def setRenderPolicy(self, renderPolicy: 'QRenderSettings.RenderPolicy') -> None: ... def setActiveFrameGraph(self, activeFrameGraph: 'QFrameGraphNode') -> None: ... def renderCapabilities(self) -> 'QRenderCapabilities': ... @@ -2015,9 +2015,9 @@ class QRenderSurfaceSelector('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def surfacePixelRatioChanged(self, ratio: float) -> None: ... - def externalRenderTargetSizeChanged(self, size: QtCore.QSize) -> None: ... - def surfaceChanged(self, surface: QtCore.QObject) -> None: ... + surfacePixelRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + externalRenderTargetSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + surfaceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSurfacePixelRatio(self, ratio: float) -> None: ... def setSurface(self, surfaceObject: QtCore.QObject) -> None: ... def setExternalRenderTargetSize(self, size: QtCore.QSize) -> None: ... @@ -2078,11 +2078,11 @@ class QRenderTargetOutput(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def faceChanged(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... - def layerChanged(self, layer: int) -> None: ... - def mipLevelChanged(self, mipLevel: int) -> None: ... - def textureChanged(self, texture: 'QAbstractTexture') -> None: ... - def attachmentPointChanged(self, attachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... + faceChanged: typing.ClassVar[QtCore.pyqtSignal] + layerChanged: typing.ClassVar[QtCore.pyqtSignal] + mipLevelChanged: typing.ClassVar[QtCore.pyqtSignal] + textureChanged: typing.ClassVar[QtCore.pyqtSignal] + attachmentPointChanged: typing.ClassVar[QtCore.pyqtSignal] def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... def setLayer(self, layer: int) -> None: ... def setMipLevel(self, level: int) -> None: ... @@ -2098,7 +2098,7 @@ class QRenderTargetSelector('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def targetChanged(self, target: 'QRenderTarget') -> None: ... + targetChanged: typing.ClassVar[QtCore.pyqtSignal] def setTarget(self, target: 'QRenderTarget') -> None: ... def target(self) -> 'QRenderTarget': ... def outputs(self) -> typing.List[QRenderTargetOutput.AttachmentPoint]: ... @@ -2136,8 +2136,8 @@ class QSceneLoader(Qt3DCore.QComponent): def component(self, entityName: str, componentType: 'QSceneLoader.ComponentType') -> Qt3DCore.QComponent: ... def entityNames(self) -> typing.List[str]: ... def entity(self, entityName: str) -> Qt3DCore.QEntity: ... - def statusChanged(self, status: 'QSceneLoader.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSource(self, arg: QtCore.QUrl) -> None: ... def status(self) -> 'QSceneLoader.Status': ... def source(self) -> QtCore.QUrl: ... @@ -2147,10 +2147,10 @@ class QScissorTest('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def heightChanged(self, height: int) -> None: ... - def widthChanged(self, width: int) -> None: ... - def bottomChanged(self, bottom: int) -> None: ... - def leftChanged(self, left: int) -> None: ... + heightChanged: typing.ClassVar[QtCore.pyqtSignal] + widthChanged: typing.ClassVar[QtCore.pyqtSignal] + bottomChanged: typing.ClassVar[QtCore.pyqtSignal] + leftChanged: typing.ClassVar[QtCore.pyqtSignal] def setHeight(self, height: int) -> None: ... def setWidth(self, width: int) -> None: ... def setBottom(self, bottom: int) -> None: ... @@ -2164,7 +2164,7 @@ class QScreenRayCaster('QAbstractRayCaster'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def positionChanged(self, position: QtCore.QPoint) -> None: ... + positionChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def trigger(self) -> None: ... @typing.overload @@ -2188,8 +2188,8 @@ class QSetFence('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def handleChanged(self, handle: typing.Any) -> None: ... - def handleTypeChanged(self, handleType: 'QSetFence.HandleType') -> None: ... + handleChanged: typing.ClassVar[QtCore.pyqtSignal] + handleTypeChanged: typing.ClassVar[QtCore.pyqtSignal] def handle(self) -> typing.Any: ... def handleType(self) -> 'QSetFence.HandleType': ... @@ -2302,12 +2302,12 @@ class QShaderImage(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def formatChanged(self, format: 'QShaderImage.ImageFormat') -> None: ... - def accessChanged(self, access: 'QShaderImage.Access') -> None: ... - def layerChanged(self, layer: int) -> None: ... - def mipLevelChanged(self, mipLevel: int) -> None: ... - def layeredChanged(self, layered: bool) -> None: ... - def textureChanged(self, texture: 'QAbstractTexture') -> None: ... + formatChanged: typing.ClassVar[QtCore.pyqtSignal] + accessChanged: typing.ClassVar[QtCore.pyqtSignal] + layerChanged: typing.ClassVar[QtCore.pyqtSignal] + mipLevelChanged: typing.ClassVar[QtCore.pyqtSignal] + layeredChanged: typing.ClassVar[QtCore.pyqtSignal] + textureChanged: typing.ClassVar[QtCore.pyqtSignal] def setFormat(self, format: 'QShaderImage.ImageFormat') -> None: ... def setAccess(self, access: 'QShaderImage.Access') -> None: ... def setLayer(self, layer: int) -> None: ... @@ -2356,20 +2356,20 @@ class QShaderProgram(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def formatChanged(self, format: 'QShaderProgram.Format') -> None: ... + formatChanged: typing.ClassVar[QtCore.pyqtSignal] def format(self) -> 'QShaderProgram.Format': ... def setFormat(self, format: 'QShaderProgram.Format') -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QShaderProgram.Status') -> None: ... - def logChanged(self, log: str) -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + logChanged: typing.ClassVar[QtCore.pyqtSignal] def status(self) -> 'QShaderProgram.Status': ... def log(self) -> str: ... - def computeShaderCodeChanged(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def fragmentShaderCodeChanged(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def geometryShaderCodeChanged(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationEvaluationShaderCodeChanged(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationControlShaderCodeChanged(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def vertexShaderCodeChanged(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + computeShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + fragmentShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationEvaluationShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationControlShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + vertexShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] def setComputeShaderCode(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def setFragmentShaderCode(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def setGeometryShaderCode(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... @@ -2392,26 +2392,26 @@ class QShaderProgramBuilder(Qt3DCore.QNode): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def computeShaderCodeChanged(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def fragmentShaderCodeChanged(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def geometryShaderCodeChanged(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationEvaluationShaderCodeChanged(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationControlShaderCodeChanged(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def vertexShaderCodeChanged(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + computeShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + fragmentShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationEvaluationShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationControlShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + vertexShaderCodeChanged: typing.ClassVar[QtCore.pyqtSignal] def computeShaderCode(self) -> QtCore.QByteArray: ... def fragmentShaderCode(self) -> QtCore.QByteArray: ... def geometryShaderCode(self) -> QtCore.QByteArray: ... def tessellationEvaluationShaderCode(self) -> QtCore.QByteArray: ... def tessellationControlShaderCode(self) -> QtCore.QByteArray: ... def vertexShaderCode(self) -> QtCore.QByteArray: ... - def computeShaderGraphChanged(self, computeShaderGraph: QtCore.QUrl) -> None: ... - def fragmentShaderGraphChanged(self, fragmentShaderGraph: QtCore.QUrl) -> None: ... - def geometryShaderGraphChanged(self, geometryShaderGraph: QtCore.QUrl) -> None: ... - def tessellationEvaluationShaderGraphChanged(self, tessellationEvaluationShaderGraph: QtCore.QUrl) -> None: ... - def tessellationControlShaderGraphChanged(self, tessellationControlShaderGraph: QtCore.QUrl) -> None: ... - def vertexShaderGraphChanged(self, vertexShaderGraph: QtCore.QUrl) -> None: ... - def enabledLayersChanged(self, layers: typing.Iterable[str]) -> None: ... - def shaderProgramChanged(self, shaderProgram: 'QShaderProgram') -> None: ... + computeShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + fragmentShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationEvaluationShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + tessellationControlShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + vertexShaderGraphChanged: typing.ClassVar[QtCore.pyqtSignal] + enabledLayersChanged: typing.ClassVar[QtCore.pyqtSignal] + shaderProgramChanged: typing.ClassVar[QtCore.pyqtSignal] def setComputeShaderGraph(self, computeShaderGraph: QtCore.QUrl) -> None: ... def setFragmentShaderGraph(self, fragmentShaderGraph: QtCore.QUrl) -> None: ... def setGeometryShaderGraph(self, geometryShaderGraph: QtCore.QUrl) -> None: ... @@ -2448,10 +2448,7 @@ class QSortPolicy('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - @typing.overload - def sortTypesChanged(self, sortTypes: typing.Iterable[QSortPolicy.SortType]) -> None: ... - @typing.overload - def sortTypesChanged(self, sortTypes: typing.Iterable[int]) -> None: ... + sortTypesChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def setSortTypes(self, sortTypes: typing.Iterable[QSortPolicy.SortType]) -> None: ... @typing.overload @@ -2463,11 +2460,11 @@ class QSpotLight('QAbstractLight'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def cutOffAngleChanged(self, cutOffAngle: float) -> None: ... - def localDirectionChanged(self, localDirection: QtGui.QVector3D) -> None: ... - def quadraticAttenuationChanged(self, quadraticAttenuation: float) -> None: ... - def linearAttenuationChanged(self, linearAttenuation: float) -> None: ... - def constantAttenuationChanged(self, constantAttenuation: float) -> None: ... + cutOffAngleChanged: typing.ClassVar[QtCore.pyqtSignal] + localDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] + quadraticAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] + linearAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] + constantAttenuationChanged: typing.ClassVar[QtCore.pyqtSignal] def setCutOffAngle(self, cutOffAngle: float) -> None: ... def setLocalDirection(self, localDirection: QtGui.QVector3D) -> None: ... def setQuadraticAttenuation(self, value: float) -> None: ... @@ -2483,8 +2480,8 @@ class QStencilMask('QRenderState'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def backOutputMaskChanged(self, backOutputMask: int) -> None: ... - def frontOutputMaskChanged(self, frontOutputMask: int) -> None: ... + backOutputMaskChanged: typing.ClassVar[QtCore.pyqtSignal] + frontOutputMaskChanged: typing.ClassVar[QtCore.pyqtSignal] def setBackOutputMask(self, backOutputMask: int) -> None: ... def setFrontOutputMask(self, frontOutputMask: int) -> None: ... def backOutputMask(self) -> int: ... @@ -2527,10 +2524,10 @@ class QStencilOperationArguments(QtCore.QObject): Back = ... # type: QStencilOperationArguments.FaceMode FrontAndBack = ... # type: QStencilOperationArguments.FaceMode - def faceModeChanged(self, faceMode: 'QStencilOperationArguments.FaceMode') -> None: ... - def allTestsPassOperationChanged(self, stencilDepthPass: 'QStencilOperationArguments.Operation') -> None: ... - def depthTestFailureOperationChanged(self, depthFail: 'QStencilOperationArguments.Operation') -> None: ... - def stencilTestFailureOperationChanged(self, stencilFail: 'QStencilOperationArguments.Operation') -> None: ... + faceModeChanged: typing.ClassVar[QtCore.pyqtSignal] + allTestsPassOperationChanged: typing.ClassVar[QtCore.pyqtSignal] + depthTestFailureOperationChanged: typing.ClassVar[QtCore.pyqtSignal] + stencilTestFailureOperationChanged: typing.ClassVar[QtCore.pyqtSignal] def setAllTestsPassOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... def setDepthTestFailureOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... def setStencilTestFailureOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... @@ -2576,10 +2573,10 @@ class QStencilTestArguments(QtCore.QObject): Back = ... # type: QStencilTestArguments.StencilFaceMode FrontAndBack = ... # type: QStencilTestArguments.StencilFaceMode - def faceModeChanged(self, faceMode: 'QStencilTestArguments.StencilFaceMode') -> None: ... - def referenceValueChanged(self, referenceValue: int) -> None: ... - def stencilFunctionChanged(self, stencilFunction: 'QStencilTestArguments.StencilFunction') -> None: ... - def comparisonMaskChanged(self, comparisonMask: int) -> None: ... + faceModeChanged: typing.ClassVar[QtCore.pyqtSignal] + referenceValueChanged: typing.ClassVar[QtCore.pyqtSignal] + stencilFunctionChanged: typing.ClassVar[QtCore.pyqtSignal] + comparisonMaskChanged: typing.ClassVar[QtCore.pyqtSignal] def setStencilFunction(self, stencilFunction: 'QStencilTestArguments.StencilFunction') -> None: ... def setReferenceValue(self, referenceValue: int) -> None: ... def setComparisonMask(self, comparisonMask: int) -> None: ... @@ -2599,7 +2596,7 @@ class QSubtreeEnabler('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def enablementChanged(self, enablement: 'QSubtreeEnabler.Enablement') -> None: ... + enablementChanged: typing.ClassVar[QtCore.pyqtSignal] def requestUpdate(self) -> None: ... def setEnablement(self, enablement: 'QSubtreeEnabler.Enablement') -> None: ... def enablement(self) -> 'QSubtreeEnabler.Enablement': ... @@ -2678,10 +2675,10 @@ class QTextureLoader('QAbstractTexture'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def mirroredChanged(self, mirrored: bool) -> None: ... + mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] def setMirrored(self, mirrored: bool) -> None: ... def isMirrored(self) -> bool: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSource(self, source: QtCore.QUrl) -> None: ... def source(self) -> QtCore.QUrl: ... @@ -2689,7 +2686,7 @@ class QSharedGLTexture('QAbstractTexture'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def textureIdChanged(self, textureId: int) -> None: ... + textureIdChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureId(self, id: int) -> None: ... def textureId(self) -> int: ... @@ -2775,13 +2772,13 @@ class QTextureImage('QAbstractTextureImage'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def mirroredChanged(self, mirrored: bool) -> None: ... + mirroredChanged: typing.ClassVar[QtCore.pyqtSignal] def setMirrored(self, mirrored: bool) -> None: ... def isMirrored(self) -> bool: ... def setStatus(self, status: 'QTextureImage.Status') -> None: ... def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QTextureImage.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSource(self, source: QtCore.QUrl) -> None: ... def status(self) -> 'QTextureImage.Status': ... def source(self) -> QtCore.QUrl: ... @@ -2841,9 +2838,9 @@ class QTextureWrapMode(QtCore.QObject): @typing.overload def __init__(self, x: 'QTextureWrapMode.WrapMode', y: 'QTextureWrapMode.WrapMode', z: 'QTextureWrapMode.WrapMode', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def zChanged(self, z: 'QTextureWrapMode.WrapMode') -> None: ... - def yChanged(self, y: 'QTextureWrapMode.WrapMode') -> None: ... - def xChanged(self, x: 'QTextureWrapMode.WrapMode') -> None: ... + zChanged: typing.ClassVar[QtCore.pyqtSignal] + yChanged: typing.ClassVar[QtCore.pyqtSignal] + xChanged: typing.ClassVar[QtCore.pyqtSignal] def setZ(self, z: 'QTextureWrapMode.WrapMode') -> None: ... def setY(self, y: 'QTextureWrapMode.WrapMode') -> None: ... def setX(self, x: 'QTextureWrapMode.WrapMode') -> None: ... @@ -2855,10 +2852,10 @@ class QViewport('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def gammaChanged(self, gamma: float) -> None: ... + gammaChanged: typing.ClassVar[QtCore.pyqtSignal] def setGamma(self, gamma: float) -> None: ... def gamma(self) -> float: ... - def normalizedRectChanged(self, normalizedRect: QtCore.QRectF) -> None: ... + normalizedRectChanged: typing.ClassVar[QtCore.pyqtSignal] def setNormalizedRect(self, normalizedRect: QtCore.QRectF) -> None: ... def normalizedRect(self) -> QtCore.QRectF: ... @@ -2873,10 +2870,10 @@ class QWaitFence('QFrameGraphNode'): def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def handleChanged(self, handle: typing.Any) -> None: ... - def handleTypeChanged(self, handleType: 'QWaitFence.HandleType') -> None: ... - def timeoutChanged(self, timeoutChanged: int) -> None: ... - def waitOnCPUChanged(self, waitOnCPU: bool) -> None: ... + handleChanged: typing.ClassVar[QtCore.pyqtSignal] + handleTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + timeoutChanged: typing.ClassVar[QtCore.pyqtSignal] + waitOnCPUChanged: typing.ClassVar[QtCore.pyqtSignal] def setTimeout(self, timeout: int) -> None: ... def timeout(self) -> int: ... def setWaitOnCPU(self, waitOnCPU: bool) -> None: ... diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index b9bb57b5..87a432e3 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -163,10 +163,10 @@ class QBluetoothDeviceDiscoveryAgent(QtCore.QObject): def supportedDiscoveryMethods() -> 'QBluetoothDeviceDiscoveryAgent.DiscoveryMethods': ... def lowEnergyDiscoveryTimeout(self) -> int: ... def setLowEnergyDiscoveryTimeout(self, msTimeout: int) -> None: ... - def deviceUpdated(self, info: 'QBluetoothDeviceInfo', updatedFields: typing.Union['QBluetoothDeviceInfo.Fields', 'QBluetoothDeviceInfo.Field']) -> None: ... - def canceled(self) -> None: ... - def finished(self) -> None: ... - def deviceDiscovered(self, info: 'QBluetoothDeviceInfo') -> None: ... + deviceUpdated: typing.ClassVar[QtCore.pyqtSignal] + canceled: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + deviceDiscovered: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... @typing.overload def start(self) -> None: ... @@ -174,10 +174,7 @@ class QBluetoothDeviceDiscoveryAgent(QtCore.QObject): def start(self, method: typing.Union['QBluetoothDeviceDiscoveryAgent.DiscoveryMethods', 'QBluetoothDeviceDiscoveryAgent.DiscoveryMethod']) -> None: ... def discoveredDevices(self) -> typing.List['QBluetoothDeviceInfo']: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QBluetoothDeviceDiscoveryAgent.Error': ... - @typing.overload - def error(self, error: 'QBluetoothDeviceDiscoveryAgent.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isActive(self) -> bool: ... def setInquiryType(self, type: 'QBluetoothDeviceDiscoveryAgent.InquiryType') -> None: ... def inquiryType(self) -> 'QBluetoothDeviceDiscoveryAgent.InquiryType': ... @@ -575,13 +572,13 @@ class QBluetoothLocalDevice(QtCore.QObject): @typing.overload def __init__(self, address: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def deviceDisconnected(self, address: QBluetoothAddress) -> None: ... - def deviceConnected(self, address: QBluetoothAddress) -> None: ... - def error(self, error: 'QBluetoothLocalDevice.Error') -> None: ... - def pairingDisplayConfirmation(self, address: QBluetoothAddress, pin: str) -> None: ... - def pairingDisplayPinCode(self, address: QBluetoothAddress, pin: str) -> None: ... - def pairingFinished(self, address: QBluetoothAddress, pairing: 'QBluetoothLocalDevice.Pairing') -> None: ... - def hostModeStateChanged(self, state: 'QBluetoothLocalDevice.HostMode') -> None: ... + deviceDisconnected: typing.ClassVar[QtCore.pyqtSignal] + deviceConnected: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + pairingDisplayConfirmation: typing.ClassVar[QtCore.pyqtSignal] + pairingDisplayPinCode: typing.ClassVar[QtCore.pyqtSignal] + pairingFinished: typing.ClassVar[QtCore.pyqtSignal] + hostModeStateChanged: typing.ClassVar[QtCore.pyqtSignal] def pairingConfirmation(self, confirmation: bool) -> None: ... def connectedDevices(self) -> typing.List[QBluetoothAddress]: ... @staticmethod @@ -615,11 +612,8 @@ class QBluetoothServer(QtCore.QObject): def __init__(self, serverType: 'QBluetoothServiceInfo.Protocol', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def newConnection(self) -> None: ... - @typing.overload - def error(self) -> 'QBluetoothServer.Error': ... - @typing.overload - def error(self, a0: 'QBluetoothServer.Error') -> None: ... + newConnection: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] def serverType(self) -> 'QBluetoothServiceInfo.Protocol': ... def securityFlags(self) -> QBluetooth.SecurityFlags: ... def setSecurityFlags(self, security: typing.Union[QBluetooth.SecurityFlags, QBluetooth.Security]) -> None: ... @@ -664,9 +658,9 @@ class QBluetoothServiceDiscoveryAgent(QtCore.QObject): @typing.overload def __init__(self, deviceAdapter: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def canceled(self) -> None: ... - def finished(self) -> None: ... - def serviceDiscovered(self, info: 'QBluetoothServiceInfo') -> None: ... + canceled: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + serviceDiscovered: typing.ClassVar[QtCore.pyqtSignal] def clear(self) -> None: ... def stop(self) -> None: ... def start(self, mode: 'QBluetoothServiceDiscoveryAgent.DiscoveryMode' = ...) -> None: ... @@ -679,10 +673,7 @@ class QBluetoothServiceDiscoveryAgent(QtCore.QObject): def setUuidFilter(self, uuid: 'QBluetoothUuid') -> None: ... def discoveredServices(self) -> typing.List['QBluetoothServiceInfo']: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QBluetoothServiceDiscoveryAgent.Error': ... - @typing.overload - def error(self, error: 'QBluetoothServiceDiscoveryAgent.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isActive(self) -> bool: ... @@ -825,14 +816,11 @@ class QBluetoothSocket(QtCore.QIODevice): def setSocketState(self, state: 'QBluetoothSocket.SocketState') -> None: ... def writeData(self, data: bytes) -> int: ... def readData(self, maxlen: int) -> bytes: ... - def stateChanged(self, state: 'QBluetoothSocket.SocketState') -> None: ... - def disconnected(self) -> None: ... - def connected(self) -> None: ... + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] + connected: typing.ClassVar[QtCore.pyqtSignal] def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QBluetoothSocket.SocketError': ... - @typing.overload - def error(self, error: 'QBluetoothSocket.SocketError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def state(self) -> 'QBluetoothSocket.SocketState': ... def socketType(self) -> QBluetoothServiceInfo.Protocol: ... def socketDescriptor(self) -> int: ... @@ -862,7 +850,7 @@ class QBluetoothTransferManager(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def finished(self, reply: 'QBluetoothTransferReply') -> None: ... + finished: typing.ClassVar[QtCore.pyqtSignal] def put(self, request: 'QBluetoothTransferRequest', data: QtCore.QIODevice) -> 'QBluetoothTransferReply': ... @@ -891,15 +879,12 @@ class QBluetoothTransferReply(QtCore.QObject): def setRequest(self, request: 'QBluetoothTransferRequest') -> None: ... def setManager(self, manager: QBluetoothTransferManager) -> None: ... - def transferProgress(self, bytesTransferred: int, bytesTotal: int) -> None: ... - def finished(self, a0: 'QBluetoothTransferReply') -> None: ... + transferProgress: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def abort(self) -> None: ... def request(self) -> 'QBluetoothTransferRequest': ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QBluetoothTransferReply.TransferError': ... - @typing.overload - def error(self, lastError: 'QBluetoothTransferReply.TransferError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def manager(self) -> QBluetoothTransferManager: ... def isRunning(self) -> bool: ... def isFinished(self) -> bool: ... @@ -1746,7 +1731,7 @@ class QLowEnergyController(QtCore.QObject): def __init__(self, remoteDevice: QBluetoothAddress, localDevice: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def remoteDeviceUuid(self) -> QBluetoothUuid: ... - def connectionUpdated(self, parameters: QLowEnergyConnectionParameters) -> None: ... + connectionUpdated: typing.ClassVar[QtCore.pyqtSignal] def role(self) -> 'QLowEnergyController.Role': ... def requestConnectionUpdate(self, parameters: QLowEnergyConnectionParameters) -> None: ... def addService(self, service: 'QLowEnergyServiceData', parent: typing.Optional[QtCore.QObject] = ...) -> 'QLowEnergyService': ... @@ -1760,17 +1745,14 @@ class QLowEnergyController(QtCore.QObject): @typing.overload @staticmethod def createCentral(remoteDevice: QBluetoothAddress, localDevice: QBluetoothAddress, parent: typing.Optional[QtCore.QObject] = ...) -> 'QLowEnergyController': ... - def discoveryFinished(self) -> None: ... - def serviceDiscovered(self, newService: QBluetoothUuid) -> None: ... - def stateChanged(self, state: 'QLowEnergyController.ControllerState') -> None: ... - def disconnected(self) -> None: ... - def connected(self) -> None: ... + discoveryFinished: typing.ClassVar[QtCore.pyqtSignal] + serviceDiscovered: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] + connected: typing.ClassVar[QtCore.pyqtSignal] def remoteName(self) -> str: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QLowEnergyController.Error': ... - @typing.overload - def error(self, newError: 'QLowEnergyController.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def createServiceObject(self, service: QBluetoothUuid, parent: typing.Optional[QtCore.QObject] = ...) -> 'QLowEnergyService': ... def services(self) -> typing.List[QBluetoothUuid]: ... def discoverServices(self) -> None: ... @@ -1884,24 +1866,21 @@ class QLowEnergyService(QtCore.QObject): def __index__(self) -> int: ... def __int__(self) -> int: ... - def descriptorRead(self, info: QLowEnergyDescriptor, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def characteristicRead(self, info: QLowEnergyCharacteristic, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + descriptorRead: typing.ClassVar[QtCore.pyqtSignal] + characteristicRead: typing.ClassVar[QtCore.pyqtSignal] def readDescriptor(self, descriptor: QLowEnergyDescriptor) -> None: ... def readCharacteristic(self, characteristic: QLowEnergyCharacteristic) -> None: ... - def descriptorWritten(self, info: QLowEnergyDescriptor, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def characteristicWritten(self, info: QLowEnergyCharacteristic, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def characteristicChanged(self, info: QLowEnergyCharacteristic, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def stateChanged(self, newState: 'QLowEnergyService.ServiceState') -> None: ... + descriptorWritten: typing.ClassVar[QtCore.pyqtSignal] + characteristicWritten: typing.ClassVar[QtCore.pyqtSignal] + characteristicChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def writeDescriptor(self, descriptor: QLowEnergyDescriptor, newValue: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def writeCharacteristic(self, characteristic: QLowEnergyCharacteristic, newValue: typing.Union[QtCore.QByteArray, bytes, bytearray], mode: 'QLowEnergyService.WriteMode' = ...) -> None: ... @typing.overload def contains(self, characteristic: QLowEnergyCharacteristic) -> bool: ... @typing.overload def contains(self, descriptor: QLowEnergyDescriptor) -> bool: ... - @typing.overload - def error(self) -> 'QLowEnergyService.ServiceError': ... - @typing.overload - def error(self, error: 'QLowEnergyService.ServiceError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def discoverDetails(self) -> None: ... def serviceName(self) -> str: ... def serviceUuid(self) -> QBluetoothUuid: ... diff --git a/PyQt5-stubs/QtChart.pyi b/PyQt5-stubs/QtChart.pyi index 5520a571..33b4411b 100644 --- a/PyQt5-stubs/QtChart.pyi +++ b/PyQt5-stubs/QtChart.pyi @@ -72,14 +72,14 @@ class QAbstractAxis(QtCore.QObject): def __index__(self) -> int: ... def __int__(self) -> int: ... - def labelsEditableChanged(self, editable: bool) -> None: ... + labelsEditableChanged: typing.ClassVar[QtCore.pyqtSignal] def labelsEditable(self) -> bool: ... def setLabelsEditable(self, editable: bool = ...) -> None: ... - def reverseChanged(self, reverse: bool) -> None: ... - def minorGridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def gridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def minorGridLinePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def minorGridVisibleChanged(self, visible: bool) -> None: ... + reverseChanged: typing.ClassVar[QtCore.pyqtSignal] + minorGridLineColorChanged: typing.ClassVar[QtCore.pyqtSignal] + gridLineColorChanged: typing.ClassVar[QtCore.pyqtSignal] + minorGridLinePenChanged: typing.ClassVar[QtCore.pyqtSignal] + minorGridVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] def isReverse(self) -> bool: ... def setReverse(self, reverse: bool = ...) -> None: ... def minorGridLineColor(self) -> QtGui.QColor: ... @@ -90,17 +90,17 @@ class QAbstractAxis(QtCore.QObject): def setMinorGridLinePen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def setMinorGridLineVisible(self, visible: bool = ...) -> None: ... def isMinorGridLineVisible(self) -> bool: ... - def shadesBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesPenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def titleFontChanged(self, font: QtGui.QFont) -> None: ... - def titleVisibleChanged(self, visible: bool) -> None: ... - def titleBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def titleTextChanged(self, title: str) -> None: ... - def gridLinePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def labelsAngleChanged(self, angle: int) -> None: ... - def labelsFontChanged(self, pen: QtGui.QFont) -> None: ... - def labelsBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def linePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + shadesBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + shadesPenChanged: typing.ClassVar[QtCore.pyqtSignal] + titleFontChanged: typing.ClassVar[QtCore.pyqtSignal] + titleVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + titleBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + titleTextChanged: typing.ClassVar[QtCore.pyqtSignal] + gridLinePenChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsAngleChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsFontChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + linePenChanged: typing.ClassVar[QtCore.pyqtSignal] def alignment(self) -> QtCore.Qt.Alignment: ... def titleText(self) -> str: ... def setTitleText(self, title: str) -> None: ... @@ -110,15 +110,15 @@ class QAbstractAxis(QtCore.QObject): def setTitleBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def setTitleVisible(self, visible: bool = ...) -> None: ... def isTitleVisible(self) -> bool: ... - def shadesBorderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesVisibleChanged(self, visible: bool) -> None: ... - def labelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def gridVisibleChanged(self, visible: bool) -> None: ... - def labelsVisibleChanged(self, visible: bool) -> None: ... - def lineVisibleChanged(self, visible: bool) -> None: ... - def visibleChanged(self, visible: bool) -> None: ... + shadesBorderColorChanged: typing.ClassVar[QtCore.pyqtSignal] + shadesColorChanged: typing.ClassVar[QtCore.pyqtSignal] + shadesVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + gridVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + lineVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] def orientation(self) -> QtCore.Qt.Orientation: ... def hide(self) -> None: ... def show(self) -> None: ... @@ -190,17 +190,17 @@ class QAbstractSeries(QtCore.QObject): SeriesTypeBoxPlot = ... # type: QAbstractSeries.SeriesType SeriesTypeCandlestick = ... # type: QAbstractSeries.SeriesType - def useOpenGLChanged(self) -> None: ... + useOpenGLChanged: typing.ClassVar[QtCore.pyqtSignal] def useOpenGL(self) -> bool: ... def setUseOpenGL(self, enable: bool = ...) -> None: ... - def opacityChanged(self) -> None: ... + opacityChanged: typing.ClassVar[QtCore.pyqtSignal] def attachedAxes(self) -> typing.List['QAbstractAxis']: ... def detachAxis(self, axis: 'QAbstractAxis') -> bool: ... def attachAxis(self, axis: 'QAbstractAxis') -> bool: ... def setOpacity(self, opacity: float) -> None: ... def opacity(self) -> float: ... - def visibleChanged(self) -> None: ... - def nameChanged(self) -> None: ... + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] def hide(self) -> None: ... def show(self) -> None: ... def chart(self) -> 'QChart': ... @@ -223,27 +223,27 @@ class QAbstractBarSeries('QAbstractSeries'): LabelsInsideBase = ... # type: QAbstractBarSeries.LabelsPosition LabelsOutsideEnd = ... # type: QAbstractBarSeries.LabelsPosition - def labelsPrecisionChanged(self, precision: int) -> None: ... + labelsPrecisionChanged: typing.ClassVar[QtCore.pyqtSignal] def labelsPrecision(self) -> int: ... def setLabelsPrecision(self, precision: int) -> None: ... - def labelsAngleChanged(self, angle: float) -> None: ... + labelsAngleChanged: typing.ClassVar[QtCore.pyqtSignal] def labelsAngle(self) -> float: ... def setLabelsAngle(self, angle: float) -> None: ... - def doubleClicked(self, index: int, barset: 'QBarSet') -> None: ... - def released(self, index: int, barset: 'QBarSet') -> None: ... - def pressed(self, index: int, barset: 'QBarSet') -> None: ... - def labelsPositionChanged(self, position: 'QAbstractBarSeries.LabelsPosition') -> None: ... - def labelsFormatChanged(self, format: str) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + labelsPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsFormatChanged: typing.ClassVar[QtCore.pyqtSignal] def labelsPosition(self) -> 'QAbstractBarSeries.LabelsPosition': ... def setLabelsPosition(self, position: 'QAbstractBarSeries.LabelsPosition') -> None: ... def labelsFormat(self) -> str: ... def setLabelsFormat(self, format: str) -> None: ... - def barsetsRemoved(self, sets: typing.Iterable['QBarSet']) -> None: ... - def barsetsAdded(self, sets: typing.Iterable['QBarSet']) -> None: ... - def labelsVisibleChanged(self) -> None: ... - def countChanged(self) -> None: ... - def hovered(self, status: bool, index: int, barset: 'QBarSet') -> None: ... - def clicked(self, index: int, barset: 'QBarSet') -> None: ... + barsetsRemoved: typing.ClassVar[QtCore.pyqtSignal] + barsetsAdded: typing.ClassVar[QtCore.pyqtSignal] + labelsVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + countChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def take(self, set: 'QBarSet') -> bool: ... def isLabelsVisible(self) -> bool: ... def setLabelsVisible(self, visible: bool = ...) -> None: ... @@ -277,17 +277,17 @@ class QLegendMarker(QtCore.QObject): LegendMarkerTypeBoxPlot = ... # type: QLegendMarker.LegendMarkerType LegendMarkerTypeCandlestick = ... # type: QLegendMarker.LegendMarkerType - def shapeChanged(self) -> None: ... + shapeChanged: typing.ClassVar[QtCore.pyqtSignal] def setShape(self, shape: 'QLegend.MarkerShape') -> None: ... def shape(self) -> 'QLegend.MarkerShape': ... - def visibleChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def fontChanged(self) -> None: ... - def labelBrushChanged(self) -> None: ... - def labelChanged(self) -> None: ... - def hovered(self, status: bool) -> None: ... - def clicked(self) -> None: ... + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + penChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + labelChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def series(self) -> 'QAbstractSeries': ... def setVisible(self, visible: bool) -> None: ... def isVisible(self) -> bool: ... @@ -317,16 +317,16 @@ class QAreaSeries('QAbstractSeries'): @typing.overload def __init__(self, upperSeries: 'QLineSeries', lowerSeries: typing.Optional['QLineSeries'] = ...) -> None: ... - def pointLabelsClippingChanged(self, clipping: bool) -> None: ... + pointLabelsClippingChanged: typing.ClassVar[QtCore.pyqtSignal] def pointLabelsClipping(self) -> bool: ... def setPointLabelsClipping(self, enable: bool = ...) -> None: ... - def doubleClicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def released(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pressed(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pointLabelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointLabelsFontChanged(self, font: QtGui.QFont) -> None: ... - def pointLabelsVisibilityChanged(self, visible: bool) -> None: ... - def pointLabelsFormatChanged(self, format: str) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsColorChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsFontChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsFormatChanged: typing.ClassVar[QtCore.pyqtSignal] def pointLabelsColor(self) -> QtGui.QColor: ... def setPointLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def pointLabelsFont(self) -> QtGui.QFont: ... @@ -335,11 +335,11 @@ class QAreaSeries('QAbstractSeries'): def setPointLabelsVisible(self, visible: bool = ...) -> None: ... def pointLabelsFormat(self) -> str: ... def setPointLabelsFormat(self, format: str) -> None: ... - def hovered(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint], state: bool) -> None: ... - def selected(self) -> None: ... - def clicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + hovered: typing.ClassVar[QtCore.pyqtSignal] + selected: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] def borderColor(self) -> QtGui.QColor: ... def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def color(self) -> QtGui.QColor: ... @@ -360,11 +360,11 @@ class QBarCategoryAxis('QAbstractAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def countChanged(self) -> None: ... - def rangeChanged(self, min: str, max: str) -> None: ... - def maxChanged(self, max: str) -> None: ... - def minChanged(self, min: str) -> None: ... - def categoriesChanged(self) -> None: ... + countChanged: typing.ClassVar[QtCore.pyqtSignal] + rangeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxChanged: typing.ClassVar[QtCore.pyqtSignal] + minChanged: typing.ClassVar[QtCore.pyqtSignal] + categoriesChanged: typing.ClassVar[QtCore.pyqtSignal] def setRange(self, minCategory: str, maxCategory: str) -> None: ... def max(self) -> str: ... def setMax(self, maxCategory: str) -> None: ... @@ -403,22 +403,22 @@ class QBarSet(QtCore.QObject): def __init__(self, name: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def doubleClicked(self, index: int) -> None: ... - def released(self, index: int) -> None: ... - def pressed(self, index: int) -> None: ... - def labelColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def hovered(self, status: bool, index: int) -> None: ... - def clicked(self, index: int) -> None: ... - def valueChanged(self, index: int) -> None: ... - def valuesRemoved(self, index: int, count: int) -> None: ... - def valuesAdded(self, index: int, count: int) -> None: ... - def labelFontChanged(self) -> None: ... - def labelBrushChanged(self) -> None: ... - def labelChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + labelColorChanged: typing.ClassVar[QtCore.pyqtSignal] + borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + valuesRemoved: typing.ClassVar[QtCore.pyqtSignal] + valuesAdded: typing.ClassVar[QtCore.pyqtSignal] + labelFontChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + labelChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + penChanged: typing.ClassVar[QtCore.pyqtSignal] def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def labelColor(self) -> QtGui.QColor: ... def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... @@ -459,18 +459,18 @@ class QBoxPlotSeries('QAbstractSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def doubleClicked(self, boxset: 'QBoxSet') -> None: ... - def released(self, boxset: 'QBoxSet') -> None: ... - def pressed(self, boxset: 'QBoxSet') -> None: ... - def boxsetsRemoved(self, sets: typing.Iterable['QBoxSet']) -> None: ... - def boxsetsAdded(self, sets: typing.Iterable['QBoxSet']) -> None: ... - def boxWidthChanged(self) -> None: ... - def boxOutlineVisibilityChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def countChanged(self) -> None: ... - def hovered(self, status: bool, boxset: 'QBoxSet') -> None: ... - def clicked(self, boxset: 'QBoxSet') -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + boxsetsRemoved: typing.ClassVar[QtCore.pyqtSignal] + boxsetsAdded: typing.ClassVar[QtCore.pyqtSignal] + boxWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + boxOutlineVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + penChanged: typing.ClassVar[QtCore.pyqtSignal] + countChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def pen(self) -> QtGui.QPen: ... def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def brush(self) -> QtGui.QBrush: ... @@ -512,16 +512,16 @@ class QBoxSet(QtCore.QObject): @typing.overload def __init__(self, le: float, lq: float, m: float, uq: float, ue: float, label: str = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def doubleClicked(self) -> None: ... - def released(self) -> None: ... - def pressed(self) -> None: ... - def cleared(self) -> None: ... - def valueChanged(self, index: int) -> None: ... - def valuesChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def hovered(self, status: bool) -> None: ... - def clicked(self) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + cleared: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + valuesChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + penChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def brush(self) -> QtGui.QBrush: ... def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def pen(self) -> QtGui.QPen: ... @@ -564,8 +564,8 @@ class QCandlestickModelMapper(QtCore.QObject): def setOpen(self, open: int) -> None: ... def timestamp(self) -> int: ... def setTimestamp(self, timestamp: int) -> None: ... - def seriesReplaced(self) -> None: ... - def modelReplaced(self) -> None: ... + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] def orientation(self) -> QtCore.Qt.Orientation: ... def series(self) -> 'QCandlestickSeries': ... def setSeries(self, series: 'QCandlestickSeries') -> None: ... @@ -576,24 +576,24 @@ class QCandlestickSeries('QAbstractSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def penChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def decreasingColorChanged(self) -> None: ... - def increasingColorChanged(self) -> None: ... - def capsVisibilityChanged(self) -> None: ... - def capsWidthChanged(self) -> None: ... - def bodyOutlineVisibilityChanged(self) -> None: ... - def bodyWidthChanged(self) -> None: ... - def minimumColumnWidthChanged(self) -> None: ... - def maximumColumnWidthChanged(self) -> None: ... - def countChanged(self) -> None: ... - def candlestickSetsRemoved(self, sets: typing.Iterable['QCandlestickSet']) -> None: ... - def candlestickSetsAdded(self, sets: typing.Iterable['QCandlestickSet']) -> None: ... - def doubleClicked(self, set: 'QCandlestickSet') -> None: ... - def released(self, set: 'QCandlestickSet') -> None: ... - def pressed(self, set: 'QCandlestickSet') -> None: ... - def hovered(self, status: bool, set: 'QCandlestickSet') -> None: ... - def clicked(self, set: 'QCandlestickSet') -> None: ... + penChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + decreasingColorChanged: typing.ClassVar[QtCore.pyqtSignal] + increasingColorChanged: typing.ClassVar[QtCore.pyqtSignal] + capsVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + capsWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + bodyOutlineVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + bodyWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + minimumColumnWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + maximumColumnWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + countChanged: typing.ClassVar[QtCore.pyqtSignal] + candlestickSetsRemoved: typing.ClassVar[QtCore.pyqtSignal] + candlestickSetsAdded: typing.ClassVar[QtCore.pyqtSignal] + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def pen(self) -> QtGui.QPen: ... def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def brush(self) -> QtGui.QBrush: ... @@ -637,18 +637,18 @@ class QCandlestickSet(QtCore.QObject): @typing.overload def __init__(self, open: float, high: float, low: float, close: float, timestamp: float = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def penChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def closeChanged(self) -> None: ... - def lowChanged(self) -> None: ... - def highChanged(self) -> None: ... - def openChanged(self) -> None: ... - def timestampChanged(self) -> None: ... - def doubleClicked(self) -> None: ... - def released(self) -> None: ... - def pressed(self) -> None: ... - def hovered(self, status: bool) -> None: ... - def clicked(self) -> None: ... + penChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + closeChanged: typing.ClassVar[QtCore.pyqtSignal] + lowChanged: typing.ClassVar[QtCore.pyqtSignal] + highChanged: typing.ClassVar[QtCore.pyqtSignal] + openChanged: typing.ClassVar[QtCore.pyqtSignal] + timestampChanged: typing.ClassVar[QtCore.pyqtSignal] + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def pen(self) -> QtGui.QPen: ... def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def brush(self) -> QtGui.QBrush: ... @@ -675,23 +675,23 @@ class QValueAxis('QAbstractAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def tickTypeChanged(self, type: 'QValueAxis.TickType') -> None: ... - def tickAnchorChanged(self, anchor: float) -> None: ... - def tickIntervalChanged(self, interval: float) -> None: ... + tickTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + tickAnchorChanged: typing.ClassVar[QtCore.pyqtSignal] + tickIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] def tickType(self) -> 'QValueAxis.TickType': ... def setTickType(self, type: 'QValueAxis.TickType') -> None: ... def tickInterval(self) -> float: ... def setTickInterval(self, insterval: float) -> None: ... def tickAnchor(self) -> float: ... def setTickAnchor(self, anchor: float) -> None: ... - def minorTickCountChanged(self, tickCount: int) -> None: ... + minorTickCountChanged: typing.ClassVar[QtCore.pyqtSignal] def minorTickCount(self) -> int: ... def setMinorTickCount(self, count: int) -> None: ... - def labelFormatChanged(self, format: str) -> None: ... - def tickCountChanged(self, tickCount: int) -> None: ... - def rangeChanged(self, min: float, max: float) -> None: ... - def maxChanged(self, max: float) -> None: ... - def minChanged(self, min: float) -> None: ... + labelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + tickCountChanged: typing.ClassVar[QtCore.pyqtSignal] + rangeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxChanged: typing.ClassVar[QtCore.pyqtSignal] + minChanged: typing.ClassVar[QtCore.pyqtSignal] def applyNiceNumbers(self) -> None: ... def labelFormat(self) -> str: ... def setLabelFormat(self, format: str) -> None: ... @@ -715,10 +715,10 @@ class QCategoryAxis('QValueAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def labelsPositionChanged(self, position: 'QCategoryAxis.AxisLabelsPosition') -> None: ... + labelsPositionChanged: typing.ClassVar[QtCore.pyqtSignal] def setLabelsPosition(self, position: 'QCategoryAxis.AxisLabelsPosition') -> None: ... def labelsPosition(self) -> 'QCategoryAxis.AxisLabelsPosition': ... - def categoriesChanged(self) -> None: ... + categoriesChanged: typing.ClassVar[QtCore.pyqtSignal] def __len__(self) -> int: ... def count(self) -> int: ... def categoriesLabels(self) -> typing.List[str]: ... @@ -792,7 +792,7 @@ class QChart(QtWidgets.QGraphicsWidget): def setAnimationEasingCurve(self, curve: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... def animationDuration(self) -> int: ... def setAnimationDuration(self, msecs: int) -> None: ... - def plotAreaChanged(self, plotArea: QtCore.QRectF) -> None: ... + plotAreaChanged: typing.ClassVar[QtCore.pyqtSignal] def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def localizeNumbers(self) -> bool: ... @@ -900,11 +900,11 @@ class QDateTimeAxis('QAbstractAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def tickCountChanged(self, tick: int) -> None: ... - def formatChanged(self, format: str) -> None: ... - def rangeChanged(self, min: typing.Union[QtCore.QDateTime, datetime.datetime], max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def maxChanged(self, max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def minChanged(self, min: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... + tickCountChanged: typing.ClassVar[QtCore.pyqtSignal] + formatChanged: typing.ClassVar[QtCore.pyqtSignal] + rangeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxChanged: typing.ClassVar[QtCore.pyqtSignal] + minChanged: typing.ClassVar[QtCore.pyqtSignal] def tickCount(self) -> int: ... def setTickCount(self, count: int) -> None: ... def format(self) -> str: ... @@ -920,12 +920,12 @@ class QHBarModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def lastBarSetRowChanged(self) -> None: ... - def firstBarSetRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + lastBarSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + firstBarSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setColumnCount(self, columnCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -943,12 +943,12 @@ class QHBoxPlotModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def lastBoxSetRowChanged(self) -> None: ... - def firstBoxSetRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + lastBoxSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + firstBoxSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setColumnCount(self, rowCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -966,13 +966,13 @@ class QHCandlestickModelMapper('QCandlestickModelMapper'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def lastSetRowChanged(self) -> None: ... - def firstSetRowChanged(self) -> None: ... - def closeColumnChanged(self) -> None: ... - def lowColumnChanged(self) -> None: ... - def highColumnChanged(self) -> None: ... - def openColumnChanged(self) -> None: ... - def timestampColumnChanged(self) -> None: ... + lastSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + firstSetRowChanged: typing.ClassVar[QtCore.pyqtSignal] + closeColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + lowColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + highColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + openColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + timestampColumnChanged: typing.ClassVar[QtCore.pyqtSignal] def lastSetRow(self) -> int: ... def setLastSetRow(self, lastSetRow: int) -> None: ... def firstSetRow(self) -> int: ... @@ -1011,12 +1011,12 @@ class QHPieModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def labelsRowChanged(self) -> None: ... - def valuesRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsRowChanged: typing.ClassVar[QtCore.pyqtSignal] + valuesRowChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setColumnCount(self, columnCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -1034,12 +1034,12 @@ class QHXYModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def yRowChanged(self) -> None: ... - def xRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + yRowChanged: typing.ClassVar[QtCore.pyqtSignal] + xRowChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setColumnCount(self, columnCount: int) -> None: ... def columnCount(self) -> int: ... def setFirstColumn(self, firstColumn: int) -> None: ... @@ -1066,22 +1066,22 @@ class QLegend(QtWidgets.QGraphicsWidget): MarkerShapeCircle = ... # type: QLegend.MarkerShape MarkerShapeFromSeries = ... # type: QLegend.MarkerShape - def markerShapeChanged(self, shape: 'QLegend.MarkerShape') -> None: ... + markerShapeChanged: typing.ClassVar[QtCore.pyqtSignal] def setMarkerShape(self, shape: 'QLegend.MarkerShape') -> None: ... def markerShape(self) -> 'QLegend.MarkerShape': ... - def showToolTipsChanged(self, showToolTips: bool) -> None: ... + showToolTipsChanged: typing.ClassVar[QtCore.pyqtSignal] def setShowToolTips(self, show: bool) -> None: ... def showToolTips(self) -> bool: ... - def reverseMarkersChanged(self, reverseMarkers: bool) -> None: ... + reverseMarkersChanged: typing.ClassVar[QtCore.pyqtSignal] def setReverseMarkers(self, reverseMarkers: bool = ...) -> None: ... def reverseMarkers(self) -> bool: ... def showEvent(self, event: QtGui.QShowEvent) -> None: ... def hideEvent(self, event: QtGui.QHideEvent) -> None: ... - def labelColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def backgroundVisibleChanged(self, visible: bool) -> None: ... + labelColorChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + backgroundVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] def markers(self, series: typing.Optional['QAbstractSeries'] = ...) -> typing.List['QLegendMarker']: ... def labelColor(self) -> QtGui.QColor: ... def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... @@ -1108,20 +1108,20 @@ class QLegend(QtWidgets.QGraphicsWidget): class QXYSeries('QAbstractSeries'): - def penChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointsRemoved(self, index: int, count: int) -> None: ... - def pointLabelsClippingChanged(self, clipping: bool) -> None: ... + penChanged: typing.ClassVar[QtCore.pyqtSignal] + pointsRemoved: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsClippingChanged: typing.ClassVar[QtCore.pyqtSignal] def pointLabelsClipping(self) -> bool: ... def setPointLabelsClipping(self, enable: bool = ...) -> None: ... def pointsVector(self) -> typing.List[QtCore.QPointF]: ... def removePoints(self, index: int, count: int) -> None: ... - def doubleClicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def released(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pressed(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pointLabelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointLabelsFontChanged(self, font: QtGui.QFont) -> None: ... - def pointLabelsVisibilityChanged(self, visible: bool) -> None: ... - def pointLabelsFormatChanged(self, format: str) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsColorChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsFontChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + pointLabelsFormatChanged: typing.ClassVar[QtCore.pyqtSignal] def pointLabelsColor(self) -> QtGui.QColor: ... def setPointLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def pointLabelsFont(self) -> QtGui.QFont: ... @@ -1130,13 +1130,13 @@ class QXYSeries('QAbstractSeries'): def setPointLabelsVisible(self, visible: bool = ...) -> None: ... def pointLabelsFormat(self) -> str: ... def setPointLabelsFormat(self, format: str) -> None: ... - def hovered(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint], state: bool) -> None: ... - def pointsReplaced(self) -> None: ... - def pointAdded(self, index: int) -> None: ... - def pointRemoved(self, index: int) -> None: ... - def pointReplaced(self, index: int) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def clicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + hovered: typing.ClassVar[QtCore.pyqtSignal] + pointsReplaced: typing.ClassVar[QtCore.pyqtSignal] + pointAdded: typing.ClassVar[QtCore.pyqtSignal] + pointRemoved: typing.ClassVar[QtCore.pyqtSignal] + pointReplaced: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] def at(self, index: int) -> QtCore.QPointF: ... def pointsVisible(self) -> bool: ... def setPointsVisible(self, visible: bool = ...) -> None: ... @@ -1183,16 +1183,16 @@ class QLogValueAxis('QAbstractAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def minorTickCountChanged(self, minorTickCount: int) -> None: ... - def tickCountChanged(self, tickCount: int) -> None: ... + minorTickCountChanged: typing.ClassVar[QtCore.pyqtSignal] + tickCountChanged: typing.ClassVar[QtCore.pyqtSignal] def minorTickCount(self) -> int: ... def setMinorTickCount(self, minorTickCount: int) -> None: ... def tickCount(self) -> int: ... - def baseChanged(self, base: float) -> None: ... - def labelFormatChanged(self, format: str) -> None: ... - def rangeChanged(self, min: float, max: float) -> None: ... - def maxChanged(self, max: float) -> None: ... - def minChanged(self, min: float) -> None: ... + baseChanged: typing.ClassVar[QtCore.pyqtSignal] + labelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + rangeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxChanged: typing.ClassVar[QtCore.pyqtSignal] + minChanged: typing.ClassVar[QtCore.pyqtSignal] def base(self) -> float: ... def setBase(self, base: float) -> None: ... def labelFormat(self) -> str: ... @@ -1222,19 +1222,19 @@ class QPieSeries('QAbstractSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def doubleClicked(self, slice: 'QPieSlice') -> None: ... - def released(self, slice: 'QPieSlice') -> None: ... - def pressed(self, slice: 'QPieSlice') -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] def setLabelsPosition(self, position: 'QPieSlice.LabelPosition') -> None: ... def holeSize(self) -> float: ... def setHoleSize(self, holeSize: float) -> None: ... def take(self, slice: 'QPieSlice') -> bool: ... - def sumChanged(self) -> None: ... - def countChanged(self) -> None: ... - def hovered(self, slice: 'QPieSlice', state: bool) -> None: ... - def clicked(self, slice: 'QPieSlice') -> None: ... - def removed(self, slices: typing.Iterable['QPieSlice']) -> None: ... - def added(self, slices: typing.Iterable['QPieSlice']) -> None: ... + sumChanged: typing.ClassVar[QtCore.pyqtSignal] + countChanged: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + removed: typing.ClassVar[QtCore.pyqtSignal] + added: typing.ClassVar[QtCore.pyqtSignal] def setLabelsVisible(self, visible: bool = ...) -> None: ... def pieEndAngle(self) -> float: ... def setPieEndAngle(self, endAngle: float) -> None: ... @@ -1280,25 +1280,25 @@ class QPieSlice(QtCore.QObject): @typing.overload def __init__(self, label: str, value: float, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def doubleClicked(self) -> None: ... - def released(self) -> None: ... - def pressed(self) -> None: ... - def hovered(self, state: bool) -> None: ... - def clicked(self) -> None: ... - def labelColorChanged(self) -> None: ... - def borderWidthChanged(self) -> None: ... - def borderColorChanged(self) -> None: ... - def colorChanged(self) -> None: ... - def angleSpanChanged(self) -> None: ... - def startAngleChanged(self) -> None: ... - def percentageChanged(self) -> None: ... - def labelFontChanged(self) -> None: ... - def labelBrushChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def labelVisibleChanged(self) -> None: ... - def valueChanged(self) -> None: ... - def labelChanged(self) -> None: ... + doubleClicked: typing.ClassVar[QtCore.pyqtSignal] + released: typing.ClassVar[QtCore.pyqtSignal] + pressed: typing.ClassVar[QtCore.pyqtSignal] + hovered: typing.ClassVar[QtCore.pyqtSignal] + clicked: typing.ClassVar[QtCore.pyqtSignal] + labelColorChanged: typing.ClassVar[QtCore.pyqtSignal] + borderWidthChanged: typing.ClassVar[QtCore.pyqtSignal] + borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] + angleSpanChanged: typing.ClassVar[QtCore.pyqtSignal] + startAngleChanged: typing.ClassVar[QtCore.pyqtSignal] + percentageChanged: typing.ClassVar[QtCore.pyqtSignal] + labelFontChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBrushChanged: typing.ClassVar[QtCore.pyqtSignal] + brushChanged: typing.ClassVar[QtCore.pyqtSignal] + penChanged: typing.ClassVar[QtCore.pyqtSignal] + labelVisibleChanged: typing.ClassVar[QtCore.pyqtSignal] + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + labelChanged: typing.ClassVar[QtCore.pyqtSignal] def setLabelPosition(self, position: 'QPieSlice.LabelPosition') -> None: ... def labelPosition(self) -> 'QPieSlice.LabelPosition': ... def series(self) -> 'QPieSeries': ... @@ -1376,10 +1376,10 @@ class QScatterSeries('QXYSeries'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def markerSizeChanged(self, size: float) -> None: ... - def markerShapeChanged(self, shape: 'QScatterSeries.MarkerShape') -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + markerSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + markerShapeChanged: typing.ClassVar[QtCore.pyqtSignal] + borderColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorChanged: typing.ClassVar[QtCore.pyqtSignal] def borderColor(self) -> QtGui.QColor: ... def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... def color(self) -> QtGui.QColor: ... @@ -1409,12 +1409,12 @@ class QVBarModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def lastBarSetColumnChanged(self) -> None: ... - def firstBarSetColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] + lastBarSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + firstBarSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... @@ -1432,12 +1432,12 @@ class QVBoxPlotModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def lastBoxSetColumnChanged(self) -> None: ... - def firstBoxSetColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] + lastBoxSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + firstBoxSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... @@ -1455,13 +1455,13 @@ class QVCandlestickModelMapper('QCandlestickModelMapper'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def lastSetColumnChanged(self) -> None: ... - def firstSetColumnChanged(self) -> None: ... - def closeRowChanged(self) -> None: ... - def lowRowChanged(self) -> None: ... - def highRowChanged(self) -> None: ... - def openRowChanged(self) -> None: ... - def timestampRowChanged(self) -> None: ... + lastSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + firstSetColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + closeRowChanged: typing.ClassVar[QtCore.pyqtSignal] + lowRowChanged: typing.ClassVar[QtCore.pyqtSignal] + highRowChanged: typing.ClassVar[QtCore.pyqtSignal] + openRowChanged: typing.ClassVar[QtCore.pyqtSignal] + timestampRowChanged: typing.ClassVar[QtCore.pyqtSignal] def lastSetColumn(self) -> int: ... def setLastSetColumn(self, lastSetColumn: int) -> None: ... def firstSetColumn(self) -> int: ... @@ -1482,12 +1482,12 @@ class QVPieModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def labelsColumnChanged(self) -> None: ... - def valuesColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + valuesColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... @@ -1505,12 +1505,12 @@ class QVXYModelMapper(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def yColumnChanged(self) -> None: ... - def xColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + firstRowChanged: typing.ClassVar[QtCore.pyqtSignal] + yColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + xColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + modelReplaced: typing.ClassVar[QtCore.pyqtSignal] + seriesReplaced: typing.ClassVar[QtCore.pyqtSignal] def setRowCount(self, rowCount: int) -> None: ... def rowCount(self) -> int: ... def setFirstRow(self, firstRow: int) -> None: ... diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index e430ea9a..9e34274f 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -3135,10 +3135,10 @@ class QAbstractAnimation(QObject): def resume(self) -> None: ... def pause(self) -> None: ... def start(self, policy: 'QAbstractAnimation.DeletionPolicy' = ...) -> None: ... - def directionChanged(self, a0: 'QAbstractAnimation.Direction') -> None: ... - def currentLoopChanged(self, currentLoop: int) -> None: ... - def stateChanged(self, newState: 'QAbstractAnimation.State', oldState: 'QAbstractAnimation.State') -> None: ... - def finished(self) -> None: ... + directionChanged: typing.ClassVar[QtCore.pyqtSignal] + currentLoopChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def totalDuration(self) -> int: ... def duration(self) -> int: ... def currentLoop(self) -> int: ... @@ -3167,8 +3167,8 @@ class QAbstractEventDispatcher(QObject): def __init__(self, parent: typing.Optional[QObject] = ...) -> None: ... - def awake(self) -> None: ... - def aboutToBlock(self) -> None: ... + awake: typing.ClassVar[QtCore.pyqtSignal] + aboutToBlock: typing.ClassVar[QtCore.pyqtSignal] def filterNativeEvent(self, eventType: typing.Union['QByteArray', bytes, bytearray], message: sip.voidptr) -> typing.Tuple[bool, int]: ... def removeNativeEventFilter(self, filterObj: 'QAbstractNativeEventFilter') -> None: ... def installNativeEventFilter(self, filterObj: 'QAbstractNativeEventFilter') -> None: ... @@ -3292,10 +3292,10 @@ class QAbstractItemModel(QObject): def beginMoveColumns(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationColumn: int) -> bool: ... def endMoveRows(self) -> None: ... def beginMoveRows(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationRow: int) -> bool: ... - def columnsMoved(self, parent: QModelIndex, start: int, end: int, destination: QModelIndex, column: int) -> None: ... - def columnsAboutToBeMoved(self, sourceParent: QModelIndex, sourceStart: int, sourceEnd: int, destinationParent: QModelIndex, destinationColumn: int) -> None: ... - def rowsMoved(self, parent: QModelIndex, start: int, end: int, destination: QModelIndex, row: int) -> None: ... - def rowsAboutToBeMoved(self, sourceParent: QModelIndex, sourceStart: int, sourceEnd: int, destinationParent: QModelIndex, destinationRow: int) -> None: ... + columnsMoved: typing.ClassVar[QtCore.pyqtSignal] + columnsAboutToBeMoved: typing.ClassVar[QtCore.pyqtSignal] + rowsMoved: typing.ClassVar[QtCore.pyqtSignal] + rowsAboutToBeMoved: typing.ClassVar[QtCore.pyqtSignal] def createIndex(self, row: int, column: int, object: typing.Any = ...) -> QModelIndex: ... def roleNames(self) -> typing.Dict[int, 'QByteArray']: ... def supportedDragActions(self) -> Qt.DropActions: ... @@ -3318,19 +3318,19 @@ class QAbstractItemModel(QObject): def encodeData(self, indexes: typing.Iterable[QModelIndex], stream: 'QDataStream') -> None: ... def revert(self) -> None: ... def submit(self) -> bool: ... - def modelReset(self) -> None: ... - def modelAboutToBeReset(self) -> None: ... - def columnsRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... - def columnsAboutToBeRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... - def columnsInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... - def columnsAboutToBeInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... - def rowsRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... - def rowsAboutToBeRemoved(self, parent: QModelIndex, first: int, last: int) -> None: ... - def rowsInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... - def rowsAboutToBeInserted(self, parent: QModelIndex, first: int, last: int) -> None: ... - def layoutChanged(self, parents: typing.Iterable[QPersistentModelIndex] = ..., hint: 'QAbstractItemModel.LayoutChangeHint' = ...) -> None: ... - def layoutAboutToBeChanged(self, parents: typing.Iterable[QPersistentModelIndex] = ..., hint: 'QAbstractItemModel.LayoutChangeHint' = ...) -> None: ... - def headerDataChanged(self, orientation: Qt.Orientation, first: int, last: int) -> None: ... + modelReset: typing.ClassVar[QtCore.pyqtSignal] + modelAboutToBeReset: typing.ClassVar[QtCore.pyqtSignal] + columnsRemoved: typing.ClassVar[QtCore.pyqtSignal] + columnsAboutToBeRemoved: typing.ClassVar[QtCore.pyqtSignal] + columnsInserted: typing.ClassVar[QtCore.pyqtSignal] + columnsAboutToBeInserted: typing.ClassVar[QtCore.pyqtSignal] + rowsRemoved: typing.ClassVar[QtCore.pyqtSignal] + rowsAboutToBeRemoved: typing.ClassVar[QtCore.pyqtSignal] + rowsInserted: typing.ClassVar[QtCore.pyqtSignal] + rowsAboutToBeInserted: typing.ClassVar[QtCore.pyqtSignal] + layoutChanged: typing.ClassVar[QtCore.pyqtSignal] + layoutAboutToBeChanged: typing.ClassVar[QtCore.pyqtSignal] + headerDataChanged: typing.ClassVar[QtCore.pyqtSignal] dataChanged: typing.ClassVar[pyqtSignal] def span(self, index: QModelIndex) -> 'QSize': ... def match(self, start: QModelIndex, role: int, value: typing.Any, hits: int = ..., flags: typing.Union[Qt.MatchFlags, Qt.MatchFlag] = ...) -> typing.List[QModelIndex]: ... @@ -3401,7 +3401,7 @@ class QAbstractProxyModel(QAbstractItemModel): def supportedDragActions(self) -> Qt.DropActions: ... def dropMimeData(self, data: 'QMimeData', action: Qt.DropAction, row: int, column: int, parent: QModelIndex) -> bool: ... def canDropMimeData(self, data: 'QMimeData', action: Qt.DropAction, row: int, column: int, parent: QModelIndex) -> bool: ... - def sourceModelChanged(self) -> None: ... + sourceModelChanged: typing.ClassVar[QtCore.pyqtSignal] def resetInternalData(self) -> None: ... def sibling(self, row: int, column: int, idx: QModelIndex) -> QModelIndex: ... def supportedDropActions(self) -> Qt.DropActions: ... @@ -3437,9 +3437,9 @@ class QAbstractState(QObject): def event(self, e: 'QEvent') -> bool: ... def onExit(self, event: 'QEvent') -> None: ... def onEntry(self, event: 'QEvent') -> None: ... - def exited(self) -> None: ... - def entered(self) -> None: ... - def activeChanged(self, active: bool) -> None: ... + exited: typing.ClassVar[QtCore.pyqtSignal] + entered: typing.ClassVar[QtCore.pyqtSignal] + activeChanged: typing.ClassVar[QtCore.pyqtSignal] def active(self) -> bool: ... def machine(self) -> 'QStateMachine': ... def parentState(self) -> 'QState': ... @@ -3461,9 +3461,9 @@ class QAbstractTransition(QObject): def event(self, e: 'QEvent') -> bool: ... def onTransition(self, event: 'QEvent') -> None: ... def eventTest(self, event: 'QEvent') -> bool: ... - def targetStatesChanged(self) -> None: ... - def targetStateChanged(self) -> None: ... - def triggered(self) -> None: ... + targetStatesChanged: typing.ClassVar[QtCore.pyqtSignal] + targetStateChanged: typing.ClassVar[QtCore.pyqtSignal] + triggered: typing.ClassVar[QtCore.pyqtSignal] def animations(self) -> typing.List[QAbstractAnimation]: ... def removeAnimation(self, animation: QAbstractAnimation) -> None: ... def addAnimation(self, animation: QAbstractAnimation) -> None: ... @@ -3604,8 +3604,8 @@ class QIODevice(QObject): def __init__(self, parent: QObject) -> None: ... def skip(self, maxSize: int) -> int: ... - def channelBytesWritten(self, channel: int, bytes: int) -> None: ... - def channelReadyRead(self, channel: int) -> None: ... + channelBytesWritten: typing.ClassVar[QtCore.pyqtSignal] + channelReadyRead: typing.ClassVar[QtCore.pyqtSignal] def isTransactionStarted(self) -> bool: ... def rollbackTransaction(self) -> None: ... def commitTransaction(self) -> None: ... @@ -3621,10 +3621,10 @@ class QIODevice(QObject): def writeData(self, data: bytes) -> int: ... def readLineData(self, maxlen: int) -> bytes: ... def readData(self, maxlen: int) -> bytes: ... - def readChannelFinished(self) -> None: ... - def aboutToClose(self) -> None: ... - def bytesWritten(self, bytes: int) -> None: ... - def readyRead(self) -> None: ... + readChannelFinished: typing.ClassVar[QtCore.pyqtSignal] + aboutToClose: typing.ClassVar[QtCore.pyqtSignal] + bytesWritten: typing.ClassVar[QtCore.pyqtSignal] + readyRead: typing.ClassVar[QtCore.pyqtSignal] def errorString(self) -> str: ... def getChar(self) -> typing.Tuple[bool, bytes]: ... def putChar(self, c: str) -> bool: ... @@ -6074,8 +6074,8 @@ class QFileSystemWatcher(QObject): @typing.overload def __init__(self, paths: typing.Iterable[str], parent: typing.Optional[QObject] = ...) -> None: ... - def fileChanged(self, path: str) -> None: ... - def directoryChanged(self, path: str) -> None: ... + fileChanged: typing.ClassVar[QtCore.pyqtSignal] + directoryChanged: typing.ClassVar[QtCore.pyqtSignal] def removePaths(self, files: typing.Iterable[str]) -> typing.List[str]: ... def removePath(self, file: str) -> bool: ... def files(self) -> typing.List[str]: ... @@ -6107,11 +6107,11 @@ class QHistoryState(QAbstractState): @typing.overload def __init__(self, type: 'QHistoryState.HistoryType', parent: typing.Optional['QState'] = ...) -> None: ... - def defaultTransitionChanged(self) -> None: ... + defaultTransitionChanged: typing.ClassVar[QtCore.pyqtSignal] def setDefaultTransition(self, transition: QAbstractTransition) -> None: ... def defaultTransition(self) -> QAbstractTransition: ... - def historyTypeChanged(self) -> None: ... - def defaultStateChanged(self) -> None: ... + historyTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + defaultStateChanged: typing.ClassVar[QtCore.pyqtSignal] def event(self, e: QEvent) -> bool: ... def onExit(self, event: QEvent) -> None: ... def onEntry(self, event: QEvent) -> None: ... @@ -6227,15 +6227,15 @@ class QItemSelectionModel(QObject): @typing.overload def __init__(self, model: QAbstractItemModel, parent: QObject) -> None: ... - def modelChanged(self, model: QAbstractItemModel) -> None: ... + modelChanged: typing.ClassVar[QtCore.pyqtSignal] def setModel(self, model: QAbstractItemModel) -> None: ... def selectedColumns(self, row: int = ...) -> typing.List[QModelIndex]: ... def selectedRows(self, column: int = ...) -> typing.List[QModelIndex]: ... def hasSelection(self) -> bool: ... def emitSelectionChanged(self, newSelection: 'QItemSelection', oldSelection: 'QItemSelection') -> None: ... - def currentColumnChanged(self, current: QModelIndex, previous: QModelIndex) -> None: ... - def currentRowChanged(self, current: QModelIndex, previous: QModelIndex) -> None: ... - def currentChanged(self, current: QModelIndex, previous: QModelIndex) -> None: ... + currentColumnChanged: typing.ClassVar[QtCore.pyqtSignal] + currentRowChanged: typing.ClassVar[QtCore.pyqtSignal] + currentChanged: typing.ClassVar[QtCore.pyqtSignal] selectionChanged: typing.ClassVar[pyqtSignal] def clearCurrentIndex(self) -> None: ... def setCurrentIndex(self, index: QModelIndex, command: typing.Union['QItemSelectionModel.SelectionFlags', 'QItemSelectionModel.SelectionFlag']) -> None: ... @@ -9302,7 +9302,7 @@ class QVariantAnimation(QAbstractAnimation): def updateState(self, newState: QAbstractAnimation.State, oldState: QAbstractAnimation.State) -> None: ... def updateCurrentTime(self, a0: int) -> None: ... def event(self, event: QEvent) -> bool: ... - def valueChanged(self, value: typing.Any) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setEasingCurve(self, easing: typing.Union[QEasingCurve, QEasingCurve.Type]) -> None: ... def easingCurve(self) -> QEasingCurve: ... def setDuration(self, msecs: int) -> None: ... @@ -9540,10 +9540,7 @@ class QProcess(QIODevice): def waitForStarted(self, msecs: int = ...) -> bool: ... def pid(self) -> int: ... def state(self) -> 'QProcess.ProcessState': ... - @typing.overload - def error(self) -> 'QProcess.ProcessError': ... - @typing.overload - def error(self, error: 'QProcess.ProcessError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def setWorkingDirectory(self, dir: str) -> None: ... def workingDirectory(self) -> str: ... def closeWriteChannel(self) -> None: ... @@ -10166,7 +10163,7 @@ class QSequentialAnimationGroup(QAnimationGroup): def updateState(self, newState: QAbstractAnimation.State, oldState: QAbstractAnimation.State) -> None: ... def updateCurrentTime(self, a0: int) -> None: ... def event(self, event: QEvent) -> bool: ... - def currentAnimationChanged(self, current: QAbstractAnimation) -> None: ... + currentAnimationChanged: typing.ClassVar[QtCore.pyqtSignal] def duration(self) -> int: ... def currentAnimation(self) -> QAbstractAnimation: ... def insertPause(self, index: int, msecs: int) -> QPauseAnimation: ... @@ -10314,10 +10311,10 @@ class QSignalMapper(QObject): def map(self) -> None: ... @typing.overload def map(self, sender: QObject) -> None: ... - def mappedObject(self, a0: QObject) -> None: ... - def mappedWidget(self, a0: QtWidgets.QWidget) -> None: ... - def mappedString(self, a0: str) -> None: ... - def mappedInt(self, a0: int) -> None: ... + mappedObject: typing.ClassVar[QtCore.pyqtSignal] + mappedWidget: typing.ClassVar[QtCore.pyqtSignal] + mappedString: typing.ClassVar[QtCore.pyqtSignal] + mappedInt: typing.ClassVar[QtCore.pyqtSignal] mapped: typing.ClassVar[pyqtSignal] @typing.overload def mapping(self, id: int) -> QObject: ... @@ -10345,8 +10342,8 @@ class QSignalTransition(QAbstractTransition): @typing.overload def __init__(self, signal: pyqtBoundSignal, sourceState: typing.Optional['QState'] = ...) -> None: ... - def signalChanged(self) -> None: ... - def senderObjectChanged(self) -> None: ... + signalChanged: typing.ClassVar[QtCore.pyqtSignal] + senderObjectChanged: typing.ClassVar[QtCore.pyqtSignal] def event(self, e: QEvent) -> bool: ... def onTransition(self, event: QEvent) -> None: ... def eventTest(self, event: QEvent) -> bool: ... @@ -10441,7 +10438,7 @@ class QSocketNotifier(QObject): def __init__(self, socket: sip.voidptr, a1: 'QSocketNotifier.Type', parent: typing.Optional[QObject] = ...) -> None: ... def event(self, a0: QEvent) -> bool: ... - def activated(self, socket: int) -> None: ... + activated: typing.ClassVar[QtCore.pyqtSignal] def setEnabled(self, a0: bool) -> None: ... def isEnabled(self) -> bool: ... def type(self) -> 'QSocketNotifier.Type': ... @@ -10452,13 +10449,13 @@ class QSortFilterProxyModel(QAbstractProxyModel): def __init__(self, parent: typing.Optional[QObject] = ...) -> None: ... - def recursiveFilteringEnabledChanged(self, recursiveFilteringEnabled: bool) -> None: ... - def filterRoleChanged(self, filterRole: int) -> None: ... - def sortRoleChanged(self, sortRole: int) -> None: ... - def sortLocaleAwareChanged(self, sortLocaleAware: bool) -> None: ... - def sortCaseSensitivityChanged(self, sortCaseSensitivity: Qt.CaseSensitivity) -> None: ... - def filterCaseSensitivityChanged(self, filterCaseSensitivity: Qt.CaseSensitivity) -> None: ... - def dynamicSortFilterChanged(self, dynamicSortFilter: bool) -> None: ... + recursiveFilteringEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + filterRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + sortRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + sortLocaleAwareChanged: typing.ClassVar[QtCore.pyqtSignal] + sortCaseSensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] + filterCaseSensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] + dynamicSortFilterChanged: typing.ClassVar[QtCore.pyqtSignal] def invalidateFilter(self) -> None: ... def setRecursiveFilteringEnabled(self, recursive: bool) -> None: ... def isRecursiveFilteringEnabled(self) -> bool: ... @@ -10637,14 +10634,14 @@ class QState(QAbstractState): @typing.overload def __init__(self, childMode: 'QState.ChildMode', parent: typing.Optional['QState'] = ...) -> None: ... - def errorStateChanged(self) -> None: ... - def initialStateChanged(self) -> None: ... - def childModeChanged(self) -> None: ... + errorStateChanged: typing.ClassVar[QtCore.pyqtSignal] + initialStateChanged: typing.ClassVar[QtCore.pyqtSignal] + childModeChanged: typing.ClassVar[QtCore.pyqtSignal] def event(self, e: QEvent) -> bool: ... def onExit(self, event: QEvent) -> None: ... def onEntry(self, event: QEvent) -> None: ... - def propertiesAssigned(self) -> None: ... - def finished(self) -> None: ... + propertiesAssigned: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def assignProperty(self, object: QObject, name: str, value: typing.Any) -> None: ... def setChildMode(self, mode: 'QState.ChildMode') -> None: ... def childMode(self) -> 'QState.ChildMode': ... @@ -10703,9 +10700,9 @@ class QStateMachine(QState): def event(self, e: QEvent) -> bool: ... def onExit(self, event: QEvent) -> None: ... def onEntry(self, event: QEvent) -> None: ... - def runningChanged(self, running: bool) -> None: ... - def stopped(self) -> None: ... - def started(self) -> None: ... + runningChanged: typing.ClassVar[QtCore.pyqtSignal] + stopped: typing.ClassVar[QtCore.pyqtSignal] + started: typing.ClassVar[QtCore.pyqtSignal] def setRunning(self, running: bool) -> None: ... def stop(self) -> None: ... def start(self) -> None: ... @@ -11273,10 +11270,10 @@ class QTimeLine(QObject): def setEasingCurve(self, curve: typing.Union[QEasingCurve, QEasingCurve.Type]) -> None: ... def easingCurve(self) -> QEasingCurve: ... def timerEvent(self, event: QTimerEvent) -> None: ... - def valueChanged(self, x: float) -> None: ... - def stateChanged(self, newState: 'QTimeLine.State') -> None: ... - def frameChanged(self, a0: int) -> None: ... - def finished(self) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + frameChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def toggleDirection(self) -> None: ... def stop(self) -> None: ... def start(self) -> None: ... diff --git a/PyQt5-stubs/QtDBus.pyi b/PyQt5-stubs/QtDBus.pyi index ac26141b..d831bccd 100644 --- a/PyQt5-stubs/QtDBus.pyi +++ b/PyQt5-stubs/QtDBus.pyi @@ -282,10 +282,10 @@ class QDBusConnectionInterface(QDBusAbstractInterface): def disconnectNotify(self, a0: QtCore.QMetaMethod) -> None: ... def connectNotify(self, a0: QtCore.QMetaMethod) -> None: ... - def callWithCallbackFailed(self, error: 'QDBusError', call: 'QDBusMessage') -> None: ... - def serviceOwnerChanged(self, name: str, oldOwner: str, newOwner: str) -> None: ... - def serviceUnregistered(self, service: str) -> None: ... - def serviceRegistered(self, service: str) -> None: ... + callWithCallbackFailed: typing.ClassVar[QtCore.pyqtSignal] + serviceOwnerChanged: typing.ClassVar[QtCore.pyqtSignal] + serviceUnregistered: typing.ClassVar[QtCore.pyqtSignal] + serviceRegistered: typing.ClassVar[QtCore.pyqtSignal] def startService(self, name: str) -> QDBusReply: ... def serviceUid(self, serviceName: str) -> QDBusReply: ... def servicePid(self, serviceName: str) -> QDBusReply: ... @@ -498,7 +498,7 @@ class QDBusPendingCallWatcher(QtCore.QObject, QDBusPendingCall): def __init__(self, call: QDBusPendingCall, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def finished(self, watcher: typing.Optional['QDBusPendingCallWatcher'] = ...) -> None: ... + finished: typing.ClassVar[QtCore.pyqtSignal] def waitForFinished(self) -> None: ... def isFinished(self) -> bool: ... @@ -534,9 +534,9 @@ class QDBusServiceWatcher(QtCore.QObject): @typing.overload def __init__(self, service: str, connection: QDBusConnection, watchMode: typing.Union['QDBusServiceWatcher.WatchMode', 'QDBusServiceWatcher.WatchModeFlag'] = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def serviceOwnerChanged(self, service: str, oldOwner: str, newOwner: str) -> None: ... - def serviceUnregistered(self, service: str) -> None: ... - def serviceRegistered(self, service: str) -> None: ... + serviceOwnerChanged: typing.ClassVar[QtCore.pyqtSignal] + serviceUnregistered: typing.ClassVar[QtCore.pyqtSignal] + serviceRegistered: typing.ClassVar[QtCore.pyqtSignal] def setConnection(self, connection: QDBusConnection) -> None: ... def connection(self) -> QDBusConnection: ... def setWatchMode(self, mode: typing.Union['QDBusServiceWatcher.WatchMode', 'QDBusServiceWatcher.WatchModeFlag']) -> None: ... diff --git a/PyQt5-stubs/QtDataVisualization.pyi b/PyQt5-stubs/QtDataVisualization.pyi index b4c86933..3d4b0971 100644 --- a/PyQt5-stubs/QtDataVisualization.pyi +++ b/PyQt5-stubs/QtDataVisualization.pyi @@ -134,14 +134,14 @@ class QAbstract3DGraph(QtGui.QWindow): def __int__(self) -> int: ... def hasContext(self) -> bool: ... - def marginChanged(self, margin: float) -> None: ... - def queriedGraphPositionChanged(self, data: QtGui.QVector3D) -> None: ... - def localeChanged(self, locale: QtCore.QLocale) -> None: ... - def reflectivityChanged(self, reflectivity: float) -> None: ... - def reflectionChanged(self, enabled: bool) -> None: ... - def horizontalAspectRatioChanged(self, ratio: float) -> None: ... - def radialLabelOffsetChanged(self, offset: float) -> None: ... - def polarChanged(self, enabled: bool) -> None: ... + marginChanged: typing.ClassVar[QtCore.pyqtSignal] + queriedGraphPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + localeChanged: typing.ClassVar[QtCore.pyqtSignal] + reflectivityChanged: typing.ClassVar[QtCore.pyqtSignal] + reflectionChanged: typing.ClassVar[QtCore.pyqtSignal] + horizontalAspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + radialLabelOffsetChanged: typing.ClassVar[QtCore.pyqtSignal] + polarChanged: typing.ClassVar[QtCore.pyqtSignal] def margin(self) -> float: ... def setMargin(self, margin: float) -> None: ... def queriedGraphPosition(self) -> QtGui.QVector3D: ... @@ -158,12 +158,12 @@ class QAbstract3DGraph(QtGui.QWindow): def isPolar(self) -> bool: ... def setPolar(self, enable: bool) -> None: ... def customItems(self) -> typing.List['QCustom3DItem']: ... - def optimizationHintsChanged(self, hints: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... - def aspectRatioChanged(self, ratio: float) -> None: ... - def orthoProjectionChanged(self, enabled: bool) -> None: ... - def currentFpsChanged(self, fps: float) -> None: ... - def measureFpsChanged(self, enabled: bool) -> None: ... - def selectedElementChanged(self, type: 'QAbstract3DGraph.ElementType') -> None: ... + optimizationHintsChanged: typing.ClassVar[QtCore.pyqtSignal] + aspectRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + orthoProjectionChanged: typing.ClassVar[QtCore.pyqtSignal] + currentFpsChanged: typing.ClassVar[QtCore.pyqtSignal] + measureFpsChanged: typing.ClassVar[QtCore.pyqtSignal] + selectedElementChanged: typing.ClassVar[QtCore.pyqtSignal] def optimizationHints(self) -> 'QAbstract3DGraph.OptimizationHints': ... def setOptimizationHints(self, hints: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... def aspectRatio(self) -> float: ... @@ -193,10 +193,10 @@ class QAbstract3DGraph(QtGui.QWindow): def exposeEvent(self, event: QtGui.QExposeEvent) -> None: ... def resizeEvent(self, event: QtGui.QResizeEvent) -> None: ... def event(self, event: QtCore.QEvent) -> bool: ... - def shadowQualityChanged(self, quality: 'QAbstract3DGraph.ShadowQuality') -> None: ... - def selectionModeChanged(self, mode: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag']) -> None: ... - def activeThemeChanged(self, theme: 'Q3DTheme') -> None: ... - def activeInputHandlerChanged(self, inputHandler: 'QAbstract3DInputHandler') -> None: ... + shadowQualityChanged: typing.ClassVar[QtCore.pyqtSignal] + selectionModeChanged: typing.ClassVar[QtCore.pyqtSignal] + activeThemeChanged: typing.ClassVar[QtCore.pyqtSignal] + activeInputHandlerChanged: typing.ClassVar[QtCore.pyqtSignal] def shadowsSupported(self) -> bool: ... def activeInputHandler(self) -> 'QAbstract3DInputHandler': ... def clearSelection(self) -> None: ... @@ -219,18 +219,18 @@ class Q3DBars('QAbstract3DGraph'): def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - def floorLevelChanged(self, level: float) -> None: ... + floorLevelChanged: typing.ClassVar[QtCore.pyqtSignal] def floorLevel(self) -> float: ... def setFloorLevel(self, level: float) -> None: ... - def selectedSeriesChanged(self, series: 'QBar3DSeries') -> None: ... - def primarySeriesChanged(self, series: 'QBar3DSeries') -> None: ... - def valueAxisChanged(self, axis: 'QValue3DAxis') -> None: ... - def columnAxisChanged(self, axis: 'QCategory3DAxis') -> None: ... - def rowAxisChanged(self, axis: 'QCategory3DAxis') -> None: ... - def barSpacingRelativeChanged(self, relative: bool) -> None: ... - def barSpacingChanged(self, spacing: QtCore.QSizeF) -> None: ... - def barThicknessChanged(self, thicknessRatio: float) -> None: ... - def multiSeriesUniformChanged(self, uniform: bool) -> None: ... + selectedSeriesChanged: typing.ClassVar[QtCore.pyqtSignal] + primarySeriesChanged: typing.ClassVar[QtCore.pyqtSignal] + valueAxisChanged: typing.ClassVar[QtCore.pyqtSignal] + columnAxisChanged: typing.ClassVar[QtCore.pyqtSignal] + rowAxisChanged: typing.ClassVar[QtCore.pyqtSignal] + barSpacingRelativeChanged: typing.ClassVar[QtCore.pyqtSignal] + barSpacingChanged: typing.ClassVar[QtCore.pyqtSignal] + barThicknessChanged: typing.ClassVar[QtCore.pyqtSignal] + multiSeriesUniformChanged: typing.ClassVar[QtCore.pyqtSignal] def selectedSeries(self) -> 'QBar3DSeries': ... def axes(self) -> typing.List['QAbstract3DAxis']: ... def releaseAxis(self, axis: 'QAbstract3DAxis') -> None: ... @@ -262,7 +262,7 @@ class Q3DObject(QtCore.QObject): def isDirty(self) -> bool: ... def setDirty(self, dirty: bool) -> None: ... - def positionChanged(self, position: QtGui.QVector3D) -> None: ... + positionChanged: typing.ClassVar[QtCore.pyqtSignal] def setPosition(self, position: QtGui.QVector3D) -> None: ... def position(self) -> QtGui.QVector3D: ... def parentScene(self) -> 'Q3DScene': ... @@ -325,21 +325,21 @@ class Q3DCamera('Q3DObject'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def targetChanged(self, target: QtGui.QVector3D) -> None: ... - def maxZoomLevelChanged(self, zoomLevel: float) -> None: ... - def minZoomLevelChanged(self, zoomLevel: float) -> None: ... + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + maxZoomLevelChanged: typing.ClassVar[QtCore.pyqtSignal] + minZoomLevelChanged: typing.ClassVar[QtCore.pyqtSignal] def setTarget(self, target: QtGui.QVector3D) -> None: ... def target(self) -> QtGui.QVector3D: ... def setMaxZoomLevel(self, zoomLevel: float) -> None: ... def maxZoomLevel(self) -> float: ... def setMinZoomLevel(self, zoomLevel: float) -> None: ... def minZoomLevel(self) -> float: ... - def wrapYRotationChanged(self, isEnabled: bool) -> None: ... - def wrapXRotationChanged(self, isEnabled: bool) -> None: ... - def cameraPresetChanged(self, preset: 'Q3DCamera.CameraPreset') -> None: ... - def zoomLevelChanged(self, zoomLevel: float) -> None: ... - def yRotationChanged(self, rotation: float) -> None: ... - def xRotationChanged(self, rotation: float) -> None: ... + wrapYRotationChanged: typing.ClassVar[QtCore.pyqtSignal] + wrapXRotationChanged: typing.ClassVar[QtCore.pyqtSignal] + cameraPresetChanged: typing.ClassVar[QtCore.pyqtSignal] + zoomLevelChanged: typing.ClassVar[QtCore.pyqtSignal] + yRotationChanged: typing.ClassVar[QtCore.pyqtSignal] + xRotationChanged: typing.ClassVar[QtCore.pyqtSignal] def setZoomLevel(self, zoomLevel: float) -> None: ... def zoomLevel(self) -> float: ... def setCameraPosition(self, horizontal: float, vertical: float, zoom: float = ...) -> None: ... @@ -372,9 +372,9 @@ class QAbstract3DInputHandler(QtCore.QObject): def setPreviousInputPos(self, position: QtCore.QPoint) -> None: ... def prevDistance(self) -> int: ... def setPrevDistance(self, distance: int) -> None: ... - def sceneChanged(self, scene: 'Q3DScene') -> None: ... - def inputViewChanged(self, view: 'QAbstract3DInputHandler.InputView') -> None: ... - def positionChanged(self, position: QtCore.QPoint) -> None: ... + sceneChanged: typing.ClassVar[QtCore.pyqtSignal] + inputViewChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] def setScene(self, scene: 'Q3DScene') -> None: ... def scene(self) -> 'Q3DScene': ... def setInputPosition(self, position: QtCore.QPoint) -> None: ... @@ -392,10 +392,10 @@ class Q3DInputHandler('QAbstract3DInputHandler'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def zoomAtTargetEnabledChanged(self, enable: bool) -> None: ... - def selectionEnabledChanged(self, enable: bool) -> None: ... - def zoomEnabledChanged(self, enable: bool) -> None: ... - def rotationEnabledChanged(self, enable: bool) -> None: ... + zoomAtTargetEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + selectionEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + zoomEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] def isZoomAtTargetEnabled(self) -> bool: ... def setZoomAtTargetEnabled(self, enable: bool) -> None: ... def isSelectionEnabled(self) -> bool: ... @@ -413,7 +413,7 @@ class Q3DLight('Q3DObject'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def autoPositionChanged(self, autoPosition: bool) -> None: ... + autoPositionChanged: typing.ClassVar[QtCore.pyqtSignal] def isAutoPosition(self) -> bool: ... def setAutoPosition(self, enabled: bool) -> None: ... @@ -421,10 +421,10 @@ class Q3DScatter('QAbstract3DGraph'): def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - def selectedSeriesChanged(self, series: 'QScatter3DSeries') -> None: ... - def axisZChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisYChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisXChanged(self, axis: 'QValue3DAxis') -> None: ... + selectedSeriesChanged: typing.ClassVar[QtCore.pyqtSignal] + axisZChanged: typing.ClassVar[QtCore.pyqtSignal] + axisYChanged: typing.ClassVar[QtCore.pyqtSignal] + axisXChanged: typing.ClassVar[QtCore.pyqtSignal] def selectedSeries(self) -> 'QScatter3DSeries': ... def axes(self) -> typing.List['QValue3DAxis']: ... def releaseAxis(self, axis: 'QValue3DAxis') -> None: ... @@ -443,18 +443,18 @@ class Q3DScene(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def graphPositionQueryChanged(self, position: QtCore.QPoint) -> None: ... + graphPositionQueryChanged: typing.ClassVar[QtCore.pyqtSignal] def graphPositionQuery(self) -> QtCore.QPoint: ... def setGraphPositionQuery(self, point: QtCore.QPoint) -> None: ... - def selectionQueryPositionChanged(self, position: QtCore.QPoint) -> None: ... - def devicePixelRatioChanged(self, pixelRatio: float) -> None: ... - def activeLightChanged(self, light: 'Q3DLight') -> None: ... - def activeCameraChanged(self, camera: 'Q3DCamera') -> None: ... - def slicingActiveChanged(self, isSlicingActive: bool) -> None: ... - def secondarySubviewOnTopChanged(self, isSecondaryOnTop: bool) -> None: ... - def secondarySubViewportChanged(self, subViewport: QtCore.QRect) -> None: ... - def primarySubViewportChanged(self, subViewport: QtCore.QRect) -> None: ... - def viewportChanged(self, viewport: QtCore.QRect) -> None: ... + selectionQueryPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + devicePixelRatioChanged: typing.ClassVar[QtCore.pyqtSignal] + activeLightChanged: typing.ClassVar[QtCore.pyqtSignal] + activeCameraChanged: typing.ClassVar[QtCore.pyqtSignal] + slicingActiveChanged: typing.ClassVar[QtCore.pyqtSignal] + secondarySubviewOnTopChanged: typing.ClassVar[QtCore.pyqtSignal] + secondarySubViewportChanged: typing.ClassVar[QtCore.pyqtSignal] + primarySubViewportChanged: typing.ClassVar[QtCore.pyqtSignal] + viewportChanged: typing.ClassVar[QtCore.pyqtSignal] def setDevicePixelRatio(self, pixelRatio: float) -> None: ... def devicePixelRatio(self) -> float: ... def setActiveLight(self, light: 'Q3DLight') -> None: ... @@ -481,13 +481,13 @@ class Q3DSurface('QAbstract3DGraph'): def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - def flipHorizontalGridChanged(self, flip: bool) -> None: ... + flipHorizontalGridChanged: typing.ClassVar[QtCore.pyqtSignal] def flipHorizontalGrid(self) -> bool: ... def setFlipHorizontalGrid(self, flip: bool) -> None: ... - def selectedSeriesChanged(self, series: 'QSurface3DSeries') -> None: ... - def axisZChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisYChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisXChanged(self, axis: 'QValue3DAxis') -> None: ... + selectedSeriesChanged: typing.ClassVar[QtCore.pyqtSignal] + axisZChanged: typing.ClassVar[QtCore.pyqtSignal] + axisYChanged: typing.ClassVar[QtCore.pyqtSignal] + axisXChanged: typing.ClassVar[QtCore.pyqtSignal] def selectedSeries(self) -> 'QSurface3DSeries': ... def axes(self) -> typing.List['QValue3DAxis']: ... def releaseAxis(self, axis: 'QValue3DAxis') -> None: ... @@ -539,28 +539,28 @@ class Q3DTheme(QtCore.QObject): @typing.overload def __init__(self, themeType: 'Q3DTheme.Theme', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def colorStyleChanged(self, style: 'Q3DTheme.ColorStyle') -> None: ... - def labelBackgroundEnabledChanged(self, enabled: bool) -> None: ... - def gridEnabledChanged(self, enabled: bool) -> None: ... - def backgroundEnabledChanged(self, enabled: bool) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def labelBorderEnabledChanged(self, enabled: bool) -> None: ... - def highlightLightStrengthChanged(self, strength: float) -> None: ... - def ambientLightStrengthChanged(self, strength: float) -> None: ... - def lightStrengthChanged(self, strength: float) -> None: ... - def multiHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def singleHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def baseGradientsChanged(self, gradients: typing.Iterable[QtGui.QLinearGradient]) -> None: ... - def lightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def multiHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def singleHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def gridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def labelBackgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def labelTextColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def windowColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def backgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def baseColorsChanged(self, colors: typing.Iterable[typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]]) -> None: ... - def typeChanged(self, themeType: 'Q3DTheme.Theme') -> None: ... + colorStyleChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBackgroundEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + gridEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + backgroundEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBorderEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + highlightLightStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] + ambientLightStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] + lightStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] + multiHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] + singleHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] + baseGradientsChanged: typing.ClassVar[QtCore.pyqtSignal] + lightColorChanged: typing.ClassVar[QtCore.pyqtSignal] + multiHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] + singleHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] + gridLineColorChanged: typing.ClassVar[QtCore.pyqtSignal] + labelBackgroundColorChanged: typing.ClassVar[QtCore.pyqtSignal] + labelTextColorChanged: typing.ClassVar[QtCore.pyqtSignal] + windowColorChanged: typing.ClassVar[QtCore.pyqtSignal] + backgroundColorChanged: typing.ClassVar[QtCore.pyqtSignal] + baseColorsChanged: typing.ClassVar[QtCore.pyqtSignal] + typeChanged: typing.ClassVar[QtCore.pyqtSignal] def colorStyle(self) -> 'Q3DTheme.ColorStyle': ... def setColorStyle(self, style: 'Q3DTheme.ColorStyle') -> None: ... def isLabelBackgroundEnabled(self) -> bool: ... @@ -628,22 +628,22 @@ class QAbstract3DAxis(QtCore.QObject): AxisOrientationY = ... # type: QAbstract3DAxis.AxisOrientation AxisOrientationZ = ... # type: QAbstract3DAxis.AxisOrientation - def titleFixedChanged(self, fixed: bool) -> None: ... - def titleVisibilityChanged(self, visible: bool) -> None: ... - def labelAutoRotationChanged(self, angle: float) -> None: ... + titleFixedChanged: typing.ClassVar[QtCore.pyqtSignal] + titleVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + labelAutoRotationChanged: typing.ClassVar[QtCore.pyqtSignal] def isTitleFixed(self) -> bool: ... def setTitleFixed(self, fixed: bool) -> None: ... def isTitleVisible(self) -> bool: ... def setTitleVisible(self, visible: bool) -> None: ... def labelAutoRotation(self) -> float: ... def setLabelAutoRotation(self, angle: float) -> None: ... - def autoAdjustRangeChanged(self, autoAdjust: bool) -> None: ... - def rangeChanged(self, min: float, max: float) -> None: ... - def maxChanged(self, value: float) -> None: ... - def minChanged(self, value: float) -> None: ... - def orientationChanged(self, orientation: 'QAbstract3DAxis.AxisOrientation') -> None: ... - def labelsChanged(self) -> None: ... - def titleChanged(self, newTitle: str) -> None: ... + autoAdjustRangeChanged: typing.ClassVar[QtCore.pyqtSignal] + rangeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxChanged: typing.ClassVar[QtCore.pyqtSignal] + minChanged: typing.ClassVar[QtCore.pyqtSignal] + orientationChanged: typing.ClassVar[QtCore.pyqtSignal] + labelsChanged: typing.ClassVar[QtCore.pyqtSignal] + titleChanged: typing.ClassVar[QtCore.pyqtSignal] def setTitle(self, title: str) -> None: ... def setRange(self, min: float, max: float) -> None: ... def isAutoAdjustRange(self) -> bool: ... @@ -698,25 +698,25 @@ class QAbstract3DSeries(QtCore.QObject): SeriesTypeScatter = ... # type: QAbstract3DSeries.SeriesType SeriesTypeSurface = ... # type: QAbstract3DSeries.SeriesType - def itemLabelVisibilityChanged(self, visible: bool) -> None: ... - def itemLabelChanged(self, label: str) -> None: ... + itemLabelVisibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + itemLabelChanged: typing.ClassVar[QtCore.pyqtSignal] def isItemLabelVisible(self) -> bool: ... def setItemLabelVisible(self, visible: bool) -> None: ... def itemLabel(self) -> str: ... - def nameChanged(self, name: str) -> None: ... - def multiHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def multiHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def singleHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def singleHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def baseGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def baseColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def colorStyleChanged(self, style: 'Q3DTheme.ColorStyle') -> None: ... - def userDefinedMeshChanged(self, fileName: str) -> None: ... - def meshRotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def meshSmoothChanged(self, enabled: bool) -> None: ... - def meshChanged(self, mesh: 'QAbstract3DSeries.Mesh') -> None: ... - def visibilityChanged(self, visible: bool) -> None: ... - def itemLabelFormatChanged(self, format: str) -> None: ... + nameChanged: typing.ClassVar[QtCore.pyqtSignal] + multiHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] + multiHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] + singleHighlightGradientChanged: typing.ClassVar[QtCore.pyqtSignal] + singleHighlightColorChanged: typing.ClassVar[QtCore.pyqtSignal] + baseGradientChanged: typing.ClassVar[QtCore.pyqtSignal] + baseColorChanged: typing.ClassVar[QtCore.pyqtSignal] + colorStyleChanged: typing.ClassVar[QtCore.pyqtSignal] + userDefinedMeshChanged: typing.ClassVar[QtCore.pyqtSignal] + meshRotationChanged: typing.ClassVar[QtCore.pyqtSignal] + meshSmoothChanged: typing.ClassVar[QtCore.pyqtSignal] + meshChanged: typing.ClassVar[QtCore.pyqtSignal] + visibilityChanged: typing.ClassVar[QtCore.pyqtSignal] + itemLabelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] def setMeshAxisAndAngle(self, axis: QtGui.QVector3D, angle: float) -> None: ... def name(self) -> str: ... def setName(self, name: str) -> None: ... @@ -770,9 +770,9 @@ class QBar3DSeries('QAbstract3DSeries'): @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def meshAngleChanged(self, angle: float) -> None: ... - def selectedBarChanged(self, position: QtCore.QPoint) -> None: ... - def dataProxyChanged(self, proxy: 'QBarDataProxy') -> None: ... + meshAngleChanged: typing.ClassVar[QtCore.pyqtSignal] + selectedBarChanged: typing.ClassVar[QtCore.pyqtSignal] + dataProxyChanged: typing.ClassVar[QtCore.pyqtSignal] def meshAngle(self) -> float: ... def setMeshAngle(self, angle: float) -> None: ... @staticmethod @@ -802,16 +802,16 @@ class QBarDataProxy('QAbstractDataProxy'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def seriesChanged(self, series: 'QBar3DSeries') -> None: ... - def columnLabelsChanged(self) -> None: ... - def rowLabelsChanged(self) -> None: ... - def rowCountChanged(self, count: int) -> None: ... - def itemChanged(self, rowIndex: int, columnIndex: int) -> None: ... - def rowsInserted(self, startIndex: int, count: int) -> None: ... - def rowsRemoved(self, startIndex: int, count: int) -> None: ... - def rowsChanged(self, startIndex: int, count: int) -> None: ... - def rowsAdded(self, startIndex: int, count: int) -> None: ... - def arrayReset(self) -> None: ... + seriesChanged: typing.ClassVar[QtCore.pyqtSignal] + columnLabelsChanged: typing.ClassVar[QtCore.pyqtSignal] + rowLabelsChanged: typing.ClassVar[QtCore.pyqtSignal] + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + itemChanged: typing.ClassVar[QtCore.pyqtSignal] + rowsInserted: typing.ClassVar[QtCore.pyqtSignal] + rowsRemoved: typing.ClassVar[QtCore.pyqtSignal] + rowsChanged: typing.ClassVar[QtCore.pyqtSignal] + rowsAdded: typing.ClassVar[QtCore.pyqtSignal] + arrayReset: typing.ClassVar[QtCore.pyqtSignal] def series(self) -> 'QBar3DSeries': ... def removeRows(self, rowIndex: int, removeCount: int, removeLabels: bool = ...) -> None: ... @typing.overload @@ -864,7 +864,7 @@ class QCategory3DAxis('QAbstract3DAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def labelsChanged(self) -> None: ... + labelsChanged: typing.ClassVar[QtCore.pyqtSignal] def labels(self) -> typing.List[str]: ... def setLabels(self, labels: typing.Iterable[str]) -> None: ... @@ -875,17 +875,17 @@ class QCustom3DItem(QtCore.QObject): @typing.overload def __init__(self, meshFile: str, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, texture: QtGui.QImage, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def scalingAbsoluteChanged(self, scalingAbsolute: bool) -> None: ... + scalingAbsoluteChanged: typing.ClassVar[QtCore.pyqtSignal] def isScalingAbsolute(self) -> bool: ... def setScalingAbsolute(self, scalingAbsolute: bool) -> None: ... - def shadowCastingChanged(self, shadowCasting: bool) -> None: ... - def visibleChanged(self, visible: bool) -> None: ... - def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def scalingChanged(self, scaling: QtGui.QVector3D) -> None: ... - def positionAbsoluteChanged(self, positionAbsolute: bool) -> None: ... - def positionChanged(self, position: QtGui.QVector3D) -> None: ... - def textureFileChanged(self, textureFile: str) -> None: ... - def meshFileChanged(self, meshFile: str) -> None: ... + shadowCastingChanged: typing.ClassVar[QtCore.pyqtSignal] + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationChanged: typing.ClassVar[QtCore.pyqtSignal] + scalingChanged: typing.ClassVar[QtCore.pyqtSignal] + positionAbsoluteChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + textureFileChanged: typing.ClassVar[QtCore.pyqtSignal] + meshFileChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureImage(self, textureImage: QtGui.QImage) -> None: ... def setRotationAxisAndAngle(self, axis: QtGui.QVector3D, angle: float) -> None: ... def isShadowCasting(self) -> bool: ... @@ -912,13 +912,13 @@ class QCustom3DLabel('QCustom3DItem'): @typing.overload def __init__(self, text: str, font: QtGui.QFont, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def facingCameraChanged(self, enabled: bool) -> None: ... - def backgroundEnabledChanged(self, enabled: bool) -> None: ... - def borderEnabledChanged(self, enabled: bool) -> None: ... - def backgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def textColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def textChanged(self, text: str) -> None: ... + facingCameraChanged: typing.ClassVar[QtCore.pyqtSignal] + backgroundEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + borderEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + backgroundColorChanged: typing.ClassVar[QtCore.pyqtSignal] + textColorChanged: typing.ClassVar[QtCore.pyqtSignal] + fontChanged: typing.ClassVar[QtCore.pyqtSignal] + textChanged: typing.ClassVar[QtCore.pyqtSignal] def isFacingCamera(self) -> bool: ... def setFacingCamera(self, enabled: bool) -> None: ... def isBackgroundEnabled(self) -> bool: ... @@ -941,24 +941,24 @@ class QCustom3DVolume('QCustom3DItem'): @typing.overload def __init__(self, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, textureWidth: int, textureHeight: int, textureDepth: int, textureData: sip.array[int], textureFormat: QtGui.QImage.Format, colorTable: typing.Iterable[int], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def sliceFrameThicknessesChanged(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameGapsChanged(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameWidthsChanged(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def drawSliceFramesChanged(self, enabled: bool) -> None: ... - def drawSlicesChanged(self, enabled: bool) -> None: ... - def useHighDefShaderChanged(self, enabled: bool) -> None: ... - def preserveOpacityChanged(self, enabled: bool) -> None: ... - def alphaMultiplierChanged(self, mult: float) -> None: ... - def textureFormatChanged(self, format: QtGui.QImage.Format) -> None: ... - def textureDataChanged(self, data: sip.array[int]) -> None: ... - def colorTableChanged(self) -> None: ... - def sliceIndexZChanged(self, value: int) -> None: ... - def sliceIndexYChanged(self, value: int) -> None: ... - def sliceIndexXChanged(self, value: int) -> None: ... - def textureDepthChanged(self, value: int) -> None: ... - def textureHeightChanged(self, value: int) -> None: ... - def textureWidthChanged(self, value: int) -> None: ... + sliceFrameThicknessesChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceFrameGapsChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceFrameWidthsChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceFrameColorChanged: typing.ClassVar[QtCore.pyqtSignal] + drawSliceFramesChanged: typing.ClassVar[QtCore.pyqtSignal] + drawSlicesChanged: typing.ClassVar[QtCore.pyqtSignal] + useHighDefShaderChanged: typing.ClassVar[QtCore.pyqtSignal] + preserveOpacityChanged: typing.ClassVar[QtCore.pyqtSignal] + alphaMultiplierChanged: typing.ClassVar[QtCore.pyqtSignal] + textureFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + textureDataChanged: typing.ClassVar[QtCore.pyqtSignal] + colorTableChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceIndexZChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceIndexYChanged: typing.ClassVar[QtCore.pyqtSignal] + sliceIndexXChanged: typing.ClassVar[QtCore.pyqtSignal] + textureDepthChanged: typing.ClassVar[QtCore.pyqtSignal] + textureHeightChanged: typing.ClassVar[QtCore.pyqtSignal] + textureWidthChanged: typing.ClassVar[QtCore.pyqtSignal] def renderSlice(self, axis: QtCore.Qt.Axis, index: int) -> QtGui.QImage: ... def sliceFrameThicknesses(self) -> QtGui.QVector3D: ... def setSliceFrameThicknesses(self, values: QtGui.QVector3D) -> None: ... @@ -1009,15 +1009,15 @@ class QSurfaceDataProxy('QAbstractDataProxy'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def seriesChanged(self, series: 'QSurface3DSeries') -> None: ... - def columnCountChanged(self, count: int) -> None: ... - def rowCountChanged(self, count: int) -> None: ... - def itemChanged(self, rowIndex: int, columnIndex: int) -> None: ... - def rowsInserted(self, startIndex: int, count: int) -> None: ... - def rowsRemoved(self, startIndex: int, count: int) -> None: ... - def rowsChanged(self, startIndex: int, count: int) -> None: ... - def rowsAdded(self, startIndex: int, count: int) -> None: ... - def arrayReset(self) -> None: ... + seriesChanged: typing.ClassVar[QtCore.pyqtSignal] + columnCountChanged: typing.ClassVar[QtCore.pyqtSignal] + rowCountChanged: typing.ClassVar[QtCore.pyqtSignal] + itemChanged: typing.ClassVar[QtCore.pyqtSignal] + rowsInserted: typing.ClassVar[QtCore.pyqtSignal] + rowsRemoved: typing.ClassVar[QtCore.pyqtSignal] + rowsChanged: typing.ClassVar[QtCore.pyqtSignal] + rowsAdded: typing.ClassVar[QtCore.pyqtSignal] + arrayReset: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def itemAt(self, rowIndex: int, columnIndex: int) -> 'QSurfaceDataItem': ... @typing.overload @@ -1048,12 +1048,12 @@ class QHeightMapSurfaceDataProxy('QSurfaceDataProxy'): @typing.overload def __init__(self, filename: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def maxZValueChanged(self, value: float) -> None: ... - def minZValueChanged(self, value: float) -> None: ... - def maxXValueChanged(self, value: float) -> None: ... - def minXValueChanged(self, value: float) -> None: ... - def heightMapFileChanged(self, filename: str) -> None: ... - def heightMapChanged(self, image: QtGui.QImage) -> None: ... + maxZValueChanged: typing.ClassVar[QtCore.pyqtSignal] + minZValueChanged: typing.ClassVar[QtCore.pyqtSignal] + maxXValueChanged: typing.ClassVar[QtCore.pyqtSignal] + minXValueChanged: typing.ClassVar[QtCore.pyqtSignal] + heightMapFileChanged: typing.ClassVar[QtCore.pyqtSignal] + heightMapChanged: typing.ClassVar[QtCore.pyqtSignal] def maxZValue(self) -> float: ... def setMaxZValue(self, max: float) -> None: ... def minZValue(self) -> float: ... @@ -1096,15 +1096,15 @@ class QItemModelBarDataProxy('QBarDataProxy'): @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def multiMatchBehaviorChanged(self, behavior: 'QItemModelBarDataProxy.MultiMatchBehavior') -> None: ... - def rotationRoleReplaceChanged(self, replace: str) -> None: ... - def valueRoleReplaceChanged(self, replace: str) -> None: ... - def columnRoleReplaceChanged(self, replace: str) -> None: ... - def rowRoleReplaceChanged(self, replace: str) -> None: ... - def rotationRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def valueRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def columnRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def rowRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + multiMatchBehaviorChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + valueRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + valueRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] def multiMatchBehavior(self) -> 'QItemModelBarDataProxy.MultiMatchBehavior': ... def setMultiMatchBehavior(self, behavior: 'QItemModelBarDataProxy.MultiMatchBehavior') -> None: ... def rotationRoleReplace(self) -> str: ... @@ -1123,16 +1123,16 @@ class QItemModelBarDataProxy('QBarDataProxy'): def setColumnRolePattern(self, pattern: QtCore.QRegExp) -> None: ... def rowRolePattern(self) -> QtCore.QRegExp: ... def setRowRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def autoColumnCategoriesChanged(self, enable: bool) -> None: ... - def autoRowCategoriesChanged(self, enable: bool) -> None: ... - def useModelCategoriesChanged(self, enable: bool) -> None: ... - def columnCategoriesChanged(self) -> None: ... - def rowCategoriesChanged(self) -> None: ... - def rotationRoleChanged(self, role: str) -> None: ... - def valueRoleChanged(self, role: str) -> None: ... - def columnRoleChanged(self, role: str) -> None: ... - def rowRoleChanged(self, role: str) -> None: ... - def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + autoColumnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + autoRowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + useModelCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + columnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + rowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + valueRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + itemModelChanged: typing.ClassVar[QtCore.pyqtSignal] def remap(self, rowRole: str, columnRole: str, valueRole: str, rotationRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str]) -> None: ... def rotationRole(self) -> str: ... def setRotationRole(self, role: str) -> None: ... @@ -1161,13 +1161,13 @@ class QScatterDataProxy('QAbstractDataProxy'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def seriesChanged(self, series: 'QScatter3DSeries') -> None: ... - def itemCountChanged(self, count: int) -> None: ... - def itemsInserted(self, startIndex: int, count: int) -> None: ... - def itemsRemoved(self, startIndex: int, count: int) -> None: ... - def itemsChanged(self, startIndex: int, count: int) -> None: ... - def itemsAdded(self, startIndex: int, count: int) -> None: ... - def arrayReset(self) -> None: ... + seriesChanged: typing.ClassVar[QtCore.pyqtSignal] + itemCountChanged: typing.ClassVar[QtCore.pyqtSignal] + itemsInserted: typing.ClassVar[QtCore.pyqtSignal] + itemsRemoved: typing.ClassVar[QtCore.pyqtSignal] + itemsChanged: typing.ClassVar[QtCore.pyqtSignal] + itemsAdded: typing.ClassVar[QtCore.pyqtSignal] + arrayReset: typing.ClassVar[QtCore.pyqtSignal] def series(self) -> 'QScatter3DSeries': ... def removeItems(self, index: int, removeCount: int) -> None: ... def insertItems(self, index: int, items: typing.Iterable['QScatterDataItem']) -> None: ... @@ -1192,14 +1192,14 @@ class QItemModelScatterDataProxy('QScatterDataProxy'): @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def zPosRoleReplaceChanged(self, replace: str) -> None: ... - def yPosRoleReplaceChanged(self, replace: str) -> None: ... - def xPosRoleReplaceChanged(self, replace: str) -> None: ... - def rotationRoleReplaceChanged(self, replace: str) -> None: ... - def rotationRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def zPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def yPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def xPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + zPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + rotationRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + zPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] def rotationRoleReplace(self) -> str: ... def setRotationRoleReplace(self, replace: str) -> None: ... def zPosRoleReplace(self) -> str: ... @@ -1216,11 +1216,11 @@ class QItemModelScatterDataProxy('QScatterDataProxy'): def setYPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... def xPosRolePattern(self) -> QtCore.QRegExp: ... def setXPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def rotationRoleChanged(self, role: str) -> None: ... - def zPosRoleChanged(self, role: str) -> None: ... - def yPosRoleChanged(self, role: str) -> None: ... - def xPosRoleChanged(self, role: str) -> None: ... - def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + rotationRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + zPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + itemModelChanged: typing.ClassVar[QtCore.pyqtSignal] def remap(self, xPosRole: str, yPosRole: str, zPosRole: str, rotationRole: str) -> None: ... def rotationRole(self) -> str: ... def setRotationRole(self, role: str) -> None: ... @@ -1261,17 +1261,17 @@ class QItemModelSurfaceDataProxy('QSurfaceDataProxy'): @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def multiMatchBehaviorChanged(self, behavior: 'QItemModelSurfaceDataProxy.MultiMatchBehavior') -> None: ... - def zPosRoleReplaceChanged(self, replace: str) -> None: ... - def yPosRoleReplaceChanged(self, replace: str) -> None: ... - def xPosRoleReplaceChanged(self, replace: str) -> None: ... - def columnRoleReplaceChanged(self, replace: str) -> None: ... - def rowRoleReplaceChanged(self, replace: str) -> None: ... - def zPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def yPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def xPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def columnRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def rowRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + multiMatchBehaviorChanged: typing.ClassVar[QtCore.pyqtSignal] + zPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRoleReplaceChanged: typing.ClassVar[QtCore.pyqtSignal] + zPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRolePatternChanged: typing.ClassVar[QtCore.pyqtSignal] def multiMatchBehavior(self) -> 'QItemModelSurfaceDataProxy.MultiMatchBehavior': ... def setMultiMatchBehavior(self, behavior: 'QItemModelSurfaceDataProxy.MultiMatchBehavior') -> None: ... def zPosRoleReplace(self) -> str: ... @@ -1294,17 +1294,17 @@ class QItemModelSurfaceDataProxy('QSurfaceDataProxy'): def setColumnRolePattern(self, pattern: QtCore.QRegExp) -> None: ... def rowRolePattern(self) -> QtCore.QRegExp: ... def setRowRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def autoColumnCategoriesChanged(self, enable: bool) -> None: ... - def autoRowCategoriesChanged(self, enable: bool) -> None: ... - def useModelCategoriesChanged(self, enable: bool) -> None: ... - def columnCategoriesChanged(self) -> None: ... - def rowCategoriesChanged(self) -> None: ... - def zPosRoleChanged(self, role: str) -> None: ... - def yPosRoleChanged(self, role: str) -> None: ... - def xPosRoleChanged(self, role: str) -> None: ... - def columnRoleChanged(self, role: str) -> None: ... - def rowRoleChanged(self, role: str) -> None: ... - def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + autoColumnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + autoRowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + useModelCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + columnCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + rowCategoriesChanged: typing.ClassVar[QtCore.pyqtSignal] + zPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + yPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + xPosRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + columnRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + rowRoleChanged: typing.ClassVar[QtCore.pyqtSignal] + itemModelChanged: typing.ClassVar[QtCore.pyqtSignal] def remap(self, rowRole: str, columnRole: str, xPosRole: str, yPosRole: str, zPosRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str]) -> None: ... def zPosRole(self) -> str: ... def setZPosRole(self, role: str) -> None: ... @@ -1363,9 +1363,9 @@ class QLogValue3DAxisFormatter('QValue3DAxisFormatter'): def positionAt(self, value: float) -> float: ... def recalculate(self) -> None: ... def createNewInstance(self) -> 'QValue3DAxisFormatter': ... - def showEdgeLabelsChanged(self, enabled: bool) -> None: ... - def autoSubGridChanged(self, enabled: bool) -> None: ... - def baseChanged(self, base: float) -> None: ... + showEdgeLabelsChanged: typing.ClassVar[QtCore.pyqtSignal] + autoSubGridChanged: typing.ClassVar[QtCore.pyqtSignal] + baseChanged: typing.ClassVar[QtCore.pyqtSignal] def showEdgeLabels(self) -> bool: ... def setShowEdgeLabels(self, enabled: bool) -> None: ... def autoSubGrid(self) -> bool: ... @@ -1380,9 +1380,9 @@ class QScatter3DSeries('QAbstract3DSeries'): @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def itemSizeChanged(self, size: float) -> None: ... - def selectedItemChanged(self, index: int) -> None: ... - def dataProxyChanged(self, proxy: 'QScatterDataProxy') -> None: ... + itemSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + selectedItemChanged: typing.ClassVar[QtCore.pyqtSignal] + dataProxyChanged: typing.ClassVar[QtCore.pyqtSignal] def itemSize(self) -> float: ... def setItemSize(self, size: float) -> None: ... @staticmethod @@ -1445,17 +1445,17 @@ class QSurface3DSeries('QAbstract3DSeries'): @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def textureFileChanged(self, filename: str) -> None: ... - def textureChanged(self, image: QtGui.QImage) -> None: ... + textureFileChanged: typing.ClassVar[QtCore.pyqtSignal] + textureChanged: typing.ClassVar[QtCore.pyqtSignal] def textureFile(self) -> str: ... def setTextureFile(self, filename: str) -> None: ... def texture(self) -> QtGui.QImage: ... def setTexture(self, texture: QtGui.QImage) -> None: ... - def drawModeChanged(self, mode: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... - def flatShadingSupportedChanged(self, enable: bool) -> None: ... - def flatShadingEnabledChanged(self, enable: bool) -> None: ... - def selectedPointChanged(self, position: QtCore.QPoint) -> None: ... - def dataProxyChanged(self, proxy: 'QSurfaceDataProxy') -> None: ... + drawModeChanged: typing.ClassVar[QtCore.pyqtSignal] + flatShadingSupportedChanged: typing.ClassVar[QtCore.pyqtSignal] + flatShadingEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + selectedPointChanged: typing.ClassVar[QtCore.pyqtSignal] + dataProxyChanged: typing.ClassVar[QtCore.pyqtSignal] def isFlatShadingSupported(self) -> bool: ... def drawMode(self) -> 'QSurface3DSeries.DrawFlags': ... def setDrawMode(self, mode: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... @@ -1496,15 +1496,15 @@ class QValue3DAxis('QAbstract3DAxis'): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def reversedChanged(self, enable: bool) -> None: ... - def formatterChanged(self, formatter: 'QValue3DAxisFormatter') -> None: ... + reversedChanged: typing.ClassVar[QtCore.pyqtSignal] + formatterChanged: typing.ClassVar[QtCore.pyqtSignal] def reversed(self) -> bool: ... def setReversed(self, enable: bool) -> None: ... def formatter(self) -> 'QValue3DAxisFormatter': ... def setFormatter(self, formatter: 'QValue3DAxisFormatter') -> None: ... - def labelFormatChanged(self, format: str) -> None: ... - def subSegmentCountChanged(self, count: int) -> None: ... - def segmentCountChanged(self, count: int) -> None: ... + labelFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + subSegmentCountChanged: typing.ClassVar[QtCore.pyqtSignal] + segmentCountChanged: typing.ClassVar[QtCore.pyqtSignal] def labelFormat(self) -> str: ... def setLabelFormat(self, format: str) -> None: ... def subSegmentCount(self) -> int: ... diff --git a/PyQt5-stubs/QtDesigner.pyi b/PyQt5-stubs/QtDesigner.pyi index 8bd1874d..e24e8cf4 100644 --- a/PyQt5-stubs/QtDesigner.pyi +++ b/PyQt5-stubs/QtDesigner.pyi @@ -112,19 +112,19 @@ class QDesignerFormWindowInterface(QtWidgets.QWidget): def formContainer(self) -> QtWidgets.QWidget: ... def activeResourceFilePaths(self) -> typing.List[str]: ... def checkContents(self) -> typing.List[str]: ... - def objectRemoved(self, o: QtCore.QObject) -> None: ... - def widgetRemoved(self, w: QtWidgets.QWidget) -> None: ... - def changed(self) -> None: ... - def activated(self, widget: QtWidgets.QWidget) -> None: ... - def aboutToUnmanageWidget(self, widget: QtWidgets.QWidget) -> None: ... - def widgetUnmanaged(self, widget: QtWidgets.QWidget) -> None: ... - def widgetManaged(self, widget: QtWidgets.QWidget) -> None: ... - def resourceFilesChanged(self) -> None: ... - def geometryChanged(self) -> None: ... - def selectionChanged(self) -> None: ... - def featureChanged(self, f: typing.Union['QDesignerFormWindowInterface.Feature', 'QDesignerFormWindowInterface.FeatureFlag']) -> None: ... - def fileNameChanged(self, fileName: str) -> None: ... - def mainContainerChanged(self, mainContainer: QtWidgets.QWidget) -> None: ... + objectRemoved: typing.ClassVar[QtCore.pyqtSignal] + widgetRemoved: typing.ClassVar[QtCore.pyqtSignal] + changed: typing.ClassVar[QtCore.pyqtSignal] + activated: typing.ClassVar[QtCore.pyqtSignal] + aboutToUnmanageWidget: typing.ClassVar[QtCore.pyqtSignal] + widgetUnmanaged: typing.ClassVar[QtCore.pyqtSignal] + widgetManaged: typing.ClassVar[QtCore.pyqtSignal] + resourceFilesChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryChanged: typing.ClassVar[QtCore.pyqtSignal] + selectionChanged: typing.ClassVar[QtCore.pyqtSignal] + featureChanged: typing.ClassVar[QtCore.pyqtSignal] + fileNameChanged: typing.ClassVar[QtCore.pyqtSignal] + mainContainerChanged: typing.ClassVar[QtCore.pyqtSignal] def setFileName(self, fileName: str) -> None: ... def setGrid(self, grid: QtCore.QPoint) -> None: ... def selectWidget(self, widget: QtWidgets.QWidget, select: bool = ...) -> None: ... @@ -286,10 +286,10 @@ class QDesignerFormWindowManagerInterface(QtCore.QObject): def setActiveFormWindow(self, formWindow: QDesignerFormWindowInterface) -> None: ... def removeFormWindow(self, formWindow: QDesignerFormWindowInterface) -> None: ... def addFormWindow(self, formWindow: QDesignerFormWindowInterface) -> None: ... - def formWindowSettingsChanged(self, fw: QDesignerFormWindowInterface) -> None: ... - def activeFormWindowChanged(self, formWindow: QDesignerFormWindowInterface) -> None: ... - def formWindowRemoved(self, formWindow: QDesignerFormWindowInterface) -> None: ... - def formWindowAdded(self, formWindow: QDesignerFormWindowInterface) -> None: ... + formWindowSettingsChanged: typing.ClassVar[QtCore.pyqtSignal] + activeFormWindowChanged: typing.ClassVar[QtCore.pyqtSignal] + formWindowRemoved: typing.ClassVar[QtCore.pyqtSignal] + formWindowAdded: typing.ClassVar[QtCore.pyqtSignal] def core(self) -> QDesignerFormEditorInterface: ... def createFormWindow(self, parent: typing.Optional[QtWidgets.QWidget] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> QDesignerFormWindowInterface: ... def formWindow(self, index: int) -> QDesignerFormWindowInterface: ... @@ -314,7 +314,7 @@ class QDesignerPropertyEditorInterface(QtWidgets.QWidget): def setReadOnly(self, readOnly: bool) -> None: ... def setPropertyValue(self, name: str, value: typing.Any, changed: bool = ...) -> None: ... def setObject(self, object: QtCore.QObject) -> None: ... - def propertyChanged(self, name: str, value: typing.Any) -> None: ... + propertyChanged: typing.ClassVar[QtCore.pyqtSignal] def currentPropertyName(self) -> str: ... def object(self) -> QtCore.QObject: ... def isReadOnly(self) -> bool: ... diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 2dddd700..624d6960 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -80,10 +80,10 @@ class QAbstractTextDocumentLayout(QtCore.QObject): def positionInlineObject(self, item: 'QTextInlineObject', posInDocument: int, format: 'QTextFormat') -> None: ... def resizeInlineObject(self, item: 'QTextInlineObject', posInDocument: int, format: 'QTextFormat') -> None: ... def documentChanged(self, from_: int, charsRemoved: int, charsAdded: int) -> None: ... - def updateBlock(self, block: 'QTextBlock') -> None: ... - def pageCountChanged(self, newPages: int) -> None: ... - def documentSizeChanged(self, newSize: QtCore.QSizeF) -> None: ... - def update(self, rect: QtCore.QRectF = ...) -> None: ... + updateBlock: typing.ClassVar[QtCore.pyqtSignal] + pageCountChanged: typing.ClassVar[QtCore.pyqtSignal] + documentSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + update: typing.ClassVar[QtCore.pyqtSignal] def handlerForObject(self, objectType: int) -> 'QTextObjectInterface': ... def unregisterHandler(self, objectType: int, component: typing.Optional[QtCore.QObject] = ...) -> None: ... def registerHandler(self, objectType: int, component: QtCore.QObject) -> None: ... @@ -1291,8 +1291,8 @@ class QDrag(QtCore.QObject): def defaultAction(self) -> QtCore.Qt.DropAction: ... def supportedActions(self) -> QtCore.Qt.DropActions: ... def dragCursor(self, action: QtCore.Qt.DropAction) -> QPixmap: ... - def targetChanged(self, newTarget: QtCore.QObject) -> None: ... - def actionChanged(self, action: QtCore.Qt.DropAction) -> None: ... + targetChanged: typing.ClassVar[QtCore.pyqtSignal] + actionChanged: typing.ClassVar[QtCore.pyqtSignal] def setDragCursor(self, cursor: QPixmap, action: QtCore.Qt.DropAction) -> None: ... def target(self) -> QtCore.QObject: ... def source(self) -> QtCore.QObject: ... @@ -2653,21 +2653,21 @@ class QGuiApplication(QtCore.QCoreApplication): def highDpiScaleFactorRoundingPolicy() -> QtCore.Qt.HighDpiScaleFactorRoundingPolicy: ... @staticmethod def setHighDpiScaleFactorRoundingPolicy(policy: QtCore.Qt.HighDpiScaleFactorRoundingPolicy) -> None: ... - def fontChanged(self, font: QFont) -> None: ... + fontChanged: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def screenAt(point: QtCore.QPoint) -> 'QScreen': ... @staticmethod def desktopFileName() -> str: ... @staticmethod def setDesktopFileName(name: str) -> None: ... - def primaryScreenChanged(self, screen: 'QScreen') -> None: ... + primaryScreenChanged: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def setFallbackSessionManagementEnabled(a0: bool) -> None: ... @staticmethod def isFallbackSessionManagementEnabled() -> bool: ... - def paletteChanged(self, pal: 'QPalette') -> None: ... - def layoutDirectionChanged(self, direction: QtCore.Qt.LayoutDirection) -> None: ... - def screenRemoved(self, screen: 'QScreen') -> None: ... + paletteChanged: typing.ClassVar[QtCore.pyqtSignal] + layoutDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] + screenRemoved: typing.ClassVar[QtCore.pyqtSignal] def event(self, a0: QtCore.QEvent) -> bool: ... @staticmethod def windowIcon() -> 'QIcon': ... @@ -2692,15 +2692,15 @@ class QGuiApplication(QtCore.QCoreApplication): def applicationDisplayName() -> str: ... @staticmethod def setApplicationDisplayName(name: str) -> None: ... - def applicationDisplayNameChanged(self) -> None: ... - def applicationStateChanged(self, state: QtCore.Qt.ApplicationState) -> None: ... - def focusWindowChanged(self, focusWindow: 'QWindow') -> None: ... - def saveStateRequest(self, sessionManager: 'QSessionManager') -> None: ... - def commitDataRequest(self, sessionManager: 'QSessionManager') -> None: ... - def focusObjectChanged(self, focusObject: QtCore.QObject) -> None: ... + applicationDisplayNameChanged: typing.ClassVar[QtCore.pyqtSignal] + applicationStateChanged: typing.ClassVar[QtCore.pyqtSignal] + focusWindowChanged: typing.ClassVar[QtCore.pyqtSignal] + saveStateRequest: typing.ClassVar[QtCore.pyqtSignal] + commitDataRequest: typing.ClassVar[QtCore.pyqtSignal] + focusObjectChanged: typing.ClassVar[QtCore.pyqtSignal] lastWindowClosed: typing.ClassVar[QtCore.pyqtSignal] - def screenAdded(self, screen: 'QScreen') -> None: ... - def fontDatabaseChanged(self) -> None: ... + screenAdded: typing.ClassVar[QtCore.pyqtSignal] + fontDatabaseChanged: typing.ClassVar[QtCore.pyqtSignal] def notify(self, a0: QtCore.QObject, a1: QtCore.QEvent) -> bool: ... @staticmethod def exec() -> int: ... @@ -3376,16 +3376,16 @@ class QInputMethod(QtCore.QObject): Click = ... # type: QInputMethod.Action ContextMenu = ... # type: QInputMethod.Action - def inputItemClipRectangleChanged(self) -> None: ... - def anchorRectangleChanged(self) -> None: ... + inputItemClipRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] + anchorRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] def inputItemClipRectangle(self) -> QtCore.QRectF: ... def anchorRectangle(self) -> QtCore.QRectF: ... - def inputDirectionChanged(self, newDirection: QtCore.Qt.LayoutDirection) -> None: ... - def localeChanged(self) -> None: ... - def animatingChanged(self) -> None: ... - def visibleChanged(self) -> None: ... - def keyboardRectangleChanged(self) -> None: ... - def cursorRectangleChanged(self) -> None: ... + inputDirectionChanged: typing.ClassVar[QtCore.pyqtSignal] + localeChanged: typing.ClassVar[QtCore.pyqtSignal] + animatingChanged: typing.ClassVar[QtCore.pyqtSignal] + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] + keyboardRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] + cursorRectangleChanged: typing.ClassVar[QtCore.pyqtSignal] def invokeAction(self, a: 'QInputMethod.Action', cursorPosition: int) -> None: ... def commit(self) -> None: ... def reset(self) -> None: ... @@ -3717,13 +3717,13 @@ class QMovie(QtCore.QObject): def setPaused(self, paused: bool) -> None: ... def jumpToNextFrame(self) -> bool: ... def start(self) -> None: ... - def frameChanged(self, frameNumber: int) -> None: ... - def finished(self) -> None: ... - def error(self, error: QImageReader.ImageReaderError) -> None: ... - def stateChanged(self, state: 'QMovie.MovieState') -> None: ... - def updated(self, rect: QtCore.QRect) -> None: ... - def resized(self, size: QtCore.QSize) -> None: ... - def started(self) -> None: ... + frameChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + updated: typing.ClassVar[QtCore.pyqtSignal] + resized: typing.ClassVar[QtCore.pyqtSignal] + started: typing.ClassVar[QtCore.pyqtSignal] def setCacheMode(self, mode: 'QMovie.CacheMode') -> None: ... def cacheMode(self) -> 'QMovie.CacheMode': ... def setScaledSize(self, size: QtCore.QSize) -> None: ... @@ -3797,7 +3797,7 @@ class QOffscreenSurface(QtCore.QObject, QSurface): def setNativeHandle(self, handle: sip.voidptr) -> None: ... def nativeHandle(self) -> sip.voidptr: ... - def screenChanged(self, screen: 'QScreen') -> None: ... + screenChanged: typing.ClassVar[QtCore.pyqtSignal] def setScreen(self, screen: 'QScreen') -> None: ... def screen(self) -> 'QScreen': ... def size(self) -> QtCore.QSize: ... @@ -3946,7 +3946,7 @@ class QOpenGLContext(QtCore.QObject): @staticmethod def openGLModuleHandle() -> sip.voidptr: ... def versionFunctions(self, versionProfile: typing.Optional['QOpenGLVersionProfile'] = ...) -> typing.Any: ... - def aboutToBeDestroyed(self) -> None: ... + aboutToBeDestroyed: typing.ClassVar[QtCore.pyqtSignal] def hasExtension(self, extension: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> bool: ... def extensions(self) -> typing.Set[QtCore.QByteArray]: ... @staticmethod @@ -4122,7 +4122,7 @@ class QOpenGLDebugLogger(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def messageLogged(self, debugMessage: QOpenGLDebugMessage) -> None: ... + messageLogged: typing.ClassVar[QtCore.pyqtSignal] def stopLogging(self) -> None: ... def startLogging(self, loggingMode: 'QOpenGLDebugLogger.LoggingMode' = ...) -> None: ... def logMessage(self, debugMessage: QOpenGLDebugMessage) -> None: ... @@ -5548,7 +5548,7 @@ class QOpenGLWindow(QPaintDeviceWindow): def paintGL(self) -> None: ... def resizeGL(self, w: int, h: int) -> None: ... def initializeGL(self) -> None: ... - def frameSwapped(self) -> None: ... + frameSwapped: typing.ClassVar[QtCore.pyqtSignal] def shareContext(self) -> QOpenGLContext: ... def grabFramebuffer(self) -> QImage: ... def defaultFramebufferObject(self) -> int: ... @@ -8088,15 +8088,15 @@ class QScreen(QtCore.QObject): def serialNumber(self) -> str: ... def model(self) -> str: ... def manufacturer(self) -> str: ... - def availableGeometryChanged(self, geometry: QtCore.QRect) -> None: ... - def virtualGeometryChanged(self, rect: QtCore.QRect) -> None: ... - def physicalSizeChanged(self, size: QtCore.QSizeF) -> None: ... - def refreshRateChanged(self, refreshRate: float) -> None: ... - def orientationChanged(self, orientation: QtCore.Qt.ScreenOrientation) -> None: ... - def primaryOrientationChanged(self, orientation: QtCore.Qt.ScreenOrientation) -> None: ... - def logicalDotsPerInchChanged(self, dpi: float) -> None: ... - def physicalDotsPerInchChanged(self, dpi: float) -> None: ... - def geometryChanged(self, geometry: QtCore.QRect) -> None: ... + availableGeometryChanged: typing.ClassVar[QtCore.pyqtSignal] + virtualGeometryChanged: typing.ClassVar[QtCore.pyqtSignal] + physicalSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + refreshRateChanged: typing.ClassVar[QtCore.pyqtSignal] + orientationChanged: typing.ClassVar[QtCore.pyqtSignal] + primaryOrientationChanged: typing.ClassVar[QtCore.pyqtSignal] + logicalDotsPerInchChanged: typing.ClassVar[QtCore.pyqtSignal] + physicalDotsPerInchChanged: typing.ClassVar[QtCore.pyqtSignal] + geometryChanged: typing.ClassVar[QtCore.pyqtSignal] def devicePixelRatio(self) -> float: ... def refreshRate(self) -> float: ... def grabWindow(self, window: sip.voidptr, x: int = ..., y: int = ..., width: int = ..., height: int = ...) -> QPixmap: ... @@ -8171,7 +8171,7 @@ class QStandardItemModel(QtCore.QAbstractItemModel): def __init__(self, rows: int, columns: int, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def clearItemData(self, index: QtCore.QModelIndex) -> bool: ... - def itemChanged(self, item: 'QStandardItem') -> None: ... + itemChanged: typing.ClassVar[QtCore.pyqtSignal] def setItemRoleNames(self, roleNames: typing.Dict[int, typing.Union[QtCore.QByteArray, bytes, bytearray]]) -> None: ... def sibling(self, row: int, column: int, idx: QtCore.QModelIndex) -> QtCore.QModelIndex: ... def dropMimeData(self, data: QtCore.QMimeData, action: QtCore.Qt.DropAction, row: int, column: int, parent: QtCore.QModelIndex) -> bool: ... @@ -8392,24 +8392,24 @@ class QStyleHints(QtCore.QObject): def touchDoubleTapDistance(self) -> int: ... def mouseDoubleClickDistance(self) -> int: ... - def showShortcutsInContextMenusChanged(self, a0: bool) -> None: ... + showShortcutsInContextMenusChanged: typing.ClassVar[QtCore.pyqtSignal] def setShowShortcutsInContextMenus(self, showShortcutsInContextMenus: bool) -> None: ... - def mouseQuickSelectionThresholdChanged(self, threshold: int) -> None: ... + mouseQuickSelectionThresholdChanged: typing.ClassVar[QtCore.pyqtSignal] def mouseQuickSelectionThreshold(self) -> int: ... def showShortcutsInContextMenus(self) -> bool: ... - def wheelScrollLinesChanged(self, scrollLines: int) -> None: ... + wheelScrollLinesChanged: typing.ClassVar[QtCore.pyqtSignal] def wheelScrollLines(self) -> int: ... - def useHoverEffectsChanged(self, useHoverEffects: bool) -> None: ... + useHoverEffectsChanged: typing.ClassVar[QtCore.pyqtSignal] def setUseHoverEffects(self, useHoverEffects: bool) -> None: ... def useHoverEffects(self) -> bool: ... def showIsMaximized(self) -> bool: ... - def tabFocusBehaviorChanged(self, tabFocusBehavior: QtCore.Qt.TabFocusBehavior) -> None: ... - def mousePressAndHoldIntervalChanged(self, mousePressAndHoldInterval: int) -> None: ... - def startDragTimeChanged(self, startDragTime: int) -> None: ... - def startDragDistanceChanged(self, startDragDistance: int) -> None: ... - def mouseDoubleClickIntervalChanged(self, mouseDoubleClickInterval: int) -> None: ... - def keyboardInputIntervalChanged(self, keyboardInputInterval: int) -> None: ... - def cursorFlashTimeChanged(self, cursorFlashTime: int) -> None: ... + tabFocusBehaviorChanged: typing.ClassVar[QtCore.pyqtSignal] + mousePressAndHoldIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + startDragTimeChanged: typing.ClassVar[QtCore.pyqtSignal] + startDragDistanceChanged: typing.ClassVar[QtCore.pyqtSignal] + mouseDoubleClickIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + keyboardInputIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + cursorFlashTimeChanged: typing.ClassVar[QtCore.pyqtSignal] def singleClickActivation(self) -> bool: ... def tabFocusBehavior(self) -> QtCore.Qt.TabFocusBehavior: ... def mousePressAndHoldInterval(self) -> int: ... @@ -8834,7 +8834,7 @@ class QTextDocument(QtCore.QObject): def setMarkdown(self, markdown: str, features: typing.Union['QTextDocument.MarkdownFeatures', 'QTextDocument.MarkdownFeature'] = ...) -> None: ... def toMarkdown(self, features: typing.Union['QTextDocument.MarkdownFeatures', 'QTextDocument.MarkdownFeature'] = ...) -> str: ... def toRawText(self) -> str: ... - def baseUrlChanged(self, url: QtCore.QUrl) -> None: ... + baseUrlChanged: typing.ClassVar[QtCore.pyqtSignal] def setBaseUrl(self, url: QtCore.QUrl) -> None: ... def baseUrl(self) -> QtCore.QUrl: ... def setDefaultCursorMoveStyle(self, style: QtCore.Qt.CursorMoveStyle) -> None: ... @@ -8847,8 +8847,8 @@ class QTextDocument(QtCore.QObject): def setDocumentMargin(self, margin: float) -> None: ... def documentMargin(self) -> float: ... def characterAt(self, pos: int) -> str: ... - def documentLayoutChanged(self) -> None: ... - def undoCommandAdded(self) -> None: ... + documentLayoutChanged: typing.ClassVar[QtCore.pyqtSignal] + undoCommandAdded: typing.ClassVar[QtCore.pyqtSignal] def setIndentWidth(self, width: float) -> None: ... def indentWidth(self) -> float: ... def lastBlock(self) -> 'QTextBlock': ... @@ -8880,13 +8880,13 @@ class QTextDocument(QtCore.QObject): def undo(self) -> None: ... @typing.overload def undo(self, cursor: QTextCursor) -> None: ... - def undoAvailable(self, a0: bool) -> None: ... - def redoAvailable(self, a0: bool) -> None: ... - def modificationChanged(self, m: bool) -> None: ... - def cursorPositionChanged(self, cursor: QTextCursor) -> None: ... - def contentsChanged(self) -> None: ... - def contentsChange(self, from_: int, charsRemoves: int, charsAdded: int) -> None: ... - def blockCountChanged(self, newBlockCount: int) -> None: ... + undoAvailable: typing.ClassVar[QtCore.pyqtSignal] + redoAvailable: typing.ClassVar[QtCore.pyqtSignal] + modificationChanged: typing.ClassVar[QtCore.pyqtSignal] + cursorPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + contentsChanged: typing.ClassVar[QtCore.pyqtSignal] + contentsChange: typing.ClassVar[QtCore.pyqtSignal] + blockCountChanged: typing.ClassVar[QtCore.pyqtSignal] def useDesignMetrics(self) -> bool: ... def setUseDesignMetrics(self, b: bool) -> None: ... def markContentsDirty(self, from_: int, length: int) -> None: ... @@ -10314,7 +10314,7 @@ class QValidator(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def changed(self) -> None: ... + changed: typing.ClassVar[QtCore.pyqtSignal] def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def fixup(self, a0: str) -> str: ... diff --git a/PyQt5-stubs/QtHelp.pyi b/PyQt5-stubs/QtHelp.pyi index 0b87c478..28946023 100644 --- a/PyQt5-stubs/QtHelp.pyi +++ b/PyQt5-stubs/QtHelp.pyi @@ -69,8 +69,8 @@ class QHelpContentItem(sip.simplewrapper): class QHelpContentModel(QtCore.QAbstractItemModel): - def contentsCreated(self) -> None: ... - def contentsCreationStarted(self) -> None: ... + contentsCreated: typing.ClassVar[QtCore.pyqtSignal] + contentsCreationStarted: typing.ClassVar[QtCore.pyqtSignal] def isCreatingContents(self) -> bool: ... def columnCount(self, parent: QtCore.QModelIndex = ...) -> int: ... def rowCount(self, parent: QtCore.QModelIndex = ...) -> int: ... @@ -83,7 +83,7 @@ class QHelpContentModel(QtCore.QAbstractItemModel): class QHelpContentWidget(QtWidgets.QTreeView): - def linkActivated(self, link: QtCore.QUrl) -> None: ... + linkActivated: typing.ClassVar[QtCore.pyqtSignal] def indexOf(self, link: QtCore.QUrl) -> QtCore.QModelIndex: ... @@ -102,11 +102,11 @@ class QHelpEngineCore(QtCore.QObject): def usesFilterEngine(self) -> bool: ... def setUsesFilterEngine(self, uses: bool) -> None: ... def filterEngine(self) -> 'QHelpFilterEngine': ... - def readersAboutToBeInvalidated(self) -> None: ... - def warning(self, msg: str) -> None: ... - def currentFilterChanged(self, newFilter: str) -> None: ... - def setupFinished(self) -> None: ... - def setupStarted(self) -> None: ... + readersAboutToBeInvalidated: typing.ClassVar[QtCore.pyqtSignal] + warning: typing.ClassVar[QtCore.pyqtSignal] + currentFilterChanged: typing.ClassVar[QtCore.pyqtSignal] + setupFinished: typing.ClassVar[QtCore.pyqtSignal] + setupStarted: typing.ClassVar[QtCore.pyqtSignal] def setAutoSaveFilter(self, save: bool) -> None: ... def autoSaveFilter(self) -> bool: ... def error(self) -> str: ... @@ -177,7 +177,7 @@ class QHelpFilterEngine(QtCore.QObject): @typing.overload def indices(self, filterName: str) -> typing.List[str]: ... def availableVersions(self) -> typing.List[QtCore.QVersionNumber]: ... - def filterActivated(self, newFilter: str) -> None: ... + filterActivated: typing.ClassVar[QtCore.pyqtSignal] def namespacesForFilter(self, filterName: str) -> typing.List[str]: ... def removeFilter(self, filterName: str) -> bool: ... def setFilterData(self, filterName: str, filterData: QHelpFilterData) -> bool: ... @@ -202,8 +202,8 @@ class QHelpFilterSettingsWidget(QtWidgets.QWidget): class QHelpIndexModel(QtCore.QStringListModel): - def indexCreated(self) -> None: ... - def indexCreationStarted(self) -> None: ... + indexCreated: typing.ClassVar[QtCore.pyqtSignal] + indexCreationStarted: typing.ClassVar[QtCore.pyqtSignal] def isCreatingIndex(self) -> bool: ... def linksForKeyword(self, keyword: str) -> typing.Dict[str, QtCore.QUrl]: ... def filter(self, filter: str, wildcard: str = ...) -> QtCore.QModelIndex: ... @@ -213,12 +213,12 @@ class QHelpIndexModel(QtCore.QStringListModel): class QHelpIndexWidget(QtWidgets.QListView): - def documentsActivated(self, documents: typing.Iterable['QHelpLink'], keyword: str) -> None: ... - def documentActivated(self, document: 'QHelpLink', keyword: str) -> None: ... + documentsActivated: typing.ClassVar[QtCore.pyqtSignal] + documentActivated: typing.ClassVar[QtCore.pyqtSignal] def activateCurrentItem(self) -> None: ... def filterIndices(self, filter: str, wildcard: str = ...) -> None: ... - def linksActivated(self, links: typing.Dict[str, QtCore.QUrl], keyword: str) -> None: ... - def linkActivated(self, link: QtCore.QUrl, keyword: str) -> None: ... + linksActivated: typing.ClassVar[QtCore.pyqtSignal] + linkActivated: typing.ClassVar[QtCore.pyqtSignal] class QHelpLink(sip.simplewrapper): @@ -264,10 +264,10 @@ class QHelpSearchEngine(QtCore.QObject): def searchInput(self) -> str: ... def searchResults(self, start: int, end: int) -> typing.List['QHelpSearchResult']: ... def searchResultCount(self) -> int: ... - def searchingFinished(self, hits: int) -> None: ... - def searchingStarted(self) -> None: ... - def indexingFinished(self) -> None: ... - def indexingStarted(self) -> None: ... + searchingFinished: typing.ClassVar[QtCore.pyqtSignal] + searchingStarted: typing.ClassVar[QtCore.pyqtSignal] + indexingFinished: typing.ClassVar[QtCore.pyqtSignal] + indexingStarted: typing.ClassVar[QtCore.pyqtSignal] def cancelSearching(self) -> None: ... @typing.overload def search(self, queryList: typing.Iterable[QHelpSearchQuery]) -> None: ... @@ -304,7 +304,7 @@ class QHelpSearchQueryWidget(QtWidgets.QWidget): def searchInput(self) -> str: ... def setCompactMode(self, on: bool) -> None: ... def isCompactMode(self) -> bool: ... - def search(self) -> None: ... + search: typing.ClassVar[QtCore.pyqtSignal] def collapseExtendedSearch(self) -> None: ... def expandExtendedSearch(self) -> None: ... def setQuery(self, queryList: typing.Iterable[QHelpSearchQuery]) -> None: ... @@ -313,5 +313,5 @@ class QHelpSearchQueryWidget(QtWidgets.QWidget): class QHelpSearchResultWidget(QtWidgets.QWidget): - def requestShowLink(self, url: QtCore.QUrl) -> None: ... + requestShowLink: typing.ClassVar[QtCore.pyqtSignal] def linkAt(self, point: QtCore.QPoint) -> QtCore.QUrl: ... diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index 3926f660..6b42b097 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -64,25 +64,22 @@ class QGeoCodeReply(QtCore.QObject): def setViewport(self, viewport: QtPositioning.QGeoShape) -> None: ... def setFinished(self, finished: bool) -> None: ... def setError(self, error: 'QGeoCodeReply.Error', errorString: str) -> None: ... - def finished(self) -> None: ... - def aborted(self) -> None: ... + finished: typing.ClassVar[QtCore.pyqtSignal] + aborted: typing.ClassVar[QtCore.pyqtSignal] def abort(self) -> None: ... def offset(self) -> int: ... def limit(self) -> int: ... def locations(self) -> typing.List[QtPositioning.QGeoLocation]: ... def viewport(self) -> QtPositioning.QGeoShape: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QGeoCodeReply.Error': ... - @typing.overload - def error(self, error: 'QGeoCodeReply.Error', errorString: str = ...) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isFinished(self) -> bool: ... class QGeoCodingManager(QtCore.QObject): - def error(self, reply: QGeoCodeReply, error: QGeoCodeReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QGeoCodeReply) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def reverseGeocode(self, coordinate: QtPositioning.QGeoCoordinate, bounds: QtPositioning.QGeoShape = ...) -> QGeoCodeReply: ... @@ -98,8 +95,8 @@ class QGeoCodingManagerEngine(QtCore.QObject): def __init__(self, parameters: typing.Dict[str, typing.Any], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def error(self, reply: QGeoCodeReply, error: QGeoCodeReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QGeoCodeReply) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def locale(self) -> QtCore.QLocale: ... def setLocale(self, locale: QtCore.QLocale) -> None: ... def reverseGeocode(self, coordinate: QtPositioning.QGeoCoordinate, bounds: QtPositioning.QGeoShape) -> QGeoCodeReply: ... @@ -230,16 +227,13 @@ class QGeoRouteReply(QtCore.QObject): def setRoutes(self, routes: typing.Iterable[QGeoRoute]) -> None: ... def setFinished(self, finished: bool) -> None: ... def setError(self, error: 'QGeoRouteReply.Error', errorString: str) -> None: ... - def finished(self) -> None: ... - def aborted(self) -> None: ... + finished: typing.ClassVar[QtCore.pyqtSignal] + aborted: typing.ClassVar[QtCore.pyqtSignal] def abort(self) -> None: ... def routes(self) -> typing.List[QGeoRoute]: ... def request(self) -> 'QGeoRouteRequest': ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QGeoRouteReply.Error': ... - @typing.overload - def error(self, error: 'QGeoRouteReply.Error', errorString: str = ...) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isFinished(self) -> bool: ... @@ -464,8 +458,8 @@ class QGeoRouteSegment(sip.simplewrapper): class QGeoRoutingManager(QtCore.QObject): - def error(self, reply: QGeoRouteReply, error: QGeoRouteReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QGeoRouteReply) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def measurementSystem(self) -> QtCore.QLocale.MeasurementSystem: ... def setMeasurementSystem(self, system: QtCore.QLocale.MeasurementSystem) -> None: ... def locale(self) -> QtCore.QLocale: ... @@ -492,8 +486,8 @@ class QGeoRoutingManagerEngine(QtCore.QObject): def setSupportedFeatureWeights(self, featureWeights: typing.Union[QGeoRouteRequest.FeatureWeights, QGeoRouteRequest.FeatureWeight]) -> None: ... def setSupportedFeatureTypes(self, featureTypes: typing.Union[QGeoRouteRequest.FeatureTypes, QGeoRouteRequest.FeatureType]) -> None: ... def setSupportedTravelModes(self, travelModes: typing.Union[QGeoRouteRequest.TravelModes, QGeoRouteRequest.TravelMode]) -> None: ... - def error(self, reply: QGeoRouteReply, error: QGeoRouteReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QGeoRouteReply) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def measurementSystem(self) -> QtCore.QLocale.MeasurementSystem: ... def setMeasurementSystem(self, system: QtCore.QLocale.MeasurementSystem) -> None: ... def locale(self) -> QtCore.QLocale: ... @@ -930,14 +924,11 @@ class QPlaceReply(QtCore.QObject): def setError(self, error: 'QPlaceReply.Error', errorString: str) -> None: ... def setFinished(self, finished: bool) -> None: ... - def contentUpdated(self) -> None: ... - def finished(self) -> None: ... - def aborted(self) -> None: ... + contentUpdated: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + aborted: typing.ClassVar[QtCore.pyqtSignal] def abort(self) -> None: ... - @typing.overload - def error(self) -> 'QPlaceReply.Error': ... - @typing.overload - def error(self, error: 'QPlaceReply.Error', errorString: str = ...) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def errorString(self) -> str: ... def type(self) -> 'QPlaceReply.Type': ... def isFinished(self) -> bool: ... @@ -1061,15 +1052,15 @@ class QPlaceImage(QPlaceContent): class QPlaceManager(QtCore.QObject): - def dataChanged(self) -> None: ... - def categoryRemoved(self, categoryId: str, parentId: str) -> None: ... - def categoryUpdated(self, category: QPlaceCategory, parentId: str) -> None: ... - def categoryAdded(self, category: QPlaceCategory, parentId: str) -> None: ... - def placeRemoved(self, placeId: str) -> None: ... - def placeUpdated(self, placeId: str) -> None: ... - def placeAdded(self, placeId: str) -> None: ... - def error(self, a0: QPlaceReply, error: QPlaceReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QPlaceReply) -> None: ... + dataChanged: typing.ClassVar[QtCore.pyqtSignal] + categoryRemoved: typing.ClassVar[QtCore.pyqtSignal] + categoryUpdated: typing.ClassVar[QtCore.pyqtSignal] + categoryAdded: typing.ClassVar[QtCore.pyqtSignal] + placeRemoved: typing.ClassVar[QtCore.pyqtSignal] + placeUpdated: typing.ClassVar[QtCore.pyqtSignal] + placeAdded: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def matchingPlaces(self, request: 'QPlaceMatchRequest') -> 'QPlaceMatchReply': ... def compatiblePlace(self, place: QPlace) -> QPlace: ... def setLocales(self, locale: typing.Iterable[QtCore.QLocale]) -> None: ... @@ -1097,15 +1088,15 @@ class QPlaceManagerEngine(QtCore.QObject): def __init__(self, parameters: typing.Dict[str, typing.Any], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def manager(self) -> QPlaceManager: ... - def dataChanged(self) -> None: ... - def categoryRemoved(self, categoryId: str, parentCategoryId: str) -> None: ... - def categoryUpdated(self, category: QPlaceCategory, parentCategoryId: str) -> None: ... - def categoryAdded(self, category: QPlaceCategory, parentCategoryId: str) -> None: ... - def placeRemoved(self, placeId: str) -> None: ... - def placeUpdated(self, placeId: str) -> None: ... - def placeAdded(self, placeId: str) -> None: ... - def error(self, a0: QPlaceReply, error: QPlaceReply.Error, errorString: str = ...) -> None: ... - def finished(self, reply: QPlaceReply) -> None: ... + dataChanged: typing.ClassVar[QtCore.pyqtSignal] + categoryRemoved: typing.ClassVar[QtCore.pyqtSignal] + categoryUpdated: typing.ClassVar[QtCore.pyqtSignal] + categoryAdded: typing.ClassVar[QtCore.pyqtSignal] + placeRemoved: typing.ClassVar[QtCore.pyqtSignal] + placeUpdated: typing.ClassVar[QtCore.pyqtSignal] + placeAdded: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def matchingPlaces(self, request: 'QPlaceMatchRequest') -> 'QPlaceMatchReply': ... def compatiblePlace(self, original: QPlace) -> QPlace: ... def constructIconUrl(self, icon: QPlaceIcon, size: QtCore.QSize) -> QtCore.QUrl: ... diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index e574b8cd..eb35ac66 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -115,7 +115,7 @@ class QAbstractVideoFilter(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def activeChanged(self) -> None: ... + activeChanged: typing.ClassVar[QtCore.pyqtSignal] def createFilterRunnable(self) -> QVideoFilterRunnable: ... def isActive(self) -> bool: ... @@ -137,13 +137,13 @@ class QAbstractVideoSurface(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def nativeResolutionChanged(self, a0: QtCore.QSize) -> None: ... + nativeResolutionChanged: typing.ClassVar[QtCore.pyqtSignal] def setNativeResolution(self, resolution: QtCore.QSize) -> None: ... def nativeResolution(self) -> QtCore.QSize: ... def setError(self, error: 'QAbstractVideoSurface.Error') -> None: ... - def supportedFormatsChanged(self) -> None: ... - def surfaceFormatChanged(self, format: 'QVideoSurfaceFormat') -> None: ... - def activeChanged(self, active: bool) -> None: ... + supportedFormatsChanged: typing.ClassVar[QtCore.pyqtSignal] + surfaceFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + activeChanged: typing.ClassVar[QtCore.pyqtSignal] def error(self) -> 'QAbstractVideoSurface.Error': ... def present(self, frame: 'QVideoFrame') -> bool: ... def isActive(self) -> bool: ... @@ -257,16 +257,10 @@ class QMediaObject(QtCore.QObject): def removePropertyWatch(self, name: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def addPropertyWatch(self, name: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - @typing.overload - def availabilityChanged(self, availability: 'QMultimedia.AvailabilityStatus') -> None: ... - @typing.overload - def availabilityChanged(self, available: bool) -> None: ... - @typing.overload - def metaDataChanged(self) -> None: ... - @typing.overload - def metaDataChanged(self, key: str, value: typing.Any) -> None: ... - def metaDataAvailableChanged(self, available: bool) -> None: ... - def notifyIntervalChanged(self, milliSeconds: int) -> None: ... + availabilityChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + notifyIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] def availableMetaData(self) -> typing.List[str]: ... def metaData(self, key: str) -> typing.Any: ... def isMetaDataAvailable(self) -> bool: ... @@ -305,14 +299,14 @@ class QAudioDecoder(QMediaObject): def unbind(self, a0: QtCore.QObject) -> None: ... def bind(self, a0: QtCore.QObject) -> bool: ... - def durationChanged(self, duration: int) -> None: ... - def positionChanged(self, position: int) -> None: ... - def sourceChanged(self) -> None: ... - def formatChanged(self, format: 'QAudioFormat') -> None: ... - def stateChanged(self, newState: 'QAudioDecoder.State') -> None: ... - def finished(self) -> None: ... - def bufferReady(self) -> None: ... - def bufferAvailableChanged(self, a0: bool) -> None: ... + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + formatChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + bufferReady: typing.ClassVar[QtCore.pyqtSignal] + bufferAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def start(self) -> None: ... def duration(self) -> int: ... @@ -320,10 +314,7 @@ class QAudioDecoder(QMediaObject): def bufferAvailable(self) -> bool: ... def read(self) -> QAudioBuffer: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QAudioDecoder.Error': ... - @typing.overload - def error(self, error: 'QAudioDecoder.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def setAudioFormat(self, format: 'QAudioFormat') -> None: ... def audioFormat(self) -> 'QAudioFormat': ... def setSourceDevice(self, device: QtCore.QIODevice) -> None: ... @@ -344,15 +335,15 @@ class QAudioDecoderControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def durationChanged(self, duration: int) -> None: ... - def positionChanged(self, position: int) -> None: ... - def finished(self) -> None: ... - def bufferAvailableChanged(self, available: bool) -> None: ... - def bufferReady(self) -> None: ... - def error(self, error: int, errorString: str) -> None: ... - def sourceChanged(self) -> None: ... - def formatChanged(self, format: 'QAudioFormat') -> None: ... - def stateChanged(self, newState: QAudioDecoder.State) -> None: ... + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + bufferAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + bufferReady: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] + formatChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def duration(self) -> int: ... def position(self) -> int: ... def bufferAvailable(self) -> bool: ... @@ -462,8 +453,8 @@ class QAudioInput(QtCore.QObject): def volume(self) -> float: ... def setVolume(self, volume: float) -> None: ... - def notify(self) -> None: ... - def stateChanged(self, a0: QAudio.State) -> None: ... + notify: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def state(self) -> QAudio.State: ... def error(self) -> QAudio.Error: ... def elapsedUSecs(self) -> int: ... @@ -489,8 +480,8 @@ class QAudioInputSelectorControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def availableInputsChanged(self) -> None: ... - def activeInputChanged(self, name: str) -> None: ... + availableInputsChanged: typing.ClassVar[QtCore.pyqtSignal] + activeInputChanged: typing.ClassVar[QtCore.pyqtSignal] def setActiveInput(self, name: str) -> None: ... def activeInput(self) -> str: ... def defaultInput(self) -> str: ... @@ -509,8 +500,8 @@ class QAudioOutput(QtCore.QObject): def category(self) -> str: ... def volume(self) -> float: ... def setVolume(self, a0: float) -> None: ... - def notify(self) -> None: ... - def stateChanged(self, a0: QAudio.State) -> None: ... + notify: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def state(self) -> QAudio.State: ... def error(self) -> QAudio.Error: ... def elapsedUSecs(self) -> int: ... @@ -536,8 +527,8 @@ class QAudioOutputSelectorControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def availableOutputsChanged(self) -> None: ... - def activeOutputChanged(self, name: str) -> None: ... + availableOutputsChanged: typing.ClassVar[QtCore.pyqtSignal] + activeOutputChanged: typing.ClassVar[QtCore.pyqtSignal] def setActiveOutput(self, name: str) -> None: ... def activeOutput(self) -> str: ... def defaultOutput(self) -> str: ... @@ -549,8 +540,8 @@ class QAudioProbe(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def flush(self) -> None: ... - def audioBufferProbed(self, audioBuffer: QAudioBuffer) -> None: ... + flush: typing.ClassVar[QtCore.pyqtSignal] + audioBufferProbed: typing.ClassVar[QtCore.pyqtSignal] def isActive(self) -> bool: ... @typing.overload def setSource(self, source: QMediaObject) -> bool: ... @@ -613,22 +604,16 @@ class QMediaRecorder(QtCore.QObject, QMediaBindableInterface): def __init__(self, mediaObject: QMediaObject, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, object: QMediaObject) -> bool: ... - @typing.overload - def availabilityChanged(self, availability: 'QMultimedia.AvailabilityStatus') -> None: ... - @typing.overload - def availabilityChanged(self, available: bool) -> None: ... - @typing.overload - def metaDataChanged(self, key: str, value: typing.Any) -> None: ... - @typing.overload - def metaDataChanged(self) -> None: ... - def metaDataWritableChanged(self, writable: bool) -> None: ... - def metaDataAvailableChanged(self, available: bool) -> None: ... - def actualLocationChanged(self, location: QtCore.QUrl) -> None: ... - def volumeChanged(self, volume: float) -> None: ... - def mutedChanged(self, muted: bool) -> None: ... - def durationChanged(self, duration: int) -> None: ... - def statusChanged(self, status: 'QMediaRecorder.Status') -> None: ... - def stateChanged(self, state: 'QMediaRecorder.State') -> None: ... + availabilityChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataWritableChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + actualLocationChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def setVolume(self, volume: float) -> None: ... def setMuted(self, muted: bool) -> None: ... def stop(self) -> None: ... @@ -659,10 +644,7 @@ class QMediaRecorder(QtCore.QObject, QMediaBindableInterface): def isMuted(self) -> bool: ... def duration(self) -> int: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QMediaRecorder.Error': ... - @typing.overload - def error(self, error: 'QMediaRecorder.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def status(self) -> 'QMediaRecorder.Status': ... def state(self) -> 'QMediaRecorder.State': ... def actualLocation(self) -> QtCore.QUrl: ... @@ -677,8 +659,8 @@ class QAudioRecorder(QMediaRecorder): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def availableAudioInputsChanged(self) -> None: ... - def audioInputChanged(self, name: str) -> None: ... + availableAudioInputsChanged: typing.ClassVar[QtCore.pyqtSignal] + audioInputChanged: typing.ClassVar[QtCore.pyqtSignal] def setAudioInput(self, name: str) -> None: ... def audioInput(self) -> str: ... def audioInputDescription(self, name: str) -> str: ... @@ -690,7 +672,7 @@ class QAudioRoleControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def audioRoleChanged(self, role: QAudio.Role) -> None: ... + audioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] def supportedAudioRoles(self) -> typing.List[QAudio.Role]: ... def setAudioRole(self, role: QAudio.Role) -> None: ... def audioRole(self) -> QAudio.Role: ... @@ -849,16 +831,13 @@ class QCamera(QMediaObject): def supportedViewfinderSettings(self, settings: 'QCameraViewfinderSettings' = ...) -> typing.List['QCameraViewfinderSettings']: ... def setViewfinderSettings(self, settings: 'QCameraViewfinderSettings') -> None: ... def viewfinderSettings(self) -> 'QCameraViewfinderSettings': ... - def errorOccurred(self, a0: 'QCamera.Error') -> None: ... - @typing.overload - def lockStatusChanged(self, a0: 'QCamera.LockStatus', a1: 'QCamera.LockChangeReason') -> None: ... - @typing.overload - def lockStatusChanged(self, a0: 'QCamera.LockType', a1: 'QCamera.LockStatus', a2: 'QCamera.LockChangeReason') -> None: ... - def lockFailed(self) -> None: ... - def locked(self) -> None: ... - def statusChanged(self, a0: 'QCamera.Status') -> None: ... - def captureModeChanged(self, a0: typing.Union['QCamera.CaptureModes', 'QCamera.CaptureMode']) -> None: ... - def stateChanged(self, a0: 'QCamera.State') -> None: ... + errorOccurred: typing.ClassVar[QtCore.pyqtSignal] + lockStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + lockFailed: typing.ClassVar[QtCore.pyqtSignal] + locked: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + captureModeChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def unlock(self) -> None: ... @typing.overload @@ -879,10 +858,7 @@ class QCamera(QMediaObject): def requestedLocks(self) -> 'QCamera.LockTypes': ... def supportedLocks(self) -> 'QCamera.LockTypes': ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QCamera.Error': ... - @typing.overload - def error(self, a0: 'QCamera.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def setViewfinder(self, viewfinder: QtMultimediaWidgets.QVideoWidget) -> None: ... @typing.overload @@ -907,7 +883,7 @@ class QCameraCaptureBufferFormatControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def bufferFormatChanged(self, format: 'QVideoFrame.PixelFormat') -> None: ... + bufferFormatChanged: typing.ClassVar[QtCore.pyqtSignal] def setBufferFormat(self, format: 'QVideoFrame.PixelFormat') -> None: ... def bufferFormat(self) -> 'QVideoFrame.PixelFormat': ... def supportedBufferFormats(self) -> typing.List['QVideoFrame.PixelFormat']: ... @@ -917,7 +893,7 @@ class QCameraCaptureDestinationControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def captureDestinationChanged(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... + captureDestinationChanged: typing.ClassVar[QtCore.pyqtSignal] def setCaptureDestination(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... def captureDestination(self) -> 'QCameraImageCapture.CaptureDestinations': ... def isCaptureDestinationSupported(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> bool: ... @@ -940,10 +916,10 @@ class QCameraControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def captureModeChanged(self, mode: typing.Union[QCamera.CaptureModes, QCamera.CaptureMode]) -> None: ... - def error(self, error: int, errorString: str) -> None: ... - def statusChanged(self, a0: QCamera.Status) -> None: ... - def stateChanged(self, a0: QCamera.State) -> None: ... + captureModeChanged: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def canChangeProperty(self, changeType: 'QCameraControl.PropertyChangeType', status: QCamera.Status) -> bool: ... def isCaptureModeSupported(self, mode: typing.Union[QCamera.CaptureModes, QCamera.CaptureMode]) -> bool: ... def setCaptureMode(self, a0: typing.Union[QCamera.CaptureModes, QCamera.CaptureMode]) -> None: ... @@ -1049,13 +1025,13 @@ class QCameraExposure(QtCore.QObject): def __index__(self) -> int: ... def __int__(self) -> int: ... - def exposureCompensationChanged(self, a0: float) -> None: ... - def isoSensitivityChanged(self, a0: int) -> None: ... - def shutterSpeedRangeChanged(self) -> None: ... - def shutterSpeedChanged(self, a0: float) -> None: ... - def apertureRangeChanged(self) -> None: ... - def apertureChanged(self, a0: float) -> None: ... - def flashReady(self, a0: bool) -> None: ... + exposureCompensationChanged: typing.ClassVar[QtCore.pyqtSignal] + isoSensitivityChanged: typing.ClassVar[QtCore.pyqtSignal] + shutterSpeedRangeChanged: typing.ClassVar[QtCore.pyqtSignal] + shutterSpeedChanged: typing.ClassVar[QtCore.pyqtSignal] + apertureRangeChanged: typing.ClassVar[QtCore.pyqtSignal] + apertureChanged: typing.ClassVar[QtCore.pyqtSignal] + flashReady: typing.ClassVar[QtCore.pyqtSignal] def setAutoShutterSpeed(self) -> None: ... def setManualShutterSpeed(self, seconds: float) -> None: ... def setAutoAperture(self) -> None: ... @@ -1117,9 +1093,9 @@ class QCameraExposureControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def parameterRangeChanged(self, parameter: int) -> None: ... - def actualValueChanged(self, parameter: int) -> None: ... - def requestedValueChanged(self, parameter: int) -> None: ... + parameterRangeChanged: typing.ClassVar[QtCore.pyqtSignal] + actualValueChanged: typing.ClassVar[QtCore.pyqtSignal] + requestedValueChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, parameter: 'QCameraExposureControl.ExposureParameter', value: typing.Any) -> bool: ... def actualValue(self, parameter: 'QCameraExposureControl.ExposureParameter') -> typing.Any: ... def requestedValue(self, parameter: 'QCameraExposureControl.ExposureParameter') -> typing.Any: ... @@ -1167,7 +1143,7 @@ class QCameraFlashControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def flashReady(self, a0: bool) -> None: ... + flashReady: typing.ClassVar[QtCore.pyqtSignal] def isFlashReady(self) -> bool: ... def isFlashModeSupported(self, mode: typing.Union[QCameraExposure.FlashModes, QCameraExposure.FlashMode]) -> bool: ... def setFlashMode(self, mode: typing.Union[QCameraExposure.FlashModes, QCameraExposure.FlashMode]) -> None: ... @@ -1237,11 +1213,11 @@ class QCameraFocus(QtCore.QObject): def __index__(self) -> int: ... def __int__(self) -> int: ... - def maximumDigitalZoomChanged(self, a0: float) -> None: ... - def maximumOpticalZoomChanged(self, a0: float) -> None: ... - def focusZonesChanged(self) -> None: ... - def digitalZoomChanged(self, a0: float) -> None: ... - def opticalZoomChanged(self, a0: float) -> None: ... + maximumDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + maximumOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + focusZonesChanged: typing.ClassVar[QtCore.pyqtSignal] + digitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + opticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] def zoomTo(self, opticalZoom: float, digitalZoom: float) -> None: ... def digitalZoom(self) -> float: ... def opticalZoom(self) -> float: ... @@ -1263,10 +1239,10 @@ class QCameraFocusControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def focusZonesChanged(self) -> None: ... - def customFocusPointChanged(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def focusPointModeChanged(self, mode: QCameraFocus.FocusPointMode) -> None: ... - def focusModeChanged(self, mode: typing.Union[QCameraFocus.FocusModes, QCameraFocus.FocusMode]) -> None: ... + focusZonesChanged: typing.ClassVar[QtCore.pyqtSignal] + customFocusPointChanged: typing.ClassVar[QtCore.pyqtSignal] + focusPointModeChanged: typing.ClassVar[QtCore.pyqtSignal] + focusModeChanged: typing.ClassVar[QtCore.pyqtSignal] def focusZones(self) -> typing.List[QCameraFocusZone]: ... def setCustomFocusPoint(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... def customFocusPoint(self) -> QtCore.QPointF: ... @@ -1325,14 +1301,14 @@ class QCameraImageCapture(QtCore.QObject, QMediaBindableInterface): def __init__(self, mediaObject: QMediaObject, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, a0: QMediaObject) -> bool: ... - def imageSaved(self, id: int, fileName: str) -> None: ... - def imageAvailable(self, id: int, image: 'QVideoFrame') -> None: ... - def imageMetadataAvailable(self, id: int, key: str, value: typing.Any) -> None: ... - def imageCaptured(self, id: int, preview: QtGui.QImage) -> None: ... - def imageExposed(self, id: int) -> None: ... - def captureDestinationChanged(self, a0: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... - def bufferFormatChanged(self, a0: 'QVideoFrame.PixelFormat') -> None: ... - def readyForCaptureChanged(self, a0: bool) -> None: ... + imageSaved: typing.ClassVar[QtCore.pyqtSignal] + imageAvailable: typing.ClassVar[QtCore.pyqtSignal] + imageMetadataAvailable: typing.ClassVar[QtCore.pyqtSignal] + imageCaptured: typing.ClassVar[QtCore.pyqtSignal] + imageExposed: typing.ClassVar[QtCore.pyqtSignal] + captureDestinationChanged: typing.ClassVar[QtCore.pyqtSignal] + bufferFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + readyForCaptureChanged: typing.ClassVar[QtCore.pyqtSignal] def cancelCapture(self) -> None: ... def capture(self, file: str = ...) -> int: ... def setCaptureDestination(self, destination: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... @@ -1348,10 +1324,7 @@ class QCameraImageCapture(QtCore.QObject, QMediaBindableInterface): def supportedImageCodecs(self) -> typing.List[str]: ... def isReadyForCapture(self) -> bool: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QCameraImageCapture.Error': ... - @typing.overload - def error(self, id: int, error: 'QCameraImageCapture.Error', errorString: str) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def mediaObject(self) -> QMediaObject: ... def availability(self) -> 'QMultimedia.AvailabilityStatus': ... def isAvailable(self) -> bool: ... @@ -1361,13 +1334,13 @@ class QCameraImageCaptureControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def error(self, id: int, error: int, errorString: str) -> None: ... - def imageSaved(self, requestId: int, fileName: str) -> None: ... - def imageAvailable(self, requestId: int, buffer: 'QVideoFrame') -> None: ... - def imageMetadataAvailable(self, id: int, key: str, value: typing.Any) -> None: ... - def imageCaptured(self, requestId: int, preview: QtGui.QImage) -> None: ... - def imageExposed(self, requestId: int) -> None: ... - def readyForCaptureChanged(self, ready: bool) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + imageSaved: typing.ClassVar[QtCore.pyqtSignal] + imageAvailable: typing.ClassVar[QtCore.pyqtSignal] + imageMetadataAvailable: typing.ClassVar[QtCore.pyqtSignal] + imageCaptured: typing.ClassVar[QtCore.pyqtSignal] + imageExposed: typing.ClassVar[QtCore.pyqtSignal] + readyForCaptureChanged: typing.ClassVar[QtCore.pyqtSignal] def cancelCapture(self) -> None: ... def capture(self, fileName: str) -> int: ... def setDriveMode(self, mode: QCameraImageCapture.DriveMode) -> None: ... @@ -1517,7 +1490,7 @@ class QCameraLocksControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def lockStatusChanged(self, type: QCamera.LockType, status: QCamera.LockStatus, reason: QCamera.LockChangeReason) -> None: ... + lockStatusChanged: typing.ClassVar[QtCore.pyqtSignal] def unlock(self, locks: typing.Union[QCamera.LockTypes, QCamera.LockType]) -> None: ... def searchAndLock(self, locks: typing.Union[QCamera.LockTypes, QCamera.LockType]) -> None: ... def lockStatus(self, lock: QCamera.LockType) -> QCamera.LockStatus: ... @@ -1588,12 +1561,12 @@ class QCameraZoomControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def currentDigitalZoomChanged(self, digitalZoom: float) -> None: ... - def currentOpticalZoomChanged(self, opticalZoom: float) -> None: ... - def requestedDigitalZoomChanged(self, digitalZoom: float) -> None: ... - def requestedOpticalZoomChanged(self, opticalZoom: float) -> None: ... - def maximumDigitalZoomChanged(self, a0: float) -> None: ... - def maximumOpticalZoomChanged(self, a0: float) -> None: ... + currentDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + currentOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + requestedDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + requestedOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + maximumDigitalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] + maximumOpticalZoomChanged: typing.ClassVar[QtCore.pyqtSignal] def zoomTo(self, optical: float, digital: float) -> None: ... def currentDigitalZoom(self) -> float: ... def currentOpticalZoom(self) -> float: ... @@ -1607,7 +1580,7 @@ class QCustomAudioRoleControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def customAudioRoleChanged(self, role: str) -> None: ... + customAudioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] def supportedCustomAudioRoles(self) -> typing.List[str]: ... def setCustomAudioRole(self, role: str) -> None: ... def customAudioRole(self) -> str: ... @@ -1628,15 +1601,15 @@ class QMediaAudioProbeControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def flush(self) -> None: ... - def audioBufferProbed(self, buffer: QAudioBuffer) -> None: ... + flush: typing.ClassVar[QtCore.pyqtSignal] + audioBufferProbed: typing.ClassVar[QtCore.pyqtSignal] class QMediaAvailabilityControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def availabilityChanged(self, availability: 'QMultimedia.AvailabilityStatus') -> None: ... + availabilityChanged: typing.ClassVar[QtCore.pyqtSignal] def availability(self) -> 'QMultimedia.AvailabilityStatus': ... @@ -1758,9 +1731,9 @@ class QMediaGaplessPlaybackControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def advancedToNextMedia(self) -> None: ... - def nextMediaChanged(self, media: QMediaContent) -> None: ... - def crossfadeTimeChanged(self, crossfadeTime: float) -> None: ... + advancedToNextMedia: typing.ClassVar[QtCore.pyqtSignal] + nextMediaChanged: typing.ClassVar[QtCore.pyqtSignal] + crossfadeTimeChanged: typing.ClassVar[QtCore.pyqtSignal] def setCrossfadeTime(self, crossfadeTime: float) -> None: ... def crossfadeTime(self) -> float: ... def isCrossfadeSupported(self) -> bool: ... @@ -1867,7 +1840,7 @@ class QMediaNetworkAccessControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def configurationChanged(self, configuration: QtNetwork.QNetworkConfiguration) -> None: ... + configurationChanged: typing.ClassVar[QtCore.pyqtSignal] def currentConfiguration(self) -> QtNetwork.QNetworkConfiguration: ... def setConfigurations(self, configuration: typing.Iterable[QtNetwork.QNetworkConfiguration]) -> None: ... @@ -1945,30 +1918,30 @@ class QMediaPlayer(QMediaObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ..., flags: typing.Union['QMediaPlayer.Flags', 'QMediaPlayer.Flag'] = ...) -> None: ... - def customAudioRoleChanged(self, role: str) -> None: ... + customAudioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] def supportedCustomAudioRoles(self) -> typing.List[str]: ... def setCustomAudioRole(self, audioRole: str) -> None: ... def customAudioRole(self) -> str: ... - def audioRoleChanged(self, role: QAudio.Role) -> None: ... + audioRoleChanged: typing.ClassVar[QtCore.pyqtSignal] def supportedAudioRoles(self) -> typing.List[QAudio.Role]: ... def setAudioRole(self, audioRole: QAudio.Role) -> None: ... def audioRole(self) -> QAudio.Role: ... def unbind(self, a0: QtCore.QObject) -> None: ... def bind(self, a0: QtCore.QObject) -> bool: ... - def networkConfigurationChanged(self, configuration: QtNetwork.QNetworkConfiguration) -> None: ... - def playbackRateChanged(self, rate: float) -> None: ... - def seekableChanged(self, seekable: bool) -> None: ... - def bufferStatusChanged(self, percentFilled: int) -> None: ... - def videoAvailableChanged(self, videoAvailable: bool) -> None: ... - def audioAvailableChanged(self, available: bool) -> None: ... - def mutedChanged(self, muted: bool) -> None: ... - def volumeChanged(self, volume: int) -> None: ... - def positionChanged(self, position: int) -> None: ... - def durationChanged(self, duration: int) -> None: ... - def mediaStatusChanged(self, status: 'QMediaPlayer.MediaStatus') -> None: ... - def stateChanged(self, newState: 'QMediaPlayer.State') -> None: ... - def currentMediaChanged(self, media: QMediaContent) -> None: ... - def mediaChanged(self, media: QMediaContent) -> None: ... + networkConfigurationChanged: typing.ClassVar[QtCore.pyqtSignal] + playbackRateChanged: typing.ClassVar[QtCore.pyqtSignal] + seekableChanged: typing.ClassVar[QtCore.pyqtSignal] + bufferStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + videoAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + audioAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + mediaStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + currentMediaChanged: typing.ClassVar[QtCore.pyqtSignal] + mediaChanged: typing.ClassVar[QtCore.pyqtSignal] def setNetworkConfigurations(self, configurations: typing.Iterable[QtNetwork.QNetworkConfiguration]) -> None: ... def setPlaylist(self, playlist: 'QMediaPlaylist') -> None: ... def setMedia(self, media: QMediaContent, stream: typing.Optional[QtCore.QIODevice] = ...) -> None: ... @@ -1982,10 +1955,7 @@ class QMediaPlayer(QMediaObject): def availability(self) -> 'QMultimedia.AvailabilityStatus': ... def currentNetworkConfiguration(self) -> QtNetwork.QNetworkConfiguration: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QMediaPlayer.Error': ... - @typing.overload - def error(self, error: 'QMediaPlayer.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def playbackRate(self) -> float: ... def isSeekable(self) -> bool: ... def bufferStatus(self) -> int: ... @@ -2019,20 +1989,20 @@ class QMediaPlayerControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def error(self, error: int, errorString: str) -> None: ... - def playbackRateChanged(self, rate: float) -> None: ... - def availablePlaybackRangesChanged(self, ranges: 'QMediaTimeRange') -> None: ... - def seekableChanged(self, seekable: bool) -> None: ... - def bufferStatusChanged(self, percentFilled: int) -> None: ... - def videoAvailableChanged(self, videoAvailable: bool) -> None: ... - def audioAvailableChanged(self, audioAvailable: bool) -> None: ... - def mutedChanged(self, mute: bool) -> None: ... - def volumeChanged(self, volume: int) -> None: ... - def mediaStatusChanged(self, status: QMediaPlayer.MediaStatus) -> None: ... - def stateChanged(self, newState: QMediaPlayer.State) -> None: ... - def positionChanged(self, position: int) -> None: ... - def durationChanged(self, duration: int) -> None: ... - def mediaChanged(self, content: QMediaContent) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + playbackRateChanged: typing.ClassVar[QtCore.pyqtSignal] + availablePlaybackRangesChanged: typing.ClassVar[QtCore.pyqtSignal] + seekableChanged: typing.ClassVar[QtCore.pyqtSignal] + bufferStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + videoAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + audioAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + mediaStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + positionChanged: typing.ClassVar[QtCore.pyqtSignal] + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + mediaChanged: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def pause(self) -> None: ... def play(self) -> None: ... @@ -2088,16 +2058,16 @@ class QMediaPlaylist(QtCore.QObject, QMediaBindableInterface): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, object: QMediaObject) -> bool: ... - def loadFailed(self) -> None: ... - def loaded(self) -> None: ... - def mediaChanged(self, start: int, end: int) -> None: ... - def mediaRemoved(self, start: int, end: int) -> None: ... - def mediaAboutToBeRemoved(self, start: int, end: int) -> None: ... - def mediaInserted(self, start: int, end: int) -> None: ... - def mediaAboutToBeInserted(self, start: int, end: int) -> None: ... - def currentMediaChanged(self, a0: QMediaContent) -> None: ... - def playbackModeChanged(self, mode: 'QMediaPlaylist.PlaybackMode') -> None: ... - def currentIndexChanged(self, index: int) -> None: ... + loadFailed: typing.ClassVar[QtCore.pyqtSignal] + loaded: typing.ClassVar[QtCore.pyqtSignal] + mediaChanged: typing.ClassVar[QtCore.pyqtSignal] + mediaRemoved: typing.ClassVar[QtCore.pyqtSignal] + mediaAboutToBeRemoved: typing.ClassVar[QtCore.pyqtSignal] + mediaInserted: typing.ClassVar[QtCore.pyqtSignal] + mediaAboutToBeInserted: typing.ClassVar[QtCore.pyqtSignal] + currentMediaChanged: typing.ClassVar[QtCore.pyqtSignal] + playbackModeChanged: typing.ClassVar[QtCore.pyqtSignal] + currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] def setCurrentIndex(self, index: int) -> None: ... def previous(self) -> None: ... def next(self) -> None: ... @@ -2148,13 +2118,13 @@ class QMediaRecorderControl(QMediaControl): def setVolume(self, volume: float) -> None: ... def setMuted(self, muted: bool) -> None: ... def setState(self, state: QMediaRecorder.State) -> None: ... - def error(self, error: int, errorString: str) -> None: ... - def actualLocationChanged(self, location: QtCore.QUrl) -> None: ... - def volumeChanged(self, volume: float) -> None: ... - def mutedChanged(self, muted: bool) -> None: ... - def durationChanged(self, position: int) -> None: ... - def statusChanged(self, status: QMediaRecorder.Status) -> None: ... - def stateChanged(self, state: QMediaRecorder.State) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + actualLocationChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + durationChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def applySettings(self) -> None: ... def volume(self) -> float: ... def isMuted(self) -> bool: ... @@ -2228,8 +2198,8 @@ class QMediaStreamsControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def activeStreamsChanged(self) -> None: ... - def streamsChanged(self) -> None: ... + activeStreamsChanged: typing.ClassVar[QtCore.pyqtSignal] + streamsChanged: typing.ClassVar[QtCore.pyqtSignal] def setActive(self, streamNumber: int, state: bool) -> None: ... def isActive(self, streamNumber: int) -> bool: ... def metaData(self, streamNumber: int, key: str) -> typing.Any: ... @@ -2288,19 +2258,16 @@ class QMediaVideoProbeControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def flush(self) -> None: ... - def videoFrameProbed(self, frame: 'QVideoFrame') -> None: ... + flush: typing.ClassVar[QtCore.pyqtSignal] + videoFrameProbed: typing.ClassVar[QtCore.pyqtSignal] class QMetaDataReaderControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def metaDataAvailableChanged(self, available: bool) -> None: ... - @typing.overload - def metaDataChanged(self) -> None: ... - @typing.overload - def metaDataChanged(self, key: str, value: typing.Any) -> None: ... + metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] def availableMetaData(self) -> typing.List[str]: ... def metaData(self, key: str) -> typing.Any: ... def isMetaDataAvailable(self) -> bool: ... @@ -2310,12 +2277,9 @@ class QMetaDataWriterControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def metaDataAvailableChanged(self, available: bool) -> None: ... - def writableChanged(self, writable: bool) -> None: ... - @typing.overload - def metaDataChanged(self) -> None: ... - @typing.overload - def metaDataChanged(self, key: str, value: typing.Any) -> None: ... + metaDataAvailableChanged: typing.ClassVar[QtCore.pyqtSignal] + writableChanged: typing.ClassVar[QtCore.pyqtSignal] + metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] def availableMetaData(self) -> typing.List[str]: ... def setMetaData(self, key: str, value: typing.Any) -> None: ... def metaData(self, key: str) -> typing.Any: ... @@ -2487,18 +2451,15 @@ class QRadioData(QtCore.QObject, QMediaBindableInterface): def __init__(self, mediaObject: QMediaObject, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setMediaObject(self, a0: QMediaObject) -> bool: ... - def alternativeFrequenciesEnabledChanged(self, enabled: bool) -> None: ... - def radioTextChanged(self, radioText: str) -> None: ... - def stationNameChanged(self, stationName: str) -> None: ... - def programTypeNameChanged(self, programTypeName: str) -> None: ... - def programTypeChanged(self, programType: 'QRadioData.ProgramType') -> None: ... - def stationIdChanged(self, stationId: str) -> None: ... + alternativeFrequenciesEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + radioTextChanged: typing.ClassVar[QtCore.pyqtSignal] + stationNameChanged: typing.ClassVar[QtCore.pyqtSignal] + programTypeNameChanged: typing.ClassVar[QtCore.pyqtSignal] + programTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + stationIdChanged: typing.ClassVar[QtCore.pyqtSignal] def setAlternativeFrequenciesEnabled(self, enabled: bool) -> None: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QRadioData.Error': ... - @typing.overload - def error(self, error: 'QRadioData.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isAlternativeFrequenciesEnabled(self) -> bool: ... def radioText(self) -> str: ... def stationName(self) -> str: ... @@ -2513,17 +2474,14 @@ class QRadioDataControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def alternativeFrequenciesEnabledChanged(self, enabled: bool) -> None: ... - def radioTextChanged(self, radioText: str) -> None: ... - def stationNameChanged(self, stationName: str) -> None: ... - def programTypeNameChanged(self, programTypeName: str) -> None: ... - def programTypeChanged(self, programType: QRadioData.ProgramType) -> None: ... - def stationIdChanged(self, stationId: str) -> None: ... + alternativeFrequenciesEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + radioTextChanged: typing.ClassVar[QtCore.pyqtSignal] + stationNameChanged: typing.ClassVar[QtCore.pyqtSignal] + programTypeNameChanged: typing.ClassVar[QtCore.pyqtSignal] + programTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + stationIdChanged: typing.ClassVar[QtCore.pyqtSignal] def errorString(self) -> str: ... - @typing.overload - def error(self) -> QRadioData.Error: ... - @typing.overload - def error(self, err: QRadioData.Error) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isAlternativeFrequenciesEnabled(self) -> bool: ... def setAlternativeFrequenciesEnabled(self, enabled: bool) -> None: ... def radioText(self) -> str: ... @@ -2584,16 +2542,16 @@ class QRadioTuner(QMediaObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def antennaConnectedChanged(self, connectionStatus: bool) -> None: ... - def stationFound(self, frequency: int, stationId: str) -> None: ... - def mutedChanged(self, muted: bool) -> None: ... - def volumeChanged(self, volume: int) -> None: ... - def signalStrengthChanged(self, signalStrength: int) -> None: ... - def searchingChanged(self, searching: bool) -> None: ... - def stereoStatusChanged(self, stereo: bool) -> None: ... - def frequencyChanged(self, frequency: int) -> None: ... - def bandChanged(self, band: 'QRadioTuner.Band') -> None: ... - def stateChanged(self, state: 'QRadioTuner.State') -> None: ... + antennaConnectedChanged: typing.ClassVar[QtCore.pyqtSignal] + stationFound: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + signalStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] + searchingChanged: typing.ClassVar[QtCore.pyqtSignal] + stereoStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + frequencyChanged: typing.ClassVar[QtCore.pyqtSignal] + bandChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def start(self) -> None: ... def setMuted(self, muted: bool) -> None: ... @@ -2606,10 +2564,7 @@ class QRadioTuner(QMediaObject): def searchForward(self) -> None: ... def radioData(self) -> QRadioData: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QRadioTuner.Error': ... - @typing.overload - def error(self, error: 'QRadioTuner.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def isAntennaConnected(self) -> bool: ... def isSearching(self) -> bool: ... def isMuted(self) -> bool: ... @@ -2631,21 +2586,18 @@ class QRadioTunerControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def antennaConnectedChanged(self, connectionStatus: bool) -> None: ... - def stationFound(self, frequency: int, stationId: str) -> None: ... - def mutedChanged(self, muted: bool) -> None: ... - def volumeChanged(self, volume: int) -> None: ... - def signalStrengthChanged(self, signalStrength: int) -> None: ... - def searchingChanged(self, searching: bool) -> None: ... - def stereoStatusChanged(self, stereo: bool) -> None: ... - def frequencyChanged(self, frequency: int) -> None: ... - def bandChanged(self, band: QRadioTuner.Band) -> None: ... - def stateChanged(self, state: QRadioTuner.State) -> None: ... + antennaConnectedChanged: typing.ClassVar[QtCore.pyqtSignal] + stationFound: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + signalStrengthChanged: typing.ClassVar[QtCore.pyqtSignal] + searchingChanged: typing.ClassVar[QtCore.pyqtSignal] + stereoStatusChanged: typing.ClassVar[QtCore.pyqtSignal] + frequencyChanged: typing.ClassVar[QtCore.pyqtSignal] + bandChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def errorString(self) -> str: ... - @typing.overload - def error(self) -> QRadioTuner.Error: ... - @typing.overload - def error(self, err: QRadioTuner.Error) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def start(self) -> None: ... def cancelSearch(self) -> None: ... @@ -2719,15 +2671,15 @@ class QSoundEffect(QtCore.QObject): def stop(self) -> None: ... def play(self) -> None: ... - def categoryChanged(self) -> None: ... - def statusChanged(self) -> None: ... - def playingChanged(self) -> None: ... - def loadedChanged(self) -> None: ... - def mutedChanged(self) -> None: ... - def volumeChanged(self) -> None: ... - def loopsRemainingChanged(self) -> None: ... - def loopCountChanged(self) -> None: ... - def sourceChanged(self) -> None: ... + categoryChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + playingChanged: typing.ClassVar[QtCore.pyqtSignal] + loadedChanged: typing.ClassVar[QtCore.pyqtSignal] + mutedChanged: typing.ClassVar[QtCore.pyqtSignal] + volumeChanged: typing.ClassVar[QtCore.pyqtSignal] + loopsRemainingChanged: typing.ClassVar[QtCore.pyqtSignal] + loopCountChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceChanged: typing.ClassVar[QtCore.pyqtSignal] def setCategory(self, category: str) -> None: ... def category(self) -> str: ... def status(self) -> 'QSoundEffect.Status': ... @@ -2750,11 +2702,8 @@ class QVideoDeviceSelectorControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def devicesChanged(self) -> None: ... - @typing.overload - def selectedDeviceChanged(self, index: int) -> None: ... - @typing.overload - def selectedDeviceChanged(self, name: str) -> None: ... + devicesChanged: typing.ClassVar[QtCore.pyqtSignal] + selectedDeviceChanged: typing.ClassVar[QtCore.pyqtSignal] def setSelectedDevice(self, index: int) -> None: ... def selectedDevice(self) -> int: ... def defaultDevice(self) -> int: ... @@ -2918,8 +2867,8 @@ class QVideoProbe(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def flush(self) -> None: ... - def videoFrameProbed(self, videoFrame: QVideoFrame) -> None: ... + flush: typing.ClassVar[QtCore.pyqtSignal] + videoFrameProbed: typing.ClassVar[QtCore.pyqtSignal] def isActive(self) -> bool: ... @typing.overload def setSource(self, source: QMediaObject) -> bool: ... @@ -3001,12 +2950,12 @@ class QVideoWindowControl(QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def nativeSizeChanged(self) -> None: ... - def saturationChanged(self, saturation: int) -> None: ... - def hueChanged(self, hue: int) -> None: ... - def contrastChanged(self, contrast: int) -> None: ... - def brightnessChanged(self, brightness: int) -> None: ... - def fullScreenChanged(self, fullScreen: bool) -> None: ... + nativeSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + saturationChanged: typing.ClassVar[QtCore.pyqtSignal] + hueChanged: typing.ClassVar[QtCore.pyqtSignal] + contrastChanged: typing.ClassVar[QtCore.pyqtSignal] + brightnessChanged: typing.ClassVar[QtCore.pyqtSignal] + fullScreenChanged: typing.ClassVar[QtCore.pyqtSignal] def setSaturation(self, saturation: int) -> None: ... def saturation(self) -> int: ... def setHue(self, hue: int) -> None: ... diff --git a/PyQt5-stubs/QtMultimediaWidgets.pyi b/PyQt5-stubs/QtMultimediaWidgets.pyi index c7a0cc68..0de761fb 100644 --- a/PyQt5-stubs/QtMultimediaWidgets.pyi +++ b/PyQt5-stubs/QtMultimediaWidgets.pyi @@ -53,11 +53,11 @@ class QVideoWidget(QtWidgets.QWidget, QtMultimedia.QMediaBindableInterface): def hideEvent(self, event: QtGui.QHideEvent) -> None: ... def showEvent(self, event: QtGui.QShowEvent) -> None: ... def event(self, event: QtCore.QEvent) -> bool: ... - def saturationChanged(self, saturation: int) -> None: ... - def hueChanged(self, hue: int) -> None: ... - def contrastChanged(self, contrast: int) -> None: ... - def brightnessChanged(self, brightness: int) -> None: ... - def fullScreenChanged(self, fullScreen: bool) -> None: ... + saturationChanged: typing.ClassVar[QtCore.pyqtSignal] + hueChanged: typing.ClassVar[QtCore.pyqtSignal] + contrastChanged: typing.ClassVar[QtCore.pyqtSignal] + brightnessChanged: typing.ClassVar[QtCore.pyqtSignal] + fullScreenChanged: typing.ClassVar[QtCore.pyqtSignal] def setSaturation(self, saturation: int) -> None: ... def setHue(self, hue: int) -> None: ... def setContrast(self, contrast: int) -> None: ... @@ -89,7 +89,7 @@ class QGraphicsVideoItem(QtWidgets.QGraphicsObject, QtMultimedia.QMediaBindableI def setMediaObject(self, object: QtMultimedia.QMediaObject) -> bool: ... def itemChange(self, change: QtWidgets.QGraphicsItem.GraphicsItemChange, value: typing.Any) -> typing.Any: ... def timerEvent(self, event: QtCore.QTimerEvent) -> None: ... - def nativeSizeChanged(self, size: QtCore.QSizeF) -> None: ... + nativeSizeChanged: typing.ClassVar[QtCore.pyqtSignal] def paint(self, painter: QtGui.QPainter, option: QtWidgets.QStyleOptionGraphicsItem, widget: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... def boundingRect(self) -> QtCore.QRectF: ... def nativeSize(self) -> QtCore.QSizeF: ... @@ -106,11 +106,11 @@ class QVideoWidgetControl(QtMultimedia.QMediaControl): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def saturationChanged(self, saturation: int) -> None: ... - def hueChanged(self, hue: int) -> None: ... - def contrastChanged(self, contrast: int) -> None: ... - def brightnessChanged(self, brightness: int) -> None: ... - def fullScreenChanged(self, fullScreen: bool) -> None: ... + saturationChanged: typing.ClassVar[QtCore.pyqtSignal] + hueChanged: typing.ClassVar[QtCore.pyqtSignal] + contrastChanged: typing.ClassVar[QtCore.pyqtSignal] + brightnessChanged: typing.ClassVar[QtCore.pyqtSignal] + fullScreenChanged: typing.ClassVar[QtCore.pyqtSignal] def setSaturation(self, saturation: int) -> None: ... def saturation(self) -> int: ... def setHue(self, hue: int) -> None: ... diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 4acd10cb..0133f9b5 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -270,12 +270,12 @@ class QAbstractSocket(QtCore.QIODevice): def writeData(self, data: bytes) -> int: ... def readLineData(self, maxlen: int) -> bytes: ... def readData(self, maxlen: int) -> bytes: ... - def proxyAuthenticationRequired(self, proxy: 'QNetworkProxy', authenticator: 'QAuthenticator') -> None: ... - def errorOccurred(self, a0: 'QAbstractSocket.SocketError') -> None: ... - def stateChanged(self, a0: 'QAbstractSocket.SocketState') -> None: ... - def disconnected(self) -> None: ... - def connected(self) -> None: ... - def hostFound(self) -> None: ... + proxyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + errorOccurred: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] + connected: typing.ClassVar[QtCore.pyqtSignal] + hostFound: typing.ClassVar[QtCore.pyqtSignal] def proxy(self) -> 'QNetworkProxy': ... def setProxy(self, networkProxy: 'QNetworkProxy') -> None: ... def waitForDisconnected(self, msecs: int = ...) -> bool: ... @@ -286,10 +286,7 @@ class QAbstractSocket(QtCore.QIODevice): def atEnd(self) -> bool: ... def isSequential(self) -> bool: ... def close(self) -> None: ... - @typing.overload - def error(self) -> 'QAbstractSocket.SocketError': ... - @typing.overload - def error(self, a0: 'QAbstractSocket.SocketError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def state(self) -> 'QAbstractSocket.SocketState': ... def socketType(self) -> 'QAbstractSocket.SocketType': ... def socketDescriptor(self) -> sip.voidptr: ... @@ -449,12 +446,12 @@ class QDnsLookup(QtCore.QObject): @typing.overload def __init__(self, type: 'QDnsLookup.Type', name: str, nameserver: typing.Union['QHostAddress', 'QHostAddress.SpecialAddress'], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def nameserverChanged(self, nameserver: typing.Union['QHostAddress', 'QHostAddress.SpecialAddress']) -> None: ... + nameserverChanged: typing.ClassVar[QtCore.pyqtSignal] def setNameserver(self, nameserver: typing.Union['QHostAddress', 'QHostAddress.SpecialAddress']) -> None: ... def nameserver(self) -> 'QHostAddress': ... - def typeChanged(self, type: 'QDnsLookup.Type') -> None: ... - def nameChanged(self, name: str) -> None: ... - def finished(self) -> None: ... + typeChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def lookup(self) -> None: ... def abort(self) -> None: ... def textRecords(self) -> typing.List[QDnsTextRecord]: ... @@ -739,7 +736,7 @@ class QLocalServer(QtCore.QObject): def socketOptions(self) -> 'QLocalServer.SocketOptions': ... def setSocketOptions(self, options: typing.Union['QLocalServer.SocketOptions', 'QLocalServer.SocketOption']) -> None: ... def incomingConnection(self, socketDescriptor: sip.voidptr) -> None: ... - def newConnection(self) -> None: ... + newConnection: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def removeServer(name: str) -> bool: ... def waitForNewConnection(self, msecs: int = ...) -> typing.Tuple[bool, bool]: ... @@ -801,10 +798,10 @@ class QLocalSocket(QtCore.QIODevice): def writeData(self, a0: bytes) -> int: ... def readData(self, maxlen: int) -> bytes: ... - def stateChanged(self, socketState: 'QLocalSocket.LocalSocketState') -> None: ... - def errorOccurred(self, socketError: 'QLocalSocket.LocalSocketError') -> None: ... - def disconnected(self) -> None: ... - def connected(self) -> None: ... + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + errorOccurred: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] + connected: typing.ClassVar[QtCore.pyqtSignal] def waitForReadyRead(self, msecs: int = ...) -> bool: ... def waitForDisconnected(self, msecs: int = ...) -> bool: ... def waitForConnected(self, msecs: int = ...) -> bool: ... @@ -816,10 +813,7 @@ class QLocalSocket(QtCore.QIODevice): def readBufferSize(self) -> int: ... def isValid(self) -> bool: ... def flush(self) -> bool: ... - @typing.overload - def error(self) -> 'QLocalSocket.LocalSocketError': ... - @typing.overload - def error(self, socketError: 'QLocalSocket.LocalSocketError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def close(self) -> None: ... def canReadLine(self) -> bool: ... def bytesToWrite(self) -> int: ... @@ -966,11 +960,11 @@ class QNetworkConfigurationManager(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def updateCompleted(self) -> None: ... - def onlineStateChanged(self, isOnline: bool) -> None: ... - def configurationChanged(self, config: 'QNetworkConfiguration') -> None: ... - def configurationRemoved(self, config: 'QNetworkConfiguration') -> None: ... - def configurationAdded(self, config: 'QNetworkConfiguration') -> None: ... + updateCompleted: typing.ClassVar[QtCore.pyqtSignal] + onlineStateChanged: typing.ClassVar[QtCore.pyqtSignal] + configurationChanged: typing.ClassVar[QtCore.pyqtSignal] + configurationRemoved: typing.ClassVar[QtCore.pyqtSignal] + configurationAdded: typing.ClassVar[QtCore.pyqtSignal] def isOnline(self) -> bool: ... def updateConfigurations(self) -> None: ... def configurationFromIdentifier(self, identifier: str) -> 'QNetworkConfiguration': ... @@ -1552,16 +1546,16 @@ class QNetworkReply(QtCore.QIODevice): def setRequest(self, request: 'QNetworkRequest') -> None: ... def setOperation(self, operation: QNetworkAccessManager.Operation) -> None: ... def writeData(self, data: bytes) -> int: ... - def redirectAllowed(self) -> None: ... - def redirected(self, url: QtCore.QUrl) -> None: ... - def preSharedKeyAuthenticationRequired(self, authenticator: 'QSslPreSharedKeyAuthenticator') -> None: ... - def downloadProgress(self, bytesReceived: int, bytesTotal: int) -> None: ... - def uploadProgress(self, bytesSent: int, bytesTotal: int) -> None: ... - def sslErrors(self, errors: typing.Iterable['QSslError']) -> None: ... - def errorOccurred(self, a0: 'QNetworkReply.NetworkError') -> None: ... - def encrypted(self) -> None: ... - def finished(self) -> None: ... - def metaDataChanged(self) -> None: ... + redirectAllowed: typing.ClassVar[QtCore.pyqtSignal] + redirected: typing.ClassVar[QtCore.pyqtSignal] + preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + downloadProgress: typing.ClassVar[QtCore.pyqtSignal] + uploadProgress: typing.ClassVar[QtCore.pyqtSignal] + sslErrors: typing.ClassVar[QtCore.pyqtSignal] + errorOccurred: typing.ClassVar[QtCore.pyqtSignal] + encrypted: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + metaDataChanged: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def ignoreSslErrors(self) -> None: ... @typing.overload @@ -1574,10 +1568,7 @@ class QNetworkReply(QtCore.QIODevice): def hasRawHeader(self, headerName: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> bool: ... def header(self, header: 'QNetworkRequest.KnownHeaders') -> typing.Any: ... def url(self) -> QtCore.QUrl: ... - @typing.overload - def error(self) -> 'QNetworkReply.NetworkError': ... - @typing.overload - def error(self, a0: 'QNetworkReply.NetworkError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def request(self) -> 'QNetworkRequest': ... def operation(self) -> QNetworkAccessManager.Operation: ... def manager(self) -> QNetworkAccessManager: ... @@ -1811,15 +1802,15 @@ class QNetworkSession(QtCore.QObject): def __init__(self, connConfig: QNetworkConfiguration, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def usagePoliciesChanged(self, usagePolicies: typing.Union['QNetworkSession.UsagePolicies', 'QNetworkSession.UsagePolicy']) -> None: ... + usagePoliciesChanged: typing.ClassVar[QtCore.pyqtSignal] def usagePolicies(self) -> 'QNetworkSession.UsagePolicies': ... def disconnectNotify(self, signal: QtCore.QMetaMethod) -> None: ... def connectNotify(self, signal: QtCore.QMetaMethod) -> None: ... - def newConfigurationActivated(self) -> None: ... - def preferredConfigurationChanged(self, config: QNetworkConfiguration, isSeamless: bool) -> None: ... - def closed(self) -> None: ... - def opened(self) -> None: ... - def stateChanged(self, a0: 'QNetworkSession.State') -> None: ... + newConfigurationActivated: typing.ClassVar[QtCore.pyqtSignal] + preferredConfigurationChanged: typing.ClassVar[QtCore.pyqtSignal] + closed: typing.ClassVar[QtCore.pyqtSignal] + opened: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] def reject(self) -> None: ... def accept(self) -> None: ... def ignore(self) -> None: ... @@ -1834,10 +1825,7 @@ class QNetworkSession(QtCore.QObject): def setSessionProperty(self, key: str, value: typing.Any) -> None: ... def sessionProperty(self, key: str) -> typing.Any: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> 'QNetworkSession.SessionError': ... - @typing.overload - def error(self, a0: 'QNetworkSession.SessionError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def state(self) -> 'QNetworkSession.State': ... def interface(self) -> QNetworkInterface: ... def configuration(self) -> QNetworkConfiguration: ... @@ -2392,7 +2380,7 @@ class QSslSocket(QTcpSocket): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def newSessionTicketReceived(self) -> None: ... + newSessionTicketReceived: typing.ClassVar[QtCore.pyqtSignal] def sslHandshakeErrors(self) -> typing.List[QSslError]: ... def ocspResponses(self) -> typing.List[QOcspResponse]: ... @staticmethod @@ -2413,8 +2401,8 @@ class QSslSocket(QTcpSocket): def peerVerifyName(self) -> str: ... def socketOption(self, option: QAbstractSocket.SocketOption) -> typing.Any: ... def setSocketOption(self, option: QAbstractSocket.SocketOption, value: typing.Any) -> None: ... - def encryptedBytesWritten(self, totalBytes: int) -> None: ... - def peerVerifyError(self, error: QSslError) -> None: ... + encryptedBytesWritten: typing.ClassVar[QtCore.pyqtSignal] + peerVerifyError: typing.ClassVar[QtCore.pyqtSignal] def setSslConfiguration(self, config: QSslConfiguration) -> None: ... def sslConfiguration(self) -> QSslConfiguration: ... def encryptedBytesToWrite(self) -> int: ... @@ -2426,9 +2414,9 @@ class QSslSocket(QTcpSocket): def peerVerifyMode(self) -> 'QSslSocket.PeerVerifyMode': ... def writeData(self, data: bytes) -> int: ... def readData(self, maxlen: int) -> bytes: ... - def preSharedKeyAuthenticationRequired(self, authenticator: QSslPreSharedKeyAuthenticator) -> None: ... - def modeChanged(self, newMode: 'QSslSocket.SslMode') -> None: ... - def encrypted(self) -> None: ... + preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + modeChanged: typing.ClassVar[QtCore.pyqtSignal] + encrypted: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def ignoreSslErrors(self) -> None: ... @typing.overload @@ -2437,10 +2425,7 @@ class QSslSocket(QTcpSocket): def startClientEncryption(self) -> None: ... @staticmethod def supportsSsl() -> bool: ... - @typing.overload - def sslErrors(self) -> typing.List[QSslError]: ... - @typing.overload - def sslErrors(self, errors: typing.Iterable[QSslError]) -> None: ... + sslErrors: typing.ClassVar[QtCore.pyqtSignal] def waitForDisconnected(self, msecs: int = ...) -> bool: ... def waitForBytesWritten(self, msecs: int = ...) -> bool: ... def waitForReadyRead(self, msecs: int = ...) -> bool: ... @@ -2513,8 +2498,8 @@ class QTcpServer(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def acceptError(self, socketError: QAbstractSocket.SocketError) -> None: ... - def newConnection(self) -> None: ... + acceptError: typing.ClassVar[QtCore.pyqtSignal] + newConnection: typing.ClassVar[QtCore.pyqtSignal] def addPendingConnection(self, socket: QTcpSocket) -> None: ... def incomingConnection(self, handle: sip.voidptr) -> None: ... def resumeAccepting(self) -> None: ... diff --git a/PyQt5-stubs/QtNetworkAuth.pyi b/PyQt5-stubs/QtNetworkAuth.pyi index b9f650b4..9925af09 100644 --- a/PyQt5-stubs/QtNetworkAuth.pyi +++ b/PyQt5-stubs/QtNetworkAuth.pyi @@ -64,17 +64,17 @@ class QAbstractOAuth(QtCore.QObject): def resourceOwnerAuthorization(self, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any]) -> None: ... def callback(self) -> str: ... def setStatus(self, status: 'QAbstractOAuth.Status') -> None: ... - def replyDataReceived(self, data: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def finished(self, reply: QtNetwork.QNetworkReply) -> None: ... - def granted(self) -> None: ... - def authorizeWithBrowser(self, url: QtCore.QUrl) -> None: ... - def requestFailed(self, error: 'QAbstractOAuth.Error') -> None: ... - def contentTypeChanged(self, contentType: 'QAbstractOAuth.ContentType') -> None: ... - def extraTokensChanged(self, tokens: typing.Dict[str, typing.Any]) -> None: ... - def authorizationUrlChanged(self, url: QtCore.QUrl) -> None: ... - def statusChanged(self, status: 'QAbstractOAuth.Status') -> None: ... - def tokenChanged(self, token: str) -> None: ... - def clientIdentifierChanged(self, clientIdentifier: str) -> None: ... + replyDataReceived: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] + granted: typing.ClassVar[QtCore.pyqtSignal] + authorizeWithBrowser: typing.ClassVar[QtCore.pyqtSignal] + requestFailed: typing.ClassVar[QtCore.pyqtSignal] + contentTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + extraTokensChanged: typing.ClassVar[QtCore.pyqtSignal] + authorizationUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] + tokenChanged: typing.ClassVar[QtCore.pyqtSignal] + clientIdentifierChanged: typing.ClassVar[QtCore.pyqtSignal] def grant(self) -> None: ... def prepareRequest(self, request: QtNetwork.QNetworkRequest, verb: typing.Union[QtCore.QByteArray, bytes, bytearray], body: typing.Union[QtCore.QByteArray, bytes, bytearray] = ...) -> None: ... def setContentType(self, contentType: 'QAbstractOAuth.ContentType') -> None: ... @@ -108,15 +108,15 @@ class QAbstractOAuth2(QAbstractOAuth): def __init__(self, manager: QtNetwork.QNetworkAccessManager, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def setResponseType(self, responseType: str) -> None: ... - def authorizationCallbackReceived(self, data: typing.Dict[str, typing.Any]) -> None: ... - def error(self, error: str, errorDescription: str, uri: QtCore.QUrl) -> None: ... - def expirationAtChanged(self, expiration: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def stateChanged(self, state: str) -> None: ... - def clientIdentifierSharedKeyChanged(self, clientIdentifierSharedKey: str) -> None: ... - def responseTypeChanged(self, responseType: str) -> None: ... - def refreshTokenChanged(self, refreshToken: str) -> None: ... - def userAgentChanged(self, userAgent: str) -> None: ... - def scopeChanged(self, scope: str) -> None: ... + authorizationCallbackReceived: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + expirationAtChanged: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + clientIdentifierSharedKeyChanged: typing.ClassVar[QtCore.pyqtSignal] + responseTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + refreshTokenChanged: typing.ClassVar[QtCore.pyqtSignal] + userAgentChanged: typing.ClassVar[QtCore.pyqtSignal] + scopeChanged: typing.ClassVar[QtCore.pyqtSignal] def setRefreshToken(self, refreshToken: str) -> None: ... def refreshToken(self) -> str: ... def expirationAt(self) -> QtCore.QDateTime: ... @@ -151,10 +151,10 @@ class QAbstractOAuthReplyHandler(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def callbackDataReceived(self, data: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def replyDataReceived(self, data: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tokensReceived(self, tokens: typing.Dict[str, typing.Any]) -> None: ... - def callbackReceived(self, values: typing.Dict[str, typing.Any]) -> None: ... + callbackDataReceived: typing.ClassVar[QtCore.pyqtSignal] + replyDataReceived: typing.ClassVar[QtCore.pyqtSignal] + tokensReceived: typing.ClassVar[QtCore.pyqtSignal] + callbackReceived: typing.ClassVar[QtCore.pyqtSignal] def networkReplyFinished(self, reply: QtNetwork.QNetworkReply) -> None: ... def callback(self) -> str: ... @@ -183,11 +183,11 @@ class QOAuth1(QAbstractOAuth): def setup(self, request: QtNetwork.QNetworkRequest, signingParameters: typing.Dict[str, typing.Any], operationVerb: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def requestTokenCredentials(self, operation: QtNetwork.QNetworkAccessManager.Operation, url: QtCore.QUrl, temporaryToken: typing.Tuple[str, str], parameters: typing.Dict[str, typing.Any] = ...) -> QtNetwork.QNetworkReply: ... def requestTemporaryCredentials(self, operation: QtNetwork.QNetworkAccessManager.Operation, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any] = ...) -> QtNetwork.QNetworkReply: ... - def tokenCredentialsUrlChanged(self, url: QtCore.QUrl) -> None: ... - def temporaryCredentialsUrlChanged(self, url: QtCore.QUrl) -> None: ... - def tokenSecretChanged(self, token: str) -> None: ... - def clientSharedSecretChanged(self, credential: str) -> None: ... - def signatureMethodChanged(self, method: 'QOAuth1.SignatureMethod') -> None: ... + tokenCredentialsUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + temporaryCredentialsUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + tokenSecretChanged: typing.ClassVar[QtCore.pyqtSignal] + clientSharedSecretChanged: typing.ClassVar[QtCore.pyqtSignal] + signatureMethodChanged: typing.ClassVar[QtCore.pyqtSignal] def continueGrantWithVerifier(self, verifier: str) -> None: ... def grant(self) -> None: ... def deleteResource(self, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any] = ...) -> QtNetwork.QNetworkReply: ... @@ -278,7 +278,7 @@ class QOAuth2AuthorizationCodeFlow(QAbstractOAuth2): def resourceOwnerAuthorization(self, url: QtCore.QUrl, parameters: typing.Dict[str, typing.Any] = ...) -> None: ... def requestAccessToken(self, code: str) -> None: ... def buildAuthenticateUrl(self, parameters: typing.Dict[str, typing.Any] = ...) -> QtCore.QUrl: ... - def accessTokenUrlChanged(self, accessTokenUrl: QtCore.QUrl) -> None: ... + accessTokenUrlChanged: typing.ClassVar[QtCore.pyqtSignal] def refreshAccessToken(self) -> None: ... def grant(self) -> None: ... def setAccessTokenUrl(self, accessTokenUrl: QtCore.QUrl) -> None: ... diff --git a/PyQt5-stubs/QtNfc.pyi b/PyQt5-stubs/QtNfc.pyi index 669afa27..5257bc84 100644 --- a/PyQt5-stubs/QtNfc.pyi +++ b/PyQt5-stubs/QtNfc.pyi @@ -274,10 +274,10 @@ class QNearFieldManager(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def adapterStateChanged(self, state: 'QNearFieldManager.AdapterState') -> None: ... + adapterStateChanged: typing.ClassVar[QtCore.pyqtSignal] def isSupported(self) -> bool: ... - def targetLost(self, target: 'QNearFieldTarget') -> None: ... - def targetDetected(self, target: 'QNearFieldTarget') -> None: ... + targetLost: typing.ClassVar[QtCore.pyqtSignal] + targetDetected: typing.ClassVar[QtCore.pyqtSignal] def unregisterNdefMessageHandler(self, handlerId: int) -> bool: ... @typing.overload def registerNdefMessageHandler(self, slot: PYQT_SLOT) -> int: ... @@ -341,9 +341,9 @@ class QNearFieldShareManager(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def error(self, error: 'QNearFieldShareManager.ShareError') -> None: ... - def shareModesChanged(self, modes: typing.Union['QNearFieldShareManager.ShareModes', 'QNearFieldShareManager.ShareMode']) -> None: ... - def targetDetected(self, shareTarget: 'QNearFieldShareTarget') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + shareModesChanged: typing.ClassVar[QtCore.pyqtSignal] + targetDetected: typing.ClassVar[QtCore.pyqtSignal] def shareError(self) -> 'QNearFieldShareManager.ShareError': ... def shareModes(self) -> 'QNearFieldShareManager.ShareModes': ... def setShareModes(self, modes: typing.Union['QNearFieldShareManager.ShareModes', 'QNearFieldShareManager.ShareMode']) -> None: ... @@ -353,8 +353,8 @@ class QNearFieldShareManager(QtCore.QObject): class QNearFieldShareTarget(QtCore.QObject): - def shareFinished(self) -> None: ... - def error(self, error: QNearFieldShareManager.ShareError) -> None: ... + shareFinished: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] def shareError(self) -> QNearFieldShareManager.ShareError: ... def isShareInProgress(self) -> bool: ... def cancel(self) -> None: ... @@ -447,11 +447,11 @@ class QNearFieldTarget(QtCore.QObject): def disconnect(self) -> bool: ... # type: ignore[override] def setKeepConnection(self, isPersistent: bool) -> bool: ... def keepConnection(self) -> bool: ... - def error(self, error: 'QNearFieldTarget.Error', id: 'QNearFieldTarget.RequestId') -> None: ... - def requestCompleted(self, id: 'QNearFieldTarget.RequestId') -> None: ... - def ndefMessagesWritten(self) -> None: ... - def ndefMessageRead(self, message: QNdefMessage) -> None: ... - def disconnected(self) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] + requestCompleted: typing.ClassVar[QtCore.pyqtSignal] + ndefMessagesWritten: typing.ClassVar[QtCore.pyqtSignal] + ndefMessageRead: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] def reportError(self, error: 'QNearFieldTarget.Error', id: 'QNearFieldTarget.RequestId') -> None: ... def handleResponse(self, id: 'QNearFieldTarget.RequestId', response: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> bool: ... def setResponseForRequest(self, id: 'QNearFieldTarget.RequestId', response: typing.Any, emitRequestCompleted: bool = ...) -> None: ... @@ -491,9 +491,9 @@ class QQmlNdefRecord(QtCore.QObject): @typing.overload def __init__(self, record: QNdefRecord, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def recordChanged(self) -> None: ... - def typeNameFormatChanged(self) -> None: ... - def typeChanged(self) -> None: ... + recordChanged: typing.ClassVar[QtCore.pyqtSignal] + typeNameFormatChanged: typing.ClassVar[QtCore.pyqtSignal] + typeChanged: typing.ClassVar[QtCore.pyqtSignal] def setRecord(self, record: QNdefRecord) -> None: ... def record(self) -> QNdefRecord: ... def typeNameFormat(self) -> 'QQmlNdefRecord.TypeNameFormat': ... diff --git a/PyQt5-stubs/QtPositioning.pyi b/PyQt5-stubs/QtPositioning.pyi index de57e255..2923e553 100644 --- a/PyQt5-stubs/QtPositioning.pyi +++ b/PyQt5-stubs/QtPositioning.pyi @@ -120,9 +120,9 @@ class QGeoAreaMonitorSource(QtCore.QObject): def __init__(self, parent: QtCore.QObject) -> None: ... - def monitorExpired(self, monitor: QGeoAreaMonitorInfo) -> None: ... - def areaExited(self, monitor: QGeoAreaMonitorInfo, update: 'QGeoPositionInfo') -> None: ... - def areaEntered(self, monitor: QGeoAreaMonitorInfo, update: 'QGeoPositionInfo') -> None: ... + monitorExpired: typing.ClassVar[QtCore.pyqtSignal] + areaExited: typing.ClassVar[QtCore.pyqtSignal] + areaEntered: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def activeMonitors(self) -> typing.List[QGeoAreaMonitorInfo]: ... @typing.overload @@ -131,10 +131,7 @@ class QGeoAreaMonitorSource(QtCore.QObject): def stopMonitoring(self, monitor: QGeoAreaMonitorInfo) -> bool: ... def startMonitoring(self, monitor: QGeoAreaMonitorInfo) -> bool: ... def supportedAreaMonitorFeatures(self) -> 'QGeoAreaMonitorSource.AreaMonitorFeatures': ... - @typing.overload - def error(self) -> 'QGeoAreaMonitorSource.Error': ... - @typing.overload - def error(self, error: 'QGeoAreaMonitorSource.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def sourceName(self) -> str: ... def positionInfoSource(self) -> 'QGeoPositionInfoSource': ... def setPositionInfoSource(self, source: 'QGeoPositionInfoSource') -> None: ... @@ -414,14 +411,14 @@ class QGeoPositionInfoSource(QtCore.QObject): def backendProperty(self, name: str) -> typing.Any: ... def setBackendProperty(self, name: str, value: typing.Any) -> bool: ... - def supportedPositioningMethodsChanged(self) -> None: ... - def updateTimeout(self) -> None: ... - def positionUpdated(self, update: QGeoPositionInfo) -> None: ... + supportedPositioningMethodsChanged: typing.ClassVar[QtCore.pyqtSignal] + updateTimeout: typing.ClassVar[QtCore.pyqtSignal] + positionUpdated: typing.ClassVar[QtCore.pyqtSignal] def requestUpdate(self, timeout: int = ...) -> None: ... def stopUpdates(self) -> None: ... def startUpdates(self) -> None: ... # If the error signal is real, it isn't accessible in PyQt 5.15.1 - def error(self) -> 'QGeoPositionInfoSource.Error': ... + error: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def availableSources() -> typing.List[str]: ... @typing.overload @@ -534,16 +531,13 @@ class QGeoSatelliteInfoSource(QtCore.QObject): def __init__(self, parent: QtCore.QObject) -> None: ... - def requestTimeout(self) -> None: ... - def satellitesInUseUpdated(self, satellites: typing.Iterable[QGeoSatelliteInfo]) -> None: ... - def satellitesInViewUpdated(self, satellites: typing.Iterable[QGeoSatelliteInfo]) -> None: ... + requestTimeout: typing.ClassVar[QtCore.pyqtSignal] + satellitesInUseUpdated: typing.ClassVar[QtCore.pyqtSignal] + satellitesInViewUpdated: typing.ClassVar[QtCore.pyqtSignal] def requestUpdate(self, timeout: int = ...) -> None: ... def stopUpdates(self) -> None: ... def startUpdates(self) -> None: ... - @typing.overload - def error(self) -> 'QGeoSatelliteInfoSource.Error': ... - @typing.overload - def error(self, a0: 'QGeoSatelliteInfoSource.Error') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def minimumUpdateInterval(self) -> int: ... def updateInterval(self) -> int: ... def setUpdateInterval(self, msec: int) -> None: ... diff --git a/PyQt5-stubs/QtPrintSupport.pyi b/PyQt5-stubs/QtPrintSupport.pyi index c49a0efa..a4698cad 100644 --- a/PyQt5-stubs/QtPrintSupport.pyi +++ b/PyQt5-stubs/QtPrintSupport.pyi @@ -129,10 +129,7 @@ class QPrintDialog(QAbstractPrintDialog): @typing.overload def __init__(self, parent: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... - @typing.overload # type: ignore[override] - def accepted(self) -> None: ... - @typing.overload - def accepted(self, printer: 'QPrinter') -> None: ... + accepted: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def open(self) -> None: ... @typing.overload diff --git a/PyQt5-stubs/QtPurchasing.pyi b/PyQt5-stubs/QtPurchasing.pyi index 5dc2605a..2eb2a1eb 100644 --- a/PyQt5-stubs/QtPurchasing.pyi +++ b/PyQt5-stubs/QtPurchasing.pyi @@ -53,9 +53,9 @@ class QInAppStore(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def transactionReady(self, transaction: 'QInAppTransaction') -> None: ... - def productUnknown(self, productType: QInAppProduct.ProductType, identifier: str) -> None: ... - def productRegistered(self, product: QInAppProduct) -> None: ... + transactionReady: typing.ClassVar[QtCore.pyqtSignal] + productUnknown: typing.ClassVar[QtCore.pyqtSignal] + productRegistered: typing.ClassVar[QtCore.pyqtSignal] def setPlatformProperty(self, propertyName: str, value: str) -> None: ... def registeredProduct(self, identifier: str) -> QInAppProduct: ... def registerProduct(self, productType: QInAppProduct.ProductType, identifier: str) -> None: ... diff --git a/PyQt5-stubs/QtQml.pyi b/PyQt5-stubs/QtQml.pyi index 78e530bd..9db6eaf2 100644 --- a/PyQt5-stubs/QtQml.pyi +++ b/PyQt5-stubs/QtQml.pyi @@ -66,7 +66,7 @@ class QJSEngine(QtCore.QObject): @typing.overload def __init__(self, parent: QtCore.QObject) -> None: ... - def uiLanguageChanged(self) -> None: ... + uiLanguageChanged: typing.ClassVar[QtCore.pyqtSignal] def setUiLanguage(self, language: str) -> None: ... def uiLanguage(self) -> str: ... def isInterrupted(self) -> bool: ... @@ -299,8 +299,8 @@ class QQmlComponent(QtCore.QObject): def setInitialProperties(self, component: QtCore.QObject, properties: typing.Dict[str, typing.Any]) -> None: ... def engine(self) -> QQmlEngine: ... - def progressChanged(self, a0: float) -> None: ... - def statusChanged(self, a0: 'QQmlComponent.Status') -> None: ... + progressChanged: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] def setData(self, a0: typing.Union[QtCore.QByteArray, bytes, bytearray], baseUrl: QtCore.QUrl) -> None: ... @typing.overload def loadUrl(self, url: QtCore.QUrl) -> None: ... @@ -429,7 +429,7 @@ class QQmlExpression(QtCore.QObject): @typing.overload def __init__(self, a0: 'QQmlScriptString', context: typing.Optional[QQmlContext] = ..., scope: typing.Optional[QtCore.QObject] = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def valueChanged(self) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def evaluate(self) -> typing.Tuple[typing.Any, bool]: ... def error(self) -> QQmlError: ... def clearError(self) -> None: ... @@ -663,7 +663,7 @@ class QQmlPropertyMap(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def updateValue(self, key: str, input: typing.Any) -> typing.Any: ... - def valueChanged(self, key: str, value: typing.Any) -> None: ... + valueChanged: typing.ClassVar[QtCore.pyqtSignal] def __getitem__(self, key: str) -> typing.Any: ... def contains(self, key: str) -> bool: ... def isEmpty(self) -> bool: ... diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 0f9ea248..ee95d603 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -142,7 +142,7 @@ class QQuickItem(QtCore.QObject, QtQml.QQmlParserStatus): def __init__(self, parent: typing.Optional['QQuickItem'] = ...) -> None: ... - def containmentMaskChanged(self) -> None: ... + containmentMaskChanged: typing.ClassVar[QtCore.pyqtSignal] def setContainmentMask(self, mask: QtCore.QObject) -> None: ... def containmentMask(self) -> QtCore.QObject: ... def setAcceptTouchEvents(self, accept: bool) -> None: ... @@ -153,7 +153,7 @@ class QQuickItem(QtCore.QObject, QtQml.QQmlParserStatus): def isAncestorOf(self, child: 'QQuickItem') -> bool: ... def grabToImage(self, targetSize: QtCore.QSize = ...) -> 'QQuickItemGrabResult': ... def resetAntialiasing(self) -> None: ... - def windowChanged(self, window: 'QQuickWindow') -> None: ... + windowChanged: typing.ClassVar[QtCore.pyqtSignal] def nextItemInFocusChain(self, forward: bool = ...) -> 'QQuickItem': ... def setActiveFocusOnTab(self, a0: bool) -> None: ... def activeFocusOnTab(self) -> bool: ... @@ -302,13 +302,13 @@ class QQuickFramebufferObject(QQuickItem): def __init__(self, parent: typing.Optional[QQuickItem] = ...) -> None: ... - def mirrorVerticallyChanged(self, a0: bool) -> None: ... + mirrorVerticallyChanged: typing.ClassVar[QtCore.pyqtSignal] def setMirrorVertically(self, enable: bool) -> None: ... def mirrorVertically(self) -> bool: ... def releaseResources(self) -> None: ... def textureProvider(self) -> 'QSGTextureProvider': ... def isTextureProvider(self) -> bool: ... - def textureFollowsItemSizeChanged(self, a0: bool) -> None: ... + textureFollowsItemSizeChanged: typing.ClassVar[QtCore.pyqtSignal] def updatePaintNode(self, a0: 'QSGNode', a1: QQuickItem.UpdatePaintNodeData) -> 'QSGNode': ... def geometryChanged(self, newGeometry: QtCore.QRectF, oldGeometry: QtCore.QRectF) -> None: ... def createRenderer(self) -> 'QQuickFramebufferObject.Renderer': ... @@ -346,7 +346,7 @@ class QQuickImageResponse(QtCore.QObject): def __init__(self) -> None: ... - def finished(self) -> None: ... + finished: typing.ClassVar[QtCore.pyqtSignal] def cancel(self) -> None: ... def errorString(self) -> str: ... def textureFactory(self) -> QQuickTextureFactory: ... @@ -364,7 +364,7 @@ class QQuickAsyncImageProvider(QQuickImageProvider): class QQuickItemGrabResult(QtCore.QObject): - def ready(self) -> None: ... + ready: typing.ClassVar[QtCore.pyqtSignal] def event(self, a0: QtCore.QEvent) -> bool: ... def saveToFile(self, fileName: str) -> bool: ... def url(self) -> QtCore.QUrl: ... @@ -404,7 +404,7 @@ class QQuickPaintedItem(QQuickItem): def __init__(self, parent: typing.Optional[QQuickItem] = ...) -> None: ... - def textureSizeChanged(self) -> None: ... + textureSizeChanged: typing.ClassVar[QtCore.pyqtSignal] def setTextureSize(self, size: QtCore.QSize) -> None: ... def textureSize(self) -> QtCore.QSize: ... def itemChange(self, a0: QQuickItem.ItemChange, a1: QQuickItem.ItemChangeData) -> None: ... @@ -412,10 +412,10 @@ class QQuickPaintedItem(QQuickItem): def textureProvider(self) -> 'QSGTextureProvider': ... def isTextureProvider(self) -> bool: ... def updatePaintNode(self, a0: 'QSGNode', a1: QQuickItem.UpdatePaintNodeData) -> 'QSGNode': ... - def renderTargetChanged(self) -> None: ... - def contentsScaleChanged(self) -> None: ... - def contentsSizeChanged(self) -> None: ... - def fillColorChanged(self) -> None: ... + renderTargetChanged: typing.ClassVar[QtCore.pyqtSignal] + contentsScaleChanged: typing.ClassVar[QtCore.pyqtSignal] + contentsSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + fillColorChanged: typing.ClassVar[QtCore.pyqtSignal] def paint(self, painter: QtGui.QPainter) -> None: ... def setRenderTarget(self, target: 'QQuickPaintedItem.RenderTarget') -> None: ... def renderTarget(self) -> 'QQuickPaintedItem.RenderTarget': ... @@ -443,8 +443,8 @@ class QQuickRenderControl(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def sceneChanged(self) -> None: ... - def renderRequested(self) -> None: ... + sceneChanged: typing.ClassVar[QtCore.pyqtSignal] + renderRequested: typing.ClassVar[QtCore.pyqtSignal] def prepareThread(self, targetThread: QtCore.QThread) -> None: ... def renderWindow(self, offset: QtCore.QPoint) -> QtGui.QWindow: ... @staticmethod @@ -651,7 +651,7 @@ class QQuickView(QQuickWindow): def keyPressEvent(self, a0: QtGui.QKeyEvent) -> None: ... def timerEvent(self, a0: QtCore.QTimerEvent) -> None: ... def resizeEvent(self, a0: QtGui.QResizeEvent) -> None: ... - def statusChanged(self, a0: 'QQuickView.Status') -> None: ... + statusChanged: typing.ClassVar[QtCore.pyqtSignal] def setInitialProperties(self, initialProperties: typing.Dict[str, typing.Any]) -> None: ... def setSource(self, a0: QtCore.QUrl) -> None: ... def initialSize(self) -> QtCore.QSize: ... @@ -714,7 +714,7 @@ class QSGAbstractRenderer(QtCore.QObject): def __index__(self) -> int: ... def __int__(self) -> int: ... - def sceneGraphChanged(self) -> None: ... + sceneGraphChanged: typing.ClassVar[QtCore.pyqtSignal] def renderScene(self, fboId: int = ...) -> None: ... def clearMode(self) -> 'QSGAbstractRenderer.ClearMode': ... def setClearMode(self, mode: typing.Union['QSGAbstractRenderer.ClearMode', 'QSGAbstractRenderer.ClearModeBit']) -> None: ... @@ -1805,7 +1805,7 @@ class QSGTextureProvider(QtCore.QObject): def __init__(self) -> None: ... - def textureChanged(self) -> None: ... + textureChanged: typing.ClassVar[QtCore.pyqtSignal] def texture(self) -> QSGTexture: ... diff --git a/PyQt5-stubs/QtQuickWidgets.pyi b/PyQt5-stubs/QtQuickWidgets.pyi index e3cc6b57..62c14f4b 100644 --- a/PyQt5-stubs/QtQuickWidgets.pyi +++ b/PyQt5-stubs/QtQuickWidgets.pyi @@ -92,8 +92,8 @@ class QQuickWidget(QtWidgets.QWidget): def keyPressEvent(self, a0: QtGui.QKeyEvent) -> None: ... def timerEvent(self, a0: QtCore.QTimerEvent) -> None: ... def resizeEvent(self, a0: QtGui.QResizeEvent) -> None: ... - def sceneGraphError(self, error: QtQuick.QQuickWindow.SceneGraphError, message: str) -> None: ... - def statusChanged(self, a0: 'QQuickWidget.Status') -> None: ... + sceneGraphError: typing.ClassVar[QtCore.pyqtSignal] + statusChanged: typing.ClassVar[QtCore.pyqtSignal] def setSource(self, a0: QtCore.QUrl) -> None: ... def format(self) -> QtGui.QSurfaceFormat: ... def setFormat(self, format: QtGui.QSurfaceFormat) -> None: ... diff --git a/PyQt5-stubs/QtRemoteObjects.pyi b/PyQt5-stubs/QtRemoteObjects.pyi index 8ae155b2..ed9a41e4 100644 --- a/PyQt5-stubs/QtRemoteObjects.pyi +++ b/PyQt5-stubs/QtRemoteObjects.pyi @@ -34,7 +34,7 @@ PYQT_SLOT = typing.Union[typing.Callable[..., None], QtCore.pyqtBoundSignal] class QAbstractItemModelReplica(QtCore.QAbstractItemModel): - def initialized(self) -> None: ... + initialized: typing.ClassVar[QtCore.pyqtSignal] def setRootCacheSize(self, rootCacheSize: int) -> None: ... def rootCacheSize(self) -> int: ... def hasData(self, index: QtCore.QModelIndex, role: int) -> bool: ... @@ -68,9 +68,9 @@ class QRemoteObjectReplica(QtCore.QObject): Suspect = ... # type: QRemoteObjectReplica.State SignatureMismatch = ... # type: QRemoteObjectReplica.State - def notified(self) -> None: ... - def stateChanged(self, state: 'QRemoteObjectReplica.State', oldState: 'QRemoteObjectReplica.State') -> None: ... - def initialized(self) -> None: ... + notified: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + initialized: typing.ClassVar[QtCore.pyqtSignal] def setNode(self, node: 'QRemoteObjectNode') -> None: ... def node(self) -> 'QRemoteObjectNode': ... def state(self) -> 'QRemoteObjectReplica.State': ... @@ -125,10 +125,10 @@ class QRemoteObjectNode(QtCore.QObject): def __init__(self, registryAddress: QtCore.QUrl, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def timerEvent(self, a0: QtCore.QTimerEvent) -> None: ... - def heartbeatIntervalChanged(self, heartbeatInterval: int) -> None: ... - def error(self, errorCode: 'QRemoteObjectNode.ErrorCode') -> None: ... - def remoteObjectRemoved(self, a0: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... - def remoteObjectAdded(self, a0: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... + heartbeatIntervalChanged: typing.ClassVar[QtCore.pyqtSignal] + error: typing.ClassVar[QtCore.pyqtSignal] + remoteObjectRemoved: typing.ClassVar[QtCore.pyqtSignal] + remoteObjectAdded: typing.ClassVar[QtCore.pyqtSignal] def setHeartbeatInterval(self, interval: int) -> None: ... def heartbeatInterval(self) -> int: ... def lastError(self) -> 'QRemoteObjectNode.ErrorCode': ... @@ -175,7 +175,7 @@ class QRemoteObjectHost(QRemoteObjectHostBase): @typing.overload def __init__(self, address: QtCore.QUrl, parent: QtCore.QObject) -> None: ... - def hostUrlChanged(self) -> None: ... + hostUrlChanged: typing.ClassVar[QtCore.pyqtSignal] def setHostUrl(self, hostAddress: QtCore.QUrl, allowedSchemas: QRemoteObjectHostBase.AllowedSchemas = ...) -> bool: ... def hostUrl(self) -> QtCore.QUrl: ... @@ -189,8 +189,8 @@ class QRemoteObjectRegistryHost(QRemoteObjectHostBase): class QRemoteObjectRegistry(QRemoteObjectReplica): - def remoteObjectRemoved(self, entry: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... - def remoteObjectAdded(self, entry: typing.Tuple[str, 'QRemoteObjectSourceLocationInfo']) -> None: ... + remoteObjectRemoved: typing.ClassVar[QtCore.pyqtSignal] + remoteObjectAdded: typing.ClassVar[QtCore.pyqtSignal] def sourceLocations(self) -> typing.Dict[str, 'QRemoteObjectSourceLocationInfo']: ... diff --git a/PyQt5-stubs/QtSensors.pyi b/PyQt5-stubs/QtSensors.pyi index 017cbd80..fcd947e6 100644 --- a/PyQt5-stubs/QtSensors.pyi +++ b/PyQt5-stubs/QtSensors.pyi @@ -102,20 +102,20 @@ class QSensor(QtCore.QObject): def __init__(self, type: typing.Union[QtCore.QByteArray, bytes, bytearray], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def bufferSizeChanged(self, bufferSize: int) -> None: ... - def efficientBufferSizeChanged(self, efficientBufferSize: int) -> None: ... - def maxBufferSizeChanged(self, maxBufferSize: int) -> None: ... - def userOrientationChanged(self, userOrientation: int) -> None: ... - def currentOrientationChanged(self, currentOrientation: int) -> None: ... - def axesOrientationModeChanged(self, axesOrientationMode: 'QSensor.AxesOrientationMode') -> None: ... - def skipDuplicatesChanged(self, skipDuplicates: bool) -> None: ... - def dataRateChanged(self) -> None: ... - def alwaysOnChanged(self) -> None: ... - def availableSensorsChanged(self) -> None: ... - def sensorError(self, error: int) -> None: ... - def readingChanged(self) -> None: ... - def activeChanged(self) -> None: ... - def busyChanged(self) -> None: ... + bufferSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + efficientBufferSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + maxBufferSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + userOrientationChanged: typing.ClassVar[QtCore.pyqtSignal] + currentOrientationChanged: typing.ClassVar[QtCore.pyqtSignal] + axesOrientationModeChanged: typing.ClassVar[QtCore.pyqtSignal] + skipDuplicatesChanged: typing.ClassVar[QtCore.pyqtSignal] + dataRateChanged: typing.ClassVar[QtCore.pyqtSignal] + alwaysOnChanged: typing.ClassVar[QtCore.pyqtSignal] + availableSensorsChanged: typing.ClassVar[QtCore.pyqtSignal] + sensorError: typing.ClassVar[QtCore.pyqtSignal] + readingChanged: typing.ClassVar[QtCore.pyqtSignal] + activeChanged: typing.ClassVar[QtCore.pyqtSignal] + busyChanged: typing.ClassVar[QtCore.pyqtSignal] def stop(self) -> None: ... def start(self) -> bool: ... def setBufferSize(self, bufferSize: int) -> None: ... @@ -176,7 +176,7 @@ class QAccelerometer(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def accelerationModeChanged(self, accelerationMode: 'QAccelerometer.AccelerationMode') -> None: ... + accelerationModeChanged: typing.ClassVar[QtCore.pyqtSignal] def reading(self) -> QAccelerometerReading: ... def setAccelerationMode(self, accelerationMode: 'QAccelerometer.AccelerationMode') -> None: ... def accelerationMode(self) -> 'QAccelerometer.AccelerationMode': ... @@ -414,8 +414,8 @@ class QIRProximitySensor(QSensor): class QLidReading(QSensorReading): - def frontLidChanged(self, closed: bool) -> None: ... - def backLidChanged(self, closed: bool) -> None: ... + frontLidChanged: typing.ClassVar[QtCore.pyqtSignal] + backLidChanged: typing.ClassVar[QtCore.pyqtSignal] def setFrontLidClosed(self, closed: bool) -> None: ... def frontLidClosed(self) -> bool: ... def setBackLidClosed(self, closed: bool) -> None: ... @@ -459,7 +459,7 @@ class QLightSensor(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def fieldOfViewChanged(self, fieldOfView: float) -> None: ... + fieldOfViewChanged: typing.ClassVar[QtCore.pyqtSignal] def setFieldOfView(self, fieldOfView: float) -> None: ... def fieldOfView(self) -> float: ... def reading(self) -> QLightReading: ... @@ -491,7 +491,7 @@ class QMagnetometer(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def returnGeoValuesChanged(self, returnGeoValues: bool) -> None: ... + returnGeoValuesChanged: typing.ClassVar[QtCore.pyqtSignal] def setReturnGeoValues(self, returnGeoValues: bool) -> None: ... def returnGeoValues(self) -> bool: ... def reading(self) -> QMagnetometerReading: ... @@ -648,7 +648,7 @@ class QTapSensor(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def returnDoubleTapEventsChanged(self, returnDoubleTapEvents: bool) -> None: ... + returnDoubleTapEventsChanged: typing.ClassVar[QtCore.pyqtSignal] def setReturnDoubleTapEvents(self, returnDoubleTapEvents: bool) -> None: ... def returnDoubleTapEvents(self) -> bool: ... def reading(self) -> QTapReading: ... @@ -702,7 +702,7 @@ class QRotationSensor(QSensor): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def hasZChanged(self, hasZ: bool) -> None: ... + hasZChanged: typing.ClassVar[QtCore.pyqtSignal] def setHasZ(self, hasZ: bool) -> None: ... def hasZ(self) -> bool: ... def reading(self) -> QRotationReading: ... diff --git a/PyQt5-stubs/QtSerialPort.pyi b/PyQt5-stubs/QtSerialPort.pyi index 607e7f50..b6512581 100644 --- a/PyQt5-stubs/QtSerialPort.pyi +++ b/PyQt5-stubs/QtSerialPort.pyi @@ -220,22 +220,22 @@ class QSerialPort(QtCore.QIODevice): @typing.overload def __init__(self, info: 'QSerialPortInfo', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def errorOccurred(self, error: 'QSerialPort.SerialPortError') -> None: ... - def breakEnabledChanged(self, set: bool) -> None: ... + errorOccurred: typing.ClassVar[QtCore.pyqtSignal] + breakEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] def isBreakEnabled(self) -> bool: ... def handle(self) -> int: ... def writeData(self, data: bytes) -> int: ... def readLineData(self, maxlen: int) -> bytes: ... def readData(self, maxlen: int) -> bytes: ... - def settingsRestoredOnCloseChanged(self, restore: bool) -> None: ... - def requestToSendChanged(self, set: bool) -> None: ... - def dataTerminalReadyChanged(self, set: bool) -> None: ... - def dataErrorPolicyChanged(self, policy: 'QSerialPort.DataErrorPolicy') -> None: ... - def flowControlChanged(self, flow: 'QSerialPort.FlowControl') -> None: ... - def stopBitsChanged(self, stopBits: 'QSerialPort.StopBits') -> None: ... - def parityChanged(self, parity: 'QSerialPort.Parity') -> None: ... - def dataBitsChanged(self, dataBits: 'QSerialPort.DataBits') -> None: ... - def baudRateChanged(self, baudRate: int, directions: typing.Union['QSerialPort.Directions', 'QSerialPort.Direction']) -> None: ... + settingsRestoredOnCloseChanged: typing.ClassVar[QtCore.pyqtSignal] + requestToSendChanged: typing.ClassVar[QtCore.pyqtSignal] + dataTerminalReadyChanged: typing.ClassVar[QtCore.pyqtSignal] + dataErrorPolicyChanged: typing.ClassVar[QtCore.pyqtSignal] + flowControlChanged: typing.ClassVar[QtCore.pyqtSignal] + stopBitsChanged: typing.ClassVar[QtCore.pyqtSignal] + parityChanged: typing.ClassVar[QtCore.pyqtSignal] + dataBitsChanged: typing.ClassVar[QtCore.pyqtSignal] + baudRateChanged: typing.ClassVar[QtCore.pyqtSignal] def setBreakEnabled(self, enabled: bool = ...) -> bool: ... def sendBreak(self, duration: int = ...) -> bool: ... def waitForBytesWritten(self, msecs: int = ...) -> bool: ... @@ -247,10 +247,7 @@ class QSerialPort(QtCore.QIODevice): def setReadBufferSize(self, size: int) -> None: ... def readBufferSize(self) -> int: ... def clearError(self) -> None: ... - @typing.overload - def error(self) -> 'QSerialPort.SerialPortError': ... - @typing.overload - def error(self, serialPortError: 'QSerialPort.SerialPortError') -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def dataErrorPolicy(self) -> 'QSerialPort.DataErrorPolicy': ... def setDataErrorPolicy(self, policy: 'QSerialPort.DataErrorPolicy' = ...) -> bool: ... def atEnd(self) -> bool: ... diff --git a/PyQt5-stubs/QtSql.pyi b/PyQt5-stubs/QtSql.pyi index 160fcf4e..558e4ea9 100644 --- a/PyQt5-stubs/QtSql.pyi +++ b/PyQt5-stubs/QtSql.pyi @@ -213,10 +213,7 @@ class QSqlDriver(QtCore.QObject): def setNumericalPrecisionPolicy(self, precisionPolicy: 'QSql.NumericalPrecisionPolicy') -> None: ... def stripDelimiters(self, identifier: str, type: 'QSqlDriver.IdentifierType') -> str: ... def isIdentifierEscaped(self, identifier: str, type: 'QSqlDriver.IdentifierType') -> bool: ... - @typing.overload - def notification(self, name: str) -> None: ... - @typing.overload - def notification(self, name: str, source: 'QSqlDriver.NotificationSource', payload: typing.Any) -> None: ... + notification: typing.ClassVar[QtCore.pyqtSignal] def subscribedToNotifications(self) -> typing.List[str]: ... def unsubscribeFromNotification(self, name: str) -> bool: ... def subscribeToNotification(self, name: str) -> bool: ... @@ -560,10 +557,10 @@ class QSqlTableModel(QSqlQueryModel): def deleteRowFromTable(self, row: int) -> bool: ... def insertRowIntoTable(self, values: QSqlRecord) -> bool: ... def updateRowInTable(self, row: int, values: QSqlRecord) -> bool: ... - def beforeDelete(self, row: int) -> None: ... - def beforeUpdate(self, row: int, record: QSqlRecord) -> None: ... - def beforeInsert(self, record: QSqlRecord) -> None: ... - def primeInsert(self, row: int, record: QSqlRecord) -> None: ... + beforeDelete: typing.ClassVar[QtCore.pyqtSignal] + beforeUpdate: typing.ClassVar[QtCore.pyqtSignal] + beforeInsert: typing.ClassVar[QtCore.pyqtSignal] + primeInsert: typing.ClassVar[QtCore.pyqtSignal] def revertAll(self) -> None: ... def submitAll(self) -> bool: ... def revert(self) -> None: ... diff --git a/PyQt5-stubs/QtSvg.pyi b/PyQt5-stubs/QtSvg.pyi index 97d2b50b..608b3393 100644 --- a/PyQt5-stubs/QtSvg.pyi +++ b/PyQt5-stubs/QtSvg.pyi @@ -98,7 +98,7 @@ class QSvgRenderer(QtCore.QObject): def transformForElement(self, id: str) -> QtGui.QTransform: ... def setAspectRatioMode(self, mode: QtCore.Qt.AspectRatioMode) -> None: ... def aspectRatioMode(self) -> QtCore.Qt.AspectRatioMode: ... - def repaintNeeded(self) -> None: ... + repaintNeeded: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def render(self, p: QtGui.QPainter) -> None: ... @typing.overload diff --git a/PyQt5-stubs/QtWebChannel.pyi b/PyQt5-stubs/QtWebChannel.pyi index 4ff9b336..a4a5c73f 100644 --- a/PyQt5-stubs/QtWebChannel.pyi +++ b/PyQt5-stubs/QtWebChannel.pyi @@ -38,7 +38,7 @@ class QWebChannel(QtCore.QObject): def disconnectFrom(self, transport: 'QWebChannelAbstractTransport') -> None: ... def connectTo(self, transport: 'QWebChannelAbstractTransport') -> None: ... - def blockUpdatesChanged(self, block: bool) -> None: ... + blockUpdatesChanged: typing.ClassVar[QtCore.pyqtSignal] def setBlockUpdates(self, block: bool) -> None: ... def blockUpdates(self) -> bool: ... def deregisterObject(self, object: QtCore.QObject) -> None: ... @@ -51,5 +51,5 @@ class QWebChannelAbstractTransport(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def messageReceived(self, message: typing.Dict[str, typing.Union[QtCore.QJsonValue, QtCore.QJsonValue.Type, typing.Iterable[QtCore.QJsonValue], bool, int, float, None, str]], transport: 'QWebChannelAbstractTransport') -> None: ... + messageReceived: typing.ClassVar[QtCore.pyqtSignal] def sendMessage(self, message: typing.Dict[str, typing.Union[QtCore.QJsonValue, QtCore.QJsonValue.Type, typing.Iterable[QtCore.QJsonValue], bool, int, float, None, str]]) -> None: ... diff --git a/PyQt5-stubs/QtWebEngine.pyi b/PyQt5-stubs/QtWebEngine.pyi index 7b3c7fe0..856edf88 100644 --- a/PyQt5-stubs/QtWebEngine.pyi +++ b/PyQt5-stubs/QtWebEngine.pyi @@ -61,29 +61,29 @@ class QQuickWebEngineProfile(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def presentNotification(self, notification: QtWebEngineCore.QWebEngineNotification) -> None: ... - def downloadPathChanged(self) -> None: ... - def useForGlobalCertificateVerificationChanged(self) -> None: ... + presentNotification: typing.ClassVar[QtCore.pyqtSignal] + downloadPathChanged: typing.ClassVar[QtCore.pyqtSignal] + useForGlobalCertificateVerificationChanged: typing.ClassVar[QtCore.pyqtSignal] def clientCertificateStore(self) -> QtWebEngineCore.QWebEngineClientCertificateStore: ... def setDownloadPath(self, path: str) -> None: ... def downloadPath(self) -> str: ... def isUsedForGlobalCertificateVerification(self) -> bool: ... def setUseForGlobalCertificateVerification(self, b: bool) -> None: ... - def spellCheckEnabledChanged(self) -> None: ... - def spellCheckLanguagesChanged(self) -> None: ... + spellCheckEnabledChanged: typing.ClassVar[QtCore.pyqtSignal] + spellCheckLanguagesChanged: typing.ClassVar[QtCore.pyqtSignal] def isSpellCheckEnabled(self) -> bool: ... def setSpellCheckEnabled(self, enabled: bool) -> None: ... def spellCheckLanguages(self) -> typing.List[str]: ... def setSpellCheckLanguages(self, languages: typing.Iterable[str]) -> None: ... - def httpAcceptLanguageChanged(self) -> None: ... - def httpCacheMaximumSizeChanged(self) -> None: ... - def persistentCookiesPolicyChanged(self) -> None: ... - def httpCacheTypeChanged(self) -> None: ... - def httpUserAgentChanged(self) -> None: ... - def cachePathChanged(self) -> None: ... - def persistentStoragePathChanged(self) -> None: ... - def offTheRecordChanged(self) -> None: ... - def storageNameChanged(self) -> None: ... + httpAcceptLanguageChanged: typing.ClassVar[QtCore.pyqtSignal] + httpCacheMaximumSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + persistentCookiesPolicyChanged: typing.ClassVar[QtCore.pyqtSignal] + httpCacheTypeChanged: typing.ClassVar[QtCore.pyqtSignal] + httpUserAgentChanged: typing.ClassVar[QtCore.pyqtSignal] + cachePathChanged: typing.ClassVar[QtCore.pyqtSignal] + persistentStoragePathChanged: typing.ClassVar[QtCore.pyqtSignal] + offTheRecordChanged: typing.ClassVar[QtCore.pyqtSignal] + storageNameChanged: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def defaultProfile() -> 'QQuickWebEngineProfile': ... def clearHttpCache(self) -> None: ... @@ -138,12 +138,12 @@ class QQuickWebEngineScript(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def timerEvent(self, e: QtCore.QTimerEvent) -> None: ... - def runOnSubframesChanged(self, on: bool) -> None: ... - def worldIdChanged(self, scriptWorldId: 'QQuickWebEngineScript.ScriptWorldId') -> None: ... - def injectionPointChanged(self, injectionPoint: 'QQuickWebEngineScript.InjectionPoint') -> None: ... - def sourceCodeChanged(self, code: str) -> None: ... - def sourceUrlChanged(self, url: QtCore.QUrl) -> None: ... - def nameChanged(self, name: str) -> None: ... + runOnSubframesChanged: typing.ClassVar[QtCore.pyqtSignal] + worldIdChanged: typing.ClassVar[QtCore.pyqtSignal] + injectionPointChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceCodeChanged: typing.ClassVar[QtCore.pyqtSignal] + sourceUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + nameChanged: typing.ClassVar[QtCore.pyqtSignal] def setRunOnSubframes(self, on: bool) -> None: ... def setWorldId(self, scriptWorldId: 'QQuickWebEngineScript.ScriptWorldId') -> None: ... def setInjectionPoint(self, injectionPoint: 'QQuickWebEngineScript.InjectionPoint') -> None: ... diff --git a/PyQt5-stubs/QtWebEngineCore.pyi b/PyQt5-stubs/QtWebEngineCore.pyi index 4fd28480..af38c5f6 100644 --- a/PyQt5-stubs/QtWebEngineCore.pyi +++ b/PyQt5-stubs/QtWebEngineCore.pyi @@ -65,8 +65,8 @@ class QWebEngineCookieStore(QtCore.QObject): def __init__(self, a0: 'QWebEngineCookieStore.FilterRequest') -> None: ... def setCookieFilter(self, filterCallback: typing.Optional[typing.Callable[[FilterRequest], bool]] = ...) -> None: ... - def cookieRemoved(self, cookie: QtNetwork.QNetworkCookie) -> None: ... - def cookieAdded(self, cookie: QtNetwork.QNetworkCookie) -> None: ... + cookieRemoved: typing.ClassVar[QtCore.pyqtSignal] + cookieAdded: typing.ClassVar[QtCore.pyqtSignal] def loadAllCookies(self) -> None: ... def deleteAllCookies(self) -> None: ... def deleteSessionCookies(self) -> None: ... @@ -117,7 +117,7 @@ class QWebEngineHttpRequest(sip.simplewrapper): class QWebEngineNotification(QtCore.QObject): - def closed(self) -> None: ... + closed: typing.ClassVar[QtCore.pyqtSignal] def close(self) -> None: ... def click(self) -> None: ... def show(self) -> None: ... diff --git a/PyQt5-stubs/QtWebEngineWidgets.pyi b/PyQt5-stubs/QtWebEngineWidgets.pyi index fe699fc7..34a50da8 100644 --- a/PyQt5-stubs/QtWebEngineWidgets.pyi +++ b/PyQt5-stubs/QtWebEngineWidgets.pyi @@ -312,7 +312,7 @@ class QWebEngineDownloadItem(QtCore.QObject): def suggestedFileName(self) -> str: ... def page(self) -> 'QWebEnginePage': ... def isSavePageDownload(self) -> bool: ... - def isPausedChanged(self, isPaused: bool) -> None: ... + isPausedChanged: typing.ClassVar[QtCore.pyqtSignal] def resume(self) -> None: ... def pause(self) -> None: ... def isPaused(self) -> bool: ... @@ -322,9 +322,9 @@ class QWebEngineDownloadItem(QtCore.QObject): def setSavePageFormat(self, format: 'QWebEngineDownloadItem.SavePageFormat') -> None: ... def savePageFormat(self) -> 'QWebEngineDownloadItem.SavePageFormat': ... def mimeType(self) -> str: ... - def downloadProgress(self, bytesReceived: int, bytesTotal: int) -> None: ... - def stateChanged(self, state: 'QWebEngineDownloadItem.DownloadState') -> None: ... - def finished(self) -> None: ... + downloadProgress: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + finished: typing.ClassVar[QtCore.pyqtSignal] def cancel(self) -> None: ... def accept(self) -> None: ... def isFinished(self) -> bool: ... @@ -594,22 +594,22 @@ class QWebEnginePage(QtCore.QObject): @typing.overload def __init__(self, profile: 'QWebEngineProfile', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def renderProcessPidChanged(self, pid: int) -> None: ... + renderProcessPidChanged: typing.ClassVar[QtCore.pyqtSignal] def renderProcessPid(self) -> int: ... - def findTextFinished(self, result: QtWebEngineCore.QWebEngineFindTextResult) -> None: ... - def recommendedStateChanged(self, state: 'QWebEnginePage.LifecycleState') -> None: ... - def lifecycleStateChanged(self, state: 'QWebEnginePage.LifecycleState') -> None: ... - def visibleChanged(self, visible: bool) -> None: ... + findTextFinished: typing.ClassVar[QtCore.pyqtSignal] + recommendedStateChanged: typing.ClassVar[QtCore.pyqtSignal] + lifecycleStateChanged: typing.ClassVar[QtCore.pyqtSignal] + visibleChanged: typing.ClassVar[QtCore.pyqtSignal] def setVisible(self, visible: bool) -> None: ... def isVisible(self) -> bool: ... def recommendedState(self) -> 'QWebEnginePage.LifecycleState': ... def setLifecycleState(self, state: 'QWebEnginePage.LifecycleState') -> None: ... def lifecycleState(self) -> 'QWebEnginePage.LifecycleState': ... def setUrlRequestInterceptor(self, interceptor: QtWebEngineCore.QWebEngineUrlRequestInterceptor) -> None: ... - def printRequested(self) -> None: ... - def selectClientCertificate(self, clientCertSelection: QWebEngineClientCertificateSelection) -> None: ... - def registerProtocolHandlerRequested(self, request: QtWebEngineCore.QWebEngineRegisterProtocolHandlerRequest) -> None: ... - def quotaRequested(self, quotaRequest: QtWebEngineCore.QWebEngineQuotaRequest) -> None: ... + printRequested: typing.ClassVar[QtCore.pyqtSignal] + selectClientCertificate: typing.ClassVar[QtCore.pyqtSignal] + registerProtocolHandlerRequested: typing.ClassVar[QtCore.pyqtSignal] + quotaRequested: typing.ClassVar[QtCore.pyqtSignal] def devToolsPage(self) -> 'QWebEnginePage': ... def setDevToolsPage(self, page: 'QWebEnginePage') -> None: ... def inspectedPage(self) -> 'QWebEnginePage': ... @@ -618,12 +618,12 @@ class QWebEnginePage(QtCore.QObject): def print(self, printer: QtPrintSupport.QPrinter, resultCallback: typing.Callable[[bool], None]) -> None: ... def save(self, filePath: str, format: QWebEngineDownloadItem.SavePageFormat = ...) -> None: ... def replaceMisspelledWord(self, replacement: str) -> None: ... - def pdfPrintingFinished(self, filePath: str, success: bool) -> None: ... - def recentlyAudibleChanged(self, recentlyAudible: bool) -> None: ... - def audioMutedChanged(self, muted: bool) -> None: ... - def contentsSizeChanged(self, size: QtCore.QSizeF) -> None: ... - def scrollPositionChanged(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def iconChanged(self, icon: QtGui.QIcon) -> None: ... + pdfPrintingFinished: typing.ClassVar[QtCore.pyqtSignal] + recentlyAudibleChanged: typing.ClassVar[QtCore.pyqtSignal] + audioMutedChanged: typing.ClassVar[QtCore.pyqtSignal] + contentsSizeChanged: typing.ClassVar[QtCore.pyqtSignal] + scrollPositionChanged: typing.ClassVar[QtCore.pyqtSignal] + iconChanged: typing.ClassVar[QtCore.pyqtSignal] def contextMenuData(self) -> QWebEngineContextMenuData: ... @typing.overload def printToPdf(self, filePath: str, pageLayout: QtGui.QPageLayout = ...) -> None: ... @@ -635,8 +635,8 @@ class QWebEnginePage(QtCore.QObject): def contentsSize(self) -> QtCore.QSizeF: ... def scrollPosition(self) -> QtCore.QPointF: ... def icon(self) -> QtGui.QIcon: ... - def renderProcessTerminated(self, terminationStatus: 'QWebEnginePage.RenderProcessTerminationStatus', exitCode: int) -> None: ... - def fullScreenRequested(self, fullScreenRequest: QWebEngineFullScreenRequest) -> None: ... + renderProcessTerminated: typing.ClassVar[QtCore.pyqtSignal] + fullScreenRequested: typing.ClassVar[QtCore.pyqtSignal] def setBackgroundColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... def backgroundColor(self) -> QtGui.QColor: ... def acceptNavigationRequest(self, url: QtCore.QUrl, type: 'QWebEnginePage.NavigationType', isMainFrame: bool) -> bool: ... @@ -654,20 +654,20 @@ class QWebEnginePage(QtCore.QObject): def javaScriptAlert(self, securityOrigin: QtCore.QUrl, msg: str) -> None: ... def chooseFiles(self, mode: 'QWebEnginePage.FileSelectionMode', oldFiles: typing.Iterable[str], acceptedMimeTypes: typing.Iterable[str]) -> typing.List[str]: ... def createWindow(self, type: 'QWebEnginePage.WebWindowType') -> 'QWebEnginePage': ... - def iconUrlChanged(self, url: QtCore.QUrl) -> None: ... - def urlChanged(self, url: QtCore.QUrl) -> None: ... - def titleChanged(self, title: str) -> None: ... - def proxyAuthenticationRequired(self, requestUrl: QtCore.QUrl, authenticator: QtNetwork.QAuthenticator, proxyHost: str) -> None: ... - def authenticationRequired(self, requestUrl: QtCore.QUrl, authenticator: QtNetwork.QAuthenticator) -> None: ... - def featurePermissionRequestCanceled(self, securityOrigin: QtCore.QUrl, feature: 'QWebEnginePage.Feature') -> None: ... - def featurePermissionRequested(self, securityOrigin: QtCore.QUrl, feature: 'QWebEnginePage.Feature') -> None: ... - def windowCloseRequested(self) -> None: ... - def geometryChangeRequested(self, geom: QtCore.QRect) -> None: ... - def selectionChanged(self) -> None: ... - def linkHovered(self, url: str) -> None: ... - def loadFinished(self, ok: bool) -> None: ... - def loadProgress(self, progress: int) -> None: ... - def loadStarted(self) -> None: ... + iconUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + urlChanged: typing.ClassVar[QtCore.pyqtSignal] + titleChanged: typing.ClassVar[QtCore.pyqtSignal] + proxyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + authenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + featurePermissionRequestCanceled: typing.ClassVar[QtCore.pyqtSignal] + featurePermissionRequested: typing.ClassVar[QtCore.pyqtSignal] + windowCloseRequested: typing.ClassVar[QtCore.pyqtSignal] + geometryChangeRequested: typing.ClassVar[QtCore.pyqtSignal] + selectionChanged: typing.ClassVar[QtCore.pyqtSignal] + linkHovered: typing.ClassVar[QtCore.pyqtSignal] + loadFinished: typing.ClassVar[QtCore.pyqtSignal] + loadProgress: typing.ClassVar[QtCore.pyqtSignal] + loadStarted: typing.ClassVar[QtCore.pyqtSignal] def settings(self) -> 'QWebEngineSettings': ... @typing.overload def runJavaScript(self, scriptSource: str, worldId: int) -> None: ... @@ -751,7 +751,7 @@ class QWebEngineProfile(QtCore.QObject): def cookieStore(self) -> QtWebEngineCore.QWebEngineCookieStore: ... def httpAcceptLanguage(self) -> str: ... def setHttpAcceptLanguage(self, httpAcceptLanguage: str) -> None: ... - def downloadRequested(self, download: QWebEngineDownloadItem) -> None: ... + downloadRequested: typing.ClassVar[QtCore.pyqtSignal] @staticmethod def defaultProfile() -> 'QWebEngineProfile': ... def scripts(self) -> 'QWebEngineScriptCollection': ... @@ -964,21 +964,21 @@ class QWebEngineView(QtWidgets.QWidget): def dragMoveEvent(self, e: QtGui.QDragMoveEvent) -> None: ... def dragLeaveEvent(self, e: QtGui.QDragLeaveEvent) -> None: ... def dragEnterEvent(self, e: QtGui.QDragEnterEvent) -> None: ... - def iconChanged(self, a0: QtGui.QIcon) -> None: ... + iconChanged: typing.ClassVar[QtCore.pyqtSignal] def icon(self) -> QtGui.QIcon: ... def hideEvent(self, a0: QtGui.QHideEvent) -> None: ... def showEvent(self, a0: QtGui.QShowEvent) -> None: ... def event(self, a0: QtCore.QEvent) -> bool: ... def contextMenuEvent(self, a0: QtGui.QContextMenuEvent) -> None: ... def createWindow(self, type: QWebEnginePage.WebWindowType) -> 'QWebEngineView': ... - def renderProcessTerminated(self, terminationStatus: QWebEnginePage.RenderProcessTerminationStatus, exitCode: int) -> None: ... - def iconUrlChanged(self, a0: QtCore.QUrl) -> None: ... - def urlChanged(self, a0: QtCore.QUrl) -> None: ... - def selectionChanged(self) -> None: ... - def titleChanged(self, title: str) -> None: ... - def loadFinished(self, a0: bool) -> None: ... - def loadProgress(self, progress: int) -> None: ... - def loadStarted(self) -> None: ... + renderProcessTerminated: typing.ClassVar[QtCore.pyqtSignal] + iconUrlChanged: typing.ClassVar[QtCore.pyqtSignal] + urlChanged: typing.ClassVar[QtCore.pyqtSignal] + selectionChanged: typing.ClassVar[QtCore.pyqtSignal] + titleChanged: typing.ClassVar[QtCore.pyqtSignal] + loadFinished: typing.ClassVar[QtCore.pyqtSignal] + loadProgress: typing.ClassVar[QtCore.pyqtSignal] + loadStarted: typing.ClassVar[QtCore.pyqtSignal] def reload(self) -> None: ... def forward(self) -> None: ... def back(self) -> None: ... diff --git a/PyQt5-stubs/QtWebSockets.pyi b/PyQt5-stubs/QtWebSockets.pyi index bdb0d168..b331369a 100644 --- a/PyQt5-stubs/QtWebSockets.pyi +++ b/PyQt5-stubs/QtWebSockets.pyi @@ -58,20 +58,20 @@ class QWebSocket(QtCore.QObject): def maxAllowedIncomingFrameSize(self) -> int: ... def setMaxAllowedIncomingFrameSize(self, maxAllowedIncomingFrameSize: int) -> None: ... def bytesToWrite(self) -> int: ... - def preSharedKeyAuthenticationRequired(self, authenticator: QtNetwork.QSslPreSharedKeyAuthenticator) -> None: ... - def sslErrors(self, errors: typing.Iterable[QtNetwork.QSslError]) -> None: ... - def bytesWritten(self, bytes: int) -> None: ... - def pong(self, elapsedTime: int, payload: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def binaryMessageReceived(self, message: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def textMessageReceived(self, message: str) -> None: ... - def binaryFrameReceived(self, frame: typing.Union[QtCore.QByteArray, bytes, bytearray], isLastFrame: bool) -> None: ... - def textFrameReceived(self, frame: str, isLastFrame: bool) -> None: ... - def readChannelFinished(self) -> None: ... - def proxyAuthenticationRequired(self, proxy: QtNetwork.QNetworkProxy, pAuthenticator: QtNetwork.QAuthenticator) -> None: ... - def stateChanged(self, state: QtNetwork.QAbstractSocket.SocketState) -> None: ... - def disconnected(self) -> None: ... - def connected(self) -> None: ... - def aboutToClose(self) -> None: ... + preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + sslErrors: typing.ClassVar[QtCore.pyqtSignal] + bytesWritten: typing.ClassVar[QtCore.pyqtSignal] + pong: typing.ClassVar[QtCore.pyqtSignal] + binaryMessageReceived: typing.ClassVar[QtCore.pyqtSignal] + textMessageReceived: typing.ClassVar[QtCore.pyqtSignal] + binaryFrameReceived: typing.ClassVar[QtCore.pyqtSignal] + textFrameReceived: typing.ClassVar[QtCore.pyqtSignal] + readChannelFinished: typing.ClassVar[QtCore.pyqtSignal] + proxyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + stateChanged: typing.ClassVar[QtCore.pyqtSignal] + disconnected: typing.ClassVar[QtCore.pyqtSignal] + connected: typing.ClassVar[QtCore.pyqtSignal] + aboutToClose: typing.ClassVar[QtCore.pyqtSignal] def ping(self, payload: typing.Union[QtCore.QByteArray, bytes, bytearray] = ...) -> None: ... @typing.overload def open(self, url: QtCore.QUrl) -> None: ... @@ -111,10 +111,7 @@ class QWebSocket(QtCore.QObject): def isValid(self) -> bool: ... def flush(self) -> bool: ... def errorString(self) -> str: ... - @typing.overload - def error(self) -> QtNetwork.QAbstractSocket.SocketError: ... - @typing.overload - def error(self, error: QtNetwork.QAbstractSocket.SocketError) -> None: ... + error: typing.ClassVar[QtCore.pyqtSignal] def abort(self) -> None: ... @@ -199,14 +196,14 @@ class QWebSocketServer(QtCore.QObject): def setHandshakeTimeout(self, msec: int) -> None: ... def nativeDescriptor(self) -> sip.voidptr: ... def setNativeDescriptor(self, descriptor: sip.voidptr) -> bool: ... - def preSharedKeyAuthenticationRequired(self, authenticator: QtNetwork.QSslPreSharedKeyAuthenticator) -> None: ... - def closed(self) -> None: ... - def sslErrors(self, errors: typing.Iterable[QtNetwork.QSslError]) -> None: ... - def peerVerifyError(self, error: QtNetwork.QSslError) -> None: ... - def newConnection(self) -> None: ... - def originAuthenticationRequired(self, pAuthenticator: QWebSocketCorsAuthenticator) -> None: ... - def serverError(self, closeCode: QWebSocketProtocol.CloseCode) -> None: ... - def acceptError(self, socketError: QtNetwork.QAbstractSocket.SocketError) -> None: ... + preSharedKeyAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + closed: typing.ClassVar[QtCore.pyqtSignal] + sslErrors: typing.ClassVar[QtCore.pyqtSignal] + peerVerifyError: typing.ClassVar[QtCore.pyqtSignal] + newConnection: typing.ClassVar[QtCore.pyqtSignal] + originAuthenticationRequired: typing.ClassVar[QtCore.pyqtSignal] + serverError: typing.ClassVar[QtCore.pyqtSignal] + acceptError: typing.ClassVar[QtCore.pyqtSignal] def handleConnection(self, socket: QtNetwork.QTcpSocket) -> None: ... def serverUrl(self) -> QtCore.QUrl: ... def supportedVersions(self) -> typing.List[QWebSocketProtocol.Version]: ... diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 92d28ffb..73377c7b 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -1515,10 +1515,10 @@ class QButtonGroup(QtCore.QObject): def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def idToggled(self, a0: int, a1: bool) -> None: ... - def idReleased(self, a0: int) -> None: ... - def idPressed(self, a0: int) -> None: ... - def idClicked(self, a0: int) -> None: ... + idToggled: typing.ClassVar[QtCore.pyqtSignal] + idReleased: typing.ClassVar[QtCore.pyqtSignal] + idPressed: typing.ClassVar[QtCore.pyqtSignal] + idClicked: typing.ClassVar[QtCore.pyqtSignal] buttonToggled: typing.ClassVar[QtCore.pyqtSignal] buttonReleased: typing.ClassVar[QtCore.pyqtSignal] buttonPressed: typing.ClassVar[QtCore.pyqtSignal] @@ -1810,8 +1810,8 @@ class QComboBox(QWidget): def placeholderText(self) -> str: ... def setPlaceholderText(self, placeholderText: str) -> None: ... - def textHighlighted(self, a0: str) -> None: ... - def textActivated(self, a0: str) -> None: ... + textHighlighted: typing.ClassVar[QtCore.pyqtSignal] + textActivated: typing.ClassVar[QtCore.pyqtSignal] def currentData(self, role: int = ...) -> typing.Any: ... @typing.overload def inputMethodQuery(self, a0: QtCore.Qt.InputMethodQuery) -> typing.Any: ... @@ -1832,10 +1832,7 @@ class QComboBox(QWidget): def focusOutEvent(self, e: QtGui.QFocusEvent) -> None: ... def focusInEvent(self, e: QtGui.QFocusEvent) -> None: ... def initStyleOption(self, option: 'QStyleOptionComboBox') -> None: ... - @typing.overload - def highlighted(self, index: int) -> None: ... - @typing.overload - def highlighted(self, a0: str) -> None: ... + highlighted: typing.ClassVar[QtCore.pyqtSignal] currentTextChanged: typing.ClassVar[QtCore.pyqtSignal] currentIndexChanged: typing.ClassVar[QtCore.pyqtSignal] activated: typing.ClassVar[QtCore.pyqtSignal] @@ -3478,10 +3475,10 @@ class QDesktopWidget(QWidget): def __init__(self) -> None: ... def resizeEvent(self, e: QtGui.QResizeEvent) -> None: ... - def primaryScreenChanged(self) -> None: ... - def screenCountChanged(self, a0: int) -> None: ... - def workAreaResized(self, a0: int) -> None: ... - def resized(self, a0: int) -> None: ... + primaryScreenChanged: typing.ClassVar[QtCore.pyqtSignal] + screenCountChanged: typing.ClassVar[QtCore.pyqtSignal] + workAreaResized: typing.ClassVar[QtCore.pyqtSignal] + resized: typing.ClassVar[QtCore.pyqtSignal] @typing.overload def availableGeometry(self, screen: int = ...) -> QtCore.QRect: ... @typing.overload @@ -5748,7 +5745,7 @@ class QGraphicsScene(QtCore.QObject): def setFocusOnTouch(self, enabled: bool) -> None: ... focusOnTouch: typing.ClassVar[QtCore.pyqtSignal] - def focusItemChanged(self, newFocus: QGraphicsItem, oldFocus: QGraphicsItem, reason: QtCore.Qt.FocusReason) -> None: ... + focusItemChanged: typing.ClassVar[QtCore.pyqtSignal] def setMinimumRenderSize(self, minSize: float) -> None: ... def minimumRenderSize(self) -> float: ... def sendEvent(self, item: QGraphicsItem, event: QtCore.QEvent) -> bool: ... @@ -5991,7 +5988,7 @@ class QGraphicsScale(QGraphicsTransform): yScaleChanged: typing.ClassVar[QtCore.pyqtSignal] xScaleChanged: typing.ClassVar[QtCore.pyqtSignal] scaleChanged: typing.ClassVar[QtCore.pyqtSignal] - def originChanged(self) -> None: ... + originChanged: typing.ClassVar[QtCore.pyqtSignal] def applyTo(self, matrix: QtGui.QMatrix4x4) -> None: ... def setZScale(self, a0: float) -> None: ... def zScale(self) -> float: ... @@ -6839,7 +6836,7 @@ class QLineEdit(QWidget): @typing.overload def __init__(self, contents: str, parent: typing.Optional[QWidget] = ...) -> None: ... - def inputRejected(self) -> None: ... + inputRejected: typing.ClassVar[QtCore.pyqtSignal] def selectionLength(self) -> int: ... def selectionEnd(self) -> int: ... @typing.overload @@ -7702,7 +7699,7 @@ class QMessageBox(QDialog): def setCheckBox(self, cb: QCheckBox) -> None: ... def textInteractionFlags(self) -> QtCore.Qt.TextInteractionFlags: ... def setTextInteractionFlags(self, flags: typing.Union[QtCore.Qt.TextInteractionFlags, QtCore.Qt.TextInteractionFlag]) -> None: ... - def buttonClicked(self, button: QAbstractButton) -> None: ... + buttonClicked: typing.ClassVar[QtCore.pyqtSignal] def buttonRole(self, button: QAbstractButton) -> 'QMessageBox.ButtonRole': ... def buttons(self) -> typing.List[QAbstractButton]: ... @typing.overload @@ -8536,7 +8533,7 @@ class QSpinBox(QAbstractSpinBox): def stepType(self) -> QAbstractSpinBox.StepType: ... def setDisplayIntegerBase(self, base: int) -> None: ... def displayIntegerBase(self) -> int: ... - def textChanged(self, a0: str) -> None: ... + textChanged: typing.ClassVar[QtCore.pyqtSignal] valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, val: int) -> None: ... def event(self, e: QtCore.QEvent) -> bool: ... @@ -8565,7 +8562,7 @@ class QDoubleSpinBox(QAbstractSpinBox): def setStepType(self, stepType: QAbstractSpinBox.StepType) -> None: ... def stepType(self) -> QAbstractSpinBox.StepType: ... - def textChanged(self, a0: str) -> None: ... + textChanged: typing.ClassVar[QtCore.pyqtSignal] valueChanged: typing.ClassVar[QtCore.pyqtSignal] def setValue(self, val: float) -> None: ... def fixup(self, str: str) -> str: ... diff --git a/signal_fixer.py b/signal_fixer.py index 6524f9eb..12e86edc 100644 --- a/signal_fixer.py +++ b/signal_fixer.py @@ -1,13 +1,15 @@ """Script that will check stub files and fix signal annotations.""" import importlib import os -from typing import List, Optional, Union +from types import ModuleType +from typing import List, Optional, Union, cast, Iterable import libcst as cst + from PyQt5 import QtCore -def is_signal(module: object, cls_name: str, func_name: str) -> bool: +def is_signal(module: ModuleType, cls_name: str, func_name: str) -> bool: """Check if a method of the given Qt class is a signal.""" cls = getattr(module, cls_name) try: @@ -25,7 +27,7 @@ def __init__(self, mod_name: str): super().__init__() self._last_class: List[cst.ClassDef] = [] self._fixed_signals: List[str] = [] - self._module = importlib.import_module(f"PyQt5.{mod_name}") + self._module: ModuleType = importlib.import_module(f"PyQt5.{mod_name}") def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: """Put a class on top of the stack when visiting.""" @@ -34,7 +36,11 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: def leave_FunctionDef( self, original_node: cst.FunctionDef, _: cst.FunctionDef - ) -> Union[cst.BaseStatement, cst.FlattenSentinel[cst.BaseStatement], cst.RemovalSentinel]: + ) -> Union[ + cst.BaseStatement, + cst.FlattenSentinel[cst.BaseStatement], + cst.RemovalSentinel, + ]: """Leave the method and change signature if a signal.""" if not self._last_class: return original_node @@ -45,24 +51,46 @@ def leave_FunctionDef( if is_signal(self._module, self._last_class[-1].name.value, f_name): full_name = f"{self._last_class[-1].name.value}.{f_name}" if full_name in self._fixed_signals: - # Handle the use-case of overloaded signals, i.e.: - # QComboBox.highlighted + # Handle the use-case of overloaded signals, that are defined + # multiple time because of their different signal arguments + # i.e.: QComboBox.highlighted return cst.RemovalSentinel.REMOVE self._fixed_signals.append(full_name) - return cst.parse_statement(f"{f_name}: typing.ClassVar[QtCore.pyqtSignal]") + stmt = f"{f_name}: typing.ClassVar[QtCore.pyqtSignal]" + node = cst.parse_statement(stmt) + if original_node.leading_lines: + # Copy the leading lines and return them with a + # FlattenSentinel. Just adding a newline char results in an + # indented EmptyLine which isn't bad but clutters the diff + # unnecessarily + empty_nodes = [ + line.deep_clone() for line in original_node.leading_lines + ] + return cst.FlattenSentinel( + cast(Iterable[cst.BaseStatement], [*empty_nodes, node]) + ) + return node return original_node def leave_ClassDef( self, original_node: cst.ClassDef, updated_node: cst.ClassDef - ) -> Union[cst.BaseStatement, cst.FlattenSentinel[cst.BaseStatement], cst.RemovalSentinel]: + ) -> Union[ + cst.BaseStatement, + cst.FlattenSentinel[cst.BaseStatement], + cst.RemovalSentinel, + ]: """Remove a class from the stack and return the updated node.""" self._last_class.pop() return updated_node -if __name__ == '__main__': +if __name__ == "__main__": for file in os.listdir("PyQt5-stubs"): - if file.startswith("QtWebKit") or file in ["QtX11Extras.pyi", "sip.pyi", "__init__.pyi"]: + if file.startswith("QtWebKit") or file in [ + "QtX11Extras.pyi", + "sip.pyi", + "__init__.pyi", + ]: continue print("Fixing signals in " + file) path = os.path.join("PyQt5-stubs", file) From 491828859dfe72e492acdb64a4bec7d08a1ca7b6 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Tue, 24 Aug 2021 20:51:42 +0200 Subject: [PATCH 051/421] Fix for QGeoPositionInfoSource.error() --- PyQt5-stubs/QtPositioning.pyi | 2 +- signal_fixer.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/PyQt5-stubs/QtPositioning.pyi b/PyQt5-stubs/QtPositioning.pyi index 2923e553..43c5a379 100644 --- a/PyQt5-stubs/QtPositioning.pyi +++ b/PyQt5-stubs/QtPositioning.pyi @@ -418,7 +418,7 @@ class QGeoPositionInfoSource(QtCore.QObject): def stopUpdates(self) -> None: ... def startUpdates(self) -> None: ... # If the error signal is real, it isn't accessible in PyQt 5.15.1 - error: typing.ClassVar[QtCore.pyqtSignal] + def error(self) -> 'QGeoPositionInfoSource.Error': ... @staticmethod def availableSources() -> typing.List[str]: ... @typing.overload diff --git a/signal_fixer.py b/signal_fixer.py index 12e86edc..dbd5cf29 100644 --- a/signal_fixer.py +++ b/signal_fixer.py @@ -11,6 +11,9 @@ def is_signal(module: ModuleType, cls_name: str, func_name: str) -> bool: """Check if a method of the given Qt class is a signal.""" + if cls_name == "QGeoPositionInfoSource" and func_name == "error": + # this is a fix for the broken error method. + return False cls = getattr(module, cls_name) try: func = getattr(cls, func_name) From eb676aa2a60331c2a638ecbdbcd1e81ece239892 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Tue, 24 Aug 2021 20:58:15 +0200 Subject: [PATCH 052/421] Added change log. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b68289d..e252b890 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * [#138](https://github.com/python-qt-tools/PyQt5-stubs/pull/138) update to PyQt5 5.15.3 * [#144](https://github.com/python-qt-tools/PyQt5-stubs/pull/144) add `QTreeWidgetItem.__lt__()` to allow sorting of items in a QTreeWidget * [#143](https://github.com/python-qt-tools/PyQt5-stubs/pull/143) make `bytes(QByteArray())` valid by incorrectly adding `.__bytes__()` until a proper solution is developed upstream +* [#162](https://github.com/python-qt-tools/PyQt5-stubs/pull/162) fixes all signals ## 5.15.2.0 From 40589d4748c25e2fe2bbf3cfc2b4a7f816f77355 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 27 Aug 2021 23:44:08 +0200 Subject: [PATCH 053/421] Can parse pyi and check for enum class and its methods --- .../qflags/generate_qflags_stubs_and_tests.py | 58 ++---- tests/qflags/qflag_stubs_helper.py | 165 ++++++++++++++++++ 2 files changed, 179 insertions(+), 44 deletions(-) create mode 100644 tests/qflags/qflag_stubs_helper.py diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index a8e2b576..497fa1cb 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -1,4 +1,4 @@ -from typing import List, Tuple, Dict +from typing import List, Tuple, Dict, Union, Any import dataclasses import functools @@ -48,7 +48,9 @@ class QFlagLocationInfo: # list of (module_name, module_path) module_info: List[ Tuple[str, str] ] -def json_encode_qflaglocationinfo(flag_loc_info: object) -> object: + +def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[str, Any]]: + '''Encore the QFlagClassLoationInfo into a format suitable for json export (a dict)''' if not isinstance(flag_loc_info, QFlagLocationInfo): # oups, we don't know how to encode that return flag_loc_info @@ -110,6 +112,7 @@ def identify_qflag_location(fname_grep_result: str, return parsed_qflags + def group_qflags(qflag_location: List[QFlagLocationInfo] ) -> Dict[str, List[QFlagLocationInfo]]: '''Group the QFlags into the following groups: * one_flag_one_module: this flag is present once in one module exactly. @@ -137,6 +140,7 @@ def group_qflags(qflag_location: List[QFlagLocationInfo] ) -> Dict[str, List[QFl return d + def extract_qflags_to_process(qflags_modules_analysis_json: str, qflags_to_process_json: str, ) -> None: @@ -183,14 +187,15 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str) -> bool: '''Read the qflags to process from the json file Process one qflag, by either: - * identifying that this flag is already processed and moving the flag to qflags_done - * identifying a reason why this flag can't be processed and moving the flag to qflags_error + * identifying that this flag is already processed and add the flag to qflags_alraedy_done + * identifying a reason why this flag can't be processed and adding the flag to qflags_processed_error * performing the qflag ajustment process: * generate a test file for this qflag usage * change the .pyi module for this qflag for supporting all the qflag operations * run pytest on the result * run mypy on the result * run the tox on result + * add the flag to qflag_processed_done Return True when all flags have been processed ''' @@ -219,47 +224,8 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str) -> bool: flag_info.module_info[0][0] if len(flag_info.module_info) else '' )) - with open(flag_info.module_info[0][1], encoding='utf8') as f: - mod_content = f.read() - - assert mod_content.count('class %s(' % flag_info.qflag_class) == 1 - assert mod_content.count('class %s(' % flag_info.qflag_enum) == 1 - - mod_lines = mod_content.split('\n') - - # find fqn of the class - qflag_class_lines = simple_class_finder(mod_lines, flag_info.qflag_class) - qflag_enum_lines = simple_class_finder(mod_lines, flag_info.qflag_enum) - - ''' -Operation to perform: - -On the enum class, add two methods: - class KeyboardModifier(int): -+ def __or__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... # type: ignore[override] -+ def __ror__ (self, other: int) -> 'Qt.KeyboardModifiers': ... # type: ignore[override, misc] + check_qflag_in_module(flag_info) -On the qflag class, add one more argument to __init__() -- def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: ... -+ def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ... - -Possibly, remove the __init__() with only int argument if it exists - -Add more methods: - def __or__ (self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - def __and__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - def __xor__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - def __ror__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... - def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... - def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... -''' - # find the method content of the class - - # check that the mandatory operators are present or missing - # generate the filename - # if all conditions are met, declare the flag as already done - # if not, create the missing methods - # generate the test file # run tox # mark the test as done @@ -271,6 +237,10 @@ def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... json.dump(result, f, indent=4) + + + + @functools.lru_cache(maxsize=1) def read_qflag_test_template() -> Tuple[List[str], List[str], List[str]]: '''Return the source of template for generating qflags test. diff --git a/tests/qflags/qflag_stubs_helper.py b/tests/qflags/qflag_stubs_helper.py new file mode 100644 index 00000000..55979e60 --- /dev/null +++ b/tests/qflags/qflag_stubs_helper.py @@ -0,0 +1,165 @@ +from typing import Optional, List +from enum import Enum + +try: + import libcst as cst + import libcst.matchers as matchers +except ImportError: + raise ImportError('You need libcst to run the code analysis and transform\n' + 'Please run the command:\n\tpython -m pip install libcst') + +def check_qflag_in_module(flag_info: 'QFlagLocationInfo') -> None: + ''' + Check that the QFlag enum+class are present in the module and check whether they support + all the advanced QFlag operations. + + If they do not, add the missing information by performing code transformation and saving the result. + + Returns: + * QFlag operations already present + * QFlag operations were missing, now added + * QFlag operations partially missing, now added. + + Raise ValueError if something goes wrong. + + The QFlag operations are: + + On the enum class, add two methods: + class KeyboardModifier(int): + + def __or__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... # type: ignore[override] + + def __ror__ (self, other: int) -> 'Qt.KeyboardModifiers': ... # type: ignore[override, misc] + + On the qflag class, add one more argument to __init__() + - def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: ... + + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ... + + Possibly, remove the __init__() with only int argument if it exists + + Add more methods: + def __or__ (self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __and__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __xor__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __ror__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... +''' + try: + import libcst + except ImportError: + raise ImportError('You need libcst to run the code analysis and transform\n' + 'Please run the command:\n\tpython -m pip install libcst') + + mod_content = open('..\..\pyqt5-stubs\QtCore.pyi').read() + mod_cst = cst.parse_module(mod_content) + visitor = QFlagFinder('WindowState') + mod_cst.visit(visitor) + pass + +class MethodPresent(Enum): + Unset = 0 + All = 1 + Not = 2 + Partial = 3 + + +class QFlagFinder(cst.CSTVisitor): + + def __init__(self, enum_class: str) -> None: + super().__init__() + + # used internally to generate the full class name + self.full_name_stack: List[str] = [] + + # the class name we are looking for + self.enum_class_name = enum_class + + # the class full name + self.enum_class_full_name = '' + + # the node of the class, for further reference + self.enum_class_cst_node = None + + # when filled, set to one of the MethodPresent values + self.enum_methods_present = MethodPresent.Unset + + # set when enum_methods_present is set to partial, to add more contect information + self.error_msg = '' + + + def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: + self.full_name_stack.append( node.name.value ) + if node.name.value == self.enum_class_name: + # we found it + if self.enum_class_full_name != '': + raise ValueError('self.enum_class_full_name alraedy filled, can not setup a new value') + self.enum_class_full_name = '.'.join(self.full_name_stack) + self.enum_class_cst_node = node + + self.check_method_present(node) + return None + + def check_method_present(self, enum_node: cst.ClassDef) -> None: + '''Check if the class contains method __or__ and __ror__ with one argument''' + has_or = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__or__'))) + has_ror = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__ror__'))) + self.enum_methods_present = { + 0: MethodPresent.Not, + 1: MethodPresent.Partial, + 2: MethodPresent.All + }[len(has_or) + len(has_ror)] + + if self.enum_methods_present == MethodPresent.Partial: + if has_or: + args = ('__or__', '__ror__') + else: + args = ('__ror__', '__or__') + + self.error_msg += 'class %s, method %s present without method %s\n' % ((self.enum_class_full_name,)+args) + + def visit_FunctionDef(self, node: cst.FunctionDef) -> Optional[bool]: + self.full_name_stack.append( node.name.value ) + return None + + def leave_ClassDef(self, node: cst.ClassDef) -> None: + self.full_name_stack.pop() + + def leave_FunctionDef(self, node: cst.FunctionDef) -> None: + self.full_name_stack.pop() + + +import unittest +class TestMe(unittest.TestCase): + + def test1(self): + mod_cst = cst.parse_module(''' +class Toto: + + class Titi: + 'bla bla bla' + + def toto(self) -> None: ... + + @overload + def my_titi(self) -> str: ... + + + class QFlagExample: + def abd(self): ... + def __or__(self, other): ... + def __ror__(self, other): ... + ''') + visitor = QFlagFinder('Titi') + mod_cst.visit(visitor) + self.assertEqual(visitor.enum_class_full_name, 'Toto.Titi') + print(visitor.enum_class_cst_node) + + + visitor = QFlagFinder('QFlagExample') + mod_cst.visit(visitor) + self.assertEqual(visitor.enum_class_full_name, 'Toto.QFlagExample') + print(visitor.enum_class_cst_node) + + + + +check_qflag_in_module(None) \ No newline at end of file From 74a80661f74aceab5a32253b38bb34674e0a42ee Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 29 Aug 2021 10:53:48 +0200 Subject: [PATCH 054/421] work in progress: check for all method presence done --- .../qflags/generate_qflags_stubs_and_tests.py | 8 +- tests/qflags/qflag_stubs_helper.py | 114 ++++++++++++++++-- 2 files changed, 109 insertions(+), 13 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 497fa1cb..d0d047e5 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -224,10 +224,12 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str) -> bool: flag_info.module_info[0][0] if len(flag_info.module_info) else '' )) - check_qflag_in_module(flag_info) + result, error_msg = check_qflag_in_module(flag_info) - # run tox - # mark the test as done + # if result is failed, add error message and move to next flag + # if result succeeds: + # run tox + # mark the test as done # if there are more flags to process, return False # if all flags are processed, return True diff --git a/tests/qflags/qflag_stubs_helper.py b/tests/qflags/qflag_stubs_helper.py index 55979e60..0c2de4b7 100644 --- a/tests/qflags/qflag_stubs_helper.py +++ b/tests/qflags/qflag_stubs_helper.py @@ -1,4 +1,4 @@ -from typing import Optional, List +from typing import Optional, List, Tuple from enum import Enum try: @@ -8,7 +8,13 @@ raise ImportError('You need libcst to run the code analysis and transform\n' 'Please run the command:\n\tpython -m pip install libcst') -def check_qflag_in_module(flag_info: 'QFlagLocationInfo') -> None: +class QFlagCheckResult(Enum): + CodeModifiedSuccessfully = 0 + CodeAlreadyModified = 1 + ErrorDuringProcessing = 2 + + +def check_qflag_in_module(flag_info: 'QFlagLocationInfo') -> Tuple[QFlagCheckResult, str]: ''' Check that the QFlag enum+class are present in the module and check whether they support all the advanced QFlag operations. @@ -42,6 +48,19 @@ def __xor__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifi def __ror__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + + Returns a tuple of (result, error_msg): + * CodeModifiedSuccessfully: + All modifications to the code of the module have been performed successfully + + * CodeAlreadyModified: + All modifications to the code were already done, no processing done. + + * ErrorDuringProcessing: + Some error occured during the processing, such as some modifications were partially done, + clas not found, class found multiple times, ... + + The detail of the error is provided in the second argument of the return value. ''' try: import libcst @@ -51,9 +70,22 @@ def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... mod_content = open('..\..\pyqt5-stubs\QtCore.pyi').read() mod_cst = cst.parse_module(mod_content) - visitor = QFlagFinder('WindowState') + visitor = QFlagFinder('WindowState', 'WindowStates') mod_cst.visit(visitor) - pass + + if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): + # TODO: check also for existence of the test file + return (QFlagCheckResult.CodeAlreadyModified, visitor.error_msg) + + if visitor.error_msg: + return (QFlagCheckResult.ErrorDuringProcessing, visitor.error_msg) + + assert visitor.enum_methods_present == MethodPresent.Not + assert visitor.qflag_method_present == MethodPresent.Not + + # perform code modification + # generate test file + class MethodPresent(Enum): Unset = 0 @@ -64,7 +96,7 @@ class MethodPresent(Enum): class QFlagFinder(cst.CSTVisitor): - def __init__(self, enum_class: str) -> None: + def __init__(self, enum_class: str, qflag_class: str) -> None: super().__init__() # used internally to generate the full class name @@ -72,15 +104,19 @@ def __init__(self, enum_class: str) -> None: # the class name we are looking for self.enum_class_name = enum_class + self.qflag_class_name = qflag_class # the class full name self.enum_class_full_name = '' + self.qflag_class_full_name = '' - # the node of the class, for further reference + # the node of the class, for debugging purpose self.enum_class_cst_node = None + self.qflag_class_cst_node = None # when filled, set to one of the MethodPresent values self.enum_methods_present = MethodPresent.Unset + self.qflag_method_present = MethodPresent.Unset # set when enum_methods_present is set to partial, to add more contect information self.error_msg = '' @@ -91,15 +127,31 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: if node.name.value == self.enum_class_name: # we found it if self.enum_class_full_name != '': - raise ValueError('self.enum_class_full_name alraedy filled, can not setup a new value') + self.error_msg = 'class %s found multiple times' % self.enum_class_name + return self.enum_class_full_name = '.'.join(self.full_name_stack) self.enum_class_cst_node = node - self.check_method_present(node) + self.check_enum_method_present(node) + + elif node.name.value == self.qflag_class_name: + # we found it + if self.qflag_class_full_name != '': + self.error_msg = 'class %s found multiple times' % self.qflag_class_name + return + self.qflag_class_full_name = '.'.join(self.full_name_stack) + self.qflag_class_cst_node = node + + self.check_qflag_method_present(node) return None - def check_method_present(self, enum_node: cst.ClassDef) -> None: - '''Check if the class contains method __or__ and __ror__ with one argument''' + + def check_enum_method_present(self, enum_node: cst.ClassDef) -> None: + '''Check if the class contains method __or__ and __ror__ with one argument and if class + inherit from int''' + if len(enum_node.bases) == 0 or enum_node.bases[0].value != 'int': + self.error_msg += 'Class %s does not inherit from int' % self.enum_class_full_name + return has_or = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__or__'))) has_ror = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__ror__'))) self.enum_methods_present = { @@ -116,6 +168,48 @@ def check_method_present(self, enum_node: cst.ClassDef) -> None: self.error_msg += 'class %s, method %s present without method %s\n' % ((self.enum_class_full_name,)+args) + + def check_qflag_method_present(self, qflag_node: cst.ClassDef) -> None: + '''Check if the class contains method: + def __or__ + def __and__ + def __xor__ + def __ror__ + def __rand__ + def __rxor__ + + with one argument. + + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: + ''' + + has_method = [ + (m, matchers.findall(qflag_node.body, matchers.FunctionDef(name=matchers.Name(m)))) + for m in ('__or__', '__and__', '__xor__', '__ror__', '__rxor__', '__rand__') + ] + + if all(has_info[1] for has_info in has_method): + # all method presents + self.qflag_method_present = MethodPresent.All + return + + if all(not has_info[1] for has_info in has_method): + # all method absent + self.qflag_method_present = MethodPresent.Not + return + + self.qflag_method_present = MethodPresent.Partial + + for m_name, m_has in has_method: + if m_has: + self.error_msg += 'class %s, method %s present without all others\n' \ + % ((self.qflag_class_full_name, m_name)) + else: + self.error_msg += 'class %s, method %s missing\n' \ + % ((self.qflag_class_full_name, m_name)) + + def visit_FunctionDef(self, node: cst.FunctionDef) -> Optional[bool]: self.full_name_stack.append( node.name.value ) return None From 90554e8f86b3a53546adafa4f79b833d54f43ca2 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 29 Aug 2021 18:48:11 +0200 Subject: [PATCH 055/421] wip: module is modified for the enum class --- tests/qflags/qflag_stubs_helper.py | 92 +++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 7 deletions(-) diff --git a/tests/qflags/qflag_stubs_helper.py b/tests/qflags/qflag_stubs_helper.py index 0c2de4b7..c725e356 100644 --- a/tests/qflags/qflag_stubs_helper.py +++ b/tests/qflags/qflag_stubs_helper.py @@ -8,6 +8,9 @@ raise ImportError('You need libcst to run the code analysis and transform\n' 'Please run the command:\n\tpython -m pip install libcst') +def log_progress(s: str) -> None: + print('>>>>>>>>>>>>>>', s) + class QFlagCheckResult(Enum): CodeModifiedSuccessfully = 0 CodeAlreadyModified = 1 @@ -68,9 +71,15 @@ def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... raise ImportError('You need libcst to run the code analysis and transform\n' 'Please run the command:\n\tpython -m pip install libcst') - mod_content = open('..\..\pyqt5-stubs\QtCore.pyi').read() + log_progress('Opening module %s' % 'QtCore.pyi') + with open('..\..\pyqt5-stubs\QtCore.pyi') as f: + mod_content = f.read() + + log_progress('Parsing module %s' % 'QtCore.pyi') mod_cst = cst.parse_module(mod_content) - visitor = QFlagFinder('WindowState', 'WindowStates') + + log_progress('Checking qflags and enumh module %s' % 'QtCore.pyi') + visitor = QFlagAndEnumFinder('WindowState', 'WindowStates') mod_cst.visit(visitor) if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): @@ -83,7 +92,16 @@ def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... assert visitor.enum_methods_present == MethodPresent.Not assert visitor.qflag_method_present == MethodPresent.Not - # perform code modification + log_progress('Transforming module %s by adding new methods' % 'QtCore.pyi') + transformer = QFlagAndEnumUpdater(visitor.enum_class_name, visitor.enum_class_full_name, + visitor.qflag_class_name, visitor.qflag_class_full_name) + updated_mod_cst = mod_cst.visit(transformer) + + log_progress('Saving updated module %s' % 'QtCore.pyi') + with open('..\..\pyqt5-stubs\QtCore.pyi', 'w') as f: + f.write(updated_mod_cst.code) + + pass # generate test file @@ -94,7 +112,7 @@ class MethodPresent(Enum): Partial = 3 -class QFlagFinder(cst.CSTVisitor): +class QFlagAndEnumFinder(cst.CSTVisitor): def __init__(self, enum_class: str, qflag_class: str) -> None: super().__init__() @@ -149,7 +167,7 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: def check_enum_method_present(self, enum_node: cst.ClassDef) -> None: '''Check if the class contains method __or__ and __ror__ with one argument and if class inherit from int''' - if len(enum_node.bases) == 0 or enum_node.bases[0].value != 'int': + if len(enum_node.bases) == 0 or enum_node.bases[0].value.value != 'int': self.error_msg += 'Class %s does not inherit from int' % self.enum_class_full_name return has_or = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__or__'))) @@ -221,6 +239,66 @@ def leave_FunctionDef(self, node: cst.FunctionDef) -> None: self.full_name_stack.pop() +class QFlagAndEnumUpdater(cst.CSTTransformer): + + def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag_full_name: str) -> None: + super().__init__() + + self.error_msg = '' + + # the class name we are looking for + self.enum_class = enum_class + self.qflag_class = qflag_class + self.enum_full_name = enum_full_name + self.qflag_full_name = qflag_full_name + + # set when enum_methods_present is set to partial, to add more contect information + self.error_msg = '' + + + def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: + if original_node.name.value == self.enum_class: + return self.transform_enum_class(original_node, updated_node) + elif original_node.name.value == self.qflag_class: + return self.transform_qflag_class(original_node, updated_node) + return updated_node + + + def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: + '''Add the two methods __or__ and __ror__ to the class body''' + + # we keep comments separated to align them properly in the final file + new_methods_parts = ( + ("def __or__ (self, other: '{enum}') -> '{qflag}': ...", "# type: ignore[override]\n"), + ("def __ror__ (self, other: int) -> '{qflag}': ...", "# type: ignore[override, misc]\n\n") + ) + + # fill the class names + new_methods_filled = tuple( + (code.format(enum=self.enum_full_name, qflag=self.qflag_full_name), comment) + for code, comment in new_methods_parts + ) + + # new calculate the proper spacing to have aligned comments + max_code_len = max(len(code) for code, comment in new_methods_filled) + new_methods_spaced = tuple( + code + ' '*(4+max_code_len-len(code)) + comment + for code, comment in new_methods_filled + ) + new_methods_cst = tuple(cst.parse_statement(s) for s in new_methods_spaced) + return updated_node.with_changes(body=updated_node.body.with_changes(body= + new_methods_cst \ + + (updated_node.body.body[0].with_changes(leading_lines= + updated_node.body.body[0].leading_lines + (cst.EmptyLine(),)),) \ + + updated_node.body.body[1:] ) ) + + + def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: + return updated_node + + + + import unittest class TestMe(unittest.TestCase): @@ -242,13 +320,13 @@ def abd(self): ... def __or__(self, other): ... def __ror__(self, other): ... ''') - visitor = QFlagFinder('Titi') + visitor = QFlagAndEnumFinder('Titi') mod_cst.visit(visitor) self.assertEqual(visitor.enum_class_full_name, 'Toto.Titi') print(visitor.enum_class_cst_node) - visitor = QFlagFinder('QFlagExample') + visitor = QFlagAndEnumFinder('QFlagExample') mod_cst.visit(visitor) self.assertEqual(visitor.enum_class_full_name, 'Toto.QFlagExample') print(visitor.enum_class_cst_node) From a90e5c47536a8ff0f99a4d37828f6406a5e77908 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 29 Aug 2021 22:54:19 +0200 Subject: [PATCH 056/421] wip: full code modification is working --- tests/qflags/qflag_stubs_helper.py | 100 ++++++++++++++++++----------- 1 file changed, 62 insertions(+), 38 deletions(-) diff --git a/tests/qflags/qflag_stubs_helper.py b/tests/qflags/qflag_stubs_helper.py index c725e356..ee7ab908 100644 --- a/tests/qflags/qflag_stubs_helper.py +++ b/tests/qflags/qflag_stubs_helper.py @@ -86,6 +86,12 @@ def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... # TODO: check also for existence of the test file return (QFlagCheckResult.CodeAlreadyModified, visitor.error_msg) + if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.Not): + visitor.error_msg += 'Enum methods are present but not QFlag methods\n' + + if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.Not, MethodPresent.All): + visitor.error_msg += 'QFlag methods are present but not Enum methods\n' + if visitor.error_msg: return (QFlagCheckResult.ErrorDuringProcessing, visitor.error_msg) @@ -101,9 +107,10 @@ def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... with open('..\..\pyqt5-stubs\QtCore.pyi', 'w') as f: f.write(updated_mod_cst.code) - pass # generate test file + return (QFlagCheckResult.CodeModifiedSuccessfully, '') + class MethodPresent(Enum): Unset = 0 @@ -145,7 +152,7 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: if node.name.value == self.enum_class_name: # we found it if self.enum_class_full_name != '': - self.error_msg = 'class %s found multiple times' % self.enum_class_name + self.error_msg = 'class %s found multiple times\n' % self.enum_class_name return self.enum_class_full_name = '.'.join(self.full_name_stack) self.enum_class_cst_node = node @@ -155,7 +162,7 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: elif node.name.value == self.qflag_class_name: # we found it if self.qflag_class_full_name != '': - self.error_msg = 'class %s found multiple times' % self.qflag_class_name + self.error_msg = 'class %s found multiple times\n' % self.qflag_class_name return self.qflag_class_full_name = '.'.join(self.full_name_stack) self.qflag_class_cst_node = node @@ -168,7 +175,7 @@ def check_enum_method_present(self, enum_node: cst.ClassDef) -> None: '''Check if the class contains method __or__ and __ror__ with one argument and if class inherit from int''' if len(enum_node.bases) == 0 or enum_node.bases[0].value.value != 'int': - self.error_msg += 'Class %s does not inherit from int' % self.enum_class_full_name + self.error_msg += 'Class %s does not inherit from int\n' % self.enum_class_full_name return has_or = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__or__'))) has_ror = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__ror__'))) @@ -294,44 +301,61 @@ def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.Cl def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: - return updated_node - - - - -import unittest -class TestMe(unittest.TestCase): - - def test1(self): - mod_cst = cst.parse_module(''' -class Toto: + ''' + On the qflag class, add one more argument to __init__() + - def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: ... + + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ... - class Titi: - 'bla bla bla' - - def toto(self) -> None: ... - - @overload - def my_titi(self) -> str: ... - - - class QFlagExample: - def abd(self): ... - def __or__(self, other): ... - def __ror__(self, other): ... - ''') - visitor = QFlagAndEnumFinder('Titi') - mod_cst.visit(visitor) - self.assertEqual(visitor.enum_class_full_name, 'Toto.Titi') - print(visitor.enum_class_cst_node) + Possibly, remove the __init__() with only int argument if it exists + ''' + init_methods = matchers.findall(updated_node.body, matchers.FunctionDef(name=matchers.Name('__init__'))) + if len(init_methods) == 1: + # we do not handle the case where there is only one init function + # to handle it, we would need to do the following: + # * add an @typing.overload to the current init function + # * add a new init function + # + # This is not difficult, it's just that I don't think we have such cases + self.error_msg += 'Only one __init__ method in QFlag class %s, do not know how to transform it\n' % self.qflag_full_name + return updated_node + + # find the last __init__() method index + last_init_idx = 0 + nb_init_found = 0 + for i, body_element in enumerate(updated_node.body.body): + if matchers.matches(body_element, matchers.FunctionDef(name=matchers.Name('__init__'))): + nb_init_found += 1 + if nb_init_found == len(init_methods): + last_init_idx = i + break + assert last_init_idx != 0 + + cst_init = cst.parse_statement( '@typing.overload\ndef __init__(self, f: int) -> None: ...' ) + updated_node = updated_node.with_changes(body=updated_node.body.with_changes(body= + tuple(updated_node.body.body[:last_init_idx+1]) + + (cst_init,) + + tuple(updated_node.body.body[last_init_idx+1:]) + ) + ) + new_methods = ( + "def __or__ (self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", + "def __and__(self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", + "def __xor__(self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", + "def __ror__ (self, other: '{enum}') -> '{qflag}': ...", + "def __rand__(self, other: '{enum}') -> '{qflag}': ...", + "def __rxor__(self, other: '{enum}') -> '{qflag}': ...", + ) + new_methods_cst = tuple( + cst.parse_statement(s.format(enum=self.enum_full_name, qflag=self.qflag_full_name)) + for s in new_methods + ) + return updated_node.with_changes(body=updated_node.body.with_changes(body= + tuple(updated_node.body.body) + new_methods_cst ) ) - visitor = QFlagAndEnumFinder('QFlagExample') - mod_cst.visit(visitor) - self.assertEqual(visitor.enum_class_full_name, 'Toto.QFlagExample') - print(visitor.enum_class_cst_node) -check_qflag_in_module(None) \ No newline at end of file +result, error = check_qflag_in_module(None) +print(result, error) \ No newline at end of file From ce1bf7dde8d3f1445015d8ca5a3b9768d2e0c4d0 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Thu, 2 Sep 2021 12:13:15 +0200 Subject: [PATCH 057/421] Fixes annotation for QLineEdit to allow None as argument. --- PyQt5-stubs/QtWidgets.pyi | 2 +- tests/qlineedit.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/qlineedit.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 92d28ffb..f7408bd9 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -6900,7 +6900,7 @@ class QLineEdit(QWidget): def undo(self) -> None: ... def selectAll(self) -> None: ... def clear(self) -> None: ... - def setText(self, a0: str) -> None: ... + def setText(self, a0: Optional[str]) -> None: ... def hasAcceptableInput(self) -> bool: ... def setInputMask(self, inputMask: str) -> None: ... def inputMask(self) -> str: ... diff --git a/tests/qlineedit.py b/tests/qlineedit.py new file mode 100644 index 00000000..1bc6caf4 --- /dev/null +++ b/tests/qlineedit.py @@ -0,0 +1,7 @@ +"""Tests for QLineEdit.""" +from PyQt5.QtWidgets import QApplication, QLineEdit + +# test that QLineEdit.setText() accepts None as parameter +app = QApplication([]) +edit = QLineEdit() +edit.setText(None) From 6637e7ceacac169e501d61add89a58536006b367 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Thu, 2 Sep 2021 12:17:29 +0200 Subject: [PATCH 058/421] Added changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b68289d..9c6af566 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * [#138](https://github.com/python-qt-tools/PyQt5-stubs/pull/138) update to PyQt5 5.15.3 * [#144](https://github.com/python-qt-tools/PyQt5-stubs/pull/144) add `QTreeWidgetItem.__lt__()` to allow sorting of items in a QTreeWidget * [#143](https://github.com/python-qt-tools/PyQt5-stubs/pull/143) make `bytes(QByteArray())` valid by incorrectly adding `.__bytes__()` until a proper solution is developed upstream +* [#165](https://github.com/python-qt-tools/PyQt5-stubs/pull/165) allow `None` as argument for `QLineEdit.setText()` ## 5.15.2.0 From 662dd9d59173905ba60ce354c302e49babb98d20 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Thu, 2 Sep 2021 12:35:41 +0200 Subject: [PATCH 059/421] Fixes missing import. --- PyQt5-stubs/QtWidgets.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index f7408bd9..a2c68fa9 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -6900,7 +6900,7 @@ class QLineEdit(QWidget): def undo(self) -> None: ... def selectAll(self) -> None: ... def clear(self) -> None: ... - def setText(self, a0: Optional[str]) -> None: ... + def setText(self, a0: typing.Optional[str]) -> None: ... def hasAcceptableInput(self) -> bool: ... def setInputMask(self, inputMask: str) -> None: ... def inputMask(self) -> str: ... From 7077b605e4ebcb8ac1ac66c47bdc35c49c16a200 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 2 Sep 2021 13:49:59 +0200 Subject: [PATCH 060/421] wip: move code modification back to generate_qflags_stubs_and_tests --- .../qflags/generate_qflags_stubs_and_tests.py | 361 +++++++++++++++++- tests/qflags/qflag_stubs_helper.py | 361 ------------------ 2 files changed, 357 insertions(+), 365 deletions(-) delete mode 100644 tests/qflags/qflag_stubs_helper.py diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index d0d047e5..0501d3a2 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -1,10 +1,17 @@ -from typing import List, Tuple, Dict, Union, Any +from typing import List, Tuple, Dict, Union, Any, Optional import dataclasses import functools -import itertools import json -import collections +from enum import Enum + +try: + import libcst as cst + import libcst.matchers as matchers +except ImportError: + raise ImportError('You need libcst to run the code analysis and transform\n' + 'Please run the command:\n\tpython -m pip install libcst') + '''How to use this generator script: @@ -39,6 +46,9 @@ ['QtXml', '../../PyQt5-stubs/QtXml.pyi'], ] +def log_progress(s: str) -> None: + print('>>>>>>>>>>>>>>', s) + @dataclasses.dataclass class QFlagLocationInfo: grep_line: str @@ -240,6 +250,344 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str) -> bool: +class QFlagCheckResult(Enum): + CodeModifiedSuccessfully = 0 + CodeAlreadyModified = 1 + ErrorDuringProcessing = 2 + + +def check_qflag_in_module(flag_info: 'QFlagLocationInfo') -> Tuple[QFlagCheckResult, str]: + ''' + Check that the QFlag enum+class are present in the module and check whether they support + all the advanced QFlag operations. + + If they do not, add the missing information by performing code transformation and saving the result. + + Returns: + * QFlag operations already present + * QFlag operations were missing, now added + * QFlag operations partially missing, now added. + + Raise ValueError if something goes wrong. + + The QFlag operations are: + + On the enum class, add two methods: + class KeyboardModifier(int): + + def __or__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... # type: ignore[override] + + def __ror__ (self, other: int) -> 'Qt.KeyboardModifiers': ... # type: ignore[override, misc] + + On the qflag class, add one more argument to __init__() + - def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: ... + + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ... + + Possibly, remove the __init__() with only int argument if it exists + + Add more methods: + def __or__ (self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __and__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __xor__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __ror__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + + Returns a tuple of (result, error_msg): + * CodeModifiedSuccessfully: + All modifications to the code of the module have been performed successfully + + * CodeAlreadyModified: + All modifications to the code were already done, no processing done. + + * ErrorDuringProcessing: + Some error occured during the processing, such as some modifications were partially done, + class not found, class found multiple times, ... + + The detail of the error is provided in the second argument of the return value. +''' + log_progress('Opening module %s' % flag_info.module_info[0][0]) + with open(flag_info.module_info[0][1]) as f: + mod_content = f.read() + + log_progress('Parsing module %s' % flag_info.module_info[0][0]) + mod_cst = cst.parse_module(mod_content) + + log_progress('Looking for class %s and %s in module %s' % (flag_info.qflag_class, flag_info.qflag_enum, + flag_info.module_info[0][0])) + visitor = QFlagAndEnumFinder(flag_info.qflag_enum, flag_info.qflag_class) + mod_cst.visit(visitor) + + if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): + # TODO: check also for existence of the test file + return (QFlagCheckResult.CodeAlreadyModified, visitor.error_msg) + + if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.Not): + visitor.error_msg += 'Enum methods are present but not QFlag methods\n' + + if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.Not, MethodPresent.All): + visitor.error_msg += 'QFlag methods are present but not Enum methods\n' + + if visitor.error_msg: + return (QFlagCheckResult.ErrorDuringProcessing, visitor.error_msg) + + assert visitor.enum_methods_present == MethodPresent.Not + assert visitor.qflag_method_present == MethodPresent.Not + + log_progress('Transforming module %s by adding new methods' % flag_info.module_info[0][0]) + transformer = QFlagAndEnumUpdater(visitor.enum_class_name, visitor.enum_class_full_name, + visitor.qflag_class_name, visitor.qflag_class_full_name) + updated_mod_cst = mod_cst.visit(transformer) + + log_progress('Saving updated module %s' % flag_info.module_info[0][0]) + with open(flag_info.module_info[0][1], 'w') as f: + f.write(updated_mod_cst.code) + + # generate test file + + return (QFlagCheckResult.CodeModifiedSuccessfully, '') + + +class MethodPresent(Enum): + Unset = 0 + All = 1 + Not = 2 + Partial = 3 + + +class QFlagAndEnumFinder(cst.CSTVisitor): + + def __init__(self, enum_class: str, qflag_class: str) -> None: + super().__init__() + + # used internally to generate the full class name + self.full_name_stack: List[str] = [] + + # the class name we are looking for + self.enum_class_name = enum_class + self.qflag_class_name = qflag_class + + # the class full name + self.enum_class_full_name = '' + self.qflag_class_full_name = '' + + # the node of the class, for debugging purpose + self.enum_class_cst_node = None + self.qflag_class_cst_node = None + + # when filled, set to one of the MethodPresent values + self.enum_methods_present = MethodPresent.Unset + self.qflag_method_present = MethodPresent.Unset + + # set when enum_methods_present is set to partial, to add more contect information + self.error_msg = '' + + + def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: + self.full_name_stack.append( node.name.value ) + if node.name.value == self.enum_class_name: + # we found it + if self.enum_class_full_name != '': + self.error_msg = 'class %s found multiple times\n' % self.enum_class_name + return + self.enum_class_full_name = '.'.join(self.full_name_stack) + self.enum_class_cst_node = node + + self.check_enum_method_present(node) + + elif node.name.value == self.qflag_class_name: + # we found it + if self.qflag_class_full_name != '': + self.error_msg = 'class %s found multiple times\n' % self.qflag_class_name + return + self.qflag_class_full_name = '.'.join(self.full_name_stack) + self.qflag_class_cst_node = node + + self.check_qflag_method_present(node) + return None + + + def check_enum_method_present(self, enum_node: cst.ClassDef) -> None: + '''Check if the class contains method __or__ and __ror__ with one argument and if class + inherit from int''' + if len(enum_node.bases) == 0 or enum_node.bases[0].value.value != 'int': + self.error_msg += 'Class %s does not inherit from int\n' % self.enum_class_full_name + return + has_or = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__or__'))) + has_ror = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__ror__'))) + self.enum_methods_present = { + 0: MethodPresent.Not, + 1: MethodPresent.Partial, + 2: MethodPresent.All + }[len(has_or) + len(has_ror)] + + if self.enum_methods_present == MethodPresent.Partial: + if has_or: + args = ('__or__', '__ror__') + else: + args = ('__ror__', '__or__') + + self.error_msg += 'class %s, method %s present without method %s\n' % ((self.enum_class_full_name,)+args) + + + def check_qflag_method_present(self, qflag_node: cst.ClassDef) -> None: + '''Check if the class contains method: + def __or__ + def __and__ + def __xor__ + def __ror__ + def __rand__ + def __rxor__ + + with one argument. + + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: + ''' + + has_method = [ + (m, matchers.findall(qflag_node.body, matchers.FunctionDef(name=matchers.Name(m)))) + for m in ('__or__', '__and__', '__xor__', '__ror__', '__rxor__', '__rand__') + ] + + if all(has_info[1] for has_info in has_method): + # all method presents + self.qflag_method_present = MethodPresent.All + return + + if all(not has_info[1] for has_info in has_method): + # all method absent + self.qflag_method_present = MethodPresent.Not + return + + self.qflag_method_present = MethodPresent.Partial + + for m_name, m_has in has_method: + if m_has: + self.error_msg += 'class %s, method %s present without all others\n' \ + % ((self.qflag_class_full_name, m_name)) + else: + self.error_msg += 'class %s, method %s missing\n' \ + % ((self.qflag_class_full_name, m_name)) + + + def visit_FunctionDef(self, node: cst.FunctionDef) -> Optional[bool]: + self.full_name_stack.append( node.name.value ) + return None + + def leave_ClassDef(self, node: cst.ClassDef) -> None: + self.full_name_stack.pop() + + def leave_FunctionDef(self, node: cst.FunctionDef) -> None: + self.full_name_stack.pop() + + +class QFlagAndEnumUpdater(cst.CSTTransformer): + + def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag_full_name: str) -> None: + super().__init__() + + self.error_msg = '' + + # the class name we are looking for + self.enum_class = enum_class + self.qflag_class = qflag_class + self.enum_full_name = enum_full_name + self.qflag_full_name = qflag_full_name + + # set when enum_methods_present is set to partial, to add more contect information + self.error_msg = '' + + + def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: + if original_node.name.value == self.enum_class: + return self.transform_enum_class(original_node, updated_node) + elif original_node.name.value == self.qflag_class: + return self.transform_qflag_class(original_node, updated_node) + return updated_node + + + def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: + '''Add the two methods __or__ and __ror__ to the class body''' + + # we keep comments separated to align them properly in the final file + new_methods_parts = ( + ("def __or__ (self, other: '{enum}') -> '{qflag}': ...", "# type: ignore[override]\n"), + ("def __ror__ (self, other: int) -> '{qflag}': ...", "# type: ignore[override, misc]\n\n") + ) + + # fill the class names + new_methods_filled = tuple( + (code.format(enum=self.enum_full_name, qflag=self.qflag_full_name), comment) + for code, comment in new_methods_parts + ) + + # new calculate the proper spacing to have aligned comments + max_code_len = max(len(code) for code, comment in new_methods_filled) + new_methods_spaced = tuple( + code + ' '*(4+max_code_len-len(code)) + comment + for code, comment in new_methods_filled + ) + new_methods_cst = tuple(cst.parse_statement(s) for s in new_methods_spaced) + return updated_node.with_changes(body=updated_node.body.with_changes(body= + new_methods_cst \ + + (updated_node.body.body[0].with_changes(leading_lines= + updated_node.body.body[0].leading_lines + (cst.EmptyLine(),)),) \ + + updated_node.body.body[1:] ) ) + + + def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: + ''' + On the qflag class, add one more argument to __init__() + - def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: ... + + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ... + + Possibly, remove the __init__() with only int argument if it exists + ''' + init_methods = matchers.findall(updated_node.body, matchers.FunctionDef(name=matchers.Name('__init__'))) + if len(init_methods) == 1: + # we do not handle the case where there is only one init function + # to handle it, we would need to do the following: + # * add an @typing.overload to the current init function + # * add a new init function + # + # This is not difficult, it's just that I don't think we have such cases + self.error_msg += 'Only one __init__ method in QFlag class %s, do not know how to transform it\n' % self.qflag_full_name + return updated_node + + # find the last __init__() method index + last_init_idx = 0 + nb_init_found = 0 + for i, body_element in enumerate(updated_node.body.body): + if matchers.matches(body_element, matchers.FunctionDef(name=matchers.Name('__init__'))): + nb_init_found += 1 + if nb_init_found == len(init_methods): + last_init_idx = i + break + assert last_init_idx != 0 + + cst_init = cst.parse_statement( '@typing.overload\ndef __init__(self, f: int) -> None: ...' ) + updated_node = updated_node.with_changes(body=updated_node.body.with_changes(body= + tuple(updated_node.body.body[:last_init_idx+1]) + + (cst_init,) + + tuple(updated_node.body.body[last_init_idx+1:]) + ) + ) + + new_methods = ( + "def __or__ (self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", + "def __and__(self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", + "def __xor__(self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", + "def __ror__ (self, other: '{enum}') -> '{qflag}': ...", + "def __rand__(self, other: '{enum}') -> '{qflag}': ...", + "def __rxor__(self, other: '{enum}') -> '{qflag}': ...", + ) + new_methods_cst = tuple( + cst.parse_statement(s.format(enum=self.enum_full_name, qflag=self.qflag_full_name)) + for s in new_methods + ) + return updated_node.with_changes(body=updated_node.body.with_changes(body= + tuple(updated_node.body.body) + new_methods_cst ) ) + + @@ -341,6 +689,11 @@ def generate_qflags_to_process(): qflag_result_json = 'qflag_process_result.json' - process_qflag(qflags_to_process_json, qflag_result_json) + # process_qflag(qflags_to_process_json, qflag_result_json) + flag_info = QFlagLocationInfo(qflag_enum='WindowState', + qflag_class='WindowStates', + module_info=[ ('QtCore.pyi', r'..\..\pyqt5-stubs\QtCore.pyi')], + grep_line='') + result, error_msg = check_qflag_in_module(flag_info) diff --git a/tests/qflags/qflag_stubs_helper.py b/tests/qflags/qflag_stubs_helper.py deleted file mode 100644 index ee7ab908..00000000 --- a/tests/qflags/qflag_stubs_helper.py +++ /dev/null @@ -1,361 +0,0 @@ -from typing import Optional, List, Tuple -from enum import Enum - -try: - import libcst as cst - import libcst.matchers as matchers -except ImportError: - raise ImportError('You need libcst to run the code analysis and transform\n' - 'Please run the command:\n\tpython -m pip install libcst') - -def log_progress(s: str) -> None: - print('>>>>>>>>>>>>>>', s) - -class QFlagCheckResult(Enum): - CodeModifiedSuccessfully = 0 - CodeAlreadyModified = 1 - ErrorDuringProcessing = 2 - - -def check_qflag_in_module(flag_info: 'QFlagLocationInfo') -> Tuple[QFlagCheckResult, str]: - ''' - Check that the QFlag enum+class are present in the module and check whether they support - all the advanced QFlag operations. - - If they do not, add the missing information by performing code transformation and saving the result. - - Returns: - * QFlag operations already present - * QFlag operations were missing, now added - * QFlag operations partially missing, now added. - - Raise ValueError if something goes wrong. - - The QFlag operations are: - - On the enum class, add two methods: - class KeyboardModifier(int): - + def __or__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... # type: ignore[override] - + def __ror__ (self, other: int) -> 'Qt.KeyboardModifiers': ... # type: ignore[override, misc] - - On the qflag class, add one more argument to __init__() - - def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: ... - + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ... - - Possibly, remove the __init__() with only int argument if it exists - - Add more methods: - def __or__ (self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - def __and__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - def __xor__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - def __ror__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... - def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... - def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... - - Returns a tuple of (result, error_msg): - * CodeModifiedSuccessfully: - All modifications to the code of the module have been performed successfully - - * CodeAlreadyModified: - All modifications to the code were already done, no processing done. - - * ErrorDuringProcessing: - Some error occured during the processing, such as some modifications were partially done, - clas not found, class found multiple times, ... - - The detail of the error is provided in the second argument of the return value. -''' - try: - import libcst - except ImportError: - raise ImportError('You need libcst to run the code analysis and transform\n' - 'Please run the command:\n\tpython -m pip install libcst') - - log_progress('Opening module %s' % 'QtCore.pyi') - with open('..\..\pyqt5-stubs\QtCore.pyi') as f: - mod_content = f.read() - - log_progress('Parsing module %s' % 'QtCore.pyi') - mod_cst = cst.parse_module(mod_content) - - log_progress('Checking qflags and enumh module %s' % 'QtCore.pyi') - visitor = QFlagAndEnumFinder('WindowState', 'WindowStates') - mod_cst.visit(visitor) - - if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): - # TODO: check also for existence of the test file - return (QFlagCheckResult.CodeAlreadyModified, visitor.error_msg) - - if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.Not): - visitor.error_msg += 'Enum methods are present but not QFlag methods\n' - - if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.Not, MethodPresent.All): - visitor.error_msg += 'QFlag methods are present but not Enum methods\n' - - if visitor.error_msg: - return (QFlagCheckResult.ErrorDuringProcessing, visitor.error_msg) - - assert visitor.enum_methods_present == MethodPresent.Not - assert visitor.qflag_method_present == MethodPresent.Not - - log_progress('Transforming module %s by adding new methods' % 'QtCore.pyi') - transformer = QFlagAndEnumUpdater(visitor.enum_class_name, visitor.enum_class_full_name, - visitor.qflag_class_name, visitor.qflag_class_full_name) - updated_mod_cst = mod_cst.visit(transformer) - - log_progress('Saving updated module %s' % 'QtCore.pyi') - with open('..\..\pyqt5-stubs\QtCore.pyi', 'w') as f: - f.write(updated_mod_cst.code) - - # generate test file - - return (QFlagCheckResult.CodeModifiedSuccessfully, '') - - -class MethodPresent(Enum): - Unset = 0 - All = 1 - Not = 2 - Partial = 3 - - -class QFlagAndEnumFinder(cst.CSTVisitor): - - def __init__(self, enum_class: str, qflag_class: str) -> None: - super().__init__() - - # used internally to generate the full class name - self.full_name_stack: List[str] = [] - - # the class name we are looking for - self.enum_class_name = enum_class - self.qflag_class_name = qflag_class - - # the class full name - self.enum_class_full_name = '' - self.qflag_class_full_name = '' - - # the node of the class, for debugging purpose - self.enum_class_cst_node = None - self.qflag_class_cst_node = None - - # when filled, set to one of the MethodPresent values - self.enum_methods_present = MethodPresent.Unset - self.qflag_method_present = MethodPresent.Unset - - # set when enum_methods_present is set to partial, to add more contect information - self.error_msg = '' - - - def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: - self.full_name_stack.append( node.name.value ) - if node.name.value == self.enum_class_name: - # we found it - if self.enum_class_full_name != '': - self.error_msg = 'class %s found multiple times\n' % self.enum_class_name - return - self.enum_class_full_name = '.'.join(self.full_name_stack) - self.enum_class_cst_node = node - - self.check_enum_method_present(node) - - elif node.name.value == self.qflag_class_name: - # we found it - if self.qflag_class_full_name != '': - self.error_msg = 'class %s found multiple times\n' % self.qflag_class_name - return - self.qflag_class_full_name = '.'.join(self.full_name_stack) - self.qflag_class_cst_node = node - - self.check_qflag_method_present(node) - return None - - - def check_enum_method_present(self, enum_node: cst.ClassDef) -> None: - '''Check if the class contains method __or__ and __ror__ with one argument and if class - inherit from int''' - if len(enum_node.bases) == 0 or enum_node.bases[0].value.value != 'int': - self.error_msg += 'Class %s does not inherit from int\n' % self.enum_class_full_name - return - has_or = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__or__'))) - has_ror = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__ror__'))) - self.enum_methods_present = { - 0: MethodPresent.Not, - 1: MethodPresent.Partial, - 2: MethodPresent.All - }[len(has_or) + len(has_ror)] - - if self.enum_methods_present == MethodPresent.Partial: - if has_or: - args = ('__or__', '__ror__') - else: - args = ('__ror__', '__or__') - - self.error_msg += 'class %s, method %s present without method %s\n' % ((self.enum_class_full_name,)+args) - - - def check_qflag_method_present(self, qflag_node: cst.ClassDef) -> None: - '''Check if the class contains method: - def __or__ - def __and__ - def __xor__ - def __ror__ - def __rand__ - def __rxor__ - - with one argument. - - def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: - def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: - ''' - - has_method = [ - (m, matchers.findall(qflag_node.body, matchers.FunctionDef(name=matchers.Name(m)))) - for m in ('__or__', '__and__', '__xor__', '__ror__', '__rxor__', '__rand__') - ] - - if all(has_info[1] for has_info in has_method): - # all method presents - self.qflag_method_present = MethodPresent.All - return - - if all(not has_info[1] for has_info in has_method): - # all method absent - self.qflag_method_present = MethodPresent.Not - return - - self.qflag_method_present = MethodPresent.Partial - - for m_name, m_has in has_method: - if m_has: - self.error_msg += 'class %s, method %s present without all others\n' \ - % ((self.qflag_class_full_name, m_name)) - else: - self.error_msg += 'class %s, method %s missing\n' \ - % ((self.qflag_class_full_name, m_name)) - - - def visit_FunctionDef(self, node: cst.FunctionDef) -> Optional[bool]: - self.full_name_stack.append( node.name.value ) - return None - - def leave_ClassDef(self, node: cst.ClassDef) -> None: - self.full_name_stack.pop() - - def leave_FunctionDef(self, node: cst.FunctionDef) -> None: - self.full_name_stack.pop() - - -class QFlagAndEnumUpdater(cst.CSTTransformer): - - def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag_full_name: str) -> None: - super().__init__() - - self.error_msg = '' - - # the class name we are looking for - self.enum_class = enum_class - self.qflag_class = qflag_class - self.enum_full_name = enum_full_name - self.qflag_full_name = qflag_full_name - - # set when enum_methods_present is set to partial, to add more contect information - self.error_msg = '' - - - def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: - if original_node.name.value == self.enum_class: - return self.transform_enum_class(original_node, updated_node) - elif original_node.name.value == self.qflag_class: - return self.transform_qflag_class(original_node, updated_node) - return updated_node - - - def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: - '''Add the two methods __or__ and __ror__ to the class body''' - - # we keep comments separated to align them properly in the final file - new_methods_parts = ( - ("def __or__ (self, other: '{enum}') -> '{qflag}': ...", "# type: ignore[override]\n"), - ("def __ror__ (self, other: int) -> '{qflag}': ...", "# type: ignore[override, misc]\n\n") - ) - - # fill the class names - new_methods_filled = tuple( - (code.format(enum=self.enum_full_name, qflag=self.qflag_full_name), comment) - for code, comment in new_methods_parts - ) - - # new calculate the proper spacing to have aligned comments - max_code_len = max(len(code) for code, comment in new_methods_filled) - new_methods_spaced = tuple( - code + ' '*(4+max_code_len-len(code)) + comment - for code, comment in new_methods_filled - ) - new_methods_cst = tuple(cst.parse_statement(s) for s in new_methods_spaced) - return updated_node.with_changes(body=updated_node.body.with_changes(body= - new_methods_cst \ - + (updated_node.body.body[0].with_changes(leading_lines= - updated_node.body.body[0].leading_lines + (cst.EmptyLine(),)),) \ - + updated_node.body.body[1:] ) ) - - - def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: - ''' - On the qflag class, add one more argument to __init__() - - def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: ... - + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ... - - Possibly, remove the __init__() with only int argument if it exists - ''' - init_methods = matchers.findall(updated_node.body, matchers.FunctionDef(name=matchers.Name('__init__'))) - if len(init_methods) == 1: - # we do not handle the case where there is only one init function - # to handle it, we would need to do the following: - # * add an @typing.overload to the current init function - # * add a new init function - # - # This is not difficult, it's just that I don't think we have such cases - self.error_msg += 'Only one __init__ method in QFlag class %s, do not know how to transform it\n' % self.qflag_full_name - return updated_node - - # find the last __init__() method index - last_init_idx = 0 - nb_init_found = 0 - for i, body_element in enumerate(updated_node.body.body): - if matchers.matches(body_element, matchers.FunctionDef(name=matchers.Name('__init__'))): - nb_init_found += 1 - if nb_init_found == len(init_methods): - last_init_idx = i - break - assert last_init_idx != 0 - - cst_init = cst.parse_statement( '@typing.overload\ndef __init__(self, f: int) -> None: ...' ) - updated_node = updated_node.with_changes(body=updated_node.body.with_changes(body= - tuple(updated_node.body.body[:last_init_idx+1]) + - (cst_init,) + - tuple(updated_node.body.body[last_init_idx+1:]) - ) - ) - - new_methods = ( - "def __or__ (self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", - "def __and__(self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", - "def __xor__(self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", - "def __ror__ (self, other: '{enum}') -> '{qflag}': ...", - "def __rand__(self, other: '{enum}') -> '{qflag}': ...", - "def __rxor__(self, other: '{enum}') -> '{qflag}': ...", - ) - new_methods_cst = tuple( - cst.parse_statement(s.format(enum=self.enum_full_name, qflag=self.qflag_full_name)) - for s in new_methods - ) - return updated_node.with_changes(body=updated_node.body.with_changes(body= - tuple(updated_node.body.body) + new_methods_cst ) ) - - - - - -result, error = check_qflag_in_module(None) -print(result, error) \ No newline at end of file From 1ee9864434ba4f76b3f4c8d4df51b71ddb8fd0b7 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 3 Sep 2021 12:54:54 +0200 Subject: [PATCH 061/421] work in progress --- tests/generate_qflags_tests.py | 69 ------- .../qflags/generate_qflags_stubs_and_tests.py | 171 ++++++++++++------ ...windowflags.py => qflags_test_template.py} | 0 3 files changed, 114 insertions(+), 126 deletions(-) delete mode 100644 tests/generate_qflags_tests.py rename tests/qflags/{qflags_windowflags.py => qflags_test_template.py} (100%) diff --git a/tests/generate_qflags_tests.py b/tests/generate_qflags_tests.py deleted file mode 100644 index d410ca78..00000000 --- a/tests/generate_qflags_tests.py +++ /dev/null @@ -1,69 +0,0 @@ -from typing import Tuple, List - -SOURCE = 'windowFlags.py' -MARKER_SPECIFIC_START = '### Specific part' -MARKER_SPECIFIC_END = '### End of specific part' - -# Content is: -# - name of the file to generate -# - name of the QFlags<> class -# - name of the individual flag class (inheriting from int) -# - one individual flag value -# - a second individual flag value -FLAGS_FILES = [ - ('qflags_alignmentflags.py', 'QtCore.Qt.Alignment', 'QtCore.Qt.AlignmentFlag', 'QtCore.Qt.AlignLeft', 'QtCore.Qt.AlignRight'), - -] - -# global values for simplicity of the code -sourcePart1, sourcePart2, sourcePart3 = [], [], [] # type: Tuple[List[str], List[str], List[str]] - -def generate_qflags_files() -> None: - global sourcePart1, sourcePart2, sourcePart3 - with open(SOURCE) as f: - lines = f.readlines() - - sourcePart1, sourcePart2, sourcePart3 = [], [], [] - fillPart2, fillPart3 = False, False - for l in lines: - if fillPart3: - sourcePart3.append(l) - continue - - if fillPart2: - if MARKER_SPECIFIC_END in l: - fillPart3 = True - sourcePart3.append(l) - continue - - sourcePart2.append(l) - continue - - sourcePart1.append(l) - if MARKER_SPECIFIC_START in l: - fillPart2 = True - - for qflag_info in FLAGS_FILES: - generate_one_qflag_file(*qflag_info) - - -def generate_one_qflag_file(qflag_fname: str, multiFlagName: str, oneFlagName: str, oneFlagValue1: str, oneFlagValue2: str) -> None: - with open(qflag_fname, 'w') as f: - f.writelines(sourcePart1) - f.write('''# file generated from {source} for QFlags class "{multiFlagName}" and flag class "{oneFlagName}" - -OneFlagClass = {oneFlagName} -MultiFlagClass = {multiFlagName} - -oneFlagRefValue1 = {oneFlagValue1} -oneFlagRefValue2 = {oneFlagValue2} -'''.format(source=SOURCE, multiFlagName=multiFlagName, oneFlagName=oneFlagName, - oneFlagValue1=oneFlagValue1, oneFlagValue2=oneFlagValue2 - )) - f.writelines(sourcePart3) - print('File %s generated' % qflag_fname) - - -if __name__ == '__main__': - generate_qflags_files() - diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 0501d3a2..f6462047 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -3,6 +3,7 @@ import dataclasses import functools import json +import os from enum import Enum try: @@ -26,7 +27,7 @@ QFLAG_SRC='src\\corelib\\global\\qflags.h' # the template after which we model all generated qflag tests -SOURCE_QFLAGS_TESTS = 'qflags_windowFlags.py' +TEMPLATE_QFLAGS_TESTS = 'qflags_test_template.py' # the markers inside the above template to identify the parts to replace MARKER_SPECIFIC_START = '### Specific part' @@ -55,6 +56,11 @@ class QFlagLocationInfo: qflag_class: str qflag_enum: str + qflag_value1: str + qflag_value2: str + qflag_full_class_name: str + qflag_full_enum_name: str + # list of (module_name, module_path) module_info: List[ Tuple[str, str] ] @@ -173,7 +179,7 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, { 'qflag_class': qflag_info['qflag_class'], 'qflag_enum': qflag_info['qflag_enum'], - 'skipReason': 'QFlag present more than once or in multiple modules' + 'skip_reason': 'QFlag present more than once or in multiple modules' } ) @@ -182,7 +188,7 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, { 'qflag_class': qflag_info['qflag_class'], 'qflag_enum': qflag_info['qflag_enum'], - 'skipReason': 'QFlag not found', + 'skip_reason': 'QFlag not found', } ) @@ -212,41 +218,61 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str) -> bool: with open(qflag_to_process_json) as f: d = json.load(f) - result = { + qflags_to_process = d['qflags_to_process'] + + result_json = { 'qflag_already_done': [], 'qflag_processed_done': [], 'qflag_process_error': [], } - if len(d['qflags_to_process']) == 0: - return True + def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: + '''Return True if the qflag is already included in one of the lists + of result_json''' + flag_info_tuple = dataclasses.astuple(flag_info) + if flag_info_tuple in set(result['qflag_already_done']) \ + or flag_info_tuple in set(result['qflag_processed_done']) \ + or flag_info_tuple in set(result['qflag_process_error']): + return True + return False - try: - flag_info_dict = d['qflags_to_process'].pop(0) + while len(qflags_to_process) != 0: + flag_info_dict = qflags_to_process.pop(0) + flag_info = QFlagLocationInfo(**flag_info_dict) + if not qflag_already_processed(flag_info): + break + else: + # we have exhausted the list of qflag to process + return False - # check if qflag has already been processed. If so move to the next one - # if all qflags have been processed, return True + # check that the qflag is actually in the module + check_result, error_msg = check_qflag_in_module(flag_info) - flag_info = QFlagLocationInfo(**flag_info_dict) - print('Processing qflag: %s / %s in module %s ' % - (flag_info.qflag_class, - flag_info.qflag_enum, - flag_info.module_info[0][0] if len(flag_info.module_info) else '' - )) + # flag_info has been modified in-place with additional info: qflag_value1 and qflag_value2 + if check_result == QFlagCheckResult.CodeModifiedSuccessfully: + generate_qflag_test_file(flag_info) - result, error_msg = check_qflag_in_module(flag_info) + # run verifications - # if result is failed, add error message and move to next flag - # if result succeeds: - # run tox - # mark the test as done + if check_result == QFlagCheckResult.CodeAlreadyModified: + # qflag methods are already there, check that the test filename is here too + test_qflag_fname = gen_test_fname(flag_info) + if os.path.exists(test_qflag_fname): + result_json['qflag_already_done'].append(flag_info_dict) + else: + error_msg += 'QFlag methods presents but test file %s is missing\n' % test_qflag_fname + check_result = QFlagCheckResult.ErrorDuringProcessing - # if there are more flags to process, return False - # if all flags are processed, return True - return False - finally: - with open(qflag_result_json, 'w') as f: - json.dump(result, f, indent=4) + if check_result == QFlagCheckResult.ErrorDuringProcessing: + flag_info_dict['error'] = flag_info_dict.get('error', '') + error_msg + result_json['qflag_process_error'].append(flag_info_dict) + + # save our processing result + with open(qflag_result_json, 'w') as f: + json.dump(result, f, indent=4) + + # return True to indicate that more flags may be processed + return True @@ -263,6 +289,9 @@ def check_qflag_in_module(flag_info: 'QFlagLocationInfo') -> Tuple[QFlagCheckRes If they do not, add the missing information by performing code transformation and saving the result. + The flag_info is also modified in place to add one or two of the possible values taken by the enum. This + is needed for generating a proper test file. I don't like in-pace modification but here, it's the simplest. + Returns: * QFlag operations already present * QFlag operations were missing, now added @@ -317,7 +346,6 @@ class not found, class found multiple times, ... mod_cst.visit(visitor) if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): - # TODO: check also for existence of the test file return (QFlagCheckResult.CodeAlreadyModified, visitor.error_msg) if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.Not): @@ -332,6 +360,12 @@ class not found, class found multiple times, ... assert visitor.enum_methods_present == MethodPresent.Not assert visitor.qflag_method_present == MethodPresent.Not + # storing the enum_values for further usage + flag_info.qflag_full_enum_name = visitor.enum_class_full_name + flag_info.qflag_value1 = visitor.enum_value1 + flag_info.qflag_value2 = visitor.enum_value2 + flag_info.qflag_full_class_name = visitor.qflag_class_full_name + log_progress('Transforming module %s by adding new methods' % flag_info.module_info[0][0]) transformer = QFlagAndEnumUpdater(visitor.enum_class_name, visitor.enum_class_full_name, visitor.qflag_class_name, visitor.qflag_class_full_name) @@ -369,6 +403,10 @@ def __init__(self, enum_class: str, qflag_class: str) -> None: self.enum_class_full_name = '' self.qflag_class_full_name = '' + # the name of two values of the enum class + self.enum_value1 = '' + self.enum_value2 = '' + # the node of the class, for debugging purpose self.enum_class_cst_node = None self.qflag_class_cst_node = None @@ -392,6 +430,7 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: self.enum_class_cst_node = node self.check_enum_method_present(node) + self.collect_enum_values(node) elif node.name.value == self.qflag_class_name: # we found it @@ -427,6 +466,24 @@ def check_enum_method_present(self, enum_node: cst.ClassDef) -> None: self.error_msg += 'class %s, method %s present without method %s\n' % ((self.enum_class_full_name,)+args) + def collect_enum_values(self, enum_node: cst.ClassDef) -> None: + '''Collect two actual values for the enum and store them into self.enum_value1 and enum_value2 + ''' + # find all lines consisting of an assignment to an ellipsis: + # example: AlignLeft = ... + enum_values = matchers.findall(enum_node.body, matchers.SimpleStatementLine( + body=[matchers.Assign(value=matchers.Ellipsis())])) + if len(enum_values) == 0: + self.error_msg += 'class %s, could not find any enum values\n' % self.enum_class_full_name + return + + self.enum_value1 = enum_values[0].body[0].targets[0].target.value + if len(enum_values) > 1: + self.enum_value2 = enum_values[1].body[0].targets[0].target.value + else: + # it works find if both values are the same so don't bother + self.enum_value2 = self.enum_value1 + def check_qflag_method_present(self, qflag_node: cst.ClassDef) -> None: '''Check if the class contains method: @@ -592,7 +649,7 @@ def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.C @functools.lru_cache(maxsize=1) -def read_qflag_test_template() -> Tuple[List[str], List[str], List[str]]: +def read_qflag_test_template(template_fname: str) -> Tuple[List[str], List[str], List[str]]: '''Return the source of template for generating qflags test. Return 3 parts: @@ -600,7 +657,7 @@ def read_qflag_test_template() -> Tuple[List[str], List[str], List[str]]: - the second part should be replaced for a specific QFlag class - the third part should be unmodified ''' - with open(SOURCE_QFLAGS_TESTS) as f: + with open(template_fname) as f: lines = f.readlines() sourcePart1, sourcePart2, sourcePart3 = [], [], [] @@ -626,11 +683,23 @@ def read_qflag_test_template() -> Tuple[List[str], List[str], List[str]]: return sourcePart1, sourcePart2, sourcePart3 -def generate_one_qflag_file(qflag_fname: str, multiFlagName: str, oneFlagName: str, oneFlagValue1: str, oneFlagValue2: str) -> None: - sourcePart1, sourcePart2, sourcePart3 = read_qflag_test_template() +def gen_test_fname(fli: QFlagLocationInfo) -> str: + '''Generate the name of the test file which will verify this qflag''' + return 'test_{fli.module_info[0][0]}_{fli.qflag_class}_{fli.qflag_enum}'.format(fli=fli) + + +def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: + '''Generate a qflag test file. + + The filename is inferred from flag_info using gen_test_fname() + ''' + test_qflag_fname = gen_test_fname(flag_info) + generic_part_before, _replacable_part, generic_part_after = read_qflag_test_template(TEMPLATE_QFLAGS_TESTS) + + with open(test_qflag_fname, 'w') as f: + f.writelines(generic_part_before) - with open(qflag_fname, 'w') as f: - f.writelines(sourcePart1) + # replace the repplacable_part with code dedicated to our qflag f.write('''# file generated from {source} for QFlags class "{multiFlagName}" and flag class "{oneFlagName}" OneFlagClass = {oneFlagName} @@ -638,31 +707,16 @@ def generate_one_qflag_file(qflag_fname: str, multiFlagName: str, oneFlagName: s oneFlagRefValue1 = {oneFlagValue1} oneFlagRefValue2 = {oneFlagValue2} -'''.format(source=SOURCE_QFLAGS_TESTS, multiFlagName=multiFlagName, oneFlagName=oneFlagName, - oneFlagValue1=oneFlagValue1, oneFlagValue2=oneFlagValue2 +'''.format(source=TEMPLATE_QFLAGS_TESTS, + multiFlagName=flag_info.qflag_full_class_name, + oneFlagName=flag_info.qflag_full_enum_name, + oneFlagValue1=flag_info.qflag_value1, + oneFlagValue2=flag_info.qflag_value2 )) - f.writelines(sourcePart3) - print('File %s generated' % qflag_fname) - + f.writelines(generic_part_after) + print('File %s generated' % test_qflag_fname) -# TODO: - -# for each module/flag -# - generate a test file is not already present -# - run test file. If it fails, skip this flag -# - find where the class is located in the module -# - check if class is in raw form (not QFlag based yet) or already patched -# - if not patched -# - modify the code of the module with better implementation -# - generate a test file is not already present -# - run test file and mypy for the qflag class -# - if successful execution, commit it -# - if unsuccessful execution, revert the changes on the module -# repeat... -# -# analyse the result - def generate_qflags_to_process(): '''Run the generation process from the grep output parsing to the generation of json file listing the flags to process''' qt_qflag_grep_result_fname = 'qt-qflag-grep-result.txt' @@ -694,6 +748,9 @@ def generate_qflags_to_process(): flag_info = QFlagLocationInfo(qflag_enum='WindowState', qflag_class='WindowStates', module_info=[ ('QtCore.pyi', r'..\..\pyqt5-stubs\QtCore.pyi')], - grep_line='') + grep_line='', qflag_value1='', qflag_value2='') result, error_msg = check_qflag_in_module(flag_info) + +# TODO: +# * check_qflag should be renamed \ No newline at end of file diff --git a/tests/qflags/qflags_windowflags.py b/tests/qflags/qflags_test_template.py similarity index 100% rename from tests/qflags/qflags_windowflags.py rename to tests/qflags/qflags_test_template.py From 6adfdc6fac43d4da03299e4b4dce6395ef04ed91 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 3 Sep 2021 12:55:02 +0200 Subject: [PATCH 062/421] Fix typo --- PyQt5-stubs/QtCore.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 74ce497c..302fe779 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2761,12 +2761,12 @@ class Qt(sip.simplewrapper): def __invert__(self) -> 'Qt.Alignment': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - def __or__ (self, other: typing.Union['Qt.Alignemtn', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignemtn': ... - def __and__(self, other: typing.Union['Qt.Alignemtn', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignemtn': ... - def __xor__(self, other: typing.Union['Qt.Alignemtn', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignemtn': ... - def __ror__ (self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignemtn': ... - def __rand__(self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignemtn': ... - def __rxor__(self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignemtn': ... + def __or__ (self, other: typing.Union['Qt.Alignment', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignment': ... + def __and__(self, other: typing.Union['Qt.Alignment', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignment': ... + def __xor__(self, other: typing.Union['Qt.Alignment', 'Qt.AlignmentFlag', int]) -> 'Qt.Alignment': ... + def __ror__ (self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignment': ... + def __rand__(self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignment': ... + def __rxor__(self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignment': ... class WindowFlags(sip.simplewrapper): From 4d48d558090e2ae55866d6bab80fcb2a14cac77d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 3 Sep 2021 16:21:32 +0200 Subject: [PATCH 063/421] Renaming and documentation update --- .../qflags/generate_qflags_stubs_and_tests.py | 264 +++++++++--------- 1 file changed, 130 insertions(+), 134 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index f6462047..e4412e56 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -10,7 +10,7 @@ import libcst as cst import libcst.matchers as matchers except ImportError: - raise ImportError('You need libcst to run the code analysis and transform\n' + raise ImportError('You need libcst to run the missing stubs generation\n' 'Please run the command:\n\tpython -m pip install libcst') @@ -35,16 +35,16 @@ QTBASE_MODULES = [ - ['QtCore', '../../PyQt5-stubs/QtCore.pyi'], - ['QtWidgets', '../../PyQt5-stubs/QtWidgets.pyi'], - ['QtGui', '../../PyQt5-stubs/QtGui.pyi'], - ['QtNetwork', '../../PyQt5-stubs/QtNetwork.pyi'], - ['QtDbus', '../../PyQt5-stubs/QtDbus.pyi'], - ['QtOpengl', '../../PyQt5-stubs/QtOpengl.pyi'], - ['QtPrintsupport', '../../PyQt5-stubs/QtPrintsupport.pyi'], - ['QtSql', '../../PyQt5-stubs/QtSql.pyi'], - ['QtTest', '../../PyQt5-stubs/QtTest.pyi'], - ['QtXml', '../../PyQt5-stubs/QtXml.pyi'], + ('QtCore', '../../PyQt5-stubs/QtCore.pyi'), + ('QtWidgets', '../../PyQt5-stubs/QtWidgets.pyi'), + ('QtGui', '../../PyQt5-stubs/QtGui.pyi'), + ('QtNetwork', '../../PyQt5-stubs/QtNetwork.pyi'), + ('QtDbus', '../../PyQt5-stubs/QtDbus.pyi'), + ('QtOpengl', '../../PyQt5-stubs/QtOpengl.pyi'), + ('QtPrintsupport', '../../PyQt5-stubs/QtPrintsupport.pyi'), + ('QtSql', '../../PyQt5-stubs/QtSql.pyi'), + ('QtTest', '../../PyQt5-stubs/QtTest.pyi'), + ('QtXml', '../../PyQt5-stubs/QtXml.pyi'), ] def log_progress(s: str) -> None: @@ -52,21 +52,26 @@ def log_progress(s: str) -> None: @dataclasses.dataclass class QFlagLocationInfo: + + # grep line indicating this qflag grep_line: str + + # qflag and enum name used in the QDECLARE() grep line qflag_class: str - qflag_enum: str + enum_class: str - qflag_value1: str - qflag_value2: str + # full class name (including nesting classes) generated in a second pass qflag_full_class_name: str - qflag_full_enum_name: str + enum_full_class_name: str + enum_value1: str + enum_value2: str - # list of (module_name, module_path) + # list of (module_name, module_path) where the qflag has been found module_info: List[ Tuple[str, str] ] def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[str, Any]]: - '''Encore the QFlagClassLoationInfo into a format suitable for json export (a dict)''' + '''Encode the QFlagClassLoationInfo into a format suitable for json export (a dict)''' if not isinstance(flag_loc_info, QFlagLocationInfo): # oups, we don't know how to encode that return flag_loc_info @@ -80,12 +85,7 @@ def identify_qflag_location(fname_grep_result: str, '''Parses the grep results to extract each qflag, and then look into all Qt modules to see where the flag is located. - Sort the result into 4 cases: - - qflag present once in only one module: we are sure that these can be safely replaced by a better version - - qflag present multiple times in one module: probably some extra module parsing might be needed to - understand which version is the qflag which we want to modify - - qflag present multiple times in multiples modules: we can not infer which module the flag is in - - qflag not present anywhere: these are probably not exported to PyQt + Return a list of QFlagLocationInfo indicating in which module the flag has been located. ''' parsed_qflags = [] # type: List[ QFlagLocationInfo ] with open(fname_grep_result) as f: @@ -108,15 +108,15 @@ def identify_qflag_location(fname_grep_result: str, qt_modules_content = [ (mod_name, mod_stub_path, open(mod_stub_path, encoding='utf8').read()) for (mod_name, mod_stub_path) in qt_modules] - for qflag_loc_info in parsed_qflags: - decl_qflag_class = 'class %s(' % qflag_loc_info.qflag_class - decl_enum_class = 'class %s(' % qflag_loc_info.qflag_enum + for flag_info in parsed_qflags: + decl_qflag_class = 'class %s(' % flag_info.qflag_class + decl_enum_class = 'class %s(' % flag_info.enum_class for mod_name, mod_stub_path, mod_content in qt_modules_content: if decl_qflag_class in mod_content and decl_enum_class in mod_content: # we have found one module - print('Adding QFlags %s to module %s' % (qflag_loc_info.qflag_class, mod_name)) - qflag_loc_info.module_info.append((mod_name, mod_stub_path)) + print('Adding QFlags %s to module %s' % (flag_info.qflag_class, mod_name)) + flag_info.module_info.append((mod_name, mod_stub_path)) count_qflag_class = mod_content.count(decl_qflag_class) count_enum_class = mod_content.count(decl_enum_class) @@ -124,33 +124,33 @@ def identify_qflag_location(fname_grep_result: str, print('QFlag present more than once, adding it more than once') extra_add = min(count_qflag_class, count_enum_class) - 1 for _ in range(extra_add): - qflag_loc_info.module_info.append((mod_name, mod_stub_path)) + flag_info.module_info.append((mod_name, mod_stub_path)) return parsed_qflags def group_qflags(qflag_location: List[QFlagLocationInfo] ) -> Dict[str, List[QFlagLocationInfo]]: - '''Group the QFlags into the following groups: + '''Group the QFlags into the following groups (inside a dictionnary): * one_flag_one_module: this flag is present once in one module exactly. * one_flag_many_modules: this flag is present once or multiple times in one or multiple modules * one_flag_no_module: this flag is not present in any modules at all. The first group is suitable for automatic processing. The second group requires human verification - The last group reflects the non exported QFlags + The last group reflects the QFlags not exported to PyQt or coming from modules not present in PyQt ''' d = { 'one_flag_one_module': [ - qflag_loc_info for qflag_loc_info in qflag_location - if len(qflag_loc_info.module_info) == 1 + flag_info for flag_info in qflag_location + if len(flag_info.module_info) == 1 ], 'one_flag_many_modules': [ - qflag_loc_info for qflag_loc_info in qflag_location - if len(qflag_loc_info.module_info) > 1 + flag_info for flag_info in qflag_location + if len(flag_info.module_info) > 1 ], 'one_flag_no_module': [ - qflag_loc_info for qflag_loc_info in qflag_location - if len(qflag_loc_info.module_info) == 0 + flag_info for flag_info in qflag_location + if len(flag_info.module_info) == 0 ], } @@ -174,26 +174,26 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, 'qflags_to_skip': [], } - for qflag_info in d['one_flag_many_modules']: + for flag_info in d['one_flag_many_modules']: result['qflags_to_skip'].append( { - 'qflag_class': qflag_info['qflag_class'], - 'qflag_enum': qflag_info['qflag_enum'], + 'qflag_class': flag_info['qflag_class'], + 'enum_class': flag_info['enum_class'], 'skip_reason': 'QFlag present more than once or in multiple modules' } ) - for qflag_info in d['one_flag_no_module']: + for flag_info in d['one_flag_no_module']: result['qflags_to_skip'].append( { - 'qflag_class': qflag_info['qflag_class'], - 'qflag_enum': qflag_info['qflag_enum'], + 'qflag_class': flag_info['qflag_class'], + 'enum_class': flag_info['enum_class'], 'skip_reason': 'QFlag not found', } ) - for qflag_info in d['one_flag_one_module']: - result['qflags_to_process'].append( qflag_info ) + for flag_info in d['one_flag_one_module']: + result['qflags_to_process'].append( flag_info ) with open(qflags_to_process_json, 'w') as f: json.dump(result, f, indent=4) @@ -227,12 +227,12 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str) -> bool: } def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: - '''Return True if the qflag is already included in one of the lists + '''Return True if the qflag is already included in one of the result lists of result_json''' flag_info_tuple = dataclasses.astuple(flag_info) - if flag_info_tuple in set(result['qflag_already_done']) \ - or flag_info_tuple in set(result['qflag_processed_done']) \ - or flag_info_tuple in set(result['qflag_process_error']): + if flag_info_tuple in set(result_json['qflag_already_done']) \ + or flag_info_tuple in set(result_json['qflag_processed_done']) \ + or flag_info_tuple in set(result_json['qflag_process_error']): return True return False @@ -246,24 +246,25 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: return False # check that the qflag is actually in the module - check_result, error_msg = check_qflag_in_module(flag_info) + gen_result, error_msg = generate_missing_stubs(flag_info) - # flag_info has been modified in-place with additional info: qflag_value1 and qflag_value2 - if check_result == QFlagCheckResult.CodeModifiedSuccessfully: + # Note that flag_info has been modified in-place with additional info: + # enum_value1, enum_value2, full_enum_class_name, full_qflag_class_name + if gen_result == QFlagGenResult.CodeModifiedSuccessfully: generate_qflag_test_file(flag_info) # run verifications - if check_result == QFlagCheckResult.CodeAlreadyModified: + if gen_result == QFlagGenResult.CodeAlreadyModified: # qflag methods are already there, check that the test filename is here too test_qflag_fname = gen_test_fname(flag_info) if os.path.exists(test_qflag_fname): result_json['qflag_already_done'].append(flag_info_dict) else: error_msg += 'QFlag methods presents but test file %s is missing\n' % test_qflag_fname - check_result = QFlagCheckResult.ErrorDuringProcessing + gen_result = QFlagGenResult.ErrorDuringProcessing - if check_result == QFlagCheckResult.ErrorDuringProcessing: + if gen_result == QFlagGenResult.ErrorDuringProcessing: flag_info_dict['error'] = flag_info_dict.get('error', '') + error_msg result_json['qflag_process_error'].append(flag_info_dict) @@ -276,56 +277,55 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: -class QFlagCheckResult(Enum): +class QFlagGenResult(Enum): + '''Enum indicating the result of generating the possibly missing stubs on the qflag classes''' CodeModifiedSuccessfully = 0 CodeAlreadyModified = 1 ErrorDuringProcessing = 2 -def check_qflag_in_module(flag_info: 'QFlagLocationInfo') -> Tuple[QFlagCheckResult, str]: +def generate_missing_stubs(flag_info: 'QFlagLocationInfo') -> Tuple[QFlagGenResult, str]: ''' Check that the QFlag enum+class are present in the module and check whether they support all the advanced QFlag operations. - If they do not, add the missing information by performing code transformation and saving the result. - - The flag_info is also modified in place to add one or two of the possible values taken by the enum. This - is needed for generating a proper test file. I don't like in-pace modification but here, it's the simplest. - - Returns: - * QFlag operations already present - * QFlag operations were missing, now added - * QFlag operations partially missing, now added. - - Raise ValueError if something goes wrong. + If they do not, generate the missing methods. - The QFlag operations are: + The flag_info input is also extended with additional information: + * full qflag class name + * full enum class name + * enum value 1 + * enum value 2 + These are needed for generating a proper test file. I don't like in-place modification + but here, it's the simplest. - On the enum class, add two methods: - class KeyboardModifier(int): - + def __or__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... # type: ignore[override] - + def __ror__ (self, other: int) -> 'Qt.KeyboardModifiers': ... # type: ignore[override, misc] + The generation consists of: - On the qflag class, add one more argument to __init__() - - def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: ... - + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ... + 1. On the enum class, add two methods: + class KeyboardModifier(int): + + def __or__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... # type: ignore[override] + + def __ror__ (self, other: int) -> 'Qt.KeyboardModifiers': ... # type: ignore[override, misc] - Possibly, remove the __init__() with only int argument if it exists + 2. On the qflag class, add one more overload of __init__() + + @typing.overload + + def __init__(self, f: int) -> None: ... - Add more methods: - def __or__ (self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - def __and__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - def __xor__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - def __ror__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... - def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... - def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + 3. On the qflag class, add more methods: + + def __or__ (self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + + def __and__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + + def __xor__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + + def __ror__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + + def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + + def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... - Returns a tuple of (result, error_msg): + Returns a tuple of (QFlagGenResult, error_msg): * CodeModifiedSuccessfully: - All modifications to the code of the module have been performed successfully + All modifications to the code of the module have been performed successfully. + Error message is empty. * CodeAlreadyModified: All modifications to the code were already done, no processing done. + Error message also indicates this information. * ErrorDuringProcessing: Some error occured during the processing, such as some modifications were partially done, @@ -340,13 +340,13 @@ class not found, class found multiple times, ... log_progress('Parsing module %s' % flag_info.module_info[0][0]) mod_cst = cst.parse_module(mod_content) - log_progress('Looking for class %s and %s in module %s' % (flag_info.qflag_class, flag_info.qflag_enum, + log_progress('Looking for class %s and %s in module %s' % (flag_info.qflag_class, flag_info.enum_class, flag_info.module_info[0][0])) - visitor = QFlagAndEnumFinder(flag_info.qflag_enum, flag_info.qflag_class) + visitor = QFlagAndEnumFinder(flag_info.enum_class, flag_info.qflag_class) mod_cst.visit(visitor) if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): - return (QFlagCheckResult.CodeAlreadyModified, visitor.error_msg) + return (QFlagGenResult.CodeAlreadyModified, visitor.error_msg) if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.Not): visitor.error_msg += 'Enum methods are present but not QFlag methods\n' @@ -355,18 +355,18 @@ class not found, class found multiple times, ... visitor.error_msg += 'QFlag methods are present but not Enum methods\n' if visitor.error_msg: - return (QFlagCheckResult.ErrorDuringProcessing, visitor.error_msg) + return (QFlagGenResult.ErrorDuringProcessing, visitor.error_msg) assert visitor.enum_methods_present == MethodPresent.Not assert visitor.qflag_method_present == MethodPresent.Not # storing the enum_values for further usage - flag_info.qflag_full_enum_name = visitor.enum_class_full_name - flag_info.qflag_value1 = visitor.enum_value1 - flag_info.qflag_value2 = visitor.enum_value2 + flag_info.enum_full_class_name = visitor.enum_class_full_name + flag_info.enum_value1 = visitor.enum_value1 + flag_info.enum_value2 = visitor.enum_value2 flag_info.qflag_full_class_name = visitor.qflag_class_full_name - log_progress('Transforming module %s by adding new methods' % flag_info.module_info[0][0]) + log_progress('Updating module %s by adding new methods' % flag_info.module_info[0][0]) transformer = QFlagAndEnumUpdater(visitor.enum_class_name, visitor.enum_class_full_name, visitor.qflag_class_name, visitor.qflag_class_full_name) updated_mod_cst = mod_cst.visit(transformer) @@ -375,12 +375,11 @@ class not found, class found multiple times, ... with open(flag_info.module_info[0][1], 'w') as f: f.write(updated_mod_cst.code) - # generate test file - - return (QFlagCheckResult.CodeModifiedSuccessfully, '') + return (QFlagGenResult.CodeModifiedSuccessfully, '') class MethodPresent(Enum): + '''An enum to reflect if a method is already present or not''' Unset = 0 All = 1 Not = 2 @@ -466,11 +465,11 @@ def check_enum_method_present(self, enum_node: cst.ClassDef) -> None: self.error_msg += 'class %s, method %s present without method %s\n' % ((self.enum_class_full_name,)+args) + def collect_enum_values(self, enum_node: cst.ClassDef) -> None: '''Collect two actual values for the enum and store them into self.enum_value1 and enum_value2 ''' - # find all lines consisting of an assignment to an ellipsis: - # example: AlignLeft = ... + # find all lines consisting of an assignment to an ellipsis, like "AlignLeft = ..." enum_values = matchers.findall(enum_node.body, matchers.SimpleStatementLine( body=[matchers.Assign(value=matchers.Ellipsis())])) if len(enum_values) == 0: @@ -577,7 +576,7 @@ def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.Cl for code, comment in new_methods_parts ) - # new calculate the proper spacing to have aligned comments + # now calculate the proper spacing to have aligned comments max_code_len = max(len(code) for code, comment in new_methods_filled) new_methods_spaced = tuple( code + ' '*(4+max_code_len-len(code)) + comment @@ -585,19 +584,18 @@ def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.Cl ) new_methods_cst = tuple(cst.parse_statement(s) for s in new_methods_spaced) return updated_node.with_changes(body=updated_node.body.with_changes(body= - new_methods_cst \ - + (updated_node.body.body[0].with_changes(leading_lines= - updated_node.body.body[0].leading_lines + (cst.EmptyLine(),)),) \ - + updated_node.body.body[1:] ) ) + new_methods_cst \ + + (updated_node.body.body[0].with_changes(leading_lines= + updated_node.body.body[0].leading_lines + + (cst.EmptyLine(),)),) \ + + updated_node.body.body[1:] ) ) def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: ''' - On the qflag class, add one more argument to __init__() - - def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: ... - + def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ... - - Possibly, remove the __init__() with only int argument if it exists + On the qflag class, add one more overload __init__() and add more methods + + @typing.overload + + def __init__(self, f: int) -> None: ... ''' init_methods = matchers.findall(updated_node.body, matchers.FunctionDef(name=matchers.Name('__init__'))) if len(init_methods) == 1: @@ -623,11 +621,11 @@ def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.C cst_init = cst.parse_statement( '@typing.overload\ndef __init__(self, f: int) -> None: ...' ) updated_node = updated_node.with_changes(body=updated_node.body.with_changes(body= - tuple(updated_node.body.body[:last_init_idx+1]) + - (cst_init,) + - tuple(updated_node.body.body[last_init_idx+1:]) - ) + tuple(updated_node.body.body[:last_init_idx+1]) + + (cst_init,) + + tuple(updated_node.body.body[last_init_idx+1:]) ) + ) new_methods = ( "def __or__ (self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", @@ -642,17 +640,15 @@ def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.C for s in new_methods ) return updated_node.with_changes(body=updated_node.body.with_changes(body= - tuple(updated_node.body.body) + new_methods_cst ) ) - - + tuple(updated_node.body.body) + new_methods_cst ) ) @functools.lru_cache(maxsize=1) def read_qflag_test_template(template_fname: str) -> Tuple[List[str], List[str], List[str]]: - '''Return the source of template for generating qflags test. + '''Return the source of the template for generating qflags test. - Return 3 parts: + Return 3 parts as a list of strings: - the first part should be unmodified - the second part should be replaced for a specific QFlag class - the third part should be unmodified @@ -660,32 +656,32 @@ def read_qflag_test_template(template_fname: str) -> Tuple[List[str], List[str], with open(template_fname) as f: lines = f.readlines() - sourcePart1, sourcePart2, sourcePart3 = [], [], [] - fillPart2, fillPart3 = False, False + source_part_before, source_part_middle, source_part_after = [], [], [] + fill_middle, fill_after = False, False for l in lines: - if fillPart3: - sourcePart3.append(l) + if fill_after: + source_part_after.append(l) continue - if fillPart2: + if fill_middle: if MARKER_SPECIFIC_END in l: - fillPart3 = True - sourcePart3.append(l) + fill_after = True + source_part_after.append(l) continue - sourcePart2.append(l) + source_part_middle.append(l) continue - sourcePart1.append(l) + source_part_before.append(l) if MARKER_SPECIFIC_START in l: - fillPart2 = True + fill_middle = True - return sourcePart1, sourcePart2, sourcePart3 + return source_part_before, source_part_middle, source_part_after def gen_test_fname(fli: QFlagLocationInfo) -> str: '''Generate the name of the test file which will verify this qflag''' - return 'test_{fli.module_info[0][0]}_{fli.qflag_class}_{fli.qflag_enum}'.format(fli=fli) + return 'test_{fli.module_info[0][0]}_{fli.qflag_class}_{fli.enum_class}'.format(fli=fli) def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: @@ -709,9 +705,9 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: oneFlagRefValue2 = {oneFlagValue2} '''.format(source=TEMPLATE_QFLAGS_TESTS, multiFlagName=flag_info.qflag_full_class_name, - oneFlagName=flag_info.qflag_full_enum_name, - oneFlagValue1=flag_info.qflag_value1, - oneFlagValue2=flag_info.qflag_value2 + oneFlagName=flag_info.enum_full_class_name, + oneFlagValue1=flag_info.enum_value1, + oneFlagValue2=flag_info.enum_value2 )) f.writelines(generic_part_after) print('File %s generated' % test_qflag_fname) @@ -749,7 +745,7 @@ def generate_qflags_to_process(): qflag_class='WindowStates', module_info=[ ('QtCore.pyi', r'..\..\pyqt5-stubs\QtCore.pyi')], grep_line='', qflag_value1='', qflag_value2='') - result, error_msg = check_qflag_in_module(flag_info) + result, error_msg = generate_missing_stubs(flag_info) # TODO: From 376e8ae06bff16f763f81b33d872c74d67942f23 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 4 Sep 2021 22:01:13 +0200 Subject: [PATCH 064/421] work in progress --- .../qflags/generate_qflags_stubs_and_tests.py | 107 ++++++++++-------- tests/qflags/qflags_test_template.py | 2 +- 2 files changed, 62 insertions(+), 47 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index e4412e56..b5797916 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -1,4 +1,4 @@ -from typing import List, Tuple, Dict, Union, Any, Optional +from typing import List, Tuple, Dict, Union, Any, Optional, cast import dataclasses import functools @@ -53,21 +53,21 @@ def log_progress(s: str) -> None: @dataclasses.dataclass class QFlagLocationInfo: - # grep line indicating this qflag - grep_line: str - # qflag and enum name used in the QDECLARE() grep line qflag_class: str enum_class: str + # grep line indicating this qflag + grep_line: str = '' + # full class name (including nesting classes) generated in a second pass - qflag_full_class_name: str - enum_full_class_name: str - enum_value1: str - enum_value2: str + qflag_full_class_name: str = '' + enum_full_class_name: str = '' + enum_value1: str = '' + enum_value2: str = '' # list of (module_name, module_path) where the qflag has been found - module_info: List[ Tuple[str, str] ] + module_info: Tuple[ Tuple[str, str], ... ] = dataclasses.field(default_factory=tuple) def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[str, Any]]: @@ -101,7 +101,7 @@ def identify_qflag_location(fname_grep_result: str, s = qflag_declare_stmt[qflag_declare_stmt.index('(')+1:qflag_declare_stmt.index(')')] qflag_class, enum_class = [v.strip(' ') for v in s.split(',')] parsed_qflags.append( - QFlagLocationInfo(grep_line, qflag_class, enum_class, []) + QFlagLocationInfo(qflag_class, enum_class, grep_line) ) # fill up modules with content @@ -116,7 +116,7 @@ def identify_qflag_location(fname_grep_result: str, if decl_qflag_class in mod_content and decl_enum_class in mod_content: # we have found one module print('Adding QFlags %s to module %s' % (flag_info.qflag_class, mod_name)) - flag_info.module_info.append((mod_name, mod_stub_path)) + flag_info.module_info += ((mod_name, mod_stub_path),) count_qflag_class = mod_content.count(decl_qflag_class) count_enum_class = mod_content.count(decl_enum_class) @@ -124,7 +124,7 @@ def identify_qflag_location(fname_grep_result: str, print('QFlag present more than once, adding it more than once') extra_add = min(count_qflag_class, count_enum_class) - 1 for _ in range(extra_add): - flag_info.module_info.append((mod_name, mod_stub_path)) + flag_info.module_info += ((mod_name, mod_stub_path),) return parsed_qflags @@ -175,7 +175,7 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, } for flag_info in d['one_flag_many_modules']: - result['qflags_to_skip'].append( + cast(List, result['qflags_to_skip']).append( { 'qflag_class': flag_info['qflag_class'], 'enum_class': flag_info['enum_class'], @@ -184,7 +184,7 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, ) for flag_info in d['one_flag_no_module']: - result['qflags_to_skip'].append( + cast(List, result['qflags_to_skip']).append( { 'qflag_class': flag_info['qflag_class'], 'enum_class': flag_info['enum_class'], @@ -193,7 +193,7 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, ) for flag_info in d['one_flag_one_module']: - result['qflags_to_process'].append( flag_info ) + cast(List, result['qflags_to_process']).append( flag_info ) with open(qflags_to_process_json, 'w') as f: json.dump(result, f, indent=4) @@ -220,31 +220,50 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str) -> bool: qflags_to_process = d['qflags_to_process'] - result_json = { + result_json: Dict[str, List[Dict]] = { 'qflag_already_done': [], 'qflag_processed_done': [], 'qflag_process_error': [], } + if os.path.exists(qflag_result_json): + with open(qflag_result_json, 'r') as f: + result_json = json.loads(f.read()) + def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: '''Return True if the qflag is already included in one of the result lists of result_json''' - flag_info_tuple = dataclasses.astuple(flag_info) - if flag_info_tuple in set(result_json['qflag_already_done']) \ - or flag_info_tuple in set(result_json['qflag_processed_done']) \ - or flag_info_tuple in set(result_json['qflag_process_error']): + flag_desc = (flag_info.module_info[0][0], flag_info.qflag_class, flag_info.enum_class) + already_done_set = set( (flag_info_dict['module_info'][0][0], + flag_info_dict['qflag_class'], + flag_info_dict['enum_class']) + for flag_info_dict in result_json['qflag_already_done']) + processed_done_set = set( (flag_info_dict['module_info'][0][0], + flag_info_dict['qflag_class'], + flag_info_dict['enum_class']) + for flag_info_dict in result_json['qflag_processed_done']) + process_error_set = set( (flag_info_dict['module_info'][0][0], + flag_info_dict['qflag_class'], + flag_info_dict['enum_class']) + for flag_info_dict in result_json['qflag_process_error']) + if flag_desc in already_done_set or flag_desc in processed_done_set or flag_desc in process_error_set: return True return False while len(qflags_to_process) != 0: flag_info_dict = qflags_to_process.pop(0) flag_info = QFlagLocationInfo(**flag_info_dict) + # force module_info into a tuple to make it hashable + flag_info.module_info = tuple((m0, m1) for (m0, m1) in flag_info.module_info) if not qflag_already_processed(flag_info): break else: # we have exhausted the list of qflag to process return False + log_progress('Generate stubs for %s and %s in module %s' % + (flag_info.qflag_class, flag_info.enum_class, flag_info.module_info[0][0])) + # check that the qflag is actually in the module gen_result, error_msg = generate_missing_stubs(flag_info) @@ -270,7 +289,7 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: # save our processing result with open(qflag_result_json, 'w') as f: - json.dump(result, f, indent=4) + json.dump(result_json, f, indent=4) # return True to indicate that more flags may be processed return True @@ -407,8 +426,6 @@ def __init__(self, enum_class: str, qflag_class: str) -> None: self.enum_value2 = '' # the node of the class, for debugging purpose - self.enum_class_cst_node = None - self.qflag_class_cst_node = None # when filled, set to one of the MethodPresent values self.enum_methods_present = MethodPresent.Unset @@ -424,9 +441,8 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: # we found it if self.enum_class_full_name != '': self.error_msg = 'class %s found multiple times\n' % self.enum_class_name - return + return None self.enum_class_full_name = '.'.join(self.full_name_stack) - self.enum_class_cst_node = node self.check_enum_method_present(node) self.collect_enum_values(node) @@ -435,9 +451,8 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: # we found it if self.qflag_class_full_name != '': self.error_msg = 'class %s found multiple times\n' % self.qflag_class_name - return + return None self.qflag_class_full_name = '.'.join(self.full_name_stack) - self.qflag_class_cst_node = node self.check_qflag_method_present(node) return None @@ -553,7 +568,7 @@ def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag self.error_msg = '' - def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: + def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: if original_node.name.value == self.enum_class: return self.transform_enum_class(original_node, updated_node) elif original_node.name.value == self.qflag_class: @@ -561,7 +576,7 @@ def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef return updated_node - def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: + def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: '''Add the two methods __or__ and __ror__ to the class body''' # we keep comments separated to align them properly in the final file @@ -591,7 +606,7 @@ def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.Cl + updated_node.body.body[1:] ) ) - def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.CSTNode: + def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: ''' On the qflag class, add one more overload __init__() and add more methods + @typing.overload @@ -681,7 +696,7 @@ def read_qflag_test_template(template_fname: str) -> Tuple[List[str], List[str], def gen_test_fname(fli: QFlagLocationInfo) -> str: '''Generate the name of the test file which will verify this qflag''' - return 'test_{fli.module_info[0][0]}_{fli.qflag_class}_{fli.enum_class}'.format(fli=fli) + return 'test_{fli.module_info[0][0]}_{fli.qflag_class}_{fli.enum_class}.py'.format(fli=fli) def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: @@ -697,20 +712,22 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: # replace the repplacable_part with code dedicated to our qflag f.write('''# file generated from {source} for QFlags class "{multiFlagName}" and flag class "{oneFlagName}" +from PyQt5 import {qtmodule} -OneFlagClass = {oneFlagName} -MultiFlagClass = {multiFlagName} +OneFlagClass = {qtmodule}.{oneFlagName} +MultiFlagClass = {qtmodule}.{multiFlagName} -oneFlagRefValue1 = {oneFlagValue1} -oneFlagRefValue2 = {oneFlagValue2} +oneFlagRefValue1 = {qtmodule}.{oneFlagValue1} +oneFlagRefValue2 = {qtmodule}.{oneFlagValue2} '''.format(source=TEMPLATE_QFLAGS_TESTS, multiFlagName=flag_info.qflag_full_class_name, oneFlagName=flag_info.enum_full_class_name, oneFlagValue1=flag_info.enum_value1, - oneFlagValue2=flag_info.enum_value2 + oneFlagValue2=flag_info.enum_value2, + qtmodule=flag_info.module_info[0][0] )) f.writelines(generic_part_after) - print('File %s generated' % test_qflag_fname) + log_progress('Test file generated: %s' % test_qflag_fname) def generate_qflags_to_process(): @@ -739,14 +756,12 @@ def generate_qflags_to_process(): qflag_result_json = 'qflag_process_result.json' - # process_qflag(qflags_to_process_json, qflag_result_json) - - flag_info = QFlagLocationInfo(qflag_enum='WindowState', - qflag_class='WindowStates', - module_info=[ ('QtCore.pyi', r'..\..\pyqt5-stubs\QtCore.pyi')], - grep_line='', qflag_value1='', qflag_value2='') - result, error_msg = generate_missing_stubs(flag_info) + if 0: + flag_info = QFlagLocationInfo(enum_class='WindowState', + qflag_class='WindowStates', + module_info=[ ('QtCore.pyi', r'..\..\pyqt5-stubs\QtCore.pyi')]) + result, error_msg = generate_missing_stubs(flag_info) + result = process_qflag(qflags_to_process_json, qflag_result_json) + print(result) -# TODO: -# * check_qflag should be renamed \ No newline at end of file diff --git a/tests/qflags/qflags_test_template.py b/tests/qflags/qflags_test_template.py index 18c1fcd1..78185e21 100644 --- a/tests/qflags/qflags_test_template.py +++ b/tests/qflags/qflags_test_template.py @@ -1,10 +1,10 @@ from typing import Union, TypeVar, Type import pytest -from PyQt5 import QtCore, QtWidgets ### Specific part # This file is used as a source to generate all qflags related tests. The specific part # changes for each test but the rest of the file is totally identical +from PyQt5 import QtCore OneFlagClass = QtCore.Qt.WindowType MultiFlagClass = QtCore.Qt.WindowFlags From 40cfc4aa88bc030d321dde917832f975cfe541a8 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 16:03:26 +0200 Subject: [PATCH 065/421] work in progress --- tests/qflags/generate_qflags_stubs_and_tests.py | 8 ++++---- tests/qflags_alignmentflags.py | 2 +- tests/windowflags.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index b5797916..08b33860 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -39,7 +39,7 @@ ('QtWidgets', '../../PyQt5-stubs/QtWidgets.pyi'), ('QtGui', '../../PyQt5-stubs/QtGui.pyi'), ('QtNetwork', '../../PyQt5-stubs/QtNetwork.pyi'), - ('QtDbus', '../../PyQt5-stubs/QtDbus.pyi'), + ('QtDBus', '../../PyQt5-stubs/QtDbus.pyi'), ('QtOpengl', '../../PyQt5-stubs/QtOpengl.pyi'), ('QtPrintsupport', '../../PyQt5-stubs/QtPrintsupport.pyi'), ('QtSql', '../../PyQt5-stubs/QtSql.pyi'), @@ -271,8 +271,8 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: # enum_value1, enum_value2, full_enum_class_name, full_qflag_class_name if gen_result == QFlagGenResult.CodeModifiedSuccessfully: generate_qflag_test_file(flag_info) - # run verifications + result_json['qflag_processed_done'].append(flag_info_dict) if gen_result == QFlagGenResult.CodeAlreadyModified: # qflag methods are already there, check that the test filename is here too @@ -717,8 +717,8 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: OneFlagClass = {qtmodule}.{oneFlagName} MultiFlagClass = {qtmodule}.{multiFlagName} -oneFlagRefValue1 = {qtmodule}.{oneFlagValue1} -oneFlagRefValue2 = {qtmodule}.{oneFlagValue2} +oneFlagRefValue1 = {qtmodule}.{oneFlagName}.{oneFlagValue1} +oneFlagRefValue2 = {qtmodule}.{oneFlagName}.{oneFlagValue2} '''.format(source=TEMPLATE_QFLAGS_TESTS, multiFlagName=flag_info.qflag_full_class_name, oneFlagName=flag_info.enum_full_class_name, diff --git a/tests/qflags_alignmentflags.py b/tests/qflags_alignmentflags.py index 423bc809..e45aa8db 100644 --- a/tests/qflags_alignmentflags.py +++ b/tests/qflags_alignmentflags.py @@ -1,5 +1,5 @@ from typing import Union, TypeVar, Type -import pytest # type: ignore +import pytest from PyQt5 import QtCore, QtWidgets ### Specific part diff --git a/tests/windowflags.py b/tests/windowflags.py index 27065161..18c1fcd1 100644 --- a/tests/windowflags.py +++ b/tests/windowflags.py @@ -1,5 +1,5 @@ from typing import Union, TypeVar, Type -import pytest # type: ignore +import pytest from PyQt5 import QtCore, QtWidgets ### Specific part From 2b3818ea43f0dcdd2ea46ec72926a3576244b825 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 18:02:38 +0200 Subject: [PATCH 066/421] Now working: running this script creates one more supported QFlag --- .../qflags/generate_qflags_stubs_and_tests.py | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 08b33860..02eaee7a 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -4,6 +4,7 @@ import functools import json import os +import subprocess from enum import Enum try: @@ -266,24 +267,43 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: # check that the qflag is actually in the module gen_result, error_msg = generate_missing_stubs(flag_info) + test_qflag_fname = gen_test_fname(flag_info) # Note that flag_info has been modified in-place with additional info: # enum_value1, enum_value2, full_enum_class_name, full_qflag_class_name if gen_result == QFlagGenResult.CodeModifiedSuccessfully: generate_qflag_test_file(flag_info) - # run verifications - result_json['qflag_processed_done'].append(flag_info_dict) + log_progress('Running pytest %s' % test_qflag_fname) + p = subprocess.run(['pytest', '-v', '--capture=no', test_qflag_fname]) + if p.returncode != 0: + error_msg += 'pytest failed\n' + gen_result = QFlagGenResult.ErrorDuringProcessing + else: + log_progress('Running mypy %s' % test_qflag_fname) + p = subprocess.run(['mypy', test_qflag_fname]) + if p.returncode != 0: + error_msg += 'mypy failed\n' + gen_result = QFlagGenResult.ErrorDuringProcessing + else: + log_progress('validation completed successfully') + result_json['qflag_processed_done'].append(flag_info_dict) + log_progress('Staging changes to git') + subprocess.run(['git', 'add', test_qflag_fname, flag_info.module_info[0][1]]) if gen_result == QFlagGenResult.CodeAlreadyModified: # qflag methods are already there, check that the test filename is here too - test_qflag_fname = gen_test_fname(flag_info) if os.path.exists(test_qflag_fname): + log_progress('QFlag %s %s already supported by %s' % (flag_info.qflag_class, + flag_info.enum_class, + flag_info.module_info[0][0])) result_json['qflag_already_done'].append(flag_info_dict) else: error_msg += 'QFlag methods presents but test file %s is missing\n' % test_qflag_fname gen_result = QFlagGenResult.ErrorDuringProcessing if gen_result == QFlagGenResult.ErrorDuringProcessing: + log_progress('Error during processing of QFlag %s %s' % (flag_info.qflag_class, + flag_info.enum_class)) flag_info_dict['error'] = flag_info_dict.get('error', '') + error_msg result_json['qflag_process_error'].append(flag_info_dict) @@ -763,5 +783,4 @@ def generate_qflags_to_process(): result, error_msg = generate_missing_stubs(flag_info) result = process_qflag(qflags_to_process_json, qflag_result_json) - print(result) From 797d16709ee17ef5b85efcecd7de9ac355d3a87c Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 18:05:42 +0200 Subject: [PATCH 067/421] Add all QFlag operations to QDBusConnection.ConnectionCabability in module QtDBus --- PyQt5-stubs/QtDBus.pyi | 11 + ...ectionCapabilities_ConnectionCapability.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py diff --git a/PyQt5-stubs/QtDBus.pyi b/PyQt5-stubs/QtDBus.pyi index ac26141b..8952bc43 100644 --- a/PyQt5-stubs/QtDBus.pyi +++ b/PyQt5-stubs/QtDBus.pyi @@ -106,6 +106,9 @@ class QDBus(sip.simplewrapper): class QDBusConnection(sip.simplewrapper): class ConnectionCapability(int): + def __or__ (self, other: 'QDBusConnection.ConnectionCapability') -> 'QDBusConnection.ConnectionCapabilities': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QDBusConnection.ConnectionCapabilities': ... # type: ignore[override, misc] + UnixFileDescriptorPassing = ... # type: QDBusConnection.ConnectionCapability UnixFileDescriptorPassing = ... # type: QDBusConnection.ConnectionCapability @@ -188,12 +191,20 @@ class QDBusConnection(sip.simplewrapper): def __init__(self, f: typing.Union['QDBusConnection.ConnectionCapabilities', 'QDBusConnection.ConnectionCapability']) -> None: ... @typing.overload def __init__(self, a0: 'QDBusConnection.ConnectionCapabilities') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QDBusConnection.ConnectionCapabilities': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QDBusConnection.ConnectionCapabilities', 'QDBusConnection.ConnectionCapability', int]) -> 'QDBusConnection.ConnectionCapabilities': ... + def __and__(self, other: typing.Union['QDBusConnection.ConnectionCapabilities', 'QDBusConnection.ConnectionCapability', int]) -> 'QDBusConnection.ConnectionCapabilities': ... + def __xor__(self, other: typing.Union['QDBusConnection.ConnectionCapabilities', 'QDBusConnection.ConnectionCapability', int]) -> 'QDBusConnection.ConnectionCapabilities': ... + def __ror__ (self, other: 'QDBusConnection.ConnectionCapability') -> 'QDBusConnection.ConnectionCapabilities': ... + def __rand__(self, other: 'QDBusConnection.ConnectionCapability') -> 'QDBusConnection.ConnectionCapabilities': ... + def __rxor__(self, other: 'QDBusConnection.ConnectionCapability') -> 'QDBusConnection.ConnectionCapabilities': ... @typing.overload def __init__(self, name: str) -> None: ... diff --git a/tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py b/tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py new file mode 100644 index 00000000..845e0bed --- /dev/null +++ b/tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QDBusConnection.ConnectionCapabilities" and flag class "QDBusConnection.ConnectionCapability" +from PyQt5 import QtDBus + +OneFlagClass = QtDBus.QDBusConnection.ConnectionCapability +MultiFlagClass = QtDBus.QDBusConnection.ConnectionCapabilities + +oneFlagRefValue1 = QtDBus.QDBusConnection.ConnectionCapability.UnixFileDescriptorPassing +oneFlagRefValue2 = QtDBus.QDBusConnection.ConnectionCapability.UnixFileDescriptorPassing +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From e518b6a21c1550870cd2931db63f9505e5496144 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 18:06:36 +0200 Subject: [PATCH 068/421] Adding all QFlag operations to QGLFormat.OpenGLVersionFlags, QGLFormat.OpenGLVersionFlag in module QtOpenGL --- PyQt5-stubs/QtOpenGL.pyi | 11 + ...GL_OpenGLVersionFlags_OpenGLVersionFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py diff --git a/PyQt5-stubs/QtOpenGL.pyi b/PyQt5-stubs/QtOpenGL.pyi index 71863f1a..72ef2b1a 100644 --- a/PyQt5-stubs/QtOpenGL.pyi +++ b/PyQt5-stubs/QtOpenGL.pyi @@ -118,6 +118,9 @@ class QGLFormat(sip.simplewrapper): CompatibilityProfile = ... # type: QGLFormat.OpenGLContextProfile class OpenGLVersionFlag(int): + def __or__ (self, other: 'QGLFormat.OpenGLVersionFlag') -> 'QGLFormat.OpenGLVersionFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGLFormat.OpenGLVersionFlags': ... # type: ignore[override, misc] + OpenGL_Version_None = ... # type: QGLFormat.OpenGLVersionFlag OpenGL_Version_1_1 = ... # type: QGLFormat.OpenGLVersionFlag OpenGL_Version_1_2 = ... # type: QGLFormat.OpenGLVersionFlag @@ -170,12 +173,20 @@ class QGLFormat(sip.simplewrapper): def __init__(self, f: typing.Union['QGLFormat.OpenGLVersionFlags', 'QGLFormat.OpenGLVersionFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QGLFormat.OpenGLVersionFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGLFormat.OpenGLVersionFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGLFormat.OpenGLVersionFlags', 'QGLFormat.OpenGLVersionFlag', int]) -> 'QGLFormat.OpenGLVersionFlags': ... + def __and__(self, other: typing.Union['QGLFormat.OpenGLVersionFlags', 'QGLFormat.OpenGLVersionFlag', int]) -> 'QGLFormat.OpenGLVersionFlags': ... + def __xor__(self, other: typing.Union['QGLFormat.OpenGLVersionFlags', 'QGLFormat.OpenGLVersionFlag', int]) -> 'QGLFormat.OpenGLVersionFlags': ... + def __ror__ (self, other: 'QGLFormat.OpenGLVersionFlag') -> 'QGLFormat.OpenGLVersionFlags': ... + def __rand__(self, other: 'QGLFormat.OpenGLVersionFlag') -> 'QGLFormat.OpenGLVersionFlags': ... + def __rxor__(self, other: 'QGLFormat.OpenGLVersionFlag') -> 'QGLFormat.OpenGLVersionFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py b/tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py new file mode 100644 index 00000000..c8ed0209 --- /dev/null +++ b/tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGLFormat.OpenGLVersionFlags" and flag class "QGLFormat.OpenGLVersionFlag" +from PyQt5 import QtOpenGL + +OneFlagClass = QtOpenGL.QGLFormat.OpenGLVersionFlag +MultiFlagClass = QtOpenGL.QGLFormat.OpenGLVersionFlags + +oneFlagRefValue1 = QtOpenGL.QGLFormat.OpenGLVersionFlag.OpenGL_Version_None +oneFlagRefValue2 = QtOpenGL.QGLFormat.OpenGLVersionFlag.OpenGL_Version_1_1 +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From d24856ac4d1d1305216ec04d206fe53a23d78bae Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:01:46 +0200 Subject: [PATCH 069/421] Description of how to use the generation script --- tests/qflags/README_qflags.md | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/qflags/README_qflags.md diff --git a/tests/qflags/README_qflags.md b/tests/qflags/README_qflags.md new file mode 100644 index 00000000..13622d86 --- /dev/null +++ b/tests/qflags/README_qflags.md @@ -0,0 +1,69 @@ +# QFlag stubs semi-automatic generation process + +This directory is dedicated to helping with the generation of stubs related to all QFlags used in PyQt5. + +## Overview + +The general idea of the generation is: +* Grep Qt sources, looking for all QFlag based classes and store the result in a text file +* Process the grep text file to identify the QFlag names and their module. Generates a qflags_modules_analysis.json +* Using qflags_modules_analysis.json , extract the QFlags where the module is cleary identified and put + them into a qflags_to_process.json file. +* Process each flag one by one from qflags_to_process.json and output a qflags_process_result.json . For + each QFlag: + ** verify with code analysis if the QFlag is indeed present in this module + ** check if the stubs for all qflags operation are already present. If yes, stops. + ** if not, add the missing stubs to the module and generate a test file in the form test__.py + ** run pytest and mypy on the generated test file + ** if successful, stage the changes to git + ** if there is any error in the process, stops. + + +## Details + +To run all the above steps, proceed with the following steps. + + +### Grep the Qt sources + +The command-line to use is: + + qt-src\qt5\qtbase>rg --type-add "headers:*.h" -t headers Q_DECLARE_FLAGS --no-heading > qt-qflag-grep-result.txt + + +### Analyse the QFlags module location + +Run: + + python generate_qflags_stubs_and_tests.py analyse_grep_results qt-qflag-grep-result.txt + +You get two files: + * qflags_modules_analysis.json + * qflags_to_process.json + +With human verification, you can add more QFlags to the qflags_to_process.json file. + + +### Generate and test the new stubs + +Run: + python generate_qflags_stubs_and_tests.py gen_qflag_stub 5 + +This will process 5 QFlags from qflags_to_process.json . The result of the processing is: +* the file qflags_process_result.json is updated +* when the generation and test is successful: + ** the qt module is updated + ** a new test file is added in the format test__.py + ** the new test file and the module are staged in git + +Now, you can manually perform the git commit. + +## Conclusion + +The process is semi-manual at the moment. The tool will process QFlags in batches and let the user perform +the final git commit and push. + +Note that more intelligence shall be put in the future to handle QFlags with identical names located in +multiple classes or modules. + + From e806c20c75a43fafeb30aad001104f2c9d48f9fb Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:17:41 +0200 Subject: [PATCH 070/421] QFlag operations for QTextCodec.ConversionFlags, QTextCodec.ConversionFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...t_QtCore_ConversionFlags_ConversionFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 302fe779..cc17807c 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -10942,6 +10942,9 @@ class QTextBoundaryFinder(sip.simplewrapper): class QTextCodec(sip.wrapper): class ConversionFlag(int): + def __or__ (self, other: 'QTextCodec.ConversionFlag') -> 'QTextCodec.ConversionFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QTextCodec.ConversionFlags': ... # type: ignore[override, misc] + DefaultConversion = ... # type: QTextCodec.ConversionFlag ConvertInvalidToNull = ... # type: QTextCodec.ConversionFlag IgnoreHeader = ... # type: QTextCodec.ConversionFlag @@ -10958,12 +10961,20 @@ class QTextCodec(sip.wrapper): def __init__(self, f: typing.Union['QTextCodec.ConversionFlags', 'QTextCodec.ConversionFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QTextCodec.ConversionFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTextCodec.ConversionFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTextCodec.ConversionFlags', 'QTextCodec.ConversionFlag', int]) -> 'QTextCodec.ConversionFlags': ... + def __and__(self, other: typing.Union['QTextCodec.ConversionFlags', 'QTextCodec.ConversionFlag', int]) -> 'QTextCodec.ConversionFlags': ... + def __xor__(self, other: typing.Union['QTextCodec.ConversionFlags', 'QTextCodec.ConversionFlag', int]) -> 'QTextCodec.ConversionFlags': ... + def __ror__ (self, other: 'QTextCodec.ConversionFlag') -> 'QTextCodec.ConversionFlags': ... + def __rand__(self, other: 'QTextCodec.ConversionFlag') -> 'QTextCodec.ConversionFlags': ... + def __rxor__(self, other: 'QTextCodec.ConversionFlag') -> 'QTextCodec.ConversionFlags': ... class ConverterState(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py b/tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py new file mode 100644 index 00000000..e9af79fe --- /dev/null +++ b/tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTextCodec.ConversionFlags" and flag class "QTextCodec.ConversionFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QTextCodec.ConversionFlag +MultiFlagClass = QtCore.QTextCodec.ConversionFlags + +oneFlagRefValue1 = QtCore.QTextCodec.ConversionFlag.DefaultConversion +oneFlagRefValue2 = QtCore.QTextCodec.ConversionFlag.ConvertInvalidToNull +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From b7fd9bfaf68fa7e0c6e9704838ab3d1f8b242a6d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:19:08 +0200 Subject: [PATCH 071/421] More documentation and script cleaning --- .../qflags/generate_qflags_stubs_and_tests.py | 71 ++++++++++++------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 02eaee7a..f92625ae 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -15,14 +15,17 @@ 'Please run the command:\n\tpython -m pip install libcst') -'''How to use this generator script: - -1. Grep Qt sources, looking for all QFlag based classes. The command-line to use is: - - qt-src\qt5\qtbase>rg --type-add "headers:*.h" -t headers Q_DECLARE_FLAGS --no-heading > qt-qflag-grep-result.txt - -2. Run the script to identify where each QFlag is located in PyQt. -''' +USAGE = '''Usage 1: {prog} analyse_grep_results + Process the to extract all the qflag location information. Generates + two output: + - qflags_modules_analysis.json : a general file describing which qflag are suitable for processing + - qflags_to_process.json: a list of qflag ready to process with the next command. + +Usage 2: {prog} gen_qflag_stub + Using file qflag_to_process.json, process qflags and modify the PyQt modules. + The output of this processing is available in qflag_process_result.json + If is not provided, defaults to 1 +'''.format(prog=sys.argv[0]) # the file defining the qflag implementation, to be skipped QFLAG_SRC='src\\corelib\\global\\qflags.h' @@ -40,8 +43,8 @@ ('QtWidgets', '../../PyQt5-stubs/QtWidgets.pyi'), ('QtGui', '../../PyQt5-stubs/QtGui.pyi'), ('QtNetwork', '../../PyQt5-stubs/QtNetwork.pyi'), - ('QtDBus', '../../PyQt5-stubs/QtDbus.pyi'), - ('QtOpengl', '../../PyQt5-stubs/QtOpengl.pyi'), + ('QtDBus', '../../PyQt5-stubs/QtDBus.pyi'), + ('QtOpenGL', '../../PyQt5-stubs/QtOpenGL.pyi'), ('QtPrintsupport', '../../PyQt5-stubs/QtPrintsupport.pyi'), ('QtSql', '../../PyQt5-stubs/QtSql.pyi'), ('QtTest', '../../PyQt5-stubs/QtTest.pyi'), @@ -750,37 +753,53 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: log_progress('Test file generated: %s' % test_qflag_fname) -def generate_qflags_to_process(): +def generate_qflags_to_process(qt_qflag_grep_result_fname): '''Run the generation process from the grep output parsing to the generation of json file listing the flags to process''' - qt_qflag_grep_result_fname = 'qt-qflag-grep-result.txt' location_qflags = identify_qflag_location(qt_qflag_grep_result_fname, QTBASE_MODULES) - print('%d qflags extracted from grep file' % len(location_qflags)) + log_progress('%d qflags extracted from grep file' % len(location_qflags)) qflags_groups = group_qflags(location_qflags) - print('%d qflags ready to be processed' % len(qflags_groups['one_flag_one_module'])) + log_progress('%d qflags ready to be processed' % len(qflags_groups['one_flag_one_module'])) qflags_modules_analysis_json = 'qflags_modules_analysis.json' # put our intermediate classification into a json file for human review with open(qflags_modules_analysis_json, 'w') as f: json.dump(qflags_groups, f, indent=4, default=json_encode_qflaglocationinfo) - print('QFlag analysis saved to: %s' % qflags_modules_analysis_json) + log_progress('QFlag analysis saved to: %s' % qflags_modules_analysis_json) qflags_to_process_json = 'qflags_to_process.json' extract_qflags_to_process(qflags_modules_analysis_json, qflags_to_process_json) - + log_progress('qflag file ready to process: %s' % qflags_to_process_json) if __name__ == '__main__': - # generate_qflags_to_process() - qflags_to_process_json = 'qflags_to_process.json' - # here we have the opportunity for human modification of the json file + if len(sys.argv) <= 1: + print(USAGE) + sys.exit(1) + + if sys.argv[1] == 'gen_qflag_stub': + nb = 1 + if len(sys.argv) > 2: + nb = int(sys.argv[2]) + + qflags_to_process_json = 'qflags_to_process.json' + qflag_result_json = 'qflag_process_result.json' + more_available = True + while nb > 0 and more_available: + nb -= 1 + more_available = process_qflag(qflags_to_process_json, qflag_result_json) - qflag_result_json = 'qflag_process_result.json' + elif sys.argv[1] == 'analyse_grep_results': + if len(sys.argv) <= 2: + print('Error, you must provide the filename of the grep results\n') + print(USAGE) + sys.exit(1) - if 0: - flag_info = QFlagLocationInfo(enum_class='WindowState', - qflag_class='WindowStates', - module_info=[ ('QtCore.pyi', r'..\..\pyqt5-stubs\QtCore.pyi')]) - result, error_msg = generate_missing_stubs(flag_info) + grep_fname = sys.argv[2] + generate_qflags_to_process(grep_fname) + + else: + print('Error, invalid command line arguments\n') + print(USAGE) + sys.exit(1) - result = process_qflag(qflags_to_process_json, qflag_result_json) From a8b4e95c745d3a16d87911b5b1c11693ffecaa58 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:19:58 +0200 Subject: [PATCH 072/421] Restore the module when test fail --- .../qflags/generate_qflags_stubs_and_tests.py | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index f92625ae..a75c0a63 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -4,6 +4,7 @@ import functools import json import os +import sys import subprocess from enum import Enum @@ -269,7 +270,7 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: (flag_info.qflag_class, flag_info.enum_class, flag_info.module_info[0][0])) # check that the qflag is actually in the module - gen_result, error_msg = generate_missing_stubs(flag_info) + gen_result, error_msg, old_mod_content = generate_missing_stubs(flag_info) test_qflag_fname = gen_test_fname(flag_info) # Note that flag_info has been modified in-place with additional info: @@ -281,17 +282,25 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: if p.returncode != 0: error_msg += 'pytest failed\n' gen_result = QFlagGenResult.ErrorDuringProcessing + log_progress('Restoring module content') + with open(flag_info.module_info[0][1], 'w') as f: + f.write(old_mod_content) else: log_progress('Running mypy %s' % test_qflag_fname) p = subprocess.run(['mypy', test_qflag_fname]) if p.returncode != 0: error_msg += 'mypy failed\n' gen_result = QFlagGenResult.ErrorDuringProcessing + log_progress('Restoring module content') + with open(flag_info.module_info[0][1], 'w') as f: + f.write(old_mod_content) else: log_progress('validation completed successfully') result_json['qflag_processed_done'].append(flag_info_dict) log_progress('Staging changes to git') subprocess.run(['git', 'add', test_qflag_fname, flag_info.module_info[0][1]]) + print('QFlag operations for %s, %s in module %s' % + (flag_info.qflag_full_class_name, flag_info.enum_full_class_name, flag_info.module_info[0][0])) if gen_result == QFlagGenResult.CodeAlreadyModified: # qflag methods are already there, check that the test filename is here too @@ -326,7 +335,7 @@ class QFlagGenResult(Enum): ErrorDuringProcessing = 2 -def generate_missing_stubs(flag_info: 'QFlagLocationInfo') -> Tuple[QFlagGenResult, str]: +def generate_missing_stubs(flag_info: 'QFlagLocationInfo') -> Tuple[QFlagGenResult, str, str]: ''' Check that the QFlag enum+class are present in the module and check whether they support all the advanced QFlag operations. @@ -360,20 +369,25 @@ class KeyboardModifier(int): + def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... - Returns a tuple of (QFlagGenResult, error_msg): + Returns a tuple of (QFlagGenResult, error_msg, mod_content): * CodeModifiedSuccessfully: All modifications to the code of the module have been performed successfully. Error message is empty. + mod_content contains the full text of the module. If when performing verifications on this + change, it turns out that the change is not valid, you can restore the module to its + previous content using mod_content * CodeAlreadyModified: All modifications to the code were already done, no processing done. Error message also indicates this information. + mod_content is empty (not useful) * ErrorDuringProcessing: Some error occured during the processing, such as some modifications were partially done, class not found, class found multiple times, ... The detail of the error is provided in the second argument of the return value. + mod_content is empty (not useful) ''' log_progress('Opening module %s' % flag_info.module_info[0][0]) with open(flag_info.module_info[0][1]) as f: @@ -388,7 +402,7 @@ class not found, class found multiple times, ... mod_cst.visit(visitor) if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): - return (QFlagGenResult.CodeAlreadyModified, visitor.error_msg) + return (QFlagGenResult.CodeAlreadyModified, visitor.error_msg, '') if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.Not): visitor.error_msg += 'Enum methods are present but not QFlag methods\n' @@ -397,7 +411,7 @@ class not found, class found multiple times, ... visitor.error_msg += 'QFlag methods are present but not Enum methods\n' if visitor.error_msg: - return (QFlagGenResult.ErrorDuringProcessing, visitor.error_msg) + return (QFlagGenResult.ErrorDuringProcessing, visitor.error_msg, '') assert visitor.enum_methods_present == MethodPresent.Not assert visitor.qflag_method_present == MethodPresent.Not @@ -417,7 +431,7 @@ class not found, class found multiple times, ... with open(flag_info.module_info[0][1], 'w') as f: f.write(updated_mod_cst.code) - return (QFlagGenResult.CodeModifiedSuccessfully, '') + return (QFlagGenResult.CodeModifiedSuccessfully, '', mod_content) class MethodPresent(Enum): From 5ee9320efef905b72b80222748212b9c6c397410 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:21:17 +0200 Subject: [PATCH 073/421] QFlag operations for QDir.Filters, QDir.Filter in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + tests/qflags/test_QtCore_Filters_Filter.py | 231 +++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_Filters_Filter.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index cc17807c..fbe5df3d 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -5318,6 +5318,9 @@ class QDir(sip.simplewrapper): NoSort = ... # type: QDir.SortFlag class Filter(int): + def __or__ (self, other: 'QDir.Filter') -> 'QDir.Filters': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QDir.Filters': ... # type: ignore[override, misc] + Dirs = ... # type: QDir.Filter Files = ... # type: QDir.Filter Drives = ... # type: QDir.Filter @@ -5368,12 +5371,20 @@ class QDir(sip.simplewrapper): def __init__(self, f: typing.Union['QDir.Filters', 'QDir.Filter']) -> None: ... @typing.overload def __init__(self, a0: 'QDir.Filters') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QDir.Filters': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QDir.Filters', 'QDir.Filter', int]) -> 'QDir.Filters': ... + def __and__(self, other: typing.Union['QDir.Filters', 'QDir.Filter', int]) -> 'QDir.Filters': ... + def __xor__(self, other: typing.Union['QDir.Filters', 'QDir.Filter', int]) -> 'QDir.Filters': ... + def __ror__ (self, other: 'QDir.Filter') -> 'QDir.Filters': ... + def __rand__(self, other: 'QDir.Filter') -> 'QDir.Filters': ... + def __rxor__(self, other: 'QDir.Filter') -> 'QDir.Filters': ... class SortFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_Filters_Filter.py b/tests/qflags/test_QtCore_Filters_Filter.py new file mode 100644 index 00000000..fc5a6c26 --- /dev/null +++ b/tests/qflags/test_QtCore_Filters_Filter.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QDir.Filters" and flag class "QDir.Filter" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QDir.Filter +MultiFlagClass = QtCore.QDir.Filters + +oneFlagRefValue1 = QtCore.QDir.Filter.Dirs +oneFlagRefValue2 = QtCore.QDir.Filter.Files +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a41b9fa52289754e09dbaa11ad3ff0a29fb05a37 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:22:26 +0200 Subject: [PATCH 074/421] QFlag operations for QDir.SortFlags, QDir.SortFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../qflags/test_QtCore_SortFlags_SortFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_SortFlags_SortFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index fbe5df3d..877c52bb 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -5291,6 +5291,9 @@ class QDeadlineTimer(sip.simplewrapper): class QDir(sip.simplewrapper): class SortFlag(int): + def __or__ (self, other: 'QDir.SortFlag') -> 'QDir.SortFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QDir.SortFlags': ... # type: ignore[override, misc] + Name = ... # type: QDir.SortFlag Time = ... # type: QDir.SortFlag Size = ... # type: QDir.SortFlag @@ -5394,12 +5397,20 @@ class QDir(sip.simplewrapper): def __init__(self, f: typing.Union['QDir.SortFlags', 'QDir.SortFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QDir.SortFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QDir.SortFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QDir.SortFlags', 'QDir.SortFlag', int]) -> 'QDir.SortFlags': ... + def __and__(self, other: typing.Union['QDir.SortFlags', 'QDir.SortFlag', int]) -> 'QDir.SortFlags': ... + def __xor__(self, other: typing.Union['QDir.SortFlags', 'QDir.SortFlag', int]) -> 'QDir.SortFlags': ... + def __ror__ (self, other: 'QDir.SortFlag') -> 'QDir.SortFlags': ... + def __rand__(self, other: 'QDir.SortFlag') -> 'QDir.SortFlags': ... + def __rxor__(self, other: 'QDir.SortFlag') -> 'QDir.SortFlags': ... @typing.overload def __init__(self, a0: 'QDir') -> None: ... diff --git a/tests/qflags/test_QtCore_SortFlags_SortFlag.py b/tests/qflags/test_QtCore_SortFlags_SortFlag.py new file mode 100644 index 00000000..2a61d311 --- /dev/null +++ b/tests/qflags/test_QtCore_SortFlags_SortFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QDir.SortFlags" and flag class "QDir.SortFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QDir.SortFlag +MultiFlagClass = QtCore.QDir.SortFlags + +oneFlagRefValue1 = QtCore.QDir.SortFlag.Name +oneFlagRefValue2 = QtCore.QDir.SortFlag.Time +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From cb7788f5e22a36d8d8cc4fbce683715575dd38c3 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:32:04 +0200 Subject: [PATCH 075/421] QFlag operations for QFileDevice.Permissions, QFileDevice.Permission in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_Permissions_Permission.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_Permissions_Permission.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 877c52bb..2b5ca0ec 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -5820,6 +5820,9 @@ class QFileDevice(QIODevice): DontCloseHandle = ... # type: QFileDevice.FileHandleFlag class Permission(int): + def __or__ (self, other: 'QFileDevice.Permission') -> 'QFileDevice.Permissions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QFileDevice.Permissions': ... # type: ignore[override, misc] + ReadOwner = ... # type: QFileDevice.Permission WriteOwner = ... # type: QFileDevice.Permission ExeOwner = ... # type: QFileDevice.Permission @@ -5887,12 +5890,20 @@ class QFileDevice(QIODevice): def __init__(self, f: typing.Union['QFileDevice.Permissions', 'QFileDevice.Permission']) -> None: ... @typing.overload def __init__(self, a0: 'QFileDevice.Permissions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QFileDevice.Permissions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QFileDevice.Permissions', 'QFileDevice.Permission', int]) -> 'QFileDevice.Permissions': ... + def __and__(self, other: typing.Union['QFileDevice.Permissions', 'QFileDevice.Permission', int]) -> 'QFileDevice.Permissions': ... + def __xor__(self, other: typing.Union['QFileDevice.Permissions', 'QFileDevice.Permission', int]) -> 'QFileDevice.Permissions': ... + def __ror__ (self, other: 'QFileDevice.Permission') -> 'QFileDevice.Permissions': ... + def __rand__(self, other: 'QFileDevice.Permission') -> 'QFileDevice.Permissions': ... + def __rxor__(self, other: 'QFileDevice.Permission') -> 'QFileDevice.Permissions': ... class FileHandleFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_Permissions_Permission.py b/tests/qflags/test_QtCore_Permissions_Permission.py new file mode 100644 index 00000000..581bd29b --- /dev/null +++ b/tests/qflags/test_QtCore_Permissions_Permission.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QFileDevice.Permissions" and flag class "QFileDevice.Permission" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QFileDevice.Permission +MultiFlagClass = QtCore.QFileDevice.Permissions + +oneFlagRefValue1 = QtCore.QFileDevice.Permission.ReadOwner +oneFlagRefValue2 = QtCore.QFileDevice.Permission.WriteOwner +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From d5717fb2fc8ec8dacb3346e905eb916e4087e328 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:34:15 +0200 Subject: [PATCH 076/421] QFlag operations for QItemSelectionModel.SelectionFlags, QItemSelectionModel.SelectionFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...est_QtCore_SelectionFlags_SelectionFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 2b5ca0ec..4bed5a5c 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -6225,6 +6225,9 @@ class QItemSelectionRange(sip.simplewrapper): class QItemSelectionModel(QObject): class SelectionFlag(int): + def __or__ (self, other: 'QItemSelectionModel.SelectionFlag') -> 'QItemSelectionModel.SelectionFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QItemSelectionModel.SelectionFlags': ... # type: ignore[override, misc] + NoUpdate = ... # type: QItemSelectionModel.SelectionFlag Clear = ... # type: QItemSelectionModel.SelectionFlag Select = ... # type: QItemSelectionModel.SelectionFlag @@ -6257,12 +6260,20 @@ class QItemSelectionModel(QObject): def __init__(self, f: typing.Union['QItemSelectionModel.SelectionFlags', 'QItemSelectionModel.SelectionFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QItemSelectionModel.SelectionFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QItemSelectionModel.SelectionFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QItemSelectionModel.SelectionFlags', 'QItemSelectionModel.SelectionFlag', int]) -> 'QItemSelectionModel.SelectionFlags': ... + def __and__(self, other: typing.Union['QItemSelectionModel.SelectionFlags', 'QItemSelectionModel.SelectionFlag', int]) -> 'QItemSelectionModel.SelectionFlags': ... + def __xor__(self, other: typing.Union['QItemSelectionModel.SelectionFlags', 'QItemSelectionModel.SelectionFlag', int]) -> 'QItemSelectionModel.SelectionFlags': ... + def __ror__ (self, other: 'QItemSelectionModel.SelectionFlag') -> 'QItemSelectionModel.SelectionFlags': ... + def __rand__(self, other: 'QItemSelectionModel.SelectionFlag') -> 'QItemSelectionModel.SelectionFlags': ... + def __rxor__(self, other: 'QItemSelectionModel.SelectionFlag') -> 'QItemSelectionModel.SelectionFlags': ... @typing.overload def __init__(self, model: typing.Optional[QAbstractItemModel] = ...) -> None: ... diff --git a/tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py b/tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py new file mode 100644 index 00000000..266ce297 --- /dev/null +++ b/tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QItemSelectionModel.SelectionFlags" and flag class "QItemSelectionModel.SelectionFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QItemSelectionModel.SelectionFlag +MultiFlagClass = QtCore.QItemSelectionModel.SelectionFlags + +oneFlagRefValue1 = QtCore.QItemSelectionModel.SelectionFlag.NoUpdate +oneFlagRefValue2 = QtCore.QItemSelectionModel.SelectionFlag.Clear +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From e0e776d76902b07f8748e196a00a7418df67ab82 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:35:58 +0200 Subject: [PATCH 077/421] QFlag operations for Qt.KeyboardModifiers, Qt.KeyboardModifier in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...Core_KeyboardModifiers_KeyboardModifier.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 4bed5a5c..41b42477 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2641,6 +2641,9 @@ class Qt(sip.simplewrapper): UNICODE_ACCEL = ... # type: Qt.Modifier class KeyboardModifier(int): + def __or__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.KeyboardModifiers': ... # type: ignore[override, misc] + NoModifier = ... # type: Qt.KeyboardModifier ShiftModifier = ... # type: Qt.KeyboardModifier ControlModifier = ... # type: Qt.KeyboardModifier @@ -2710,12 +2713,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.KeyboardModifiers') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.KeyboardModifiers': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __and__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __xor__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + def __ror__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... class MouseButtons(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py b/tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py new file mode 100644 index 00000000..5d0d9729 --- /dev/null +++ b/tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.KeyboardModifiers" and flag class "Qt.KeyboardModifier" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.KeyboardModifier +MultiFlagClass = QtCore.Qt.KeyboardModifiers + +oneFlagRefValue1 = QtCore.Qt.KeyboardModifier.NoModifier +oneFlagRefValue2 = QtCore.Qt.KeyboardModifier.ShiftModifier +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 97f04023ebc389b145e18dc1716fc94a1e098c19 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:37:48 +0200 Subject: [PATCH 078/421] QFlag operations for Qt.MouseButtons, Qt.MouseButton in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_MouseButtons_MouseButton.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_MouseButtons_MouseButton.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 41b42477..70b74c98 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2553,6 +2553,9 @@ class Qt(sip.simplewrapper): Vertical = ... # type: Qt.Orientation class MouseButton(int): + def __or__ (self, other: 'Qt.MouseButton') -> 'Qt.MouseButtons': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.MouseButtons': ... # type: ignore[override, misc] + NoButton = ... # type: Qt.MouseButton AllButtons = ... # type: Qt.MouseButton LeftButton = ... # type: Qt.MouseButton @@ -2736,12 +2739,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.MouseButtons', 'Qt.MouseButton']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.MouseButtons') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.MouseButtons': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.MouseButtons', 'Qt.MouseButton', int]) -> 'Qt.MouseButtons': ... + def __and__(self, other: typing.Union['Qt.MouseButtons', 'Qt.MouseButton', int]) -> 'Qt.MouseButtons': ... + def __xor__(self, other: typing.Union['Qt.MouseButtons', 'Qt.MouseButton', int]) -> 'Qt.MouseButtons': ... + def __ror__ (self, other: 'Qt.MouseButton') -> 'Qt.MouseButtons': ... + def __rand__(self, other: 'Qt.MouseButton') -> 'Qt.MouseButtons': ... + def __rxor__(self, other: 'Qt.MouseButton') -> 'Qt.MouseButtons': ... class Orientations(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_MouseButtons_MouseButton.py b/tests/qflags/test_QtCore_MouseButtons_MouseButton.py new file mode 100644 index 00000000..e5870360 --- /dev/null +++ b/tests/qflags/test_QtCore_MouseButtons_MouseButton.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.MouseButtons" and flag class "Qt.MouseButton" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.MouseButton +MultiFlagClass = QtCore.Qt.MouseButtons + +oneFlagRefValue1 = QtCore.Qt.MouseButton.NoButton +oneFlagRefValue2 = QtCore.Qt.MouseButton.AllButtons +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 5ceb0aca0389e88e8574461e61c0192ca1ac5ce2 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:39:19 +0200 Subject: [PATCH 079/421] QFlag operations for Qt.Orientations, Qt.Orientation in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_Orientations_Orientation.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_Orientations_Orientation.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 70b74c98..7b854773 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2546,6 +2546,9 @@ class Qt(sip.simplewrapper): WheelFocus = ... # type: Qt.FocusPolicy class Orientation(int): + def __or__ (self, other: 'Qt.Orientation') -> 'Qt.Orientations': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.Orientations': ... # type: ignore[override, misc] + Horizontal = ... # type: Qt.Orientation Vertical = ... # type: Qt.Orientation @@ -2762,12 +2765,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.Orientations', 'Qt.Orientation']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.Orientations') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.Orientations': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.Orientations', 'Qt.Orientation', int]) -> 'Qt.Orientations': ... + def __and__(self, other: typing.Union['Qt.Orientations', 'Qt.Orientation', int]) -> 'Qt.Orientations': ... + def __xor__(self, other: typing.Union['Qt.Orientations', 'Qt.Orientation', int]) -> 'Qt.Orientations': ... + def __ror__ (self, other: 'Qt.Orientation') -> 'Qt.Orientations': ... + def __rand__(self, other: 'Qt.Orientation') -> 'Qt.Orientations': ... + def __rxor__(self, other: 'Qt.Orientation') -> 'Qt.Orientations': ... class Alignment(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_Orientations_Orientation.py b/tests/qflags/test_QtCore_Orientations_Orientation.py new file mode 100644 index 00000000..ae9922cd --- /dev/null +++ b/tests/qflags/test_QtCore_Orientations_Orientation.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.Orientations" and flag class "Qt.Orientation" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.Orientation +MultiFlagClass = QtCore.Qt.Orientations + +oneFlagRefValue1 = QtCore.Qt.Orientation.Horizontal +oneFlagRefValue2 = QtCore.Qt.Orientation.Vertical +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 9fc46ee793c0105231b0688b68a0d09a110792dd Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:42:38 +0200 Subject: [PATCH 080/421] QFlag operations for Qt.WindowStates, Qt.WindowState in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_WindowStates_WindowState.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_WindowStates_WindowState.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 7b854773..a6a5ed17 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2363,6 +2363,9 @@ class Qt(sip.simplewrapper): WA_StyleSheetTarget = ... # type: Qt.WidgetAttribute class WindowState(int): + def __or__ (self, other: 'Qt.WindowState') -> 'Qt.WindowStates': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.WindowStates': ... # type: ignore[override, misc] + WindowNoState = ... # type: Qt.WindowState WindowMinimized = ... # type: Qt.WindowState WindowMaximized = ... # type: Qt.WindowState @@ -2830,12 +2833,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.WindowStates', 'Qt.WindowState']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.WindowStates') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.WindowStates': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.WindowStates', 'Qt.WindowState', int]) -> 'Qt.WindowStates': ... + def __and__(self, other: typing.Union['Qt.WindowStates', 'Qt.WindowState', int]) -> 'Qt.WindowStates': ... + def __xor__(self, other: typing.Union['Qt.WindowStates', 'Qt.WindowState', int]) -> 'Qt.WindowStates': ... + def __ror__ (self, other: 'Qt.WindowState') -> 'Qt.WindowStates': ... + def __rand__(self, other: 'Qt.WindowState') -> 'Qt.WindowStates': ... + def __rxor__(self, other: 'Qt.WindowState') -> 'Qt.WindowStates': ... class ImageConversionFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_WindowStates_WindowState.py b/tests/qflags/test_QtCore_WindowStates_WindowState.py new file mode 100644 index 00000000..49d39105 --- /dev/null +++ b/tests/qflags/test_QtCore_WindowStates_WindowState.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.WindowStates" and flag class "Qt.WindowState" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.WindowState +MultiFlagClass = QtCore.Qt.WindowStates + +oneFlagRefValue1 = QtCore.Qt.WindowState.WindowNoState +oneFlagRefValue2 = QtCore.Qt.WindowState.WindowMinimized +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 3ddf8fdae5fd8fd4f22fd318075e7a62950e55db Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:47:20 +0200 Subject: [PATCH 081/421] QFlag operations for Qt.ScreenOrientations, Qt.ScreenOrientation in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...re_ScreenOrientations_ScreenOrientation.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index a6a5ed17..425a3651 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -271,6 +271,9 @@ class Qt(sip.simplewrapper): FindChildrenRecursively = ... # type: Qt.FindChildOption class ScreenOrientation(int): + def __or__ (self, other: 'Qt.ScreenOrientation') -> 'Qt.ScreenOrientations': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.ScreenOrientations': ... # type: ignore[override, misc] + PrimaryOrientation = ... # type: Qt.ScreenOrientation PortraitOrientation = ... # type: Qt.ScreenOrientation LandscapeOrientation = ... # type: Qt.ScreenOrientation @@ -3021,12 +3024,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.ScreenOrientations', 'Qt.ScreenOrientation']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.ScreenOrientations') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.ScreenOrientations': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.ScreenOrientations', 'Qt.ScreenOrientation', int]) -> 'Qt.ScreenOrientations': ... + def __and__(self, other: typing.Union['Qt.ScreenOrientations', 'Qt.ScreenOrientation', int]) -> 'Qt.ScreenOrientations': ... + def __xor__(self, other: typing.Union['Qt.ScreenOrientations', 'Qt.ScreenOrientation', int]) -> 'Qt.ScreenOrientations': ... + def __ror__ (self, other: 'Qt.ScreenOrientation') -> 'Qt.ScreenOrientations': ... + def __rand__(self, other: 'Qt.ScreenOrientation') -> 'Qt.ScreenOrientations': ... + def __rxor__(self, other: 'Qt.ScreenOrientation') -> 'Qt.ScreenOrientations': ... class FindChildOptions(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py b/tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py new file mode 100644 index 00000000..fe6b4ba5 --- /dev/null +++ b/tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.ScreenOrientations" and flag class "Qt.ScreenOrientation" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.ScreenOrientation +MultiFlagClass = QtCore.Qt.ScreenOrientations + +oneFlagRefValue1 = QtCore.Qt.ScreenOrientation.PrimaryOrientation +oneFlagRefValue2 = QtCore.Qt.ScreenOrientation.PortraitOrientation +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From c7a9d64ada389810c5074967a20adb8c3d2bbada Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:49:03 +0200 Subject: [PATCH 082/421] QFlag operations for Qt.ImageConversionFlags, Qt.ImageConversionFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...mageConversionFlags_ImageConversionFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 425a3651..d58596fe 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2124,6 +2124,9 @@ class Qt(sip.simplewrapper): OpaqueMode = ... # type: Qt.BGMode class ImageConversionFlag(int): + def __or__ (self, other: 'Qt.ImageConversionFlag') -> 'Qt.ImageConversionFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.ImageConversionFlags': ... # type: ignore[override, misc] + AutoColor = ... # type: Qt.ImageConversionFlag ColorOnly = ... # type: Qt.ImageConversionFlag MonoOnly = ... # type: Qt.ImageConversionFlag @@ -2859,12 +2862,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.ImageConversionFlags', 'Qt.ImageConversionFlag']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.ImageConversionFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.ImageConversionFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.ImageConversionFlags', 'Qt.ImageConversionFlag', int]) -> 'Qt.ImageConversionFlags': ... + def __and__(self, other: typing.Union['Qt.ImageConversionFlags', 'Qt.ImageConversionFlag', int]) -> 'Qt.ImageConversionFlags': ... + def __xor__(self, other: typing.Union['Qt.ImageConversionFlags', 'Qt.ImageConversionFlag', int]) -> 'Qt.ImageConversionFlags': ... + def __ror__ (self, other: 'Qt.ImageConversionFlag') -> 'Qt.ImageConversionFlags': ... + def __rand__(self, other: 'Qt.ImageConversionFlag') -> 'Qt.ImageConversionFlags': ... + def __rxor__(self, other: 'Qt.ImageConversionFlag') -> 'Qt.ImageConversionFlags': ... class DockWidgetAreas(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py b/tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py new file mode 100644 index 00000000..99113169 --- /dev/null +++ b/tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.ImageConversionFlags" and flag class "Qt.ImageConversionFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.ImageConversionFlag +MultiFlagClass = QtCore.Qt.ImageConversionFlags + +oneFlagRefValue1 = QtCore.Qt.ImageConversionFlag.AutoColor +oneFlagRefValue2 = QtCore.Qt.ImageConversionFlag.ColorOnly +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From f7f3a06a07625ecb94f6a080d41bba4bc9a06f4f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:51:05 +0200 Subject: [PATCH 083/421] QFlag operations for Qt.DockWidgetAreas, Qt.DockWidgetArea in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...t_QtCore_DockWidgetAreas_DockWidgetArea.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index d58596fe..11c5bb37 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -972,6 +972,9 @@ class Qt(sip.simplewrapper): VeryCoarseTimer = ... # type: Qt.TimerType class DockWidgetArea(int): + def __or__ (self, other: 'Qt.DockWidgetArea') -> 'Qt.DockWidgetAreas': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.DockWidgetAreas': ... # type: ignore[override, misc] + LeftDockWidgetArea = ... # type: Qt.DockWidgetArea RightDockWidgetArea = ... # type: Qt.DockWidgetArea TopDockWidgetArea = ... # type: Qt.DockWidgetArea @@ -2885,12 +2888,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.DockWidgetAreas', 'Qt.DockWidgetArea']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.DockWidgetAreas') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.DockWidgetAreas': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.DockWidgetAreas', 'Qt.DockWidgetArea', int]) -> 'Qt.DockWidgetAreas': ... + def __and__(self, other: typing.Union['Qt.DockWidgetAreas', 'Qt.DockWidgetArea', int]) -> 'Qt.DockWidgetAreas': ... + def __xor__(self, other: typing.Union['Qt.DockWidgetAreas', 'Qt.DockWidgetArea', int]) -> 'Qt.DockWidgetAreas': ... + def __ror__ (self, other: 'Qt.DockWidgetArea') -> 'Qt.DockWidgetAreas': ... + def __rand__(self, other: 'Qt.DockWidgetArea') -> 'Qt.DockWidgetAreas': ... + def __rxor__(self, other: 'Qt.DockWidgetArea') -> 'Qt.DockWidgetAreas': ... class ToolBarAreas(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py b/tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py new file mode 100644 index 00000000..6e57153a --- /dev/null +++ b/tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.DockWidgetAreas" and flag class "Qt.DockWidgetArea" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.DockWidgetArea +MultiFlagClass = QtCore.Qt.DockWidgetAreas + +oneFlagRefValue1 = QtCore.Qt.DockWidgetArea.LeftDockWidgetArea +oneFlagRefValue2 = QtCore.Qt.DockWidgetArea.RightDockWidgetArea +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a8ae4f7a237585aa866025d7e5214dabfb3f633b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:52:31 +0200 Subject: [PATCH 084/421] QFlag operations for Qt.ToolBarAreas, Qt.ToolBarArea in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_ToolBarAreas_ToolBarArea.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 11c5bb37..c91b5a23 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -946,6 +946,9 @@ class Qt(sip.simplewrapper): RFC2822Date = ... # type: Qt.DateFormat class ToolBarArea(int): + def __or__ (self, other: 'Qt.ToolBarArea') -> 'Qt.ToolBarAreas': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.ToolBarAreas': ... # type: ignore[override, misc] + LeftToolBarArea = ... # type: Qt.ToolBarArea RightToolBarArea = ... # type: Qt.ToolBarArea TopToolBarArea = ... # type: Qt.ToolBarArea @@ -2911,12 +2914,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.ToolBarAreas', 'Qt.ToolBarArea']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.ToolBarAreas') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.ToolBarAreas': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.ToolBarAreas', 'Qt.ToolBarArea', int]) -> 'Qt.ToolBarAreas': ... + def __and__(self, other: typing.Union['Qt.ToolBarAreas', 'Qt.ToolBarArea', int]) -> 'Qt.ToolBarAreas': ... + def __xor__(self, other: typing.Union['Qt.ToolBarAreas', 'Qt.ToolBarArea', int]) -> 'Qt.ToolBarAreas': ... + def __ror__ (self, other: 'Qt.ToolBarArea') -> 'Qt.ToolBarAreas': ... + def __rand__(self, other: 'Qt.ToolBarArea') -> 'Qt.ToolBarAreas': ... + def __rxor__(self, other: 'Qt.ToolBarArea') -> 'Qt.ToolBarAreas': ... class InputMethodQueries(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py b/tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py new file mode 100644 index 00000000..99a8a43b --- /dev/null +++ b/tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.ToolBarAreas" and flag class "Qt.ToolBarArea" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.ToolBarArea +MultiFlagClass = QtCore.Qt.ToolBarAreas + +oneFlagRefValue1 = QtCore.Qt.ToolBarArea.LeftToolBarArea +oneFlagRefValue2 = QtCore.Qt.ToolBarArea.RightToolBarArea +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 25fbaecbce8d8d97bb39f34e2566844408f062f3 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 6 Sep 2021 22:53:59 +0200 Subject: [PATCH 085/421] QFlag operations for Qt.Edges, Qt.Edge in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 ++ tests/qflags/test_QtCore_Edges_Edge.py | 231 +++++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_Edges_Edge.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index c91b5a23..5f48995c 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -224,6 +224,9 @@ class Qt(sip.simplewrapper): SwipeNativeGesture = ... # type: Qt.NativeGestureType class Edge(int): + def __or__ (self, other: 'Qt.Edge') -> 'Qt.Edges': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.Edges': ... # type: ignore[override, misc] + TopEdge = ... # type: Qt.Edge LeftEdge = ... # type: Qt.Edge RightEdge = ... # type: Qt.Edge @@ -3110,12 +3113,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.Edges', 'Qt.Edge']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.Edges') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.Edges': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.Edges', 'Qt.Edge', int]) -> 'Qt.Edges': ... + def __and__(self, other: typing.Union['Qt.Edges', 'Qt.Edge', int]) -> 'Qt.Edges': ... + def __xor__(self, other: typing.Union['Qt.Edges', 'Qt.Edge', int]) -> 'Qt.Edges': ... + def __ror__ (self, other: 'Qt.Edge') -> 'Qt.Edges': ... + def __rand__(self, other: 'Qt.Edge') -> 'Qt.Edges': ... + def __rxor__(self, other: 'Qt.Edge') -> 'Qt.Edges': ... class MouseEventFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_Edges_Edge.py b/tests/qflags/test_QtCore_Edges_Edge.py new file mode 100644 index 00000000..edfebbd3 --- /dev/null +++ b/tests/qflags/test_QtCore_Edges_Edge.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.Edges" and flag class "Qt.Edge" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.Edge +MultiFlagClass = QtCore.Qt.Edges + +oneFlagRefValue1 = QtCore.Qt.Edge.TopEdge +oneFlagRefValue2 = QtCore.Qt.Edge.LeftEdge +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 3d93d29c6a1b6698f5286d65cb5b2438d4fb1304 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 11:49:13 +0200 Subject: [PATCH 086/421] Individual qflags test files no longer needed. They are covered by the qflag automated tests --- tests/qflags_alignmentflags.py | 231 -------------------------------- tests/windowflags.py | 232 --------------------------------- 2 files changed, 463 deletions(-) delete mode 100644 tests/qflags_alignmentflags.py delete mode 100644 tests/windowflags.py diff --git a/tests/qflags_alignmentflags.py b/tests/qflags_alignmentflags.py deleted file mode 100644 index e45aa8db..00000000 --- a/tests/qflags_alignmentflags.py +++ /dev/null @@ -1,231 +0,0 @@ -from typing import Union, TypeVar, Type -import pytest -from PyQt5 import QtCore, QtWidgets - -### Specific part -# file generated from windowFlags.py for QFlags class "QtCore.Qt.Alignment" and flag class "QtCore.Qt.AlignmentFlag" - -OneFlagClass = QtCore.Qt.AlignmentFlag -MultiFlagClass = QtCore.Qt.Alignment - -oneFlagRefValue1 = QtCore.Qt.AlignLeft -oneFlagRefValue2 = QtCore.Qt.AlignRight -### End of specific part - -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: - '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type - - -def test_on_one_flag_class() -> None: - oneFlagValue1 = oneFlagRefValue1 - oneFlagValue2 = oneFlagRefValue2 - oneFlagValueTest = oneFlagValue1 # type: OneFlagClass - intValue = 0 # type: int - oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] - oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - - # upcast from OneFlagClass to int - intValue = oneFlagValue1 - - # conversion also accepted - intValue = int(oneFlagValue1) - - # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore - - # correct way to do it - oneFlagValueTest = OneFlagClass(33) - oneFlagValueTest = OneFlagClass(oneFlagValue1) - - # The rules of OneFlagClass conversion defined in PyQt5 are: - # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) - # Note that this breaks Liskov principle - # 2. everything else returns int: & ^ &= ^= - # 3. operations with int return int. - - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) - - # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) - - # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) - - - -def test_on_multi_flag_class() -> None: - oneFlagValue1 = oneFlagRefValue1 - multiFlagValue1 = MultiFlagClass() - multiFlagValue2 = MultiFlagClass() - multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass - intValue = 0 - - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) - - - # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) - - - # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) - - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) - - - # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) - - - # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass - # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass - multiFlagValueTest = oneFlagValue1 # type: ignore - - # correct way to do it - multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - # this is rejected for the same reason as for OneFlagClass. - intValue = multiFlagValueTest # type: ignore - - # correct way to do it - intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) - - # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore - - # correct way to do it - multiFlagValueTest = MultiFlagClass(33) - - # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - #########################################################3 - # - # Exploring errors - # - #########################################################3 - - # This checks the following: - # + and - operations are not supported on MultiFlagClass - # combining int with MultiFlagClass does not work - - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] - - pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] - - def f1() -> None: - multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] - def f2() -> None: - multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] - def f3() -> None: - multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] - def f4() -> None: - multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] - - pytest.raises(TypeError, f1) - pytest.raises(TypeError, f2) - pytest.raises(TypeError, f3) - pytest.raises(TypeError, f4) - diff --git a/tests/windowflags.py b/tests/windowflags.py deleted file mode 100644 index 18c1fcd1..00000000 --- a/tests/windowflags.py +++ /dev/null @@ -1,232 +0,0 @@ -from typing import Union, TypeVar, Type -import pytest -from PyQt5 import QtCore, QtWidgets - -### Specific part -# This file is used as a source to generate all qflags related tests. The specific part -# changes for each test but the rest of the file is totally identical - -OneFlagClass = QtCore.Qt.WindowType -MultiFlagClass = QtCore.Qt.WindowFlags - -oneFlagRefValue1 = QtCore.Qt.WindowContextHelpButtonHint -oneFlagRefValue2 = QtCore.Qt.WindowMaximizeButtonHint -### End of specific part - -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: - '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type - - -def test_on_one_flag_class() -> None: - oneFlagValue1 = oneFlagRefValue1 - oneFlagValue2 = oneFlagRefValue2 - oneFlagValueTest = oneFlagValue1 # type: OneFlagClass - intValue = 0 # type: int - oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] - oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - - # upcast from OneFlagClass to int - intValue = oneFlagValue1 - - # conversion also accepted - intValue = int(oneFlagValue1) - - # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore - - # correct way to do it - oneFlagValueTest = OneFlagClass(33) - oneFlagValueTest = OneFlagClass(oneFlagValue1) - - # The rules of OneFlagClass conversion defined in PyQt5 are: - # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) - # Note that this breaks Liskov principle - # 2. everything else returns int: & ^ &= ^= - # 3. operations with int return int. - - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) - - # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) - - # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) - - - -def test_on_multi_flag_class() -> None: - oneFlagValue1 = oneFlagRefValue1 - multiFlagValue1 = MultiFlagClass() - multiFlagValue2 = MultiFlagClass() - multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass - intValue = 0 - - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) - - - # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) - - - # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) - - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) - - - # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) - - - # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass - # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass - multiFlagValueTest = oneFlagValue1 # type: ignore - - # correct way to do it - multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - # this is rejected for the same reason as for OneFlagClass. - intValue = multiFlagValueTest # type: ignore - - # correct way to do it - intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) - - # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore - - # correct way to do it - multiFlagValueTest = MultiFlagClass(33) - - # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - - #########################################################3 - # - # Exploring errors - # - #########################################################3 - - # This checks the following: - # + and - operations are not supported on MultiFlagClass - # combining int with MultiFlagClass does not work - - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] - - pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] - - def f1() -> None: - multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] - def f2() -> None: - multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] - def f3() -> None: - multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] - def f4() -> None: - multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] - - pytest.raises(TypeError, f1) - pytest.raises(TypeError, f2) - pytest.raises(TypeError, f3) - pytest.raises(TypeError, f4) - From 1bbc1154a5c74a8db89473182b23e41c1635bc1d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 11:50:07 +0200 Subject: [PATCH 087/421] Less global variables --- .../qflags/generate_qflags_stubs_and_tests.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index a75c0a63..e0607b2c 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -24,20 +24,10 @@ Usage 2: {prog} gen_qflag_stub Using file qflag_to_process.json, process qflags and modify the PyQt modules. - The output of this processing is available in qflag_process_result.json + The output of this processing is available in qflags_process_result.json If is not provided, defaults to 1 '''.format(prog=sys.argv[0]) -# the file defining the qflag implementation, to be skipped -QFLAG_SRC='src\\corelib\\global\\qflags.h' - -# the template after which we model all generated qflag tests -TEMPLATE_QFLAGS_TESTS = 'qflags_test_template.py' - -# the markers inside the above template to identify the parts to replace -MARKER_SPECIFIC_START = '### Specific part' -MARKER_SPECIFIC_END = '### End of specific part' - QTBASE_MODULES = [ ('QtCore', '../../PyQt5-stubs/QtCore.pyi'), @@ -92,6 +82,9 @@ def identify_qflag_location(fname_grep_result: str, Return a list of QFlagLocationInfo indicating in which module the flag has been located. ''' + # the file defining the qflag implementation, to be skipped when performing QDECLARE analysis + QFLAG_SRC = 'src\\corelib\\global\\qflags.h' + parsed_qflags = [] # type: List[ QFlagLocationInfo ] with open(fname_grep_result) as f: for l in f.readlines()[:]: @@ -705,6 +698,11 @@ def read_qflag_test_template(template_fname: str) -> Tuple[List[str], List[str], - the second part should be replaced for a specific QFlag class - the third part should be unmodified ''' + + # the markers inside the above template to identify the parts to replace + MARKER_SPECIFIC_START = '### Specific part' + MARKER_SPECIFIC_END = '### End of specific part' + with open(template_fname) as f: lines = f.readlines() @@ -741,6 +739,10 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: The filename is inferred from flag_info using gen_test_fname() ''' + + # the template after which we model all generated qflag tests + TEMPLATE_QFLAGS_TESTS = 'qflags_test_template.py' + test_qflag_fname = gen_test_fname(flag_info) generic_part_before, _replacable_part, generic_part_after = read_qflag_test_template(TEMPLATE_QFLAGS_TESTS) @@ -796,7 +798,7 @@ def generate_qflags_to_process(qt_qflag_grep_result_fname): nb = int(sys.argv[2]) qflags_to_process_json = 'qflags_to_process.json' - qflag_result_json = 'qflag_process_result.json' + qflag_result_json = 'qflags_process_result.json' more_available = True while nb > 0 and more_available: nb -= 1 From fc5f57664ca72ba9c868413d0ae49308c3c64571 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 11:50:49 +0200 Subject: [PATCH 088/421] Re-run the failing commands to capture the actual error --- tests/qflags/generate_qflags_stubs_and_tests.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index e0607b2c..819e7ce9 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -273,20 +273,34 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: log_progress('Running pytest %s' % test_qflag_fname) p = subprocess.run(['pytest', '-v', '--capture=no', test_qflag_fname]) if p.returncode != 0: - error_msg += 'pytest failed\n' + error_msg += 'pytest failed:\n' + # Re-run the same command to capture the output in the error message + # in the first run, the stdout/stderr was simply displayed and not captured + # here, we want to capture it and not display it + p = subprocess.run(['pytest', '-v', '--capture=no', test_qflag_fname], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + error_msg += p.stdout gen_result = QFlagGenResult.ErrorDuringProcessing log_progress('Restoring module content') with open(flag_info.module_info[0][1], 'w') as f: f.write(old_mod_content) + os.unlink(test_qflag_fname) else: log_progress('Running mypy %s' % test_qflag_fname) p = subprocess.run(['mypy', test_qflag_fname]) if p.returncode != 0: error_msg += 'mypy failed\n' + # Re-run the same command to capture the output in the error message + # in the first run, the stdout/stderr was simply displayed and not captured + # here, we want to capture it and not display it + p = subprocess.run(['mypy', test_qflag_fname], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + error_msg += p.stdout gen_result = QFlagGenResult.ErrorDuringProcessing log_progress('Restoring module content') with open(flag_info.module_info[0][1], 'w') as f: f.write(old_mod_content) + os.unlink(test_qflag_fname) else: log_progress('validation completed successfully') result_json['qflag_processed_done'].append(flag_info_dict) From fb12a408cd61befd2bf97e1cc9af4f7809a74e02 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 12:03:31 +0200 Subject: [PATCH 089/421] QFlag operations for QGLContext.BindOptions, QGLContext.BindOption in module QtOpenGL --- PyQt5-stubs/QtOpenGL.pyi | 11 + .../test_QtOpenGL_BindOptions_BindOption.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtOpenGL_BindOptions_BindOption.py diff --git a/PyQt5-stubs/QtOpenGL.pyi b/PyQt5-stubs/QtOpenGL.pyi index 72ef2b1a..d57d4b10 100644 --- a/PyQt5-stubs/QtOpenGL.pyi +++ b/PyQt5-stubs/QtOpenGL.pyi @@ -261,6 +261,9 @@ class QGLFormat(sip.simplewrapper): class QGLContext(sip.wrapper): class BindOption(int): + def __or__ (self, other: 'QGLContext.BindOption') -> 'QGLContext.BindOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGLContext.BindOptions': ... # type: ignore[override, misc] + NoBindOption = ... # type: QGLContext.BindOption InvertedYBindOption = ... # type: QGLContext.BindOption MipmapBindOption = ... # type: QGLContext.BindOption @@ -283,12 +286,20 @@ class QGLContext(sip.wrapper): def __init__(self, f: typing.Union['QGLContext.BindOptions', 'QGLContext.BindOption']) -> None: ... @typing.overload def __init__(self, a0: 'QGLContext.BindOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGLContext.BindOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGLContext.BindOptions', 'QGLContext.BindOption', int]) -> 'QGLContext.BindOptions': ... + def __and__(self, other: typing.Union['QGLContext.BindOptions', 'QGLContext.BindOption', int]) -> 'QGLContext.BindOptions': ... + def __xor__(self, other: typing.Union['QGLContext.BindOptions', 'QGLContext.BindOption', int]) -> 'QGLContext.BindOptions': ... + def __ror__ (self, other: 'QGLContext.BindOption') -> 'QGLContext.BindOptions': ... + def __rand__(self, other: 'QGLContext.BindOption') -> 'QGLContext.BindOptions': ... + def __rxor__(self, other: 'QGLContext.BindOption') -> 'QGLContext.BindOptions': ... def __init__(self, format: QGLFormat) -> None: ... diff --git a/tests/qflags/test_QtOpenGL_BindOptions_BindOption.py b/tests/qflags/test_QtOpenGL_BindOptions_BindOption.py new file mode 100644 index 00000000..b5310fa1 --- /dev/null +++ b/tests/qflags/test_QtOpenGL_BindOptions_BindOption.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGLContext.BindOptions" and flag class "QGLContext.BindOption" +from PyQt5 import QtOpenGL + +OneFlagClass = QtOpenGL.QGLContext.BindOption +MultiFlagClass = QtOpenGL.QGLContext.BindOptions + +oneFlagRefValue1 = QtOpenGL.QGLContext.BindOption.NoBindOption +oneFlagRefValue2 = QtOpenGL.QGLContext.BindOption.InvertedYBindOption +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 3399dbcb721487937b0a3dc9faf5b664a7e23052 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 12:16:15 +0200 Subject: [PATCH 090/421] Add missing test file for WindowFlags / WindowType --- .../test_QtCore_WindowFlags_WindowType.py | 232 ++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 tests/qflags/test_QtCore_WindowFlags_WindowType.py diff --git a/tests/qflags/test_QtCore_WindowFlags_WindowType.py b/tests/qflags/test_QtCore_WindowFlags_WindowType.py new file mode 100644 index 00000000..78185e21 --- /dev/null +++ b/tests/qflags/test_QtCore_WindowFlags_WindowType.py @@ -0,0 +1,232 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# This file is used as a source to generate all qflags related tests. The specific part +# changes for each test but the rest of the file is totally identical +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.WindowType +MultiFlagClass = QtCore.Qt.WindowFlags + +oneFlagRefValue1 = QtCore.Qt.WindowContextHelpButtonHint +oneFlagRefValue2 = QtCore.Qt.WindowMaximizeButtonHint +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From fe8f92b53747bef7f11d3a0048de80e7edbbdcfe Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 12:18:13 +0200 Subject: [PATCH 091/421] QFlag test files for InputMethodQuery / InputMethodQueries --- PyQt5-stubs/QtCore.pyi | 11 +++++++ .../qflags/generate_qflags_stubs_and_tests.py | 31 +++++++++++++------ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 5f48995c..f129c702 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -745,6 +745,9 @@ class Qt(sip.simplewrapper): ToolButtonFollowStyle = ... # type: Qt.ToolButtonStyle class InputMethodQuery(int): + def __or__ (self, other: 'Qt.InputMethodQuery') -> 'Qt.InputMethodQueries': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.InputMethodQueries': ... # type: ignore[override, misc] + ImMicroFocus = ... # type: Qt.InputMethodQuery ImFont = ... # type: Qt.InputMethodQuery ImCursorPosition = ... # type: Qt.InputMethodQuery @@ -2940,12 +2943,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.InputMethodQueries', 'Qt.InputMethodQuery']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.InputMethodQueries') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.InputMethodQueries': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.InputMethodQueries', 'Qt.InputMethodQuery', int]) -> 'Qt.InputMethodQueries': ... + def __and__(self, other: typing.Union['Qt.InputMethodQueries', 'Qt.InputMethodQuery', int]) -> 'Qt.InputMethodQueries': ... + def __xor__(self, other: typing.Union['Qt.InputMethodQueries', 'Qt.InputMethodQuery', int]) -> 'Qt.InputMethodQueries': ... + def __ror__ (self, other: 'Qt.InputMethodQuery') -> 'Qt.InputMethodQueries': ... + def __rand__(self, other: 'Qt.InputMethodQuery') -> 'Qt.InputMethodQueries': ... + def __rxor__(self, other: 'Qt.InputMethodQuery') -> 'Qt.InputMethodQueries': ... class DropActions(sip.simplewrapper): diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 819e7ce9..79af3dd9 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -21,11 +21,14 @@ two output: - qflags_modules_analysis.json : a general file describing which qflag are suitable for processing - qflags_to_process.json: a list of qflag ready to process with the next command. - -Usage 2: {prog} gen_qflag_stub + +Usage 2: {prog} gen_qflag_stub (--auto-commit) Using file qflag_to_process.json, process qflags and modify the PyQt modules. The output of this processing is available in qflags_process_result.json If is not provided, defaults to 1 + + If --auto-commit is specified, a git commit is performed after each successful QFlag validation + '''.format(prog=sys.argv[0]) @@ -197,7 +200,7 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, json.dump(result, f, indent=4) -def process_qflag(qflag_to_process_json: str, qflag_result_json: str) -> bool: +def process_qflag(qflag_to_process_json: str, qflag_result_json: str, auto_commit: bool) -> bool: '''Read the qflags to process from the json file Process one qflag, by either: @@ -211,6 +214,8 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str) -> bool: * run the tox on result * add the flag to qflag_processed_done + * auto_commit: if True, a git commit is performed after each successful QFlag validation + Return True when all flags have been processed ''' with open(qflag_to_process_json) as f: @@ -278,7 +283,7 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: # in the first run, the stdout/stderr was simply displayed and not captured # here, we want to capture it and not display it p = subprocess.run(['pytest', '-v', '--capture=no', test_qflag_fname], - stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf8') error_msg += p.stdout gen_result = QFlagGenResult.ErrorDuringProcessing log_progress('Restoring module content') @@ -294,7 +299,7 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: # in the first run, the stdout/stderr was simply displayed and not captured # here, we want to capture it and not display it p = subprocess.run(['mypy', test_qflag_fname], - stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf8') error_msg += p.stdout gen_result = QFlagGenResult.ErrorDuringProcessing log_progress('Restoring module content') @@ -304,10 +309,12 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: else: log_progress('validation completed successfully') result_json['qflag_processed_done'].append(flag_info_dict) - log_progress('Staging changes to git') - subprocess.run(['git', 'add', test_qflag_fname, flag_info.module_info[0][1]]) - print('QFlag operations for %s, %s in module %s' % - (flag_info.qflag_full_class_name, flag_info.enum_full_class_name, flag_info.module_info[0][0])) + + if auto_commit: + log_progress('Staging changes to git') + subprocess.run(['git', 'add', test_qflag_fname, flag_info.module_info[0][1]]) + subprocess.run(['git', 'commit', '-m', 'QFlag operations for %s, %s in module %s' % + (flag_info.qflag_full_class_name, flag_info.enum_full_class_name, flag_info.module_info[0][0])]) if gen_result == QFlagGenResult.CodeAlreadyModified: # qflag methods are already there, check that the test filename is here too @@ -806,6 +813,10 @@ def generate_qflags_to_process(qt_qflag_grep_result_fname): print(USAGE) sys.exit(1) + auto_commit = False + if '--auto-commit' in sys.argv: + auto_commit = True + if sys.argv[1] == 'gen_qflag_stub': nb = 1 if len(sys.argv) > 2: @@ -816,7 +827,7 @@ def generate_qflags_to_process(qt_qflag_grep_result_fname): more_available = True while nb > 0 and more_available: nb -= 1 - more_available = process_qflag(qflags_to_process_json, qflag_result_json) + more_available = process_qflag(qflags_to_process_json, qflag_result_json, auto_commit) elif sys.argv[1] == 'analyse_grep_results': if len(sys.argv) <= 2: From 8415cc0d23fd36aec1adf30e9cdf9028fe8d2775 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 12:19:15 +0200 Subject: [PATCH 092/421] QFlag operations for Qt.InputMethodHints, Qt.InputMethodHint in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...QtCore_InputMethodHints_InputMethodHint.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index f129c702..8302550f 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -378,6 +378,9 @@ class Qt(sip.simplewrapper): AnchorBottom = ... # type: Qt.AnchorPoint class InputMethodHint(int): + def __or__ (self, other: 'Qt.InputMethodHint') -> 'Qt.InputMethodHints': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.InputMethodHints': ... # type: ignore[override, misc] + ImhNone = ... # type: Qt.InputMethodHint ImhHiddenText = ... # type: Qt.InputMethodHint ImhNoAutoUppercase = ... # type: Qt.InputMethodHint @@ -3026,12 +3029,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.InputMethodHints', 'Qt.InputMethodHint']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.InputMethodHints') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.InputMethodHints': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.InputMethodHints', 'Qt.InputMethodHint', int]) -> 'Qt.InputMethodHints': ... + def __and__(self, other: typing.Union['Qt.InputMethodHints', 'Qt.InputMethodHint', int]) -> 'Qt.InputMethodHints': ... + def __xor__(self, other: typing.Union['Qt.InputMethodHints', 'Qt.InputMethodHint', int]) -> 'Qt.InputMethodHints': ... + def __ror__ (self, other: 'Qt.InputMethodHint') -> 'Qt.InputMethodHints': ... + def __rand__(self, other: 'Qt.InputMethodHint') -> 'Qt.InputMethodHints': ... + def __rxor__(self, other: 'Qt.InputMethodHint') -> 'Qt.InputMethodHints': ... class TouchPointStates(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py b/tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py new file mode 100644 index 00000000..f3ca9040 --- /dev/null +++ b/tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.InputMethodHints" and flag class "Qt.InputMethodHint" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.InputMethodHint +MultiFlagClass = QtCore.Qt.InputMethodHints + +oneFlagRefValue1 = QtCore.Qt.InputMethodHint.ImhNone +oneFlagRefValue2 = QtCore.Qt.InputMethodHint.ImhHiddenText +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a3cf031ce04f9500777819554baec627bdf86fa3 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 12:20:49 +0200 Subject: [PATCH 093/421] QFlag operations for Qt.DropActions, Qt.DropAction in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_DropActions_DropAction.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_DropActions_DropAction.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 8302550f..77fbfeff 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -711,6 +711,9 @@ class Qt(sip.simplewrapper): Checked = ... # type: Qt.CheckState class DropAction(int): + def __or__ (self, other: 'Qt.DropAction') -> 'Qt.DropActions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.DropActions': ... # type: ignore[override, misc] + CopyAction = ... # type: Qt.DropAction MoveAction = ... # type: Qt.DropAction LinkAction = ... # type: Qt.DropAction @@ -2969,12 +2972,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.DropActions', 'Qt.DropAction']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.DropActions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.DropActions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.DropActions', 'Qt.DropAction', int]) -> 'Qt.DropActions': ... + def __and__(self, other: typing.Union['Qt.DropActions', 'Qt.DropAction', int]) -> 'Qt.DropActions': ... + def __xor__(self, other: typing.Union['Qt.DropActions', 'Qt.DropAction', int]) -> 'Qt.DropActions': ... + def __ror__ (self, other: 'Qt.DropAction') -> 'Qt.DropActions': ... + def __rand__(self, other: 'Qt.DropAction') -> 'Qt.DropActions': ... + def __rxor__(self, other: 'Qt.DropAction') -> 'Qt.DropActions': ... class ItemFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_DropActions_DropAction.py b/tests/qflags/test_QtCore_DropActions_DropAction.py new file mode 100644 index 00000000..2d47cce6 --- /dev/null +++ b/tests/qflags/test_QtCore_DropActions_DropAction.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.DropActions" and flag class "Qt.DropAction" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.DropAction +MultiFlagClass = QtCore.Qt.DropActions + +oneFlagRefValue1 = QtCore.Qt.DropAction.CopyAction +oneFlagRefValue2 = QtCore.Qt.DropAction.MoveAction +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 8455cdcb6293522869fc03875a430e7a30e26770 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 12:21:44 +0200 Subject: [PATCH 094/421] QFlag operations for Qt.ItemFlags, Qt.ItemFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../qflags/test_QtCore_ItemFlags_ItemFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_ItemFlags_ItemFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 77fbfeff..5e568fcc 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -638,6 +638,9 @@ class Qt(sip.simplewrapper): MatchRegularExpression = ... # type: Qt.MatchFlag class ItemFlag(int): + def __or__ (self, other: 'Qt.ItemFlag') -> 'Qt.ItemFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.ItemFlags': ... # type: ignore[override, misc] + NoItemFlags = ... # type: Qt.ItemFlag ItemIsSelectable = ... # type: Qt.ItemFlag ItemIsEditable = ... # type: Qt.ItemFlag @@ -2995,12 +2998,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.ItemFlags', 'Qt.ItemFlag']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.ItemFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.ItemFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.ItemFlags', 'Qt.ItemFlag', int]) -> 'Qt.ItemFlags': ... + def __and__(self, other: typing.Union['Qt.ItemFlags', 'Qt.ItemFlag', int]) -> 'Qt.ItemFlags': ... + def __xor__(self, other: typing.Union['Qt.ItemFlags', 'Qt.ItemFlag', int]) -> 'Qt.ItemFlags': ... + def __ror__ (self, other: 'Qt.ItemFlag') -> 'Qt.ItemFlags': ... + def __rand__(self, other: 'Qt.ItemFlag') -> 'Qt.ItemFlags': ... + def __rxor__(self, other: 'Qt.ItemFlag') -> 'Qt.ItemFlags': ... class MatchFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_ItemFlags_ItemFlag.py b/tests/qflags/test_QtCore_ItemFlags_ItemFlag.py new file mode 100644 index 00000000..8b5eb24f --- /dev/null +++ b/tests/qflags/test_QtCore_ItemFlags_ItemFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.ItemFlags" and flag class "Qt.ItemFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.ItemFlag +MultiFlagClass = QtCore.Qt.ItemFlags + +oneFlagRefValue1 = QtCore.Qt.ItemFlag.NoItemFlags +oneFlagRefValue2 = QtCore.Qt.ItemFlag.ItemIsSelectable +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 674a0b623a8fc10d47f92cb4b74f36bac6a85640 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 12:22:49 +0200 Subject: [PATCH 095/421] QFlag operations for Qt.MatchFlags, Qt.MatchFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_MatchFlags_MatchFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_MatchFlags_MatchFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 5e568fcc..74f277cf 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -613,6 +613,9 @@ class Qt(sip.simplewrapper): ApplicationModal = ... # type: Qt.WindowModality class MatchFlag(int): + def __or__ (self, other: 'Qt.MatchFlag') -> 'Qt.MatchFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.MatchFlags': ... # type: ignore[override, misc] + MatchExactly = ... # type: Qt.MatchFlag MatchFixedString = ... # type: Qt.MatchFlag MatchContains = ... # type: Qt.MatchFlag @@ -3021,12 +3024,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.MatchFlags', 'Qt.MatchFlag']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.MatchFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.MatchFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.MatchFlags', 'Qt.MatchFlag', int]) -> 'Qt.MatchFlags': ... + def __and__(self, other: typing.Union['Qt.MatchFlags', 'Qt.MatchFlag', int]) -> 'Qt.MatchFlags': ... + def __xor__(self, other: typing.Union['Qt.MatchFlags', 'Qt.MatchFlag', int]) -> 'Qt.MatchFlags': ... + def __ror__ (self, other: 'Qt.MatchFlag') -> 'Qt.MatchFlags': ... + def __rand__(self, other: 'Qt.MatchFlag') -> 'Qt.MatchFlags': ... + def __rxor__(self, other: 'Qt.MatchFlag') -> 'Qt.MatchFlags': ... class TextInteractionFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_MatchFlags_MatchFlag.py b/tests/qflags/test_QtCore_MatchFlags_MatchFlag.py new file mode 100644 index 00000000..0952adf8 --- /dev/null +++ b/tests/qflags/test_QtCore_MatchFlags_MatchFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.MatchFlags" and flag class "Qt.MatchFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.MatchFlag +MultiFlagClass = QtCore.Qt.MatchFlags + +oneFlagRefValue1 = QtCore.Qt.MatchFlag.MatchExactly +oneFlagRefValue2 = QtCore.Qt.MatchFlag.MatchFixedString +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 1ff829033363b63deadb8a2201c927305bdc939c Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 12:23:35 +0200 Subject: [PATCH 096/421] More explanation about --auto-commit --- tests/qflags/README_qflags.md | 6 ++---- tests/qflags/generate_qflags_stubs_and_tests.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/qflags/README_qflags.md b/tests/qflags/README_qflags.md index 13622d86..5087f483 100644 --- a/tests/qflags/README_qflags.md +++ b/tests/qflags/README_qflags.md @@ -47,16 +47,14 @@ With human verification, you can add more QFlags to the qflags_to_process.json f ### Generate and test the new stubs Run: - python generate_qflags_stubs_and_tests.py gen_qflag_stub 5 + python generate_qflags_stubs_and_tests.py gen_qflag_stub 5 --auto-commit This will process 5 QFlags from qflags_to_process.json . The result of the processing is: * the file qflags_process_result.json is updated * when the generation and test is successful: ** the qt module is updated ** a new test file is added in the format test__.py - ** the new test file and the module are staged in git - -Now, you can manually perform the git commit. + ** a git commit with the test file and updated module is performed (only if you specifed --auto-commit) ## Conclusion diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 79af3dd9..d1b6b45e 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -311,7 +311,7 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: result_json['qflag_processed_done'].append(flag_info_dict) if auto_commit: - log_progress('Staging changes to git') + log_progress('Performing git commit') subprocess.run(['git', 'add', test_qflag_fname, flag_info.module_info[0][1]]) subprocess.run(['git', 'commit', '-m', 'QFlag operations for %s, %s in module %s' % (flag_info.qflag_full_class_name, flag_info.enum_full_class_name, flag_info.module_info[0][0])]) From 46584cd149c3b03f3388d4858ce053f53ea19191 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 13:35:07 +0200 Subject: [PATCH 097/421] QFlag operations for Qt.TextInteractionFlags, Qt.TextInteractionFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...extInteractionFlags_TextInteractionFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 74f277cf..7691d4c2 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -505,6 +505,9 @@ class Qt(sip.simplewrapper): MaskOutColor = ... # type: Qt.MaskMode class TextInteractionFlag(int): + def __or__ (self, other: 'Qt.TextInteractionFlag') -> 'Qt.TextInteractionFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.TextInteractionFlags': ... # type: ignore[override, misc] + NoTextInteraction = ... # type: Qt.TextInteractionFlag TextSelectableByMouse = ... # type: Qt.TextInteractionFlag TextSelectableByKeyboard = ... # type: Qt.TextInteractionFlag @@ -3047,12 +3050,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.TextInteractionFlags', 'Qt.TextInteractionFlag']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.TextInteractionFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.TextInteractionFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.TextInteractionFlags', 'Qt.TextInteractionFlag', int]) -> 'Qt.TextInteractionFlags': ... + def __and__(self, other: typing.Union['Qt.TextInteractionFlags', 'Qt.TextInteractionFlag', int]) -> 'Qt.TextInteractionFlags': ... + def __xor__(self, other: typing.Union['Qt.TextInteractionFlags', 'Qt.TextInteractionFlag', int]) -> 'Qt.TextInteractionFlags': ... + def __ror__ (self, other: 'Qt.TextInteractionFlag') -> 'Qt.TextInteractionFlags': ... + def __rand__(self, other: 'Qt.TextInteractionFlag') -> 'Qt.TextInteractionFlags': ... + def __rxor__(self, other: 'Qt.TextInteractionFlag') -> 'Qt.TextInteractionFlags': ... class InputMethodHints(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py b/tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py new file mode 100644 index 00000000..e1e3d70e --- /dev/null +++ b/tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.TextInteractionFlags" and flag class "Qt.TextInteractionFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.TextInteractionFlag +MultiFlagClass = QtCore.Qt.TextInteractionFlags + +oneFlagRefValue1 = QtCore.Qt.TextInteractionFlag.NoTextInteraction +oneFlagRefValue2 = QtCore.Qt.TextInteractionFlag.TextSelectableByMouse +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 5f6581cc883d517a04a4b185f6c28c638c3a30b7 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 13:36:16 +0200 Subject: [PATCH 098/421] QFlag operations for Qt.TouchPointStates, Qt.TouchPointState in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...QtCore_TouchPointStates_TouchPointState.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 7691d4c2..5e62b9f3 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -345,6 +345,9 @@ class Qt(sip.simplewrapper): GestureCanceled = ... # type: Qt.GestureState class TouchPointState(int): + def __or__ (self, other: 'Qt.TouchPointState') -> 'Qt.TouchPointStates': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.TouchPointStates': ... # type: ignore[override, misc] + TouchPointPressed = ... # type: Qt.TouchPointState TouchPointMoved = ... # type: Qt.TouchPointState TouchPointStationary = ... # type: Qt.TouchPointState @@ -3096,12 +3099,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.TouchPointStates', 'Qt.TouchPointState']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.TouchPointStates') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.TouchPointStates': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.TouchPointStates', 'Qt.TouchPointState', int]) -> 'Qt.TouchPointStates': ... + def __and__(self, other: typing.Union['Qt.TouchPointStates', 'Qt.TouchPointState', int]) -> 'Qt.TouchPointStates': ... + def __xor__(self, other: typing.Union['Qt.TouchPointStates', 'Qt.TouchPointState', int]) -> 'Qt.TouchPointStates': ... + def __ror__ (self, other: 'Qt.TouchPointState') -> 'Qt.TouchPointStates': ... + def __rand__(self, other: 'Qt.TouchPointState') -> 'Qt.TouchPointStates': ... + def __rxor__(self, other: 'Qt.TouchPointState') -> 'Qt.TouchPointStates': ... class GestureFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py b/tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py new file mode 100644 index 00000000..3caa994f --- /dev/null +++ b/tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.TouchPointStates" and flag class "Qt.TouchPointState" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.TouchPointState +MultiFlagClass = QtCore.Qt.TouchPointStates + +oneFlagRefValue1 = QtCore.Qt.TouchPointState.TouchPointPressed +oneFlagRefValue2 = QtCore.Qt.TouchPointState.TouchPointMoved +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a27a1ee1b71181d328edc8f12bd4fad2bd65691b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 13:37:26 +0200 Subject: [PATCH 099/421] QFlag operations for Qt.GestureFlags, Qt.GestureFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_GestureFlags_GestureFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_GestureFlags_GestureFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 5e62b9f3..0427cba9 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -310,6 +310,9 @@ class Qt(sip.simplewrapper): NavigationModeCursorForceVisible = ... # type: Qt.NavigationMode class GestureFlag(int): + def __or__ (self, other: 'Qt.GestureFlag') -> 'Qt.GestureFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.GestureFlags': ... # type: ignore[override, misc] + DontStartGestureOnChildren = ... # type: Qt.GestureFlag ReceivePartialGestures = ... # type: Qt.GestureFlag IgnoredGesturesPropagateToParent = ... # type: Qt.GestureFlag @@ -3122,12 +3125,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.GestureFlags', 'Qt.GestureFlag']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.GestureFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.GestureFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.GestureFlags', 'Qt.GestureFlag', int]) -> 'Qt.GestureFlags': ... + def __and__(self, other: typing.Union['Qt.GestureFlags', 'Qt.GestureFlag', int]) -> 'Qt.GestureFlags': ... + def __xor__(self, other: typing.Union['Qt.GestureFlags', 'Qt.GestureFlag', int]) -> 'Qt.GestureFlags': ... + def __ror__ (self, other: 'Qt.GestureFlag') -> 'Qt.GestureFlags': ... + def __rand__(self, other: 'Qt.GestureFlag') -> 'Qt.GestureFlags': ... + def __rxor__(self, other: 'Qt.GestureFlag') -> 'Qt.GestureFlags': ... class ScreenOrientations(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_GestureFlags_GestureFlag.py b/tests/qflags/test_QtCore_GestureFlags_GestureFlag.py new file mode 100644 index 00000000..2878864d --- /dev/null +++ b/tests/qflags/test_QtCore_GestureFlags_GestureFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.GestureFlags" and flag class "Qt.GestureFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.GestureFlag +MultiFlagClass = QtCore.Qt.GestureFlags + +oneFlagRefValue1 = QtCore.Qt.GestureFlag.DontStartGestureOnChildren +oneFlagRefValue2 = QtCore.Qt.GestureFlag.ReceivePartialGestures +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From e815ef2d2ea3058cc1d923032da55b2626a4dfc8 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 7 Sep 2021 13:38:34 +0200 Subject: [PATCH 100/421] QFlag operations for Qt.MouseEventFlags, Qt.MouseEventFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...t_QtCore_MouseEventFlags_MouseEventFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 0427cba9..bc3b3ad8 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -178,6 +178,9 @@ class Qt(sip.simplewrapper): TabFocusAllControls = ... # type: Qt.TabFocusBehavior class MouseEventFlag(int): + def __or__ (self, other: 'Qt.MouseEventFlag') -> 'Qt.MouseEventFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.MouseEventFlags': ... # type: ignore[override, misc] + MouseEventCreatedDoubleClick = ... # type: Qt.MouseEventFlag MouseEventCreatedDoubleClick = ... # type: Qt.MouseEventFlag @@ -3224,12 +3227,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.MouseEventFlags', 'Qt.MouseEventFlag']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.MouseEventFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.MouseEventFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.MouseEventFlags', 'Qt.MouseEventFlag', int]) -> 'Qt.MouseEventFlags': ... + def __and__(self, other: typing.Union['Qt.MouseEventFlags', 'Qt.MouseEventFlag', int]) -> 'Qt.MouseEventFlags': ... + def __xor__(self, other: typing.Union['Qt.MouseEventFlags', 'Qt.MouseEventFlag', int]) -> 'Qt.MouseEventFlags': ... + def __ror__ (self, other: 'Qt.MouseEventFlag') -> 'Qt.MouseEventFlags': ... + def __rand__(self, other: 'Qt.MouseEventFlag') -> 'Qt.MouseEventFlags': ... + def __rxor__(self, other: 'Qt.MouseEventFlag') -> 'Qt.MouseEventFlags': ... def convertFromPlainText(self, plain: str, mode: QtCore.Qt.WhiteSpaceMode = ...) -> str: ... def mightBeRichText(self, a0: str) -> bool: ... diff --git a/tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py b/tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py new file mode 100644 index 00000000..f9baaf9d --- /dev/null +++ b/tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.MouseEventFlags" and flag class "Qt.MouseEventFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.MouseEventFlag +MultiFlagClass = QtCore.Qt.MouseEventFlags + +oneFlagRefValue1 = QtCore.Qt.MouseEventFlag.MouseEventCreatedDoubleClick +oneFlagRefValue2 = QtCore.Qt.MouseEventFlag.MouseEventCreatedDoubleClick +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From c279682b796680f1d88f6c08ab55769ff41af4c3 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 09:12:39 +0200 Subject: [PATCH 101/421] QFlag operations for QSurfaceFormat.FormatOptions, QSurfaceFormat.FormatOption in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + .../test_QtGui_FormatOptions_FormatOption.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtGui_FormatOptions_FormatOption.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 2dddd700..de4506a1 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -8469,6 +8469,9 @@ class QSurfaceFormat(sip.simplewrapper): TripleBuffer = ... # type: QSurfaceFormat.SwapBehavior class FormatOption(int): + def __or__ (self, other: 'QSurfaceFormat.FormatOption') -> 'QSurfaceFormat.FormatOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSurfaceFormat.FormatOptions': ... # type: ignore[override, misc] + StereoBuffers = ... # type: QSurfaceFormat.FormatOption DebugContext = ... # type: QSurfaceFormat.FormatOption DeprecatedFunctions = ... # type: QSurfaceFormat.FormatOption @@ -8487,12 +8490,20 @@ class QSurfaceFormat(sip.simplewrapper): def __init__(self, f: typing.Union['QSurfaceFormat.FormatOptions', 'QSurfaceFormat.FormatOption']) -> None: ... @typing.overload def __init__(self, a0: 'QSurfaceFormat.FormatOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSurfaceFormat.FormatOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSurfaceFormat.FormatOptions', 'QSurfaceFormat.FormatOption', int]) -> 'QSurfaceFormat.FormatOptions': ... + def __and__(self, other: typing.Union['QSurfaceFormat.FormatOptions', 'QSurfaceFormat.FormatOption', int]) -> 'QSurfaceFormat.FormatOptions': ... + def __xor__(self, other: typing.Union['QSurfaceFormat.FormatOptions', 'QSurfaceFormat.FormatOption', int]) -> 'QSurfaceFormat.FormatOptions': ... + def __ror__ (self, other: 'QSurfaceFormat.FormatOption') -> 'QSurfaceFormat.FormatOptions': ... + def __rand__(self, other: 'QSurfaceFormat.FormatOption') -> 'QSurfaceFormat.FormatOptions': ... + def __rxor__(self, other: 'QSurfaceFormat.FormatOption') -> 'QSurfaceFormat.FormatOptions': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtGui_FormatOptions_FormatOption.py b/tests/qflags/test_QtGui_FormatOptions_FormatOption.py new file mode 100644 index 00000000..e3b18bf1 --- /dev/null +++ b/tests/qflags/test_QtGui_FormatOptions_FormatOption.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSurfaceFormat.FormatOptions" and flag class "QSurfaceFormat.FormatOption" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QSurfaceFormat.FormatOption +MultiFlagClass = QtGui.QSurfaceFormat.FormatOptions + +oneFlagRefValue1 = QtGui.QSurfaceFormat.FormatOption.StereoBuffers +oneFlagRefValue2 = QtGui.QSurfaceFormat.FormatOption.DebugContext +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 31baf20fbc2a0fbee0185b4310eba44c711519af Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 09:12:52 +0200 Subject: [PATCH 102/421] QFlag operations for QGL.FormatOptions, QGL.FormatOption in module QtOpenGL --- PyQt5-stubs/QtOpenGL.pyi | 11 + ...est_QtOpenGL_FormatOptions_FormatOption.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py diff --git a/PyQt5-stubs/QtOpenGL.pyi b/PyQt5-stubs/QtOpenGL.pyi index d57d4b10..ce77bd46 100644 --- a/PyQt5-stubs/QtOpenGL.pyi +++ b/PyQt5-stubs/QtOpenGL.pyi @@ -44,6 +44,9 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], class QGL(sip.simplewrapper): class FormatOption(int): + def __or__ (self, other: 'QGL.FormatOption') -> 'QGL.FormatOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGL.FormatOptions': ... # type: ignore[override, misc] + DoubleBuffer = ... # type: QGL.FormatOption DepthBuffer = ... # type: QGL.FormatOption Rgba = ... # type: QGL.FormatOption @@ -98,12 +101,20 @@ class QGL(sip.simplewrapper): def __init__(self, f: typing.Union['QGL.FormatOptions', 'QGL.FormatOption']) -> None: ... @typing.overload def __init__(self, a0: 'QGL.FormatOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGL.FormatOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGL.FormatOptions', 'QGL.FormatOption', int]) -> 'QGL.FormatOptions': ... + def __and__(self, other: typing.Union['QGL.FormatOptions', 'QGL.FormatOption', int]) -> 'QGL.FormatOptions': ... + def __xor__(self, other: typing.Union['QGL.FormatOptions', 'QGL.FormatOption', int]) -> 'QGL.FormatOptions': ... + def __ror__ (self, other: 'QGL.FormatOption') -> 'QGL.FormatOptions': ... + def __rand__(self, other: 'QGL.FormatOption') -> 'QGL.FormatOptions': ... + def __rxor__(self, other: 'QGL.FormatOption') -> 'QGL.FormatOptions': ... class QGLFormat(sip.simplewrapper): diff --git a/tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py b/tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py new file mode 100644 index 00000000..252f1dc9 --- /dev/null +++ b/tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGL.FormatOptions" and flag class "QGL.FormatOption" +from PyQt5 import QtOpenGL + +OneFlagClass = QtOpenGL.QGL.FormatOption +MultiFlagClass = QtOpenGL.QGL.FormatOptions + +oneFlagRefValue1 = QtOpenGL.QGL.FormatOption.DoubleBuffer +oneFlagRefValue2 = QtOpenGL.QGL.FormatOption.DepthBuffer +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From ab68ebad1c6c85daac973b6573c801de523453d0 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 09:13:05 +0200 Subject: [PATCH 103/421] Proper handling of flags in multiple modules or multiple times in the same module --- .../qflags/generate_qflags_stubs_and_tests.py | 1370 +++++++++-------- 1 file changed, 716 insertions(+), 654 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index d1b6b45e..787d7a96 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -9,348 +9,372 @@ from enum import Enum try: - import libcst as cst - import libcst.matchers as matchers + import libcst as cst + import libcst.matchers as matchers except ImportError: - raise ImportError('You need libcst to run the missing stubs generation\n' - 'Please run the command:\n\tpython -m pip install libcst') + raise ImportError('You need libcst to run the missing stubs generation\n' + 'Please run the command:\n\tpython -m pip install libcst') USAGE = '''Usage 1: {prog} analyse_grep_results - Process the to extract all the qflag location information. Generates - two output: - - qflags_modules_analysis.json : a general file describing which qflag are suitable for processing - - qflags_to_process.json: a list of qflag ready to process with the next command. - -Usage 2: {prog} gen_qflag_stub (--auto-commit) - Using file qflag_to_process.json, process qflags and modify the PyQt modules. - The output of this processing is available in qflags_process_result.json - If is not provided, defaults to 1 - - If --auto-commit is specified, a git commit is performed after each successful QFlag validation + Process the to extract all the qflag location information. Generates + two output: + - qflags_modules_analysis.json : a general file describing which qflag are suitable for processing + - qflags_to_process.json: a list of qflag ready to process with the next command. + +Usage 2: {prog} gen_qflag_stub (|all) (--auto-commit) + Using file qflag_to_process.json, process qflags and modify the PyQt modules. + The output of this processing is available in qflags_process_result.json + + If is not provided, defaults to 1. If "all" is provied, all qflags + are processed. + + If --auto-commit is specified, a git commit is performed after each successful QFlag validation '''.format(prog=sys.argv[0]) -QTBASE_MODULES = [ - ('QtCore', '../../PyQt5-stubs/QtCore.pyi'), - ('QtWidgets', '../../PyQt5-stubs/QtWidgets.pyi'), - ('QtGui', '../../PyQt5-stubs/QtGui.pyi'), - ('QtNetwork', '../../PyQt5-stubs/QtNetwork.pyi'), - ('QtDBus', '../../PyQt5-stubs/QtDBus.pyi'), - ('QtOpenGL', '../../PyQt5-stubs/QtOpenGL.pyi'), - ('QtPrintsupport', '../../PyQt5-stubs/QtPrintsupport.pyi'), - ('QtSql', '../../PyQt5-stubs/QtSql.pyi'), - ('QtTest', '../../PyQt5-stubs/QtTest.pyi'), - ('QtXml', '../../PyQt5-stubs/QtXml.pyi'), -] +QTBASE_MODULES = { + 'QtCore': '../../PyQt5-stubs/QtCore.pyi', + 'QtWidgets': '../../PyQt5-stubs/QtWidgets.pyi', + 'QtGui': '../../PyQt5-stubs/QtGui.pyi', + 'QtNetwork': '../../PyQt5-stubs/QtNetwork.pyi', + 'QtDBus': '../../PyQt5-stubs/QtDBus.pyi', + 'QtOpenGL': '../../PyQt5-stubs/QtOpenGL.pyi', + 'QtPrintsupport': '../../PyQt5-stubs/QtPrintsupport.pyi', + 'QtSql': '../../PyQt5-stubs/QtSql.pyi', + 'QtTest': '../../PyQt5-stubs/QtTest.pyi', + 'QtXml': '../../PyQt5-stubs/QtXml.pyi', +} def log_progress(s: str) -> None: - print('>>>>>>>>>>>>>>', s) + print('>>>>>>>>>>>>>>', s) @dataclasses.dataclass class QFlagLocationInfo: - # qflag and enum name used in the QDECLARE() grep line - qflag_class: str - enum_class: str + # qflag and enum name used in the QDECLARE() grep line + qflag_class: str + enum_class: str - # grep line indicating this qflag - grep_line: str = '' + # one or more grep lines where this qflag name has been found + grep_line: Tuple[str] = dataclasses.field(default_factory=tuple) - # full class name (including nesting classes) generated in a second pass - qflag_full_class_name: str = '' - enum_full_class_name: str = '' - enum_value1: str = '' - enum_value2: str = '' + # full class name (including nesting classes) generated in a second pass + qflag_full_class_name: str = '' + enum_full_class_name: str = '' + enum_value1: str = '' + enum_value2: str = '' - # list of (module_name, module_path) where the qflag has been found - module_info: Tuple[ Tuple[str, str], ... ] = dataclasses.field(default_factory=tuple) + # number of occurence in this module + module_count: int = 0 + + # index of occurence in this module + module_idx: int = -1 + + # module name and path + module_name: str = '' + module_path: str = '' def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[str, Any]]: - '''Encode the QFlagClassLoationInfo into a format suitable for json export (a dict)''' - if not isinstance(flag_loc_info, QFlagLocationInfo): - # oups, we don't know how to encode that - return flag_loc_info + '''Encode the QFlagClassLoationInfo into a format suitable for json export (a dict)''' + if not isinstance(flag_loc_info, QFlagLocationInfo): + # oups, we don't know how to encode that + return flag_loc_info - return dataclasses.asdict(flag_loc_info) + return dataclasses.asdict(flag_loc_info) def identify_qflag_location(fname_grep_result: str, - qt_modules: List[Tuple[str, str]] - ) -> List[ QFlagLocationInfo ]: - '''Parses the grep results to extract each qflag, and then look into all Qt modules - to see where the flag is located. - - Return a list of QFlagLocationInfo indicating in which module the flag has been located. - ''' - # the file defining the qflag implementation, to be skipped when performing QDECLARE analysis - QFLAG_SRC = 'src\\corelib\\global\\qflags.h' - - parsed_qflags = [] # type: List[ QFlagLocationInfo ] - with open(fname_grep_result) as f: - for l in f.readlines()[:]: - grep_line = l.strip() - if len(grep_line) == 0: - continue - qflag_fname, qflag_declare_stmt = [s.strip(' \t\n') for s in grep_line.split(':')] - if qflag_fname == QFLAG_SRC: - # do not include actual implementation of qflags - continue - assert 'Q_DECLARE_FLAGS' in qflag_declare_stmt - s = qflag_declare_stmt[qflag_declare_stmt.index('(')+1:qflag_declare_stmt.index(')')] - qflag_class, enum_class = [v.strip(' ') for v in s.split(',')] - parsed_qflags.append( - QFlagLocationInfo(qflag_class, enum_class, grep_line) - ) - - # fill up modules with content - qt_modules_content = [ (mod_name, mod_stub_path, open(mod_stub_path, encoding='utf8').read()) - for (mod_name, mod_stub_path) in qt_modules] - - for flag_info in parsed_qflags: - decl_qflag_class = 'class %s(' % flag_info.qflag_class - decl_enum_class = 'class %s(' % flag_info.enum_class - for mod_name, mod_stub_path, mod_content in qt_modules_content: - - if decl_qflag_class in mod_content and decl_enum_class in mod_content: - # we have found one module - print('Adding QFlags %s to module %s' % (flag_info.qflag_class, mod_name)) - flag_info.module_info += ((mod_name, mod_stub_path),) - - count_qflag_class = mod_content.count(decl_qflag_class) - count_enum_class = mod_content.count(decl_enum_class) - if count_qflag_class > 1 and count_enum_class > 1: - print('QFlag present more than once, adding it more than once') - extra_add = min(count_qflag_class, count_enum_class) - 1 - for _ in range(extra_add): - flag_info.module_info += ((mod_name, mod_stub_path),) - - return parsed_qflags + qt_modules: Dict[str, str], + ) -> List[ QFlagLocationInfo ]: + '''Parses the grep results to extract each qflag, and then look into all Qt modules + to see where the flag is located. + + Return a list of QFlagLocationInfo indicating in which module the flag has been located. + ''' + # the file defining the qflag implementation, to be skipped when performing QDECLARE analysis + QFLAG_SRC = 'src\\corelib\\global\\qflags.h' + + parsed_qflags = {} # type: Dict[ Tuple[str, str], QFlagLocationInfo ] + with open(fname_grep_result) as f: + for l in f.readlines()[:]: + grep_line = l.strip() + if len(grep_line) == 0: + continue + qflag_fname, qflag_declare_stmt = [s.strip(' \t\n') for s in grep_line.split(':')] + if qflag_fname == QFLAG_SRC: + # do not include actual implementation of qflags + continue + assert 'Q_DECLARE_FLAGS' in qflag_declare_stmt + s = qflag_declare_stmt[qflag_declare_stmt.index('(')+1:qflag_declare_stmt.index(')')] + qflag_class, enum_class = [v.strip(' ') for v in s.split(',')] + if (qflag_class, enum_class) in parsed_qflags: + # we already have one similar name in our DB + # just extend the grep line then + parsed_qflags[(qflag_class, enum_class)].grep_line += (grep_line,) + else: + parsed_qflags[(qflag_class, enum_class)] = QFlagLocationInfo(qflag_class, enum_class, (grep_line,)) + + # fill up modules with content + qt_modules_content = [ (mod_name, open(mod_stub_path, encoding='utf8').read()) + for (mod_name, mod_stub_path) in qt_modules.items()] + + # associate a qflag enum/class with a mapping from module to QFlagLocationInfo + module_mapping: Dict[ Tuple[str, str], Dict[str, QFlagLocationInfo]] = {} + + for qflag_key, flag_info in parsed_qflags.items(): + decl_qflag_class = 'class %s(' % flag_info.qflag_class + decl_enum_class = 'class %s(' % flag_info.enum_class + for mod_name, mod_content in qt_modules_content: + + if decl_qflag_class in mod_content and decl_enum_class in mod_content: + # we have found one module + # print('Adding QFlags %s to module %s' % (flag_info.qflag_class, mod_name)) + if qflag_key not in module_mapping: + module_mapping[qflag_key] = {} + else: + pass + mod_map = module_mapping[qflag_key] + + if mod_name in mod_map: + raise ValueError('Not supposed to happen!') + + # register the number of time where this flag happens in this specific module + mod_map[mod_name] = dataclasses.replace(flag_info) # this means a fresh copy of flag_info + mod_map[mod_name].module_count = 1 + + count_qflag_class = mod_content.count(decl_qflag_class) + count_enum_class = mod_content.count(decl_enum_class) + if count_qflag_class > 1 and count_enum_class > 1: + # print('QFlag present more than once, adding it more than once') + mod_map[mod_name].module_count += min(count_qflag_class, count_enum_class) - 1 + + # now, we flatten the structure by recreating one QFlagLocationInfo per module location + + all_qflags: List[QFlagLocationInfo] = [] + for mod_map in module_mapping.values(): + for mod_name, flag_info in mod_map.items(): + idx = 0 + while idx < flag_info.module_count: + all_qflags.append(dataclasses.replace(flag_info, module_idx=idx, + module_name=mod_name, + module_path=qt_modules[mod_name])) + idx += 1 + + return all_qflags def group_qflags(qflag_location: List[QFlagLocationInfo] ) -> Dict[str, List[QFlagLocationInfo]]: - '''Group the QFlags into the following groups (inside a dictionnary): - * one_flag_one_module: this flag is present once in one module exactly. - * one_flag_many_modules: this flag is present once or multiple times in one or multiple modules - * one_flag_no_module: this flag is not present in any modules at all. - - The first group is suitable for automatic processing. - The second group requires human verification - The last group reflects the QFlags not exported to PyQt or coming from modules not present in PyQt - ''' - d = { - 'one_flag_one_module': [ - flag_info for flag_info in qflag_location - if len(flag_info.module_info) == 1 - ], - 'one_flag_many_modules': [ - flag_info for flag_info in qflag_location - if len(flag_info.module_info) > 1 - ], - 'one_flag_no_module': [ - flag_info for flag_info in qflag_location - if len(flag_info.module_info) == 0 - ], - } - - return d + '''Group the QFlags into the following groups (inside a dictionnary): + * flag_and_module_identified: this flag is present once in one module exactly. + * flag_without_module: this flag is not present in any modules at all. + + The first group is suitable for automatic processing. + The last group reflects the QFlags not exported to PyQt or coming from modules not present in PyQt + ''' + d = { + 'flag_and_module_identified': [ + flag_info for flag_info in qflag_location + if flag_info.module_name != '' + ], + 'flag_without_module': [ + flag_info for flag_info in qflag_location + if flag_info.module_name == '' + ], + } + + return d def extract_qflags_to_process(qflags_modules_analysis_json: str, - qflags_to_process_json: str, - ) -> None: - '''Take the json file as input describing qflags and their modules and output a json file of qflags planned to be processed. - - The qflags which are located in a single module will be selected for further processing. - The others are marked as skipped with a proper reason. - ''' - with open(qflags_modules_analysis_json) as f: - d = json.load(f) - - result = { - '__': 'This file can be adjusted manually by a human prior to being processed by the tool', - 'qflags_to_process': [], - 'qflags_to_skip': [], - } - - for flag_info in d['one_flag_many_modules']: - cast(List, result['qflags_to_skip']).append( - { - 'qflag_class': flag_info['qflag_class'], - 'enum_class': flag_info['enum_class'], - 'skip_reason': 'QFlag present more than once or in multiple modules' - } - ) - - for flag_info in d['one_flag_no_module']: - cast(List, result['qflags_to_skip']).append( - { - 'qflag_class': flag_info['qflag_class'], - 'enum_class': flag_info['enum_class'], - 'skip_reason': 'QFlag not found', - } - ) - - for flag_info in d['one_flag_one_module']: - cast(List, result['qflags_to_process']).append( flag_info ) - - with open(qflags_to_process_json, 'w') as f: - json.dump(result, f, indent=4) + qflags_to_process_json: str, + ) -> None: + '''Take the json file as input describing qflags and their modules and output a json file of qflags planned to be processed. + + The qflags which are located in a single module will be selected for further processing. + The others are marked as skipped with a proper reason. + ''' + with open(qflags_modules_analysis_json) as f: + d = json.load(f) + + result = { + '__': 'This file can be adjusted manually by a human prior to being processed by the tool', + 'qflags_to_process': [], + 'qflags_to_skip': [], + } + + for flag_info in d['flag_without_module']: + cast(List, result['qflags_to_skip']).append( + { + 'qflag_class': flag_info['qflag_class'], + 'enum_class': flag_info['enum_class'], + 'skip_reason': 'QFlag not found', + } + ) + + for flag_info in d['flag_and_module_identified']: + cast(List, result['qflags_to_process']).append( flag_info ) + + with open(qflags_to_process_json, 'w') as f: + json.dump(result, f, indent=4) def process_qflag(qflag_to_process_json: str, qflag_result_json: str, auto_commit: bool) -> bool: - '''Read the qflags to process from the json file - - Process one qflag, by either: - * identifying that this flag is already processed and add the flag to qflags_alraedy_done - * identifying a reason why this flag can't be processed and adding the flag to qflags_processed_error - * performing the qflag ajustment process: - * generate a test file for this qflag usage - * change the .pyi module for this qflag for supporting all the qflag operations - * run pytest on the result - * run mypy on the result - * run the tox on result - * add the flag to qflag_processed_done - - * auto_commit: if True, a git commit is performed after each successful QFlag validation - - Return True when all flags have been processed - ''' - with open(qflag_to_process_json) as f: - d = json.load(f) - - qflags_to_process = d['qflags_to_process'] - - result_json: Dict[str, List[Dict]] = { - 'qflag_already_done': [], - 'qflag_processed_done': [], - 'qflag_process_error': [], - } - - if os.path.exists(qflag_result_json): - with open(qflag_result_json, 'r') as f: - result_json = json.loads(f.read()) - - def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: - '''Return True if the qflag is already included in one of the result lists - of result_json''' - flag_desc = (flag_info.module_info[0][0], flag_info.qflag_class, flag_info.enum_class) - already_done_set = set( (flag_info_dict['module_info'][0][0], - flag_info_dict['qflag_class'], - flag_info_dict['enum_class']) - for flag_info_dict in result_json['qflag_already_done']) - processed_done_set = set( (flag_info_dict['module_info'][0][0], - flag_info_dict['qflag_class'], - flag_info_dict['enum_class']) - for flag_info_dict in result_json['qflag_processed_done']) - process_error_set = set( (flag_info_dict['module_info'][0][0], - flag_info_dict['qflag_class'], - flag_info_dict['enum_class']) - for flag_info_dict in result_json['qflag_process_error']) - if flag_desc in already_done_set or flag_desc in processed_done_set or flag_desc in process_error_set: - return True - return False - - while len(qflags_to_process) != 0: - flag_info_dict = qflags_to_process.pop(0) - flag_info = QFlagLocationInfo(**flag_info_dict) - # force module_info into a tuple to make it hashable - flag_info.module_info = tuple((m0, m1) for (m0, m1) in flag_info.module_info) - if not qflag_already_processed(flag_info): - break - else: - # we have exhausted the list of qflag to process - return False - - log_progress('Generate stubs for %s and %s in module %s' % - (flag_info.qflag_class, flag_info.enum_class, flag_info.module_info[0][0])) - - # check that the qflag is actually in the module - gen_result, error_msg, old_mod_content = generate_missing_stubs(flag_info) - test_qflag_fname = gen_test_fname(flag_info) - - # Note that flag_info has been modified in-place with additional info: - # enum_value1, enum_value2, full_enum_class_name, full_qflag_class_name - if gen_result == QFlagGenResult.CodeModifiedSuccessfully: - generate_qflag_test_file(flag_info) - log_progress('Running pytest %s' % test_qflag_fname) - p = subprocess.run(['pytest', '-v', '--capture=no', test_qflag_fname]) - if p.returncode != 0: - error_msg += 'pytest failed:\n' - # Re-run the same command to capture the output in the error message - # in the first run, the stdout/stderr was simply displayed and not captured - # here, we want to capture it and not display it - p = subprocess.run(['pytest', '-v', '--capture=no', test_qflag_fname], - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf8') - error_msg += p.stdout - gen_result = QFlagGenResult.ErrorDuringProcessing - log_progress('Restoring module content') - with open(flag_info.module_info[0][1], 'w') as f: - f.write(old_mod_content) - os.unlink(test_qflag_fname) - else: - log_progress('Running mypy %s' % test_qflag_fname) - p = subprocess.run(['mypy', test_qflag_fname]) - if p.returncode != 0: - error_msg += 'mypy failed\n' - # Re-run the same command to capture the output in the error message - # in the first run, the stdout/stderr was simply displayed and not captured - # here, we want to capture it and not display it - p = subprocess.run(['mypy', test_qflag_fname], - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf8') - error_msg += p.stdout - gen_result = QFlagGenResult.ErrorDuringProcessing - log_progress('Restoring module content') - with open(flag_info.module_info[0][1], 'w') as f: - f.write(old_mod_content) - os.unlink(test_qflag_fname) - else: - log_progress('validation completed successfully') - result_json['qflag_processed_done'].append(flag_info_dict) - - if auto_commit: - log_progress('Performing git commit') - subprocess.run(['git', 'add', test_qflag_fname, flag_info.module_info[0][1]]) - subprocess.run(['git', 'commit', '-m', 'QFlag operations for %s, %s in module %s' % - (flag_info.qflag_full_class_name, flag_info.enum_full_class_name, flag_info.module_info[0][0])]) - - if gen_result == QFlagGenResult.CodeAlreadyModified: - # qflag methods are already there, check that the test filename is here too - if os.path.exists(test_qflag_fname): - log_progress('QFlag %s %s already supported by %s' % (flag_info.qflag_class, - flag_info.enum_class, - flag_info.module_info[0][0])) - result_json['qflag_already_done'].append(flag_info_dict) - else: - error_msg += 'QFlag methods presents but test file %s is missing\n' % test_qflag_fname - gen_result = QFlagGenResult.ErrorDuringProcessing - - if gen_result == QFlagGenResult.ErrorDuringProcessing: - log_progress('Error during processing of QFlag %s %s' % (flag_info.qflag_class, - flag_info.enum_class)) - flag_info_dict['error'] = flag_info_dict.get('error', '') + error_msg - result_json['qflag_process_error'].append(flag_info_dict) - - # save our processing result - with open(qflag_result_json, 'w') as f: - json.dump(result_json, f, indent=4) - - # return True to indicate that more flags may be processed - return True + '''Read the qflags to process from the json file + + Process one qflag, by either: + * identifying that this flag is already processed and add the flag to qflags_alraedy_done + * identifying a reason why this flag can't be processed and adding the flag to qflags_processed_error + * performing the qflag ajustment process: + * generate a test file for this qflag usage + * change the .pyi module for this qflag for supporting all the qflag operations + * run pytest on the result + * run mypy on the result + * run the tox on result + * add the flag to qflag_processed_done + + * auto_commit: if True, a git commit is performed after each successful QFlag validation + + Return True when all flags have been processed + ''' + with open(qflag_to_process_json) as f: + d = json.load(f) + + qflags_to_process = d['qflags_to_process'] + + result_json: Dict[str, List[Dict]] = { + 'qflag_already_done': [], + 'qflag_processed_done': [], + 'qflag_process_error': [], + } + + if os.path.exists(qflag_result_json): + with open(qflag_result_json, 'r') as f: + result_json = json.loads(f.read()) + + def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: + '''Return True if the qflag is already included in one of the result lists + of result_json''' + flag_desc = (flag_info.module_name, flag_info.module_idx, + flag_info.qflag_class, flag_info.enum_class) + already_done_set = set( (flag_info_dict['module_name'], + flag_info_dict['module_idx'], + flag_info_dict['qflag_class'], + flag_info_dict['enum_class']) + for flag_info_dict in result_json['qflag_already_done']) + processed_done_set = set( (flag_info_dict['module_name'], + flag_info_dict['module_idx'], + flag_info_dict['qflag_class'], + flag_info_dict['enum_class']) + for flag_info_dict in result_json['qflag_processed_done']) + process_error_set = set( (flag_info_dict['module_name'], + flag_info_dict['module_idx'], + flag_info_dict['qflag_class'], + flag_info_dict['enum_class']) + for flag_info_dict in result_json['qflag_process_error']) + if flag_desc in already_done_set or flag_desc in processed_done_set or flag_desc in process_error_set: + return True + return False + + while len(qflags_to_process) != 0: + flag_info_dict = qflags_to_process.pop(0) + flag_info = QFlagLocationInfo(**flag_info_dict) + flag_info.grep_line = tuple(flag_info.grep_line) # to make it hashable + if not qflag_already_processed(flag_info): + break + else: + # we have exhausted the list of qflag to process + return False + + log_progress('Processing %s and %s in module %s, index %d' % + (flag_info.qflag_class, flag_info.enum_class, flag_info.module_name, flag_info.module_idx)) + + # check that the qflag is actually in the module + gen_result, error_msg, old_mod_content = generate_missing_stubs(flag_info) + test_qflag_fname = gen_test_fname(flag_info) + + # Note that flag_info has been modified in-place with additional info: + # enum_value1, enum_value2, full_enum_class_name, full_qflag_class_name + if gen_result == QFlagGenResult.CodeModifiedSuccessfully: + generate_qflag_test_file(flag_info) + log_progress('Running pytest %s' % test_qflag_fname) + p = subprocess.run(['pytest', '-v', '--capture=no', test_qflag_fname]) + if p.returncode != 0: + error_msg += 'pytest failed:\n' + # Re-run the same command to capture the output in the error message + # in the first run, the stdout/stderr was simply displayed and not captured + # here, we want to capture it and not display it + p = subprocess.run(['pytest', '-v', '--capture=no', test_qflag_fname], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf8') + error_msg += p.stdout + gen_result = QFlagGenResult.ErrorDuringProcessing + log_progress('Restoring module content') + with open(flag_info.module_path, 'w') as f: + f.write(old_mod_content) + os.unlink(test_qflag_fname) + else: + log_progress('Running mypy %s' % test_qflag_fname) + p = subprocess.run(['mypy', test_qflag_fname]) + if p.returncode != 0: + error_msg += 'mypy failed\n' + # Re-run the same command to capture the output in the error message + # in the first run, the stdout/stderr was simply displayed and not captured + # here, we want to capture it and not display it + p = subprocess.run(['mypy', test_qflag_fname], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf8') + error_msg += p.stdout + gen_result = QFlagGenResult.ErrorDuringProcessing + log_progress('Restoring module content') + with open(flag_info.module_path, 'w') as f: + f.write(old_mod_content) + os.unlink(test_qflag_fname) + else: + log_progress('validation completed successfully') + result_json['qflag_processed_done'].append(flag_info_dict) + + if auto_commit: + log_progress('Performing git commit') + subprocess.run(['git', 'add', test_qflag_fname, flag_info.module_path]) + subprocess.run(['git', 'commit', '-m', 'QFlag operations for %s, %s in module %s' % + (flag_info.qflag_full_class_name, flag_info.enum_full_class_name, flag_info.module_name)]) + + if gen_result == QFlagGenResult.CodeAlreadyModified: + # qflag methods are already there, check that the test filename is here too + if os.path.exists(test_qflag_fname): + log_progress('QFlag %s %s already supported by %s' % (flag_info.qflag_class, + flag_info.enum_class, + flag_info.module_name)) + result_json['qflag_already_done'].append(flag_info_dict) + else: + error_msg += 'QFlag methods presents but test file %s is missing\n' % test_qflag_fname + gen_result = QFlagGenResult.ErrorDuringProcessing + + if gen_result == QFlagGenResult.ErrorDuringProcessing: + log_progress('Error during processing of QFlag %s %s' % (flag_info.qflag_class, + flag_info.enum_class)) + flag_info_dict['error'] = flag_info_dict.get('error', '') + error_msg + result_json['qflag_process_error'].append(flag_info_dict) + + # save our processing result + with open(qflag_result_json, 'w') as f: + json.dump(result_json, f, indent=4) + + # return True to indicate that more flags may be processed + return True class QFlagGenResult(Enum): - '''Enum indicating the result of generating the possibly missing stubs on the qflag classes''' - CodeModifiedSuccessfully = 0 - CodeAlreadyModified = 1 - ErrorDuringProcessing = 2 + '''Enum indicating the result of generating the possibly missing stubs on the qflag classes''' + CodeModifiedSuccessfully = 0 + CodeAlreadyModified = 1 + ErrorDuringProcessing = 2 def generate_missing_stubs(flag_info: 'QFlagLocationInfo') -> Tuple[QFlagGenResult, str, str]: - ''' + ''' Check that the QFlag enum+class are present in the module and check whether they support all the advanced QFlag operations. @@ -364,24 +388,24 @@ def generate_missing_stubs(flag_info: 'QFlagLocationInfo') -> Tuple[QFlagGenResu These are needed for generating a proper test file. I don't like in-place modification but here, it's the simplest. - The generation consists of: + The generation consists of: 1. On the enum class, add two methods: - class KeyboardModifier(int): - + def __or__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... # type: ignore[override] - + def __ror__ (self, other: int) -> 'Qt.KeyboardModifiers': ... # type: ignore[override, misc] + class KeyboardModifier(int): + + def __or__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... # type: ignore[override] + + def __ror__ (self, other: int) -> 'Qt.KeyboardModifiers': ... # type: ignore[override, misc] 2. On the qflag class, add one more overload of __init__() - + @typing.overload - + def __init__(self, f: int) -> None: ... + + @typing.overload + + def __init__(self, f: int) -> None: ... 3. On the qflag class, add more methods: - + def __or__ (self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - + def __and__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - + def __xor__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... - + def __ror__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... - + def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... - + def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + + def __or__ (self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + + def __and__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + + def __xor__(self, other: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> 'Qt.KeyboardModifiers': ... + + def __ror__ (self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + + def __rand__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... + + def __rxor__(self, other: 'Qt.KeyboardModifier') -> 'Qt.KeyboardModifiers': ... Returns a tuple of (QFlagGenResult, error_msg, mod_content): * CodeModifiedSuccessfully: @@ -403,155 +427,176 @@ class not found, class found multiple times, ... The detail of the error is provided in the second argument of the return value. mod_content is empty (not useful) ''' - log_progress('Opening module %s' % flag_info.module_info[0][0]) - with open(flag_info.module_info[0][1]) as f: - mod_content = f.read() + log_progress('Opening module %s' % flag_info.module_name) + with open(flag_info.module_path) as f: + mod_content = f.read() - log_progress('Parsing module %s' % flag_info.module_info[0][0]) - mod_cst = cst.parse_module(mod_content) + log_progress('Parsing module %s' % flag_info.module_name) + mod_cst = cst.parse_module(mod_content) - log_progress('Looking for class %s and %s in module %s' % (flag_info.qflag_class, flag_info.enum_class, - flag_info.module_info[0][0])) - visitor = QFlagAndEnumFinder(flag_info.enum_class, flag_info.qflag_class) - mod_cst.visit(visitor) + log_progress('Looking for class %s and %s in module %s, index %d' % + (flag_info.qflag_class, flag_info.enum_class, flag_info.module_name, flag_info.module_idx)) + visitor = QFlagAndEnumFinder(flag_info.enum_class, flag_info.qflag_class, + flag_info.module_count, flag_info.module_idx) + mod_cst.visit(visitor) - if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): - return (QFlagGenResult.CodeAlreadyModified, visitor.error_msg, '') + if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): + return (QFlagGenResult.CodeAlreadyModified, visitor.error_msg, '') - if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.Not): - visitor.error_msg += 'Enum methods are present but not QFlag methods\n' + if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.Not): + visitor.error_msg += 'Enum methods are present but not QFlag methods\n' - if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.Not, MethodPresent.All): - visitor.error_msg += 'QFlag methods are present but not Enum methods\n' + if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.Not, MethodPresent.All): + visitor.error_msg += 'QFlag methods are present but not Enum methods\n' - if visitor.error_msg: - return (QFlagGenResult.ErrorDuringProcessing, visitor.error_msg, '') + if visitor.error_msg: + return (QFlagGenResult.ErrorDuringProcessing, visitor.error_msg, '') - assert visitor.enum_methods_present == MethodPresent.Not - assert visitor.qflag_method_present == MethodPresent.Not + assert visitor.enum_methods_present == MethodPresent.Not + assert visitor.qflag_method_present == MethodPresent.Not - # storing the enum_values for further usage - flag_info.enum_full_class_name = visitor.enum_class_full_name - flag_info.enum_value1 = visitor.enum_value1 - flag_info.enum_value2 = visitor.enum_value2 - flag_info.qflag_full_class_name = visitor.qflag_class_full_name + # storing the enum_values for further usage + flag_info.enum_full_class_name = visitor.enum_class_full_name + flag_info.enum_value1 = visitor.enum_value1 + flag_info.enum_value2 = visitor.enum_value2 + flag_info.qflag_full_class_name = visitor.qflag_class_full_name + log_progress('Found %s and %s' % (flag_info.qflag_full_class_name, flag_info.enum_full_class_name)) - log_progress('Updating module %s by adding new methods' % flag_info.module_info[0][0]) - transformer = QFlagAndEnumUpdater(visitor.enum_class_name, visitor.enum_class_full_name, - visitor.qflag_class_name, visitor.qflag_class_full_name) - updated_mod_cst = mod_cst.visit(transformer) + log_progress('Updating module %s by adding new methods' % flag_info.module_name) + transformer = QFlagAndEnumUpdater(visitor.enum_class_name, visitor.enum_class_full_name, + visitor.qflag_class_name, visitor.qflag_class_full_name, flag_info.module_idx) + updated_mod_cst = mod_cst.visit(transformer) - log_progress('Saving updated module %s' % flag_info.module_info[0][0]) - with open(flag_info.module_info[0][1], 'w') as f: - f.write(updated_mod_cst.code) + log_progress('Saving updated module %s' % flag_info.module_name) + with open(flag_info.module_path, 'w') as f: + f.write(updated_mod_cst.code) - return (QFlagGenResult.CodeModifiedSuccessfully, '', mod_content) + return (QFlagGenResult.CodeModifiedSuccessfully, '', mod_content) class MethodPresent(Enum): - '''An enum to reflect if a method is already present or not''' - Unset = 0 - All = 1 - Not = 2 - Partial = 3 + '''An enum to reflect if a method is already present or not''' + Unset = 0 + All = 1 + Not = 2 + Partial = 3 class QFlagAndEnumFinder(cst.CSTVisitor): - def __init__(self, enum_class: str, qflag_class: str) -> None: - super().__init__() + def __init__(self, enum_class: str, qflag_class: str, + module_count: int, module_idx: int) -> None: + super().__init__() + + # used internally to generate the full class name + self.full_name_stack: List[str] = [] + + # the class name we are looking for + self.enum_class_name = enum_class + self.qflag_class_name = qflag_class - # used internally to generate the full class name - self.full_name_stack: List[str] = [] + # the number of expected occurences in this module of this flag + self.module_count = module_count - # the class name we are looking for - self.enum_class_name = enum_class - self.qflag_class_name = qflag_class + # the index of the flag in the module which we are looking for + # useful if there are multiple same name flags + self.module_idx = module_idx - # the class full name - self.enum_class_full_name = '' - self.qflag_class_full_name = '' + # our internal index for finding this class + self.visit_enum_idx = -1 + self.visit_qflag_idx = -1 - # the name of two values of the enum class - self.enum_value1 = '' - self.enum_value2 = '' + # the class full name + self.enum_class_full_name = '' + self.qflag_class_full_name = '' - # the node of the class, for debugging purpose + # the name of two values of the enum class + self.enum_value1 = '' + self.enum_value2 = '' - # when filled, set to one of the MethodPresent values - self.enum_methods_present = MethodPresent.Unset - self.qflag_method_present = MethodPresent.Unset + # the node of the class, for debugging purpose - # set when enum_methods_present is set to partial, to add more contect information - self.error_msg = '' + # when filled, set to one of the MethodPresent values + self.enum_methods_present = MethodPresent.Unset + self.qflag_method_present = MethodPresent.Unset + # set when enum_methods_present is set to partial, to add more contect information + self.error_msg = '' - def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: - self.full_name_stack.append( node.name.value ) - if node.name.value == self.enum_class_name: - # we found it - if self.enum_class_full_name != '': - self.error_msg = 'class %s found multiple times\n' % self.enum_class_name - return None - self.enum_class_full_name = '.'.join(self.full_name_stack) - self.check_enum_method_present(node) - self.collect_enum_values(node) + def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: + self.full_name_stack.append( node.name.value ) + if node.name.value == self.enum_class_name: + self.visit_enum_idx += 1 + if self.visit_enum_idx > self.module_count: + self.error_msg = 'class %s found too times: %d\n' % (self.enum_class_name, self.visit_enum_idx) + return None - elif node.name.value == self.qflag_class_name: - # we found it - if self.qflag_class_full_name != '': - self.error_msg = 'class %s found multiple times\n' % self.qflag_class_name - return None - self.qflag_class_full_name = '.'.join(self.full_name_stack) + if self.visit_enum_idx == self.module_idx: + # we found the index we are looking for + self.enum_class_full_name = '.'.join(self.full_name_stack) + self.check_enum_method_present(node) + self.collect_enum_values(node) + return None - self.check_qflag_method_present(node) - return None + elif node.name.value == self.qflag_class_name: + self.visit_qflag_idx += 1 + if self.visit_qflag_idx > self.module_count: + self.error_msg = 'class %s found too times: %d\n' % (self.qflag_class_name, self.visit_qflag_idx) + return None + if self.visit_qflag_idx == self.module_idx: + # we found the index we are looking for + self.qflag_class_full_name = '.'.join(self.full_name_stack) + self.check_qflag_method_present(node) + return None - def check_enum_method_present(self, enum_node: cst.ClassDef) -> None: - '''Check if the class contains method __or__ and __ror__ with one argument and if class + return None + + + def check_enum_method_present(self, enum_node: cst.ClassDef) -> None: + '''Check if the class contains method __or__ and __ror__ with one argument and if class inherit from int''' - if len(enum_node.bases) == 0 or enum_node.bases[0].value.value != 'int': - self.error_msg += 'Class %s does not inherit from int\n' % self.enum_class_full_name - return - has_or = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__or__'))) - has_ror = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__ror__'))) - self.enum_methods_present = { - 0: MethodPresent.Not, - 1: MethodPresent.Partial, - 2: MethodPresent.All - }[len(has_or) + len(has_ror)] - - if self.enum_methods_present == MethodPresent.Partial: - if has_or: - args = ('__or__', '__ror__') - else: - args = ('__ror__', '__or__') - - self.error_msg += 'class %s, method %s present without method %s\n' % ((self.enum_class_full_name,)+args) - - - def collect_enum_values(self, enum_node: cst.ClassDef) -> None: - '''Collect two actual values for the enum and store them into self.enum_value1 and enum_value2 - ''' - # find all lines consisting of an assignment to an ellipsis, like "AlignLeft = ..." - enum_values = matchers.findall(enum_node.body, matchers.SimpleStatementLine( - body=[matchers.Assign(value=matchers.Ellipsis())])) - if len(enum_values) == 0: - self.error_msg += 'class %s, could not find any enum values\n' % self.enum_class_full_name - return - - self.enum_value1 = enum_values[0].body[0].targets[0].target.value - if len(enum_values) > 1: - self.enum_value2 = enum_values[1].body[0].targets[0].target.value - else: - # it works find if both values are the same so don't bother - self.enum_value2 = self.enum_value1 - - - def check_qflag_method_present(self, qflag_node: cst.ClassDef) -> None: - '''Check if the class contains method: + if len(enum_node.bases) == 0 or enum_node.bases[0].value.value != 'int': + self.error_msg += 'Class %s does not inherit from int\n' % self.enum_class_full_name + return + has_or = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__or__'))) + has_ror = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__ror__'))) + self.enum_methods_present = { + 0: MethodPresent.Not, + 1: MethodPresent.Partial, + 2: MethodPresent.All + }[len(has_or) + len(has_ror)] + + if self.enum_methods_present == MethodPresent.Partial: + if has_or: + args = ('__or__', '__ror__') + else: + args = ('__ror__', '__or__') + + self.error_msg += 'class %s, method %s present without method %s\n' % ((self.enum_class_full_name,)+args) + + + def collect_enum_values(self, enum_node: cst.ClassDef) -> None: + '''Collect two actual values for the enum and store them into self.enum_value1 and enum_value2 + ''' + # find all lines consisting of an assignment to an ellipsis, like "AlignLeft = ..." + enum_values = matchers.findall(enum_node.body, matchers.SimpleStatementLine( + body=[matchers.Assign(value=matchers.Ellipsis())])) + if len(enum_values) == 0: + self.error_msg += 'class %s, could not find any enum values\n' % self.enum_class_full_name + return + + self.enum_value1 = enum_values[0].body[0].targets[0].target.value + if len(enum_values) > 1: + self.enum_value2 = enum_values[1].body[0].targets[0].target.value + else: + # it works find if both values are the same so don't bother + self.enum_value2 = self.enum_value1 + + + def check_qflag_method_present(self, qflag_node: cst.ClassDef) -> None: + '''Check if the class contains method: def __or__ def __and__ def __xor__ @@ -565,213 +610,225 @@ def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier' def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ''' - has_method = [ - (m, matchers.findall(qflag_node.body, matchers.FunctionDef(name=matchers.Name(m)))) - for m in ('__or__', '__and__', '__xor__', '__ror__', '__rxor__', '__rand__') - ] + has_method = [ + (m, matchers.findall(qflag_node.body, matchers.FunctionDef(name=matchers.Name(m)))) + for m in ('__or__', '__and__', '__xor__', '__ror__', '__rxor__', '__rand__') + ] - if all(has_info[1] for has_info in has_method): - # all method presents - self.qflag_method_present = MethodPresent.All - return + if all(has_info[1] for has_info in has_method): + # all method presents + self.qflag_method_present = MethodPresent.All + return - if all(not has_info[1] for has_info in has_method): - # all method absent - self.qflag_method_present = MethodPresent.Not - return + if all(not has_info[1] for has_info in has_method): + # all method absent + self.qflag_method_present = MethodPresent.Not + return - self.qflag_method_present = MethodPresent.Partial + self.qflag_method_present = MethodPresent.Partial - for m_name, m_has in has_method: - if m_has: - self.error_msg += 'class %s, method %s present without all others\n' \ - % ((self.qflag_class_full_name, m_name)) - else: - self.error_msg += 'class %s, method %s missing\n' \ - % ((self.qflag_class_full_name, m_name)) + for m_name, m_has in has_method: + if m_has: + self.error_msg += 'class %s, method %s present without all others\n' \ + % ((self.qflag_class_full_name, m_name)) + else: + self.error_msg += 'class %s, method %s missing\n' \ + % ((self.qflag_class_full_name, m_name)) - def visit_FunctionDef(self, node: cst.FunctionDef) -> Optional[bool]: - self.full_name_stack.append( node.name.value ) - return None + def visit_FunctionDef(self, node: cst.FunctionDef) -> Optional[bool]: + self.full_name_stack.append( node.name.value ) + return None - def leave_ClassDef(self, node: cst.ClassDef) -> None: - self.full_name_stack.pop() + def leave_ClassDef(self, node: cst.ClassDef) -> None: + self.full_name_stack.pop() - def leave_FunctionDef(self, node: cst.FunctionDef) -> None: - self.full_name_stack.pop() + def leave_FunctionDef(self, node: cst.FunctionDef) -> None: + self.full_name_stack.pop() class QFlagAndEnumUpdater(cst.CSTTransformer): - def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag_full_name: str) -> None: - super().__init__() - - self.error_msg = '' - - # the class name we are looking for - self.enum_class = enum_class - self.qflag_class = qflag_class - self.enum_full_name = enum_full_name - self.qflag_full_name = qflag_full_name - - # set when enum_methods_present is set to partial, to add more contect information - self.error_msg = '' - - - def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: - if original_node.name.value == self.enum_class: - return self.transform_enum_class(original_node, updated_node) - elif original_node.name.value == self.qflag_class: - return self.transform_qflag_class(original_node, updated_node) - return updated_node - - - def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: - '''Add the two methods __or__ and __ror__ to the class body''' - - # we keep comments separated to align them properly in the final file - new_methods_parts = ( - ("def __or__ (self, other: '{enum}') -> '{qflag}': ...", "# type: ignore[override]\n"), - ("def __ror__ (self, other: int) -> '{qflag}': ...", "# type: ignore[override, misc]\n\n") - ) - - # fill the class names - new_methods_filled = tuple( - (code.format(enum=self.enum_full_name, qflag=self.qflag_full_name), comment) - for code, comment in new_methods_parts - ) - - # now calculate the proper spacing to have aligned comments - max_code_len = max(len(code) for code, comment in new_methods_filled) - new_methods_spaced = tuple( - code + ' '*(4+max_code_len-len(code)) + comment - for code, comment in new_methods_filled - ) - new_methods_cst = tuple(cst.parse_statement(s) for s in new_methods_spaced) - return updated_node.with_changes(body=updated_node.body.with_changes(body= - new_methods_cst \ - + (updated_node.body.body[0].with_changes(leading_lines= - updated_node.body.body[0].leading_lines + - (cst.EmptyLine(),)),) \ - + updated_node.body.body[1:] ) ) - - - def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: - ''' + def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag_full_name: str, + module_idx: int) -> None: + super().__init__() + + self.error_msg = '' + + # the class name we are looking for + self.enum_class = enum_class + self.qflag_class = qflag_class + self.enum_full_name = enum_full_name + self.qflag_full_name = qflag_full_name + + # the index in this module of the class we are looking for + self.module_idx = module_idx + + # our current count of visit + self.visit_enum_idx = -1 + self.visit_qflag_idx = -1 + + # set when enum_methods_present is set to partial, to add more contect information + self.error_msg = '' + + + def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: + if original_node.name.value == self.enum_class: + self.visit_enum_idx += 1 + if self.visit_enum_idx == self.module_idx: + return self.transform_enum_class(original_node, updated_node) + elif original_node.name.value == self.qflag_class: + self.visit_qflag_idx += 1 + if self.visit_qflag_idx == self.module_idx: + return self.transform_qflag_class(original_node, updated_node) + return updated_node + + + def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: + '''Add the two methods __or__ and __ror__ to the class body''' + + # we keep comments separated to align them properly in the final file + new_methods_parts = ( + ("def __or__ (self, other: '{enum}') -> '{qflag}': ...", "# type: ignore[override]\n"), + ("def __ror__ (self, other: int) -> '{qflag}': ...", "# type: ignore[override, misc]\n\n") + ) + + # fill the class names + new_methods_filled = tuple( + (code.format(enum=self.enum_full_name, qflag=self.qflag_full_name), comment) + for code, comment in new_methods_parts + ) + + # now calculate the proper spacing to have aligned comments + max_code_len = max(len(code) for code, comment in new_methods_filled) + new_methods_spaced = tuple( + code + ' '*(4+max_code_len-len(code)) + comment + for code, comment in new_methods_filled + ) + new_methods_cst = tuple(cst.parse_statement(s) for s in new_methods_spaced) + return updated_node.with_changes(body=updated_node.body.with_changes(body= + new_methods_cst \ + + (updated_node.body.body[0].with_changes(leading_lines= + updated_node.body.body[0].leading_lines + + (cst.EmptyLine(),)),) \ + + updated_node.body.body[1:] ) ) + + + def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: + ''' On the qflag class, add one more overload __init__() and add more methods - + @typing.overload + + @typing.overload + def __init__(self, f: int) -> None: ... ''' - init_methods = matchers.findall(updated_node.body, matchers.FunctionDef(name=matchers.Name('__init__'))) - if len(init_methods) == 1: - # we do not handle the case where there is only one init function - # to handle it, we would need to do the following: - # * add an @typing.overload to the current init function - # * add a new init function - # - # This is not difficult, it's just that I don't think we have such cases - self.error_msg += 'Only one __init__ method in QFlag class %s, do not know how to transform it\n' % self.qflag_full_name - return updated_node - - # find the last __init__() method index - last_init_idx = 0 - nb_init_found = 0 - for i, body_element in enumerate(updated_node.body.body): - if matchers.matches(body_element, matchers.FunctionDef(name=matchers.Name('__init__'))): - nb_init_found += 1 - if nb_init_found == len(init_methods): - last_init_idx = i - break - assert last_init_idx != 0 - - cst_init = cst.parse_statement( '@typing.overload\ndef __init__(self, f: int) -> None: ...' ) - updated_node = updated_node.with_changes(body=updated_node.body.with_changes(body= - tuple(updated_node.body.body[:last_init_idx+1]) + - (cst_init,) + - tuple(updated_node.body.body[last_init_idx+1:]) - ) - ) - - new_methods = ( - "def __or__ (self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", - "def __and__(self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", - "def __xor__(self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", - "def __ror__ (self, other: '{enum}') -> '{qflag}': ...", - "def __rand__(self, other: '{enum}') -> '{qflag}': ...", - "def __rxor__(self, other: '{enum}') -> '{qflag}': ...", - ) - new_methods_cst = tuple( - cst.parse_statement(s.format(enum=self.enum_full_name, qflag=self.qflag_full_name)) - for s in new_methods - ) - return updated_node.with_changes(body=updated_node.body.with_changes(body= - tuple(updated_node.body.body) + new_methods_cst ) ) + init_methods = matchers.findall(updated_node.body, matchers.FunctionDef(name=matchers.Name('__init__'))) + if len(init_methods) == 1: + # we do not handle the case where there is only one init function + # to handle it, we would need to do the following: + # * add an @typing.overload to the current init function + # * add a new init function + # + # This is not difficult, it's just that I don't think we have such cases + self.error_msg += 'Only one __init__ method in QFlag class %s, do not know how to transform it\n' % self.qflag_full_name + return updated_node + + # find the last __init__() method index + last_init_idx = 0 + nb_init_found = 0 + for i, body_element in enumerate(updated_node.body.body): + if matchers.matches(body_element, matchers.FunctionDef(name=matchers.Name('__init__'))): + nb_init_found += 1 + if nb_init_found == len(init_methods): + last_init_idx = i + break + assert last_init_idx != 0 + + cst_init = cst.parse_statement( '@typing.overload\ndef __init__(self, f: int) -> None: ...' ) + updated_node = updated_node.with_changes(body=updated_node.body.with_changes(body= + tuple(updated_node.body.body[:last_init_idx+1]) + + (cst_init,) + + tuple(updated_node.body.body[last_init_idx+1:]) + ) + ) + + new_methods = ( + "def __or__ (self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", + "def __and__(self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", + "def __xor__(self, other: typing.Union['{qflag}', '{enum}', int]) -> '{qflag}': ...", + "def __ror__ (self, other: '{enum}') -> '{qflag}': ...", + "def __rand__(self, other: '{enum}') -> '{qflag}': ...", + "def __rxor__(self, other: '{enum}') -> '{qflag}': ...", + ) + new_methods_cst = tuple( + cst.parse_statement(s.format(enum=self.enum_full_name, qflag=self.qflag_full_name)) + for s in new_methods + ) + return updated_node.with_changes(body=updated_node.body.with_changes(body= + tuple(updated_node.body.body) + new_methods_cst ) ) @functools.lru_cache(maxsize=1) def read_qflag_test_template(template_fname: str) -> Tuple[List[str], List[str], List[str]]: - '''Return the source of the template for generating qflags test. + '''Return the source of the template for generating qflags test. - Return 3 parts as a list of strings: - - the first part should be unmodified - - the second part should be replaced for a specific QFlag class - - the third part should be unmodified - ''' + Return 3 parts as a list of strings: + - the first part should be unmodified + - the second part should be replaced for a specific QFlag class + - the third part should be unmodified + ''' - # the markers inside the above template to identify the parts to replace - MARKER_SPECIFIC_START = '### Specific part' - MARKER_SPECIFIC_END = '### End of specific part' + # the markers inside the above template to identify the parts to replace + MARKER_SPECIFIC_START = '### Specific part' + MARKER_SPECIFIC_END = '### End of specific part' - with open(template_fname) as f: - lines = f.readlines() + with open(template_fname) as f: + lines = f.readlines() - source_part_before, source_part_middle, source_part_after = [], [], [] - fill_middle, fill_after = False, False - for l in lines: - if fill_after: - source_part_after.append(l) - continue + source_part_before, source_part_middle, source_part_after = [], [], [] + fill_middle, fill_after = False, False + for l in lines: + if fill_after: + source_part_after.append(l) + continue - if fill_middle: - if MARKER_SPECIFIC_END in l: - fill_after = True - source_part_after.append(l) - continue + if fill_middle: + if MARKER_SPECIFIC_END in l: + fill_after = True + source_part_after.append(l) + continue - source_part_middle.append(l) - continue + source_part_middle.append(l) + continue - source_part_before.append(l) - if MARKER_SPECIFIC_START in l: - fill_middle = True + source_part_before.append(l) + if MARKER_SPECIFIC_START in l: + fill_middle = True - return source_part_before, source_part_middle, source_part_after + return source_part_before, source_part_middle, source_part_after def gen_test_fname(fli: QFlagLocationInfo) -> str: - '''Generate the name of the test file which will verify this qflag''' - return 'test_{fli.module_info[0][0]}_{fli.qflag_class}_{fli.enum_class}.py'.format(fli=fli) + '''Generate the name of the test file which will verify this qflag''' + return 'test_{fli.module_name}_{fli.qflag_class}_{fli.enum_class}.py'.format(fli=fli) def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: - '''Generate a qflag test file. + '''Generate a qflag test file. - The filename is inferred from flag_info using gen_test_fname() - ''' + The filename is inferred from flag_info using gen_test_fname() + ''' - # the template after which we model all generated qflag tests - TEMPLATE_QFLAGS_TESTS = 'qflags_test_template.py' + # the template after which we model all generated qflag tests + TEMPLATE_QFLAGS_TESTS = 'qflags_test_template.py' - test_qflag_fname = gen_test_fname(flag_info) - generic_part_before, _replacable_part, generic_part_after = read_qflag_test_template(TEMPLATE_QFLAGS_TESTS) + test_qflag_fname = gen_test_fname(flag_info) + generic_part_before, _replacable_part, generic_part_after = read_qflag_test_template(TEMPLATE_QFLAGS_TESTS) - with open(test_qflag_fname, 'w') as f: - f.writelines(generic_part_before) + with open(test_qflag_fname, 'w') as f: + f.writelines(generic_part_before) - # replace the repplacable_part with code dedicated to our qflag - f.write('''# file generated from {source} for QFlags class "{multiFlagName}" and flag class "{oneFlagName}" + # replace the repplacable_part with code dedicated to our qflag + f.write('''# file generated from {source} for QFlags class "{multiFlagName}" and flag class "{oneFlagName}" from PyQt5 import {qtmodule} OneFlagClass = {qtmodule}.{oneFlagName} @@ -780,67 +837,72 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: oneFlagRefValue1 = {qtmodule}.{oneFlagName}.{oneFlagValue1} oneFlagRefValue2 = {qtmodule}.{oneFlagName}.{oneFlagValue2} '''.format(source=TEMPLATE_QFLAGS_TESTS, - multiFlagName=flag_info.qflag_full_class_name, - oneFlagName=flag_info.enum_full_class_name, - oneFlagValue1=flag_info.enum_value1, - oneFlagValue2=flag_info.enum_value2, - qtmodule=flag_info.module_info[0][0] - )) - f.writelines(generic_part_after) - log_progress('Test file generated: %s' % test_qflag_fname) + multiFlagName=flag_info.qflag_full_class_name, + oneFlagName=flag_info.enum_full_class_name, + oneFlagValue1=flag_info.enum_value1, + oneFlagValue2=flag_info.enum_value2, + qtmodule=flag_info.module_name + )) + f.writelines(generic_part_after) + log_progress('Test file generated: %s' % test_qflag_fname) def generate_qflags_to_process(qt_qflag_grep_result_fname): - '''Run the generation process from the grep output parsing to the generation of json file listing the flags to process''' - location_qflags = identify_qflag_location(qt_qflag_grep_result_fname, QTBASE_MODULES) - log_progress('%d qflags extracted from grep file' % len(location_qflags)) - qflags_groups = group_qflags(location_qflags) - log_progress('%d qflags ready to be processed' % len(qflags_groups['one_flag_one_module'])) - - qflags_modules_analysis_json = 'qflags_modules_analysis.json' - # put our intermediate classification into a json file for human review - with open(qflags_modules_analysis_json, 'w') as f: - json.dump(qflags_groups, f, indent=4, default=json_encode_qflaglocationinfo) - log_progress('QFlag analysis saved to: %s' % qflags_modules_analysis_json) - - qflags_to_process_json = 'qflags_to_process.json' - extract_qflags_to_process(qflags_modules_analysis_json, qflags_to_process_json) - log_progress('qflag file ready to process: %s' % qflags_to_process_json) + '''Run the generation process from the grep output parsing to the generation of json file listing the flags to process''' + location_qflags = identify_qflag_location(qt_qflag_grep_result_fname, QTBASE_MODULES) + log_progress('%d qflags extracted from grep file' % len(location_qflags)) + qflags_groups = group_qflags(location_qflags) + log_progress('%d qflags ready to be processed' % len(qflags_groups['flag_and_module_identified'])) + + qflags_modules_analysis_json = 'qflags_modules_analysis.json' + # put our intermediate classification into a json file for human review + with open(qflags_modules_analysis_json, 'w') as f: + json.dump(qflags_groups, f, indent=4, default=json_encode_qflaglocationinfo) + log_progress('QFlag analysis saved to: %s' % qflags_modules_analysis_json) + + qflags_to_process_json = 'qflags_to_process.json' + extract_qflags_to_process(qflags_modules_analysis_json, qflags_to_process_json) + log_progress('qflag file ready to process: %s' % qflags_to_process_json) if __name__ == '__main__': - if len(sys.argv) <= 1: - print(USAGE) - sys.exit(1) - - auto_commit = False - if '--auto-commit' in sys.argv: - auto_commit = True - - if sys.argv[1] == 'gen_qflag_stub': - nb = 1 - if len(sys.argv) > 2: - nb = int(sys.argv[2]) - - qflags_to_process_json = 'qflags_to_process.json' - qflag_result_json = 'qflags_process_result.json' - more_available = True - while nb > 0 and more_available: - nb -= 1 - more_available = process_qflag(qflags_to_process_json, qflag_result_json, auto_commit) - - elif sys.argv[1] == 'analyse_grep_results': - if len(sys.argv) <= 2: - print('Error, you must provide the filename of the grep results\n') - print(USAGE) - sys.exit(1) - - grep_fname = sys.argv[2] - generate_qflags_to_process(grep_fname) - - else: - print('Error, invalid command line arguments\n') - print(USAGE) - sys.exit(1) + if len(sys.argv) <= 1: + print(USAGE) + sys.exit(1) + + auto_commit = False + if '--auto-commit' in sys.argv: + auto_commit = True + + + if sys.argv[1] == 'gen_qflag_stub': + nb = 1 + process_all = False + if len(sys.argv) > 2: + if sys.argv[2] == 'all': + process_all = True + else: + nb = int(sys.argv[2]) + + qflags_to_process_json = 'qflags_to_process.json' + qflag_result_json = 'qflags_process_result.json' + more_available = True + while (nb > 0 or process_all) and more_available: + nb -= 1 + more_available = process_qflag(qflags_to_process_json, qflag_result_json, auto_commit) + + elif sys.argv[1] == 'analyse_grep_results': + if len(sys.argv) <= 2: + print('Error, you must provide the filename of the grep results\n') + print(USAGE) + sys.exit(1) + + grep_fname = sys.argv[2] + generate_qflags_to_process(grep_fname) + + else: + print('Error, invalid command line arguments\n') + print(USAGE) + sys.exit(1) From 7feab159ef263573fd4859ee72875c08f4b9c167 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 09:14:15 +0200 Subject: [PATCH 104/421] QFlag operations for QOpenGLShader.ShaderType, QOpenGLShader.ShaderTypeBit in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + .../test_QtGui_ShaderType_ShaderTypeBit.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index de4506a1..f63bffb2 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -4296,6 +4296,9 @@ class QOpenGLPixelTransferOptions(sip.simplewrapper): class QOpenGLShader(QtCore.QObject): class ShaderTypeBit(int): + def __or__ (self, other: 'QOpenGLShader.ShaderTypeBit') -> 'QOpenGLShader.ShaderType': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QOpenGLShader.ShaderType': ... # type: ignore[override, misc] + Vertex = ... # type: QOpenGLShader.ShaderTypeBit Fragment = ... # type: QOpenGLShader.ShaderTypeBit Geometry = ... # type: QOpenGLShader.ShaderTypeBit @@ -4318,12 +4321,20 @@ class QOpenGLShader(QtCore.QObject): def __init__(self, f: typing.Union['QOpenGLShader.ShaderType', 'QOpenGLShader.ShaderTypeBit']) -> None: ... @typing.overload def __init__(self, a0: 'QOpenGLShader.ShaderType') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QOpenGLShader.ShaderType': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QOpenGLShader.ShaderType', 'QOpenGLShader.ShaderTypeBit', int]) -> 'QOpenGLShader.ShaderType': ... + def __and__(self, other: typing.Union['QOpenGLShader.ShaderType', 'QOpenGLShader.ShaderTypeBit', int]) -> 'QOpenGLShader.ShaderType': ... + def __xor__(self, other: typing.Union['QOpenGLShader.ShaderType', 'QOpenGLShader.ShaderTypeBit', int]) -> 'QOpenGLShader.ShaderType': ... + def __ror__ (self, other: 'QOpenGLShader.ShaderTypeBit') -> 'QOpenGLShader.ShaderType': ... + def __rand__(self, other: 'QOpenGLShader.ShaderTypeBit') -> 'QOpenGLShader.ShaderType': ... + def __rxor__(self, other: 'QOpenGLShader.ShaderTypeBit') -> 'QOpenGLShader.ShaderType': ... def __init__(self, type: typing.Union['QOpenGLShader.ShaderType', 'QOpenGLShader.ShaderTypeBit'], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py b/tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py new file mode 100644 index 00000000..3b614810 --- /dev/null +++ b/tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QOpenGLShader.ShaderType" and flag class "QOpenGLShader.ShaderTypeBit" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QOpenGLShader.ShaderTypeBit +MultiFlagClass = QtGui.QOpenGLShader.ShaderType + +oneFlagRefValue1 = QtGui.QOpenGLShader.ShaderTypeBit.Vertex +oneFlagRefValue2 = QtGui.QOpenGLShader.ShaderTypeBit.Fragment +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 2d5bcc34972e32be081f62f8ea7454183bb883b9 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 12:56:17 +0200 Subject: [PATCH 105/421] QFlag operations for QMessageBox.StandardButtons, QMessageBox.StandardButton in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 16 +- ...tWidgets_StandardButtons_StandardButton.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+), 5 deletions(-) create mode 100644 tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 92d28ffb..8a070659 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -7580,11 +7580,10 @@ class QMenuBar(QWidget): class QMessageBox(QDialog): class StandardButton(int): - @typing.overload # type: ignore[override] - def __or__(self, other: typing.Union['QMessageBox.StandardButton', 'QMessageBox.StandardButtons']) -> 'QMessageBox.StandardButtons': ... # type: ignore[misc] - @typing.overload - def __or__(self, other: int) -> int: ... + def __or__ (self, other: 'QMessageBox.StandardButton') -> 'QMessageBox.StandardButtons': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QMessageBox.StandardButtons': ... # type: ignore[override, misc] + NoButton = ... # type: 'QMessageBox.StandardButton' Ok = ... # type: 'QMessageBox.StandardButton' Save = ... # type: 'QMessageBox.StandardButton' @@ -7685,13 +7684,20 @@ class QMessageBox(QDialog): def __init__(self, f: typing.Union['QMessageBox.StandardButtons', 'QMessageBox.StandardButton']) -> None: ... @typing.overload def __init__(self, a0: 'QMessageBox.StandardButtons') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QMessageBox.StandardButtons': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - def __or__(self, other: typing.Union[int, 'QMessageBox.StandardButtons', 'QMessageBox.StandardButton']) -> 'QMessageBox.StandardButtons': ... + def __or__ (self, other: typing.Union['QMessageBox.StandardButtons', 'QMessageBox.StandardButton', int]) -> 'QMessageBox.StandardButtons': ... + def __and__(self, other: typing.Union['QMessageBox.StandardButtons', 'QMessageBox.StandardButton', int]) -> 'QMessageBox.StandardButtons': ... + def __xor__(self, other: typing.Union['QMessageBox.StandardButtons', 'QMessageBox.StandardButton', int]) -> 'QMessageBox.StandardButtons': ... + def __ror__ (self, other: 'QMessageBox.StandardButton') -> 'QMessageBox.StandardButtons': ... + def __rand__(self, other: 'QMessageBox.StandardButton') -> 'QMessageBox.StandardButtons': ... + def __rxor__(self, other: 'QMessageBox.StandardButton') -> 'QMessageBox.StandardButtons': ... @typing.overload def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py b/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py new file mode 100644 index 00000000..a21ee5ad --- /dev/null +++ b/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QMessageBox.StandardButtons" and flag class "QMessageBox.StandardButton" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QMessageBox.StandardButton +MultiFlagClass = QtWidgets.QMessageBox.StandardButtons + +oneFlagRefValue1 = QtWidgets.QMessageBox.StandardButton.NoButton +oneFlagRefValue2 = QtWidgets.QMessageBox.StandardButton.Ok +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a91b59e324860c2c4039825c4a931f8712a20603 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 12:58:37 +0200 Subject: [PATCH 106/421] QFlag operations for QDirIterator.IteratorFlags, QDirIterator.IteratorFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_IteratorFlags_IteratorFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index bc3b3ad8..aaf69906 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -5720,6 +5720,9 @@ class QDir(sip.simplewrapper): class QDirIterator(sip.simplewrapper): class IteratorFlag(int): + def __or__ (self, other: 'QDirIterator.IteratorFlag') -> 'QDirIterator.IteratorFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QDirIterator.IteratorFlags': ... # type: ignore[override, misc] + NoIteratorFlags = ... # type: QDirIterator.IteratorFlag FollowSymlinks = ... # type: QDirIterator.IteratorFlag Subdirectories = ... # type: QDirIterator.IteratorFlag @@ -5736,12 +5739,20 @@ class QDirIterator(sip.simplewrapper): def __init__(self, f: typing.Union['QDirIterator.IteratorFlags', 'QDirIterator.IteratorFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QDirIterator.IteratorFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QDirIterator.IteratorFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QDirIterator.IteratorFlags', 'QDirIterator.IteratorFlag', int]) -> 'QDirIterator.IteratorFlags': ... + def __and__(self, other: typing.Union['QDirIterator.IteratorFlags', 'QDirIterator.IteratorFlag', int]) -> 'QDirIterator.IteratorFlags': ... + def __xor__(self, other: typing.Union['QDirIterator.IteratorFlags', 'QDirIterator.IteratorFlag', int]) -> 'QDirIterator.IteratorFlags': ... + def __ror__ (self, other: 'QDirIterator.IteratorFlag') -> 'QDirIterator.IteratorFlags': ... + def __rand__(self, other: 'QDirIterator.IteratorFlag') -> 'QDirIterator.IteratorFlags': ... + def __rxor__(self, other: 'QDirIterator.IteratorFlag') -> 'QDirIterator.IteratorFlags': ... @typing.overload def __init__(self, dir: QDir, flags: 'QDirIterator.IteratorFlags' = ...) -> None: ... diff --git a/tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py b/tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py new file mode 100644 index 00000000..02f2bbc7 --- /dev/null +++ b/tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QDirIterator.IteratorFlags" and flag class "QDirIterator.IteratorFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QDirIterator.IteratorFlag +MultiFlagClass = QtCore.QDirIterator.IteratorFlags + +oneFlagRefValue1 = QtCore.QDirIterator.IteratorFlag.NoIteratorFlags +oneFlagRefValue2 = QtCore.QDirIterator.IteratorFlag.FollowSymlinks +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 4e0f0bd6a5e5fc4ee9b970fada52f732fbf62b46 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 12:59:37 +0200 Subject: [PATCH 107/421] QFlag operations for QTreeWidgetItemIterator.IteratorFlags, QTreeWidgetItemIterator.IteratorFlag in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...st_QtWidgets_IteratorFlags_IteratorFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 8a070659..2542bd7f 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -11078,6 +11078,9 @@ class QTreeWidget(QTreeView): class QTreeWidgetItemIterator(sip.simplewrapper): class IteratorFlag(int): + def __or__ (self, other: 'QTreeWidgetItemIterator.IteratorFlag') -> 'QTreeWidgetItemIterator.IteratorFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QTreeWidgetItemIterator.IteratorFlags': ... # type: ignore[override, misc] + All = ... # type: QTreeWidgetItemIterator.IteratorFlag Hidden = ... # type: QTreeWidgetItemIterator.IteratorFlag NotHidden = ... # type: QTreeWidgetItemIterator.IteratorFlag @@ -11128,12 +11131,20 @@ class QTreeWidgetItemIterator(sip.simplewrapper): def __init__(self, f: typing.Union['QTreeWidgetItemIterator.IteratorFlags', 'QTreeWidgetItemIterator.IteratorFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QTreeWidgetItemIterator.IteratorFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTreeWidgetItemIterator.IteratorFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTreeWidgetItemIterator.IteratorFlags', 'QTreeWidgetItemIterator.IteratorFlag', int]) -> 'QTreeWidgetItemIterator.IteratorFlags': ... + def __and__(self, other: typing.Union['QTreeWidgetItemIterator.IteratorFlags', 'QTreeWidgetItemIterator.IteratorFlag', int]) -> 'QTreeWidgetItemIterator.IteratorFlags': ... + def __xor__(self, other: typing.Union['QTreeWidgetItemIterator.IteratorFlags', 'QTreeWidgetItemIterator.IteratorFlag', int]) -> 'QTreeWidgetItemIterator.IteratorFlags': ... + def __ror__ (self, other: 'QTreeWidgetItemIterator.IteratorFlag') -> 'QTreeWidgetItemIterator.IteratorFlags': ... + def __rand__(self, other: 'QTreeWidgetItemIterator.IteratorFlag') -> 'QTreeWidgetItemIterator.IteratorFlags': ... + def __rxor__(self, other: 'QTreeWidgetItemIterator.IteratorFlag') -> 'QTreeWidgetItemIterator.IteratorFlags': ... @typing.overload def __init__(self, it: 'QTreeWidgetItemIterator') -> None: ... diff --git a/tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py b/tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py new file mode 100644 index 00000000..9cf9f7cd --- /dev/null +++ b/tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTreeWidgetItemIterator.IteratorFlags" and flag class "QTreeWidgetItemIterator.IteratorFlag" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QTreeWidgetItemIterator.IteratorFlag +MultiFlagClass = QtWidgets.QTreeWidgetItemIterator.IteratorFlags + +oneFlagRefValue1 = QtWidgets.QTreeWidgetItemIterator.IteratorFlag.All +oneFlagRefValue2 = QtWidgets.QTreeWidgetItemIterator.IteratorFlag.Hidden +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 5daa4964d4aba5e5355fe9883f3839dd969a26e5 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 13:07:30 +0200 Subject: [PATCH 108/421] QFlag operations for Qt.Alignment, Qt.AlignmentFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 7 +- .../test_QtCore_Alignment_AlignmentFlag.py | 231 ++++++++++++++++++ 2 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 tests/qflags/test_QtCore_Alignment_AlignmentFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index aaf69906..71b56915 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2537,9 +2537,10 @@ class Qt(sip.simplewrapper): TextJustificationForced = ... # type: Qt.TextFlag class AlignmentFlag(int): - def __or__ (self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignment': ... # type: ignore[override] - def __ror__ (self, other: int) -> 'Qt.Alignment': ... # type: ignore[override, misc] + def __or__ (self, other: 'Qt.AlignmentFlag') -> 'Qt.Alignment': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'Qt.Alignment': ... # type: ignore[override, misc] + AlignLeft = ... # type: Qt.AlignmentFlag AlignLeading = ... # type: Qt.AlignmentFlag AlignRight = ... # type: Qt.AlignmentFlag @@ -2833,6 +2834,8 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.Alignment', 'Qt.AlignmentFlag', int]) -> None: ... @typing.overload def __init__(self, a0: 'Qt.Alignment') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... diff --git a/tests/qflags/test_QtCore_Alignment_AlignmentFlag.py b/tests/qflags/test_QtCore_Alignment_AlignmentFlag.py new file mode 100644 index 00000000..2a47e21b --- /dev/null +++ b/tests/qflags/test_QtCore_Alignment_AlignmentFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.Alignment" and flag class "Qt.AlignmentFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.AlignmentFlag +MultiFlagClass = QtCore.Qt.Alignment + +oneFlagRefValue1 = QtCore.Qt.AlignmentFlag.AlignLeft +oneFlagRefValue2 = QtCore.Qt.AlignmentFlag.AlignLeading +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From c0aa306184184616af84298e7d047fcaa8b1ae35 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 14:32:27 +0200 Subject: [PATCH 109/421] QFlag operations for Qt.InputMethodQueries, Qt.InputMethodQuery in module QtCore --- PyQt5-stubs/QtCore.pyi | 1 + ...ore_InputMethodQueries_InputMethodQuery.py | 231 ++++++++++++++++++ 2 files changed, 232 insertions(+) create mode 100644 tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 71b56915..143da504 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -771,6 +771,7 @@ class Qt(sip.simplewrapper): class InputMethodQuery(int): def __or__ (self, other: 'Qt.InputMethodQuery') -> 'Qt.InputMethodQueries': ... # type: ignore[override] def __ror__ (self, other: int) -> 'Qt.InputMethodQueries': ... # type: ignore[override, misc] + ImMicroFocus = ... # type: Qt.InputMethodQuery ImFont = ... # type: Qt.InputMethodQuery diff --git a/tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py b/tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py new file mode 100644 index 00000000..0ef994d4 --- /dev/null +++ b/tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.InputMethodQueries" and flag class "Qt.InputMethodQuery" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.InputMethodQuery +MultiFlagClass = QtCore.Qt.InputMethodQueries + +oneFlagRefValue1 = QtCore.Qt.InputMethodQuery.ImMicroFocus +oneFlagRefValue2 = QtCore.Qt.InputMethodQuery.ImFont +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 69355e36e8383110cf3b599448b967644646852a Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 15:00:19 +0200 Subject: [PATCH 110/421] QFlag operations for QEventLoop.ProcessEventsFlags, QEventLoop.ProcessEventsFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...re_ProcessEventsFlags_ProcessEventsFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 143da504..1c1cba3d 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -5937,6 +5937,9 @@ class QElapsedTimer(sip.simplewrapper): class QEventLoop(QObject): class ProcessEventsFlag(int): + def __or__ (self, other: 'QEventLoop.ProcessEventsFlag') -> 'QEventLoop.ProcessEventsFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QEventLoop.ProcessEventsFlags': ... # type: ignore[override, misc] + AllEvents = ... # type: QEventLoop.ProcessEventsFlag ExcludeUserInputEvents = ... # type: QEventLoop.ProcessEventsFlag ExcludeSocketNotifiers = ... # type: QEventLoop.ProcessEventsFlag @@ -5957,12 +5960,20 @@ class QEventLoop(QObject): def __init__(self, f: typing.Union['QEventLoop.ProcessEventsFlags', 'QEventLoop.ProcessEventsFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QEventLoop.ProcessEventsFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QEventLoop.ProcessEventsFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QEventLoop.ProcessEventsFlags', 'QEventLoop.ProcessEventsFlag', int]) -> 'QEventLoop.ProcessEventsFlags': ... + def __and__(self, other: typing.Union['QEventLoop.ProcessEventsFlags', 'QEventLoop.ProcessEventsFlag', int]) -> 'QEventLoop.ProcessEventsFlags': ... + def __xor__(self, other: typing.Union['QEventLoop.ProcessEventsFlags', 'QEventLoop.ProcessEventsFlag', int]) -> 'QEventLoop.ProcessEventsFlags': ... + def __ror__ (self, other: 'QEventLoop.ProcessEventsFlag') -> 'QEventLoop.ProcessEventsFlags': ... + def __rand__(self, other: 'QEventLoop.ProcessEventsFlag') -> 'QEventLoop.ProcessEventsFlags': ... + def __rxor__(self, other: 'QEventLoop.ProcessEventsFlag') -> 'QEventLoop.ProcessEventsFlags': ... def __init__(self, parent: typing.Optional[QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py b/tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py new file mode 100644 index 00000000..9714a53a --- /dev/null +++ b/tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QEventLoop.ProcessEventsFlags" and flag class "QEventLoop.ProcessEventsFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QEventLoop.ProcessEventsFlag +MultiFlagClass = QtCore.QEventLoop.ProcessEventsFlags + +oneFlagRefValue1 = QtCore.QEventLoop.ProcessEventsFlag.AllEvents +oneFlagRefValue2 = QtCore.QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 7832128b8959f6c42a209fee42bf09e50e1813b8 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 15:01:49 +0200 Subject: [PATCH 111/421] QFlag operations for QLibrary.LoadHints, QLibrary.LoadHint in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../qflags/test_QtCore_LoadHints_LoadHint.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_LoadHints_LoadHint.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 1c1cba3d..6126d6af 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -6748,6 +6748,9 @@ class QJsonValue(sip.simplewrapper): class QLibrary(QObject): class LoadHint(int): + def __or__ (self, other: 'QLibrary.LoadHint') -> 'QLibrary.LoadHints': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QLibrary.LoadHints': ... # type: ignore[override, misc] + ResolveAllSymbolsHint = ... # type: QLibrary.LoadHint ExportExternalSymbolsHint = ... # type: QLibrary.LoadHint LoadArchiveMemberHint = ... # type: QLibrary.LoadHint @@ -6768,12 +6771,20 @@ class QLibrary(QObject): def __init__(self, f: typing.Union['QLibrary.LoadHints', 'QLibrary.LoadHint']) -> None: ... @typing.overload def __init__(self, a0: 'QLibrary.LoadHints') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QLibrary.LoadHints': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QLibrary.LoadHints', 'QLibrary.LoadHint', int]) -> 'QLibrary.LoadHints': ... + def __and__(self, other: typing.Union['QLibrary.LoadHints', 'QLibrary.LoadHint', int]) -> 'QLibrary.LoadHints': ... + def __xor__(self, other: typing.Union['QLibrary.LoadHints', 'QLibrary.LoadHint', int]) -> 'QLibrary.LoadHints': ... + def __ror__ (self, other: 'QLibrary.LoadHint') -> 'QLibrary.LoadHints': ... + def __rand__(self, other: 'QLibrary.LoadHint') -> 'QLibrary.LoadHints': ... + def __rxor__(self, other: 'QLibrary.LoadHint') -> 'QLibrary.LoadHints': ... @typing.overload def __init__(self, parent: typing.Optional[QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtCore_LoadHints_LoadHint.py b/tests/qflags/test_QtCore_LoadHints_LoadHint.py new file mode 100644 index 00000000..a1dd2280 --- /dev/null +++ b/tests/qflags/test_QtCore_LoadHints_LoadHint.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QLibrary.LoadHints" and flag class "QLibrary.LoadHint" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QLibrary.LoadHint +MultiFlagClass = QtCore.QLibrary.LoadHints + +oneFlagRefValue1 = QtCore.QLibrary.LoadHint.ResolveAllSymbolsHint +oneFlagRefValue2 = QtCore.QLibrary.LoadHint.ExportExternalSymbolsHint +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 0634c26c015f720a16bf8392d1ce654b976f154f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 15:02:40 +0200 Subject: [PATCH 112/421] QFlag operations for QOpenGLBuffer.RangeAccessFlags, QOpenGLBuffer.RangeAccessFlag in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + ..._QtGui_RangeAccessFlags_RangeAccessFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index f63bffb2..47ff1955 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -3813,6 +3813,9 @@ class QOffscreenSurface(QtCore.QObject, QSurface): class QOpenGLBuffer(sip.simplewrapper): class RangeAccessFlag(int): + def __or__ (self, other: 'QOpenGLBuffer.RangeAccessFlag') -> 'QOpenGLBuffer.RangeAccessFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QOpenGLBuffer.RangeAccessFlags': ... # type: ignore[override, misc] + RangeRead = ... # type: QOpenGLBuffer.RangeAccessFlag RangeWrite = ... # type: QOpenGLBuffer.RangeAccessFlag RangeInvalidate = ... # type: QOpenGLBuffer.RangeAccessFlag @@ -3876,12 +3879,20 @@ class QOpenGLBuffer(sip.simplewrapper): def __init__(self, f: typing.Union['QOpenGLBuffer.RangeAccessFlags', 'QOpenGLBuffer.RangeAccessFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QOpenGLBuffer.RangeAccessFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QOpenGLBuffer.RangeAccessFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QOpenGLBuffer.RangeAccessFlags', 'QOpenGLBuffer.RangeAccessFlag', int]) -> 'QOpenGLBuffer.RangeAccessFlags': ... + def __and__(self, other: typing.Union['QOpenGLBuffer.RangeAccessFlags', 'QOpenGLBuffer.RangeAccessFlag', int]) -> 'QOpenGLBuffer.RangeAccessFlags': ... + def __xor__(self, other: typing.Union['QOpenGLBuffer.RangeAccessFlags', 'QOpenGLBuffer.RangeAccessFlag', int]) -> 'QOpenGLBuffer.RangeAccessFlags': ... + def __ror__ (self, other: 'QOpenGLBuffer.RangeAccessFlag') -> 'QOpenGLBuffer.RangeAccessFlags': ... + def __rand__(self, other: 'QOpenGLBuffer.RangeAccessFlag') -> 'QOpenGLBuffer.RangeAccessFlags': ... + def __rxor__(self, other: 'QOpenGLBuffer.RangeAccessFlag') -> 'QOpenGLBuffer.RangeAccessFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py b/tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py new file mode 100644 index 00000000..17e4efd4 --- /dev/null +++ b/tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QOpenGLBuffer.RangeAccessFlags" and flag class "QOpenGLBuffer.RangeAccessFlag" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QOpenGLBuffer.RangeAccessFlag +MultiFlagClass = QtGui.QOpenGLBuffer.RangeAccessFlags + +oneFlagRefValue1 = QtGui.QOpenGLBuffer.RangeAccessFlag.RangeRead +oneFlagRefValue2 = QtGui.QOpenGLBuffer.RangeAccessFlag.RangeWrite +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From d254fd8cefa23b9e17bdc17ffcffd66dd5972e3c Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 15:03:36 +0200 Subject: [PATCH 113/421] QFlag operations for QOpenGLDebugMessage.Sources, QOpenGLDebugMessage.Source in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 ++ tests/qflags/test_QtGui_Sources_Source.py | 231 ++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtGui_Sources_Source.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 47ff1955..42bce059 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -4042,6 +4042,9 @@ class QOpenGLDebugMessage(sip.simplewrapper): AnyType = ... # type: QOpenGLDebugMessage.Type class Source(int): + def __or__ (self, other: 'QOpenGLDebugMessage.Source') -> 'QOpenGLDebugMessage.Sources': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QOpenGLDebugMessage.Sources': ... # type: ignore[override, misc] + InvalidSource = ... # type: QOpenGLDebugMessage.Source APISource = ... # type: QOpenGLDebugMessage.Source WindowSystemSource = ... # type: QOpenGLDebugMessage.Source @@ -4068,12 +4071,20 @@ class QOpenGLDebugMessage(sip.simplewrapper): def __init__(self, f: typing.Union['QOpenGLDebugMessage.Sources', 'QOpenGLDebugMessage.Source']) -> None: ... @typing.overload def __init__(self, a0: 'QOpenGLDebugMessage.Sources') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QOpenGLDebugMessage.Sources': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QOpenGLDebugMessage.Sources', 'QOpenGLDebugMessage.Source', int]) -> 'QOpenGLDebugMessage.Sources': ... + def __and__(self, other: typing.Union['QOpenGLDebugMessage.Sources', 'QOpenGLDebugMessage.Source', int]) -> 'QOpenGLDebugMessage.Sources': ... + def __xor__(self, other: typing.Union['QOpenGLDebugMessage.Sources', 'QOpenGLDebugMessage.Source', int]) -> 'QOpenGLDebugMessage.Sources': ... + def __ror__ (self, other: 'QOpenGLDebugMessage.Source') -> 'QOpenGLDebugMessage.Sources': ... + def __rand__(self, other: 'QOpenGLDebugMessage.Source') -> 'QOpenGLDebugMessage.Sources': ... + def __rxor__(self, other: 'QOpenGLDebugMessage.Source') -> 'QOpenGLDebugMessage.Sources': ... class Types(sip.simplewrapper): diff --git a/tests/qflags/test_QtGui_Sources_Source.py b/tests/qflags/test_QtGui_Sources_Source.py new file mode 100644 index 00000000..a57f9da8 --- /dev/null +++ b/tests/qflags/test_QtGui_Sources_Source.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QOpenGLDebugMessage.Sources" and flag class "QOpenGLDebugMessage.Source" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QOpenGLDebugMessage.Source +MultiFlagClass = QtGui.QOpenGLDebugMessage.Sources + +oneFlagRefValue1 = QtGui.QOpenGLDebugMessage.Source.InvalidSource +oneFlagRefValue2 = QtGui.QOpenGLDebugMessage.Source.APISource +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From d329d0b4e700e0722e9774cdea99858c7403c525 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 15:04:43 +0200 Subject: [PATCH 114/421] QFlag operations for QOpenGLDebugMessage.Severities, QOpenGLDebugMessage.Severity in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + .../qflags/test_QtGui_Severities_Severity.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtGui_Severities_Severity.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 42bce059..68a8f498 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -4002,6 +4002,9 @@ class QOpenGLVersionProfile(sip.simplewrapper): class QOpenGLDebugMessage(sip.simplewrapper): class Severity(int): + def __or__ (self, other: 'QOpenGLDebugMessage.Severity') -> 'QOpenGLDebugMessage.Severities': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QOpenGLDebugMessage.Severities': ... # type: ignore[override, misc] + InvalidSeverity = ... # type: QOpenGLDebugMessage.Severity HighSeverity = ... # type: QOpenGLDebugMessage.Severity MediumSeverity = ... # type: QOpenGLDebugMessage.Severity @@ -4109,12 +4112,20 @@ class QOpenGLDebugMessage(sip.simplewrapper): def __init__(self, f: typing.Union['QOpenGLDebugMessage.Severities', 'QOpenGLDebugMessage.Severity']) -> None: ... @typing.overload def __init__(self, a0: 'QOpenGLDebugMessage.Severities') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QOpenGLDebugMessage.Severities': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QOpenGLDebugMessage.Severities', 'QOpenGLDebugMessage.Severity', int]) -> 'QOpenGLDebugMessage.Severities': ... + def __and__(self, other: typing.Union['QOpenGLDebugMessage.Severities', 'QOpenGLDebugMessage.Severity', int]) -> 'QOpenGLDebugMessage.Severities': ... + def __xor__(self, other: typing.Union['QOpenGLDebugMessage.Severities', 'QOpenGLDebugMessage.Severity', int]) -> 'QOpenGLDebugMessage.Severities': ... + def __ror__ (self, other: 'QOpenGLDebugMessage.Severity') -> 'QOpenGLDebugMessage.Severities': ... + def __rand__(self, other: 'QOpenGLDebugMessage.Severity') -> 'QOpenGLDebugMessage.Severities': ... + def __rxor__(self, other: 'QOpenGLDebugMessage.Severity') -> 'QOpenGLDebugMessage.Severities': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtGui_Severities_Severity.py b/tests/qflags/test_QtGui_Severities_Severity.py new file mode 100644 index 00000000..afbb002e --- /dev/null +++ b/tests/qflags/test_QtGui_Severities_Severity.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QOpenGLDebugMessage.Severities" and flag class "QOpenGLDebugMessage.Severity" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QOpenGLDebugMessage.Severity +MultiFlagClass = QtGui.QOpenGLDebugMessage.Severities + +oneFlagRefValue1 = QtGui.QOpenGLDebugMessage.Severity.InvalidSeverity +oneFlagRefValue2 = QtGui.QOpenGLDebugMessage.Severity.HighSeverity +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 37f9a2d6ddc7efbfe37c9f36681836e2e9fc3371 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 15:05:33 +0200 Subject: [PATCH 115/421] QFlag operations for QMetaType.TypeFlags, QMetaType.TypeFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../qflags/test_QtCore_TypeFlags_TypeFlag.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_TypeFlags_TypeFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 6126d6af..87bcfdd9 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -9068,6 +9068,9 @@ class QMetaClassInfo(sip.simplewrapper): class QMetaType(sip.simplewrapper): class TypeFlag(int): + def __or__ (self, other: 'QMetaType.TypeFlag') -> 'QMetaType.TypeFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QMetaType.TypeFlags': ... # type: ignore[override, misc] + NeedsConstruction = ... # type: QMetaType.TypeFlag NeedsDestruction = ... # type: QMetaType.TypeFlag MovableType = ... # type: QMetaType.TypeFlag @@ -9257,12 +9260,20 @@ class QMetaType(sip.simplewrapper): def __init__(self, f: typing.Union['QMetaType.TypeFlags', 'QMetaType.TypeFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QMetaType.TypeFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QMetaType.TypeFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QMetaType.TypeFlags', 'QMetaType.TypeFlag', int]) -> 'QMetaType.TypeFlags': ... + def __and__(self, other: typing.Union['QMetaType.TypeFlags', 'QMetaType.TypeFlag', int]) -> 'QMetaType.TypeFlags': ... + def __xor__(self, other: typing.Union['QMetaType.TypeFlags', 'QMetaType.TypeFlag', int]) -> 'QMetaType.TypeFlags': ... + def __ror__ (self, other: 'QMetaType.TypeFlag') -> 'QMetaType.TypeFlags': ... + def __rand__(self, other: 'QMetaType.TypeFlag') -> 'QMetaType.TypeFlags': ... + def __rxor__(self, other: 'QMetaType.TypeFlag') -> 'QMetaType.TypeFlags': ... def __init__(self, type: int = ...) -> None: ... diff --git a/tests/qflags/test_QtCore_TypeFlags_TypeFlag.py b/tests/qflags/test_QtCore_TypeFlags_TypeFlag.py new file mode 100644 index 00000000..52573b2b --- /dev/null +++ b/tests/qflags/test_QtCore_TypeFlags_TypeFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QMetaType.TypeFlags" and flag class "QMetaType.TypeFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QMetaType.TypeFlag +MultiFlagClass = QtCore.QMetaType.TypeFlags + +oneFlagRefValue1 = QtCore.QMetaType.TypeFlag.NeedsConstruction +oneFlagRefValue2 = QtCore.QMetaType.TypeFlag.NeedsDestruction +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 37c93a09e7b8149ea1c05db2f7d5a520a95d24cf Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 15:06:23 +0200 Subject: [PATCH 116/421] QFlag operations for QStandardPaths.LocateOptions, QStandardPaths.LocateOption in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_LocateOptions_LocateOption.py | 231 ++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_LocateOptions_LocateOption.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 87bcfdd9..f2894593 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -10831,6 +10831,9 @@ class QSortFilterProxyModel(QAbstractProxyModel): class QStandardPaths(sip.simplewrapper): class LocateOption(int): + def __or__ (self, other: 'QStandardPaths.LocateOption') -> 'QStandardPaths.LocateOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QStandardPaths.LocateOptions': ... # type: ignore[override, misc] + LocateFile = ... # type: QStandardPaths.LocateOption LocateDirectory = ... # type: QStandardPaths.LocateOption @@ -10888,12 +10891,20 @@ class QStandardPaths(sip.simplewrapper): def __init__(self, f: typing.Union['QStandardPaths.LocateOptions', 'QStandardPaths.LocateOption']) -> None: ... @typing.overload def __init__(self, a0: 'QStandardPaths.LocateOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QStandardPaths.LocateOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QStandardPaths.LocateOptions', 'QStandardPaths.LocateOption', int]) -> 'QStandardPaths.LocateOptions': ... + def __and__(self, other: typing.Union['QStandardPaths.LocateOptions', 'QStandardPaths.LocateOption', int]) -> 'QStandardPaths.LocateOptions': ... + def __xor__(self, other: typing.Union['QStandardPaths.LocateOptions', 'QStandardPaths.LocateOption', int]) -> 'QStandardPaths.LocateOptions': ... + def __ror__ (self, other: 'QStandardPaths.LocateOption') -> 'QStandardPaths.LocateOptions': ... + def __rand__(self, other: 'QStandardPaths.LocateOption') -> 'QStandardPaths.LocateOptions': ... + def __rxor__(self, other: 'QStandardPaths.LocateOption') -> 'QStandardPaths.LocateOptions': ... def __init__(self, a0: 'QStandardPaths') -> None: ... diff --git a/tests/qflags/test_QtCore_LocateOptions_LocateOption.py b/tests/qflags/test_QtCore_LocateOptions_LocateOption.py new file mode 100644 index 00000000..310379f8 --- /dev/null +++ b/tests/qflags/test_QtCore_LocateOptions_LocateOption.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QStandardPaths.LocateOptions" and flag class "QStandardPaths.LocateOption" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QStandardPaths.LocateOption +MultiFlagClass = QtCore.QStandardPaths.LocateOptions + +oneFlagRefValue1 = QtCore.QStandardPaths.LocateOption.LocateFile +oneFlagRefValue2 = QtCore.QStandardPaths.LocateOption.LocateDirectory +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 29cb7294d4345c8de3354a5e58a2d61a6135ffac Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 17:36:50 +0200 Subject: [PATCH 117/421] QFlag operations for QTextOption.Flags, QTextOption.Flag in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 ++ tests/qflags/test_QtGui_Flags_Flag.py | 231 ++++++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtGui_Flags_Flag.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 68a8f498..b487f21c 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -10074,6 +10074,9 @@ class QTextOption(sip.simplewrapper): DelimiterTab = ... # type: QTextOption.TabType class Flag(int): + def __or__ (self, other: 'QTextOption.Flag') -> 'QTextOption.Flags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QTextOption.Flags': ... # type: ignore[override, misc] + IncludeTrailingSpaces = ... # type: QTextOption.Flag ShowTabsAndSpaces = ... # type: QTextOption.Flag ShowLineAndParagraphSeparators = ... # type: QTextOption.Flag @@ -10109,12 +10112,20 @@ class QTextOption(sip.simplewrapper): def __init__(self, f: typing.Union['QTextOption.Flags', 'QTextOption.Flag']) -> None: ... @typing.overload def __init__(self, a0: 'QTextOption.Flags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTextOption.Flags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTextOption.Flags', 'QTextOption.Flag', int]) -> 'QTextOption.Flags': ... + def __and__(self, other: typing.Union['QTextOption.Flags', 'QTextOption.Flag', int]) -> 'QTextOption.Flags': ... + def __xor__(self, other: typing.Union['QTextOption.Flags', 'QTextOption.Flag', int]) -> 'QTextOption.Flags': ... + def __ror__ (self, other: 'QTextOption.Flag') -> 'QTextOption.Flags': ... + def __rand__(self, other: 'QTextOption.Flag') -> 'QTextOption.Flags': ... + def __rxor__(self, other: 'QTextOption.Flag') -> 'QTextOption.Flags': ... class Tab(sip.simplewrapper): diff --git a/tests/qflags/test_QtGui_Flags_Flag.py b/tests/qflags/test_QtGui_Flags_Flag.py new file mode 100644 index 00000000..96d514fc --- /dev/null +++ b/tests/qflags/test_QtGui_Flags_Flag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTextOption.Flags" and flag class "QTextOption.Flag" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QTextOption.Flag +MultiFlagClass = QtGui.QTextOption.Flags + +oneFlagRefValue1 = QtGui.QTextOption.Flag.IncludeTrailingSpaces +oneFlagRefValue2 = QtGui.QTextOption.Flag.ShowTabsAndSpaces +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From ecd2f81b095407c91e54fc2c5ffb324dcbfdd21a Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 17:40:17 +0200 Subject: [PATCH 118/421] Store error on multiple lines for more readability --- tests/qflags/generate_qflags_stubs_and_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 787d7a96..19ec30de 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -354,7 +354,7 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: if gen_result == QFlagGenResult.ErrorDuringProcessing: log_progress('Error during processing of QFlag %s %s' % (flag_info.qflag_class, flag_info.enum_class)) - flag_info_dict['error'] = flag_info_dict.get('error', '') + error_msg + flag_info_dict['error'] = error_msg.splitlines() result_json['qflag_process_error'].append(flag_info_dict) # save our processing result @@ -362,6 +362,7 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: json.dump(result_json, f, indent=4) # return True to indicate that more flags may be processed + log_progress('.') return True From 21f2ea10af9b65a42f7b50e8f03fafd671c604b4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 17:35:29 +0200 Subject: [PATCH 119/421] QFlag operations for QCommandLineOption.Flags, QCommandLineOption.Flag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 ++ tests/qflags/test_QtCore_Flags_Flag.py | 231 +++++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 tests/qflags/test_QtCore_Flags_Flag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index f2894593..8104d0c1 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -4388,6 +4388,9 @@ class QCollator(sip.simplewrapper): class QCommandLineOption(sip.simplewrapper): class Flag(int): + def __or__ (self, other: 'QCommandLineOption.Flag') -> 'QCommandLineOption.Flags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QCommandLineOption.Flags': ... # type: ignore[override, misc] + HiddenFromHelp = ... # type: QCommandLineOption.Flag ShortOptionStyle = ... # type: QCommandLineOption.Flag @@ -4402,12 +4405,20 @@ class QCommandLineOption(sip.simplewrapper): def __init__(self, f: typing.Union['QCommandLineOption.Flags', 'QCommandLineOption.Flag']) -> None: ... @typing.overload def __init__(self, a0: 'QCommandLineOption.Flags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QCommandLineOption.Flags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QCommandLineOption.Flags', 'QCommandLineOption.Flag', int]) -> 'QCommandLineOption.Flags': ... + def __and__(self, other: typing.Union['QCommandLineOption.Flags', 'QCommandLineOption.Flag', int]) -> 'QCommandLineOption.Flags': ... + def __xor__(self, other: typing.Union['QCommandLineOption.Flags', 'QCommandLineOption.Flag', int]) -> 'QCommandLineOption.Flags': ... + def __ror__ (self, other: 'QCommandLineOption.Flag') -> 'QCommandLineOption.Flags': ... + def __rand__(self, other: 'QCommandLineOption.Flag') -> 'QCommandLineOption.Flags': ... + def __rxor__(self, other: 'QCommandLineOption.Flag') -> 'QCommandLineOption.Flags': ... @typing.overload def __init__(self, name: str) -> None: ... diff --git a/tests/qflags/test_QtCore_Flags_Flag.py b/tests/qflags/test_QtCore_Flags_Flag.py new file mode 100644 index 00000000..97eed5a2 --- /dev/null +++ b/tests/qflags/test_QtCore_Flags_Flag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QCommandLineOption.Flags" and flag class "QCommandLineOption.Flag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QCommandLineOption.Flag +MultiFlagClass = QtCore.QCommandLineOption.Flags + +oneFlagRefValue1 = QtCore.QCommandLineOption.Flag.HiddenFromHelp +oneFlagRefValue2 = QtCore.QCommandLineOption.Flag.ShortOptionStyle +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From b5a66c96bfb8d8d797282b5ca03b281c316128f6 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 17:53:28 +0200 Subject: [PATCH 120/421] Fix QIODevice.OpenMode / OpenModeFlags --- PyQt5-stubs/QtCore.pyi | 19 +- .../test_QtCore_OpenMode_OpenModeFlag.py | 231 ++++++++++++++++++ 2 files changed, 241 insertions(+), 9 deletions(-) create mode 100644 tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 8104d0c1..615a0b1d 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -3773,6 +3773,9 @@ class QBitArray(sip.simplewrapper): class QIODevice(QObject): class OpenModeFlag(int): + def __or__ (self, other: 'QIODevice.OpenModeFlag') -> 'QIODevice.OpenMode': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QIODevice.OpenMode': ... # type: ignore[override, misc] + NotOpen = ... # type: QIODevice.OpenModeFlag ReadOnly = ... # type: QIODevice.OpenModeFlag WriteOnly = ... # type: QIODevice.OpenModeFlag @@ -3784,8 +3787,6 @@ class QIODevice(QObject): NewOnly = ... # type: QIODevice.OpenModeFlag ExistingOnly = ... # type: QIODevice.OpenModeFlag - def __or__(self, other: typing.Union['QIODevice.OpenModeFlag', 'QIODevice.OpenMode']) -> 'QIODevice.OpenModeFlag': ... #type: ignore[override] - NotOpen = ... # type: QIODevice.OpenModeFlag ReadOnly = ... # type: QIODevice.OpenModeFlag WriteOnly = ... # type: QIODevice.OpenModeFlag @@ -3804,19 +3805,19 @@ class QIODevice(QObject): @typing.overload def __init__(self, f: typing.Union['QIODevice.OpenMode', 'QIODevice.OpenModeFlag']) -> None: ... @typing.overload - def __init__(self, a0: 'QIODevice.OpenMode') -> None: ... + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QIODevice.OpenMode': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - def __and__(self, other: typing.Union['QIODevice.OpenMode', 'QIODevice.OpenModeFlag']) -> 'QIODevice.OpenMode': ... - def __iand__(self, other: typing.Union['QIODevice.OpenMode', 'QIODevice.OpenModeFlag']) -> 'QIODevice.OpenMode': ... - def __or__(self, other: typing.Union['QIODevice.OpenMode', 'QIODevice.OpenModeFlag']) -> 'QIODevice.OpenMode': ... - def __ior__(self, other: typing.Union['QIODevice.OpenMode', 'QIODevice.OpenModeFlag']) -> 'QIODevice.OpenMode': ... - def __xor__(self, other: typing.Union['QIODevice.OpenMode', 'QIODevice.OpenModeFlag']) -> 'QIODevice.OpenMode': ... - def __ixor__(self, other: typing.Union['QIODevice.OpenMode', 'QIODevice.OpenModeFlag']) -> 'QIODevice.OpenMode': ... + def __or__ (self, other: typing.Union['QIODevice.OpenMode', 'QIODevice.OpenModeFlag', int]) -> 'QIODevice.OpenMode': ... + def __and__(self, other: typing.Union['QIODevice.OpenMode', 'QIODevice.OpenModeFlag', int]) -> 'QIODevice.OpenMode': ... + def __xor__(self, other: typing.Union['QIODevice.OpenMode', 'QIODevice.OpenModeFlag', int]) -> 'QIODevice.OpenMode': ... + def __ror__ (self, other: 'QIODevice.OpenModeFlag') -> 'QIODevice.OpenMode': ... + def __rand__(self, other: 'QIODevice.OpenModeFlag') -> 'QIODevice.OpenMode': ... + def __rxor__(self, other: 'QIODevice.OpenModeFlag') -> 'QIODevice.OpenMode': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py b/tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py new file mode 100644 index 00000000..54d55e14 --- /dev/null +++ b/tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py @@ -0,0 +1,231 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QIODevice.OpenMode" and flag class "QIODevice.OpenModeFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QIODevice.OpenModeFlag +MultiFlagClass = QtCore.QIODevice.OpenMode + +oneFlagRefValue1 = QtCore.QIODevice.OpenModeFlag.NotOpen +oneFlagRefValue2 = QtCore.QIODevice.OpenModeFlag.ReadOnly +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From c46f7bcec21d7b3f4c7efa559afb7c16b93ee0fe Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 18:49:31 +0200 Subject: [PATCH 121/421] QFlag operations for QHstsPolicy.PolicyFlags, QHstsPolicy.PolicyFlag in module QtNetwork --- PyQt5-stubs/QtNetwork.pyi | 11 + .../test_QtNetwork_PolicyFlags_PolicyFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 4acd10cb..68f3c54f 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -611,6 +611,9 @@ class QHostInfo(sip.simplewrapper): class QHstsPolicy(sip.simplewrapper): class PolicyFlag(int): + def __or__ (self, other: 'QHstsPolicy.PolicyFlag') -> 'QHstsPolicy.PolicyFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QHstsPolicy.PolicyFlags': ... # type: ignore[override, misc] + IncludeSubDomains = ... # type: QHstsPolicy.PolicyFlag IncludeSubDomains = ... # type: QHstsPolicy.PolicyFlag @@ -623,12 +626,20 @@ class QHstsPolicy(sip.simplewrapper): def __init__(self, f: typing.Union['QHstsPolicy.PolicyFlags', 'QHstsPolicy.PolicyFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QHstsPolicy.PolicyFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QHstsPolicy.PolicyFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QHstsPolicy.PolicyFlags', 'QHstsPolicy.PolicyFlag', int]) -> 'QHstsPolicy.PolicyFlags': ... + def __and__(self, other: typing.Union['QHstsPolicy.PolicyFlags', 'QHstsPolicy.PolicyFlag', int]) -> 'QHstsPolicy.PolicyFlags': ... + def __xor__(self, other: typing.Union['QHstsPolicy.PolicyFlags', 'QHstsPolicy.PolicyFlag', int]) -> 'QHstsPolicy.PolicyFlags': ... + def __ror__ (self, other: 'QHstsPolicy.PolicyFlag') -> 'QHstsPolicy.PolicyFlags': ... + def __rand__(self, other: 'QHstsPolicy.PolicyFlag') -> 'QHstsPolicy.PolicyFlags': ... + def __rxor__(self, other: 'QHstsPolicy.PolicyFlag') -> 'QHstsPolicy.PolicyFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py b/tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py new file mode 100644 index 00000000..23cebe88 --- /dev/null +++ b/tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QHstsPolicy.PolicyFlags" and flag class "QHstsPolicy.PolicyFlag" +from PyQt5 import QtNetwork + +OneFlagClass = QtNetwork.QHstsPolicy.PolicyFlag +MultiFlagClass = QtNetwork.QHstsPolicy.PolicyFlags + +oneFlagRefValue1 = QtNetwork.QHstsPolicy.PolicyFlag.IncludeSubDomains +oneFlagRefValue2 = QtNetwork.QHstsPolicy.PolicyFlag.IncludeSubDomains + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From eaec5a36b79b01989762d1a25dc86697da0d6772 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 18:50:32 +0200 Subject: [PATCH 122/421] Prepare for variations of OR support between QFlags --- .../qflags/generate_qflags_stubs_and_tests.py | 4 +++ tests/qflags/qflags_test_template.py | 30 +++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 19ec30de..b31433c7 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -837,6 +837,10 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: oneFlagRefValue1 = {qtmodule}.{oneFlagName}.{oneFlagValue1} oneFlagRefValue2 = {qtmodule}.{oneFlagName}.{oneFlagValue2} + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True '''.format(source=TEMPLATE_QFLAGS_TESTS, multiFlagName=flag_info.qflag_full_class_name, oneFlagName=flag_info.enum_full_class_name, diff --git a/tests/qflags/qflags_test_template.py b/tests/qflags/qflags_test_template.py index 78185e21..322d358f 100644 --- a/tests/qflags/qflags_test_template.py +++ b/tests/qflags/qflags_test_template.py @@ -11,6 +11,10 @@ oneFlagRefValue1 = QtCore.Qt.WindowContextHelpButtonHint oneFlagRefValue2 = QtCore.Qt.WindowMaximizeButtonHint + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True ### End of specific part T = TypeVar('T') @@ -52,20 +56,30 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value(int, ~oneFlagValue1) assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) assert_type_of_value(int, oneFlagValue1 & 33) assert_type_of_value(int, oneFlagValue1 ^ 33) assert_type_of_value(int, oneFlagValue1 + 33) assert_type_of_value(int, oneFlagValue1 - 33) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) assert_type_of_value(int, 33 & oneFlagValue1) assert_type_of_value(int, 33 ^ oneFlagValue1) assert_type_of_value(int, 33 + oneFlagValue1) @@ -74,12 +88,18 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value(OneFlagClass, oneFlagOrIntValue) oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value(OneFlagClass, oneFlagOrIntValue) From 46a090d986dc4fbe8bf99a1fd2efcee3eaef0c52 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 18:52:27 +0200 Subject: [PATCH 123/421] QFlag operations for QColorDialog.ColorDialogOptions, QColorDialog.ColorDialogOption in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...ts_ColorDialogOptions_ColorDialogOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 2542bd7f..f988cb37 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -1685,6 +1685,9 @@ class QDialog(QWidget): class QColorDialog(QDialog): class ColorDialogOption(int): + def __or__ (self, other: 'QColorDialog.ColorDialogOption') -> 'QColorDialog.ColorDialogOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QColorDialog.ColorDialogOptions': ... # type: ignore[override, misc] + ShowAlphaChannel = ... # type: QColorDialog.ColorDialogOption NoButtons = ... # type: QColorDialog.ColorDialogOption DontUseNativeDialog = ... # type: QColorDialog.ColorDialogOption @@ -1701,12 +1704,20 @@ class QColorDialog(QDialog): def __init__(self, f: typing.Union['QColorDialog.ColorDialogOptions', 'QColorDialog.ColorDialogOption']) -> None: ... @typing.overload def __init__(self, a0: 'QColorDialog.ColorDialogOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QColorDialog.ColorDialogOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QColorDialog.ColorDialogOptions', 'QColorDialog.ColorDialogOption', int]) -> 'QColorDialog.ColorDialogOptions': ... + def __and__(self, other: typing.Union['QColorDialog.ColorDialogOptions', 'QColorDialog.ColorDialogOption', int]) -> 'QColorDialog.ColorDialogOptions': ... + def __xor__(self, other: typing.Union['QColorDialog.ColorDialogOptions', 'QColorDialog.ColorDialogOption', int]) -> 'QColorDialog.ColorDialogOptions': ... + def __ror__ (self, other: 'QColorDialog.ColorDialogOption') -> 'QColorDialog.ColorDialogOptions': ... + def __rand__(self, other: 'QColorDialog.ColorDialogOption') -> 'QColorDialog.ColorDialogOptions': ... + def __rxor__(self, other: 'QColorDialog.ColorDialogOption') -> 'QColorDialog.ColorDialogOptions': ... @typing.overload def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py b/tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py new file mode 100644 index 00000000..31c1d510 --- /dev/null +++ b/tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QColorDialog.ColorDialogOptions" and flag class "QColorDialog.ColorDialogOption" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QColorDialog.ColorDialogOption +MultiFlagClass = QtWidgets.QColorDialog.ColorDialogOptions + +oneFlagRefValue1 = QtWidgets.QColorDialog.ColorDialogOption.ShowAlphaChannel +oneFlagRefValue2 = QtWidgets.QColorDialog.ColorDialogOption.NoButtons + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a73523111c32505eea17704014ed328ea9aadd0a Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 18:54:07 +0200 Subject: [PATCH 124/421] QFlag operations for QFontDialog.FontDialogOptions, QFontDialog.FontDialogOption in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...gets_FontDialogOptions_FontDialogOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index f988cb37..03de9093 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -4177,6 +4177,9 @@ class QFontComboBox(QComboBox): class QFontDialog(QDialog): class FontDialogOption(int): + def __or__ (self, other: 'QFontDialog.FontDialogOption') -> 'QFontDialog.FontDialogOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QFontDialog.FontDialogOptions': ... # type: ignore[override, misc] + NoButtons = ... # type: QFontDialog.FontDialogOption DontUseNativeDialog = ... # type: QFontDialog.FontDialogOption ScalableFonts = ... # type: QFontDialog.FontDialogOption @@ -4199,12 +4202,20 @@ class QFontDialog(QDialog): def __init__(self, f: typing.Union['QFontDialog.FontDialogOptions', 'QFontDialog.FontDialogOption']) -> None: ... @typing.overload def __init__(self, a0: 'QFontDialog.FontDialogOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QFontDialog.FontDialogOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QFontDialog.FontDialogOptions', 'QFontDialog.FontDialogOption', int]) -> 'QFontDialog.FontDialogOptions': ... + def __and__(self, other: typing.Union['QFontDialog.FontDialogOptions', 'QFontDialog.FontDialogOption', int]) -> 'QFontDialog.FontDialogOptions': ... + def __xor__(self, other: typing.Union['QFontDialog.FontDialogOptions', 'QFontDialog.FontDialogOption', int]) -> 'QFontDialog.FontDialogOptions': ... + def __ror__ (self, other: 'QFontDialog.FontDialogOption') -> 'QFontDialog.FontDialogOptions': ... + def __rand__(self, other: 'QFontDialog.FontDialogOption') -> 'QFontDialog.FontDialogOptions': ... + def __rxor__(self, other: 'QFontDialog.FontDialogOption') -> 'QFontDialog.FontDialogOptions': ... @typing.overload def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py b/tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py new file mode 100644 index 00000000..9149125d --- /dev/null +++ b/tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QFontDialog.FontDialogOptions" and flag class "QFontDialog.FontDialogOption" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QFontDialog.FontDialogOption +MultiFlagClass = QtWidgets.QFontDialog.FontDialogOptions + +oneFlagRefValue1 = QtWidgets.QFontDialog.FontDialogOption.NoButtons +oneFlagRefValue2 = QtWidgets.QFontDialog.FontDialogOption.DontUseNativeDialog + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 7b71654e2f13f8bc0847b1d38e558d5f3d1c7010 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 8 Sep 2021 18:55:36 +0200 Subject: [PATCH 125/421] QFlag operations for QUrl.ComponentFormattingOptions, QUrl.ComponentFormattingOption in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...attingOptions_ComponentFormattingOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 615a0b1d..fde1a6dd 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -11816,6 +11816,9 @@ class QUrl(sip.simplewrapper): AssumeLocalFile = ... # type: QUrl.UserInputResolutionOption class ComponentFormattingOption(int): + def __or__ (self, other: 'QUrl.ComponentFormattingOption') -> 'QUrl.ComponentFormattingOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QUrl.ComponentFormattingOptions': ... # type: ignore[override, misc] + PrettyDecoded = ... # type: QUrl.ComponentFormattingOption EncodeSpaces = ... # type: QUrl.ComponentFormattingOption EncodeUnicode = ... # type: QUrl.ComponentFormattingOption @@ -11885,12 +11888,20 @@ class QUrl(sip.simplewrapper): def __init__(self, f: typing.Union['QUrl.ComponentFormattingOptions', 'QUrl.ComponentFormattingOption']) -> None: ... @typing.overload def __init__(self, a0: 'QUrl.ComponentFormattingOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QUrl.ComponentFormattingOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QUrl.ComponentFormattingOptions', 'QUrl.ComponentFormattingOption', int]) -> 'QUrl.ComponentFormattingOptions': ... + def __and__(self, other: typing.Union['QUrl.ComponentFormattingOptions', 'QUrl.ComponentFormattingOption', int]) -> 'QUrl.ComponentFormattingOptions': ... + def __xor__(self, other: typing.Union['QUrl.ComponentFormattingOptions', 'QUrl.ComponentFormattingOption', int]) -> 'QUrl.ComponentFormattingOptions': ... + def __ror__ (self, other: 'QUrl.ComponentFormattingOption') -> 'QUrl.ComponentFormattingOptions': ... + def __rand__(self, other: 'QUrl.ComponentFormattingOption') -> 'QUrl.ComponentFormattingOptions': ... + def __rxor__(self, other: 'QUrl.ComponentFormattingOption') -> 'QUrl.ComponentFormattingOptions': ... class UserInputResolutionOptions(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py b/tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py new file mode 100644 index 00000000..ffe3154e --- /dev/null +++ b/tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QUrl.ComponentFormattingOptions" and flag class "QUrl.ComponentFormattingOption" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QUrl.ComponentFormattingOption +MultiFlagClass = QtCore.QUrl.ComponentFormattingOptions + +oneFlagRefValue1 = QtCore.QUrl.ComponentFormattingOption.PrettyDecoded +oneFlagRefValue2 = QtCore.QUrl.ComponentFormattingOption.EncodeSpaces + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 8e093a7bcee3df7fcd76679072dde4f505da3397 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:40:32 +0200 Subject: [PATCH 126/421] QFlag operations for QWidget.RenderFlags, QWidget.RenderFlag in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../test_QtWidgets_RenderFlags_RenderFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 03de9093..d99d4c31 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -43,6 +43,9 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], class QWidget(QtCore.QObject, QtGui.QPaintDevice): class RenderFlag(int): + def __or__ (self, other: 'QWidget.RenderFlag') -> 'QWidget.RenderFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QWidget.RenderFlags': ... # type: ignore[override, misc] + DrawWindowBackground = ... # type: QWidget.RenderFlag DrawChildren = ... # type: QWidget.RenderFlag IgnoreMask = ... # type: QWidget.RenderFlag @@ -59,12 +62,20 @@ class QWidget(QtCore.QObject, QtGui.QPaintDevice): def __init__(self, f: typing.Union['QWidget.RenderFlags', 'QWidget.RenderFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QWidget.RenderFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QWidget.RenderFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QWidget.RenderFlags', 'QWidget.RenderFlag', int]) -> 'QWidget.RenderFlags': ... + def __and__(self, other: typing.Union['QWidget.RenderFlags', 'QWidget.RenderFlag', int]) -> 'QWidget.RenderFlags': ... + def __xor__(self, other: typing.Union['QWidget.RenderFlags', 'QWidget.RenderFlag', int]) -> 'QWidget.RenderFlags': ... + def __ror__ (self, other: 'QWidget.RenderFlag') -> 'QWidget.RenderFlags': ... + def __rand__(self, other: 'QWidget.RenderFlag') -> 'QWidget.RenderFlags': ... + def __rxor__(self, other: 'QWidget.RenderFlag') -> 'QWidget.RenderFlags': ... def __init__(self, parent: typing.Optional['QWidget'] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py b/tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py new file mode 100644 index 00000000..fe3240d6 --- /dev/null +++ b/tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QWidget.RenderFlags" and flag class "QWidget.RenderFlag" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QWidget.RenderFlag +MultiFlagClass = QtWidgets.QWidget.RenderFlags + +oneFlagRefValue1 = QtWidgets.QWidget.RenderFlag.DrawWindowBackground +oneFlagRefValue2 = QtWidgets.QWidget.RenderFlag.DrawChildren + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 0638e70a4a683e1fce7d0d30a1fbbef6d202abfc Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:41:25 +0200 Subject: [PATCH 127/421] QFlag operations for QTextItem.RenderFlags, QTextItem.RenderFlag in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + .../test_QtGui_RenderFlags_RenderFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtGui_RenderFlags_RenderFlag.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index b487f21c..0dc1c883 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -6820,6 +6820,9 @@ class QPainter(sip.simplewrapper): class QTextItem(sip.simplewrapper): class RenderFlag(int): + def __or__ (self, other: 'QTextItem.RenderFlag') -> 'QTextItem.RenderFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QTextItem.RenderFlags': ... # type: ignore[override, misc] + RightToLeft = ... # type: QTextItem.RenderFlag Overline = ... # type: QTextItem.RenderFlag Underline = ... # type: QTextItem.RenderFlag @@ -6838,12 +6841,20 @@ class QTextItem(sip.simplewrapper): def __init__(self, f: typing.Union['QTextItem.RenderFlags', 'QTextItem.RenderFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QTextItem.RenderFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTextItem.RenderFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTextItem.RenderFlags', 'QTextItem.RenderFlag', int]) -> 'QTextItem.RenderFlags': ... + def __and__(self, other: typing.Union['QTextItem.RenderFlags', 'QTextItem.RenderFlag', int]) -> 'QTextItem.RenderFlags': ... + def __xor__(self, other: typing.Union['QTextItem.RenderFlags', 'QTextItem.RenderFlag', int]) -> 'QTextItem.RenderFlags': ... + def __ror__ (self, other: 'QTextItem.RenderFlag') -> 'QTextItem.RenderFlags': ... + def __rand__(self, other: 'QTextItem.RenderFlag') -> 'QTextItem.RenderFlags': ... + def __rxor__(self, other: 'QTextItem.RenderFlag') -> 'QTextItem.RenderFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtGui_RenderFlags_RenderFlag.py b/tests/qflags/test_QtGui_RenderFlags_RenderFlag.py new file mode 100644 index 00000000..6fb081c9 --- /dev/null +++ b/tests/qflags/test_QtGui_RenderFlags_RenderFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTextItem.RenderFlags" and flag class "QTextItem.RenderFlag" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QTextItem.RenderFlag +MultiFlagClass = QtGui.QTextItem.RenderFlags + +oneFlagRefValue1 = QtGui.QTextItem.RenderFlag.RightToLeft +oneFlagRefValue2 = QtGui.QTextItem.RenderFlag.Overline + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From d095a6bac0600726d5ac4e500a996d57080cccd3 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:42:17 +0200 Subject: [PATCH 128/421] QFlag operations for QPaintEngine.PaintEngineFeatures, QPaintEngine.PaintEngineFeature in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + ..._PaintEngineFeatures_PaintEngineFeature.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 0dc1c883..40936a4f 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -6957,6 +6957,9 @@ class QPaintEngine(sip.simplewrapper): AllDirty = ... # type: QPaintEngine.DirtyFlag class PaintEngineFeature(int): + def __or__ (self, other: 'QPaintEngine.PaintEngineFeature') -> 'QPaintEngine.PaintEngineFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QPaintEngine.PaintEngineFeatures': ... # type: ignore[override, misc] + PrimitiveTransform = ... # type: QPaintEngine.PaintEngineFeature PatternTransform = ... # type: QPaintEngine.PaintEngineFeature PixmapTransform = ... # type: QPaintEngine.PaintEngineFeature @@ -7007,12 +7010,20 @@ class QPaintEngine(sip.simplewrapper): def __init__(self, f: typing.Union['QPaintEngine.PaintEngineFeatures', 'QPaintEngine.PaintEngineFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QPaintEngine.PaintEngineFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QPaintEngine.PaintEngineFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QPaintEngine.PaintEngineFeatures', 'QPaintEngine.PaintEngineFeature', int]) -> 'QPaintEngine.PaintEngineFeatures': ... + def __and__(self, other: typing.Union['QPaintEngine.PaintEngineFeatures', 'QPaintEngine.PaintEngineFeature', int]) -> 'QPaintEngine.PaintEngineFeatures': ... + def __xor__(self, other: typing.Union['QPaintEngine.PaintEngineFeatures', 'QPaintEngine.PaintEngineFeature', int]) -> 'QPaintEngine.PaintEngineFeatures': ... + def __ror__ (self, other: 'QPaintEngine.PaintEngineFeature') -> 'QPaintEngine.PaintEngineFeatures': ... + def __rand__(self, other: 'QPaintEngine.PaintEngineFeature') -> 'QPaintEngine.PaintEngineFeatures': ... + def __rxor__(self, other: 'QPaintEngine.PaintEngineFeature') -> 'QPaintEngine.PaintEngineFeatures': ... class DirtyFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py b/tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py new file mode 100644 index 00000000..fda44e58 --- /dev/null +++ b/tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QPaintEngine.PaintEngineFeatures" and flag class "QPaintEngine.PaintEngineFeature" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QPaintEngine.PaintEngineFeature +MultiFlagClass = QtGui.QPaintEngine.PaintEngineFeatures + +oneFlagRefValue1 = QtGui.QPaintEngine.PaintEngineFeature.PrimitiveTransform +oneFlagRefValue2 = QtGui.QPaintEngine.PaintEngineFeature.PatternTransform + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 98e9a219097ff0a453f458f229bab7c9c493e016 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:43:52 +0200 Subject: [PATCH 129/421] QFlag operations for QTouchDevice.Capabilities, QTouchDevice.CapabilityFlag in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + .../test_QtGui_Capabilities_CapabilityFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 40936a4f..34162e5a 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -10241,6 +10241,9 @@ class QTextTable(QTextFrame): class QTouchDevice(sip.simplewrapper): class CapabilityFlag(int): + def __or__ (self, other: 'QTouchDevice.CapabilityFlag') -> 'QTouchDevice.Capabilities': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QTouchDevice.Capabilities': ... # type: ignore[override, misc] + Position = ... # type: QTouchDevice.CapabilityFlag Area = ... # type: QTouchDevice.CapabilityFlag Pressure = ... # type: QTouchDevice.CapabilityFlag @@ -10272,12 +10275,20 @@ class QTouchDevice(sip.simplewrapper): def __init__(self, f: typing.Union['QTouchDevice.Capabilities', 'QTouchDevice.CapabilityFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QTouchDevice.Capabilities') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTouchDevice.Capabilities': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTouchDevice.Capabilities', 'QTouchDevice.CapabilityFlag', int]) -> 'QTouchDevice.Capabilities': ... + def __and__(self, other: typing.Union['QTouchDevice.Capabilities', 'QTouchDevice.CapabilityFlag', int]) -> 'QTouchDevice.Capabilities': ... + def __xor__(self, other: typing.Union['QTouchDevice.Capabilities', 'QTouchDevice.CapabilityFlag', int]) -> 'QTouchDevice.Capabilities': ... + def __ror__ (self, other: 'QTouchDevice.CapabilityFlag') -> 'QTouchDevice.Capabilities': ... + def __rand__(self, other: 'QTouchDevice.CapabilityFlag') -> 'QTouchDevice.Capabilities': ... + def __rxor__(self, other: 'QTouchDevice.CapabilityFlag') -> 'QTouchDevice.Capabilities': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py b/tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py new file mode 100644 index 00000000..bc5edf51 --- /dev/null +++ b/tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTouchDevice.Capabilities" and flag class "QTouchDevice.CapabilityFlag" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QTouchDevice.CapabilityFlag +MultiFlagClass = QtGui.QTouchDevice.Capabilities + +oneFlagRefValue1 = QtGui.QTouchDevice.CapabilityFlag.Position +oneFlagRefValue2 = QtGui.QTouchDevice.CapabilityFlag.Area + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 78e89b8ce59b908a64799c0ea9f0f6e75b50f64e Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:44:45 +0200 Subject: [PATCH 130/421] QFlag operations for QOpenGLTexture.Features, QOpenGLTexture.Feature in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + tests/qflags/test_QtGui_Features_Feature.py | 251 ++++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtGui_Features_Feature.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 34162e5a..25639b07 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -4674,6 +4674,9 @@ class QOpenGLTexture(sip.simplewrapper): SwizzleAlpha = ... # type: QOpenGLTexture.SwizzleComponent class Feature(int): + def __or__ (self, other: 'QOpenGLTexture.Feature') -> 'QOpenGLTexture.Features': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QOpenGLTexture.Features': ... # type: ignore[override, misc] + ImmutableStorage = ... # type: QOpenGLTexture.Feature ImmutableMultisampleStorage = ... # type: QOpenGLTexture.Feature TextureRectangle = ... # type: QOpenGLTexture.Feature @@ -5146,12 +5149,20 @@ class QOpenGLTexture(sip.simplewrapper): def __init__(self, f: typing.Union['QOpenGLTexture.Features', 'QOpenGLTexture.Feature']) -> None: ... @typing.overload def __init__(self, a0: 'QOpenGLTexture.Features') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QOpenGLTexture.Features': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QOpenGLTexture.Features', 'QOpenGLTexture.Feature', int]) -> 'QOpenGLTexture.Features': ... + def __and__(self, other: typing.Union['QOpenGLTexture.Features', 'QOpenGLTexture.Feature', int]) -> 'QOpenGLTexture.Features': ... + def __xor__(self, other: typing.Union['QOpenGLTexture.Features', 'QOpenGLTexture.Feature', int]) -> 'QOpenGLTexture.Features': ... + def __ror__ (self, other: 'QOpenGLTexture.Feature') -> 'QOpenGLTexture.Features': ... + def __rand__(self, other: 'QOpenGLTexture.Feature') -> 'QOpenGLTexture.Features': ... + def __rxor__(self, other: 'QOpenGLTexture.Feature') -> 'QOpenGLTexture.Features': ... @typing.overload def __init__(self, target: 'QOpenGLTexture.Target') -> None: ... diff --git a/tests/qflags/test_QtGui_Features_Feature.py b/tests/qflags/test_QtGui_Features_Feature.py new file mode 100644 index 00000000..4ed2f19b --- /dev/null +++ b/tests/qflags/test_QtGui_Features_Feature.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QOpenGLTexture.Features" and flag class "QOpenGLTexture.Feature" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QOpenGLTexture.Feature +MultiFlagClass = QtGui.QOpenGLTexture.Features + +oneFlagRefValue1 = QtGui.QOpenGLTexture.Feature.ImmutableStorage +oneFlagRefValue2 = QtGui.QOpenGLTexture.Feature.ImmutableMultisampleStorage + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a1cb6bc987c1b9ed194dac5cb005ef3bc0882b99 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:45:48 +0200 Subject: [PATCH 131/421] QFlag operations for QPainter.RenderHints, QPainter.RenderHint in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + .../test_QtGui_RenderHints_RenderHint.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtGui_RenderHints_RenderHint.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 25639b07..6cf1db13 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -6430,6 +6430,9 @@ class QPainter(sip.simplewrapper): RasterOp_NotDestination = ... # type: QPainter.CompositionMode class RenderHint(int): + def __or__ (self, other: 'QPainter.RenderHint') -> 'QPainter.RenderHints': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QPainter.RenderHints': ... # type: ignore[override, misc] + Antialiasing = ... # type: QPainter.RenderHint TextAntialiasing = ... # type: QPainter.RenderHint SmoothPixmapTransform = ... # type: QPainter.RenderHint @@ -6454,12 +6457,20 @@ class QPainter(sip.simplewrapper): def __init__(self, f: typing.Union['QPainter.RenderHints', 'QPainter.RenderHint']) -> None: ... @typing.overload def __init__(self, a0: 'QPainter.RenderHints') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QPainter.RenderHints': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QPainter.RenderHints', 'QPainter.RenderHint', int]) -> 'QPainter.RenderHints': ... + def __and__(self, other: typing.Union['QPainter.RenderHints', 'QPainter.RenderHint', int]) -> 'QPainter.RenderHints': ... + def __xor__(self, other: typing.Union['QPainter.RenderHints', 'QPainter.RenderHint', int]) -> 'QPainter.RenderHints': ... + def __ror__ (self, other: 'QPainter.RenderHint') -> 'QPainter.RenderHints': ... + def __rand__(self, other: 'QPainter.RenderHint') -> 'QPainter.RenderHints': ... + def __rxor__(self, other: 'QPainter.RenderHint') -> 'QPainter.RenderHints': ... class PixmapFragment(sip.simplewrapper): diff --git a/tests/qflags/test_QtGui_RenderHints_RenderHint.py b/tests/qflags/test_QtGui_RenderHints_RenderHint.py new file mode 100644 index 00000000..5fac9393 --- /dev/null +++ b/tests/qflags/test_QtGui_RenderHints_RenderHint.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QPainter.RenderHints" and flag class "QPainter.RenderHint" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QPainter.RenderHint +MultiFlagClass = QtGui.QPainter.RenderHints + +oneFlagRefValue1 = QtGui.QPainter.RenderHint.Antialiasing +oneFlagRefValue2 = QtGui.QPainter.RenderHint.TextAntialiasing + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 75f7410f4738f5189a9d89f2e4e571dbe78148db Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:47:22 +0200 Subject: [PATCH 132/421] QFlag operations for QSizePolicy.ControlTypes, QSizePolicy.ControlType in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...test_QtWidgets_ControlTypes_ControlType.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_ControlTypes_ControlType.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index d99d4c31..03c1db2b 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -8425,6 +8425,9 @@ class QSizeGrip(QWidget): class QSizePolicy(sip.simplewrapper): class ControlType(int): + def __or__ (self, other: 'QSizePolicy.ControlType') -> 'QSizePolicy.ControlTypes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSizePolicy.ControlTypes': ... # type: ignore[override, misc] + DefaultType = ... # type: QSizePolicy.ControlType ButtonBox = ... # type: QSizePolicy.ControlType CheckBox = ... # type: QSizePolicy.ControlType @@ -8493,12 +8496,20 @@ class QSizePolicy(sip.simplewrapper): def __init__(self, f: typing.Union['QSizePolicy.ControlTypes', 'QSizePolicy.ControlType']) -> None: ... @typing.overload def __init__(self, a0: 'QSizePolicy.ControlTypes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSizePolicy.ControlTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSizePolicy.ControlTypes', 'QSizePolicy.ControlType', int]) -> 'QSizePolicy.ControlTypes': ... + def __and__(self, other: typing.Union['QSizePolicy.ControlTypes', 'QSizePolicy.ControlType', int]) -> 'QSizePolicy.ControlTypes': ... + def __xor__(self, other: typing.Union['QSizePolicy.ControlTypes', 'QSizePolicy.ControlType', int]) -> 'QSizePolicy.ControlTypes': ... + def __ror__ (self, other: 'QSizePolicy.ControlType') -> 'QSizePolicy.ControlTypes': ... + def __rand__(self, other: 'QSizePolicy.ControlType') -> 'QSizePolicy.ControlTypes': ... + def __rxor__(self, other: 'QSizePolicy.ControlType') -> 'QSizePolicy.ControlTypes': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtWidgets_ControlTypes_ControlType.py b/tests/qflags/test_QtWidgets_ControlTypes_ControlType.py new file mode 100644 index 00000000..94f8c184 --- /dev/null +++ b/tests/qflags/test_QtWidgets_ControlTypes_ControlType.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSizePolicy.ControlTypes" and flag class "QSizePolicy.ControlType" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QSizePolicy.ControlType +MultiFlagClass = QtWidgets.QSizePolicy.ControlTypes + +oneFlagRefValue1 = QtWidgets.QSizePolicy.ControlType.DefaultType +oneFlagRefValue2 = QtWidgets.QSizePolicy.ControlType.ButtonBox + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 868bf4b63b87de7b33f1169d4c51c330e7f7ca0f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:48:45 +0200 Subject: [PATCH 133/421] QFlag operations for QRawFont.LayoutFlags, QRawFont.LayoutFlag in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + .../test_QtGui_LayoutFlags_LayoutFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 6cf1db13..9c3b7a0e 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -7989,6 +7989,9 @@ class QRasterWindow(QPaintDeviceWindow): class QRawFont(sip.simplewrapper): class LayoutFlag(int): + def __or__ (self, other: 'QRawFont.LayoutFlag') -> 'QRawFont.LayoutFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QRawFont.LayoutFlags': ... # type: ignore[override, misc] + SeparateAdvances = ... # type: QRawFont.LayoutFlag KernedAdvances = ... # type: QRawFont.LayoutFlag UseDesignMetrics = ... # type: QRawFont.LayoutFlag @@ -8012,12 +8015,20 @@ class QRawFont(sip.simplewrapper): def __init__(self, f: typing.Union['QRawFont.LayoutFlags', 'QRawFont.LayoutFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QRawFont.LayoutFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QRawFont.LayoutFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QRawFont.LayoutFlags', 'QRawFont.LayoutFlag', int]) -> 'QRawFont.LayoutFlags': ... + def __and__(self, other: typing.Union['QRawFont.LayoutFlags', 'QRawFont.LayoutFlag', int]) -> 'QRawFont.LayoutFlags': ... + def __xor__(self, other: typing.Union['QRawFont.LayoutFlags', 'QRawFont.LayoutFlag', int]) -> 'QRawFont.LayoutFlags': ... + def __ror__ (self, other: 'QRawFont.LayoutFlag') -> 'QRawFont.LayoutFlags': ... + def __rand__(self, other: 'QRawFont.LayoutFlag') -> 'QRawFont.LayoutFlags': ... + def __rxor__(self, other: 'QRawFont.LayoutFlag') -> 'QRawFont.LayoutFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py b/tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py new file mode 100644 index 00000000..b8e270e8 --- /dev/null +++ b/tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QRawFont.LayoutFlags" and flag class "QRawFont.LayoutFlag" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QRawFont.LayoutFlag +MultiFlagClass = QtGui.QRawFont.LayoutFlags + +oneFlagRefValue1 = QtGui.QRawFont.LayoutFlag.SeparateAdvances +oneFlagRefValue2 = QtGui.QRawFont.LayoutFlag.KernedAdvances + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From b281dbf3479c3374a0e50dd8e4fe799f73207d41 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:50:03 +0200 Subject: [PATCH 134/421] QFlag operations for QTextDocument.FindFlags, QTextDocument.FindFlag in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + tests/qflags/test_QtGui_FindFlags_FindFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtGui_FindFlags_FindFlag.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 9c3b7a0e..3c785801 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -8891,6 +8891,9 @@ class QTextDocument(QtCore.QObject): UserResource = ... # type: QTextDocument.ResourceType class FindFlag(int): + def __or__ (self, other: 'QTextDocument.FindFlag') -> 'QTextDocument.FindFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QTextDocument.FindFlags': ... # type: ignore[override, misc] + FindBackward = ... # type: QTextDocument.FindFlag FindCaseSensitively = ... # type: QTextDocument.FindFlag FindWholeWords = ... # type: QTextDocument.FindFlag @@ -8914,12 +8917,20 @@ class QTextDocument(QtCore.QObject): def __init__(self, f: typing.Union['QTextDocument.FindFlags', 'QTextDocument.FindFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QTextDocument.FindFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTextDocument.FindFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTextDocument.FindFlags', 'QTextDocument.FindFlag', int]) -> 'QTextDocument.FindFlags': ... + def __and__(self, other: typing.Union['QTextDocument.FindFlags', 'QTextDocument.FindFlag', int]) -> 'QTextDocument.FindFlags': ... + def __xor__(self, other: typing.Union['QTextDocument.FindFlags', 'QTextDocument.FindFlag', int]) -> 'QTextDocument.FindFlags': ... + def __ror__ (self, other: 'QTextDocument.FindFlag') -> 'QTextDocument.FindFlags': ... + def __rand__(self, other: 'QTextDocument.FindFlag') -> 'QTextDocument.FindFlags': ... + def __rxor__(self, other: 'QTextDocument.FindFlag') -> 'QTextDocument.FindFlags': ... class MarkdownFeatures(sip.simplewrapper): diff --git a/tests/qflags/test_QtGui_FindFlags_FindFlag.py b/tests/qflags/test_QtGui_FindFlags_FindFlag.py new file mode 100644 index 00000000..06e56d28 --- /dev/null +++ b/tests/qflags/test_QtGui_FindFlags_FindFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTextDocument.FindFlags" and flag class "QTextDocument.FindFlag" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QTextDocument.FindFlag +MultiFlagClass = QtGui.QTextDocument.FindFlags + +oneFlagRefValue1 = QtGui.QTextDocument.FindFlag.FindBackward +oneFlagRefValue2 = QtGui.QTextDocument.FindFlag.FindCaseSensitively + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From d0ecac4acd6d6be59d0b59eec8261def50677ea1 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:51:03 +0200 Subject: [PATCH 135/421] QFlag operations for QHostAddress.ConversionMode, QHostAddress.ConversionModeFlag in module QtNetwork --- PyQt5-stubs/QtNetwork.pyi | 11 + ...twork_ConversionMode_ConversionModeFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 68f3c54f..4005b9cd 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -476,6 +476,9 @@ class QDnsLookup(QtCore.QObject): class QHostAddress(sip.simplewrapper): class ConversionModeFlag(int): + def __or__ (self, other: 'QHostAddress.ConversionModeFlag') -> 'QHostAddress.ConversionMode': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QHostAddress.ConversionMode': ... # type: ignore[override, misc] + ConvertV4MappedToIPv4 = ... # type: QHostAddress.ConversionModeFlag ConvertV4CompatToIPv4 = ... # type: QHostAddress.ConversionModeFlag ConvertUnspecifiedAddress = ... # type: QHostAddress.ConversionModeFlag @@ -515,12 +518,20 @@ class QHostAddress(sip.simplewrapper): def __init__(self, f: typing.Union['QHostAddress.ConversionMode', 'QHostAddress.ConversionModeFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QHostAddress.ConversionMode') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QHostAddress.ConversionMode': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QHostAddress.ConversionMode', 'QHostAddress.ConversionModeFlag', int]) -> 'QHostAddress.ConversionMode': ... + def __and__(self, other: typing.Union['QHostAddress.ConversionMode', 'QHostAddress.ConversionModeFlag', int]) -> 'QHostAddress.ConversionMode': ... + def __xor__(self, other: typing.Union['QHostAddress.ConversionMode', 'QHostAddress.ConversionModeFlag', int]) -> 'QHostAddress.ConversionMode': ... + def __ror__ (self, other: 'QHostAddress.ConversionModeFlag') -> 'QHostAddress.ConversionMode': ... + def __rand__(self, other: 'QHostAddress.ConversionModeFlag') -> 'QHostAddress.ConversionMode': ... + def __rxor__(self, other: 'QHostAddress.ConversionModeFlag') -> 'QHostAddress.ConversionMode': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py b/tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py new file mode 100644 index 00000000..e84df21e --- /dev/null +++ b/tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QHostAddress.ConversionMode" and flag class "QHostAddress.ConversionModeFlag" +from PyQt5 import QtNetwork + +OneFlagClass = QtNetwork.QHostAddress.ConversionModeFlag +MultiFlagClass = QtNetwork.QHostAddress.ConversionMode + +oneFlagRefValue1 = QtNetwork.QHostAddress.ConversionModeFlag.ConvertV4MappedToIPv4 +oneFlagRefValue2 = QtNetwork.QHostAddress.ConversionModeFlag.ConvertV4CompatToIPv4 + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a2b782525c878f682a5b85c861964f77398bf0b1 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:51:20 +0200 Subject: [PATCH 136/421] QFlag operations for QAbstractSocket.BindMode, QAbstractSocket.BindFlag in module QtNetwork --- PyQt5-stubs/QtNetwork.pyi | 11 + .../test_QtNetwork_BindMode_BindFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtNetwork_BindMode_BindFlag.py diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 4005b9cd..6c27345b 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -98,6 +98,9 @@ class QAbstractSocket(QtCore.QIODevice): PauseOnSslErrors = ... # type: QAbstractSocket.PauseMode class BindFlag(int): + def __or__ (self, other: 'QAbstractSocket.BindFlag') -> 'QAbstractSocket.BindMode': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QAbstractSocket.BindMode': ... # type: ignore[override, misc] + DefaultForPlatform = ... # type: QAbstractSocket.BindFlag ShareAddress = ... # type: QAbstractSocket.BindFlag DontShareAddress = ... # type: QAbstractSocket.BindFlag @@ -225,12 +228,20 @@ class QAbstractSocket(QtCore.QIODevice): def __init__(self, f: typing.Union['QAbstractSocket.BindMode', 'QAbstractSocket.BindFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QAbstractSocket.BindMode') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QAbstractSocket.BindMode': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QAbstractSocket.BindMode', 'QAbstractSocket.BindFlag', int]) -> 'QAbstractSocket.BindMode': ... + def __and__(self, other: typing.Union['QAbstractSocket.BindMode', 'QAbstractSocket.BindFlag', int]) -> 'QAbstractSocket.BindMode': ... + def __xor__(self, other: typing.Union['QAbstractSocket.BindMode', 'QAbstractSocket.BindFlag', int]) -> 'QAbstractSocket.BindMode': ... + def __ror__ (self, other: 'QAbstractSocket.BindFlag') -> 'QAbstractSocket.BindMode': ... + def __rand__(self, other: 'QAbstractSocket.BindFlag') -> 'QAbstractSocket.BindMode': ... + def __rxor__(self, other: 'QAbstractSocket.BindFlag') -> 'QAbstractSocket.BindMode': ... class PauseModes(sip.simplewrapper): diff --git a/tests/qflags/test_QtNetwork_BindMode_BindFlag.py b/tests/qflags/test_QtNetwork_BindMode_BindFlag.py new file mode 100644 index 00000000..3bd89f20 --- /dev/null +++ b/tests/qflags/test_QtNetwork_BindMode_BindFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QAbstractSocket.BindMode" and flag class "QAbstractSocket.BindFlag" +from PyQt5 import QtNetwork + +OneFlagClass = QtNetwork.QAbstractSocket.BindFlag +MultiFlagClass = QtNetwork.QAbstractSocket.BindMode + +oneFlagRefValue1 = QtNetwork.QAbstractSocket.BindFlag.DefaultForPlatform +oneFlagRefValue2 = QtNetwork.QAbstractSocket.BindFlag.ShareAddress + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a786b054413eee348f7c4165308ef584977c75c1 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:51:43 +0200 Subject: [PATCH 137/421] QFlag operations for QAbstractSocket.PauseModes, QAbstractSocket.PauseMode in module QtNetwork --- PyQt5-stubs/QtNetwork.pyi | 11 + .../test_QtNetwork_PauseModes_PauseMode.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtNetwork_PauseModes_PauseMode.py diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 6c27345b..55534dae 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -91,6 +91,9 @@ class QAbstractNetworkCache(QtCore.QObject): class QAbstractSocket(QtCore.QIODevice): class PauseMode(int): + def __or__ (self, other: 'QAbstractSocket.PauseMode') -> 'QAbstractSocket.PauseModes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QAbstractSocket.PauseModes': ... # type: ignore[override, misc] + PauseNever = ... # type: QAbstractSocket.PauseMode PauseOnSslErrors = ... # type: QAbstractSocket.PauseMode @@ -251,12 +254,20 @@ class QAbstractSocket(QtCore.QIODevice): def __init__(self, f: typing.Union['QAbstractSocket.PauseModes', 'QAbstractSocket.PauseMode']) -> None: ... @typing.overload def __init__(self, a0: 'QAbstractSocket.PauseModes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QAbstractSocket.PauseModes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QAbstractSocket.PauseModes', 'QAbstractSocket.PauseMode', int]) -> 'QAbstractSocket.PauseModes': ... + def __and__(self, other: typing.Union['QAbstractSocket.PauseModes', 'QAbstractSocket.PauseMode', int]) -> 'QAbstractSocket.PauseModes': ... + def __xor__(self, other: typing.Union['QAbstractSocket.PauseModes', 'QAbstractSocket.PauseMode', int]) -> 'QAbstractSocket.PauseModes': ... + def __ror__ (self, other: 'QAbstractSocket.PauseMode') -> 'QAbstractSocket.PauseModes': ... + def __rand__(self, other: 'QAbstractSocket.PauseMode') -> 'QAbstractSocket.PauseModes': ... + def __rxor__(self, other: 'QAbstractSocket.PauseMode') -> 'QAbstractSocket.PauseModes': ... def __init__(self, socketType: 'QAbstractSocket.SocketType', parent: QtCore.QObject) -> None: ... diff --git a/tests/qflags/test_QtNetwork_PauseModes_PauseMode.py b/tests/qflags/test_QtNetwork_PauseModes_PauseMode.py new file mode 100644 index 00000000..029e9a5a --- /dev/null +++ b/tests/qflags/test_QtNetwork_PauseModes_PauseMode.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QAbstractSocket.PauseModes" and flag class "QAbstractSocket.PauseMode" +from PyQt5 import QtNetwork + +OneFlagClass = QtNetwork.QAbstractSocket.PauseMode +MultiFlagClass = QtNetwork.QAbstractSocket.PauseModes + +oneFlagRefValue1 = QtNetwork.QAbstractSocket.PauseMode.PauseNever +oneFlagRefValue2 = QtNetwork.QAbstractSocket.PauseMode.PauseOnSslErrors + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 150e08a7eb458a11d7e2a21aa79addb64e6c40a9 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:53:05 +0200 Subject: [PATCH 138/421] QFlag operations for QTextFormat.PageBreakFlags, QTextFormat.PageBreakFlag in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + ...test_QtGui_PageBreakFlags_PageBreakFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 3c785801..3077323d 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -9347,6 +9347,9 @@ class QTextFormat(sip.simplewrapper): UserProperty = ... # type: QTextFormat.Property class PageBreakFlag(int): + def __or__ (self, other: 'QTextFormat.PageBreakFlag') -> 'QTextFormat.PageBreakFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QTextFormat.PageBreakFlags': ... # type: ignore[override, misc] + PageBreak_Auto = ... # type: QTextFormat.PageBreakFlag PageBreak_AlwaysBefore = ... # type: QTextFormat.PageBreakFlag PageBreak_AlwaysAfter = ... # type: QTextFormat.PageBreakFlag @@ -9393,12 +9396,20 @@ class QTextFormat(sip.simplewrapper): def __init__(self, f: typing.Union['QTextFormat.PageBreakFlags', 'QTextFormat.PageBreakFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QTextFormat.PageBreakFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTextFormat.PageBreakFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTextFormat.PageBreakFlags', 'QTextFormat.PageBreakFlag', int]) -> 'QTextFormat.PageBreakFlags': ... + def __and__(self, other: typing.Union['QTextFormat.PageBreakFlags', 'QTextFormat.PageBreakFlag', int]) -> 'QTextFormat.PageBreakFlags': ... + def __xor__(self, other: typing.Union['QTextFormat.PageBreakFlags', 'QTextFormat.PageBreakFlag', int]) -> 'QTextFormat.PageBreakFlags': ... + def __ror__ (self, other: 'QTextFormat.PageBreakFlag') -> 'QTextFormat.PageBreakFlags': ... + def __rand__(self, other: 'QTextFormat.PageBreakFlag') -> 'QTextFormat.PageBreakFlags': ... + def __rxor__(self, other: 'QTextFormat.PageBreakFlag') -> 'QTextFormat.PageBreakFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py b/tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py new file mode 100644 index 00000000..ca8d1604 --- /dev/null +++ b/tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTextFormat.PageBreakFlags" and flag class "QTextFormat.PageBreakFlag" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QTextFormat.PageBreakFlag +MultiFlagClass = QtGui.QTextFormat.PageBreakFlags + +oneFlagRefValue1 = QtGui.QTextFormat.PageBreakFlag.PageBreak_Auto +oneFlagRefValue2 = QtGui.QTextFormat.PageBreakFlag.PageBreak_AlwaysBefore + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 6bc63544a16e2c79a8926ce11331669794f54efe Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:54:37 +0200 Subject: [PATCH 139/421] QFlag operations for QNetworkInterface.InterfaceFlags, QNetworkInterface.InterfaceFlag in module QtNetwork --- PyQt5-stubs/QtNetwork.pyi | 11 + ..._QtNetwork_InterfaceFlags_InterfaceFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 55534dae..1c6424a5 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -1294,6 +1294,9 @@ class QNetworkInterface(sip.simplewrapper): Ieee1394 = ... # type: QNetworkInterface.InterfaceType class InterfaceFlag(int): + def __or__ (self, other: 'QNetworkInterface.InterfaceFlag') -> 'QNetworkInterface.InterfaceFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QNetworkInterface.InterfaceFlags': ... # type: ignore[override, misc] + IsUp = ... # type: QNetworkInterface.InterfaceFlag IsRunning = ... # type: QNetworkInterface.InterfaceFlag CanBroadcast = ... # type: QNetworkInterface.InterfaceFlag @@ -1316,12 +1319,20 @@ class QNetworkInterface(sip.simplewrapper): def __init__(self, f: typing.Union['QNetworkInterface.InterfaceFlags', 'QNetworkInterface.InterfaceFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QNetworkInterface.InterfaceFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QNetworkInterface.InterfaceFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QNetworkInterface.InterfaceFlags', 'QNetworkInterface.InterfaceFlag', int]) -> 'QNetworkInterface.InterfaceFlags': ... + def __and__(self, other: typing.Union['QNetworkInterface.InterfaceFlags', 'QNetworkInterface.InterfaceFlag', int]) -> 'QNetworkInterface.InterfaceFlags': ... + def __xor__(self, other: typing.Union['QNetworkInterface.InterfaceFlags', 'QNetworkInterface.InterfaceFlag', int]) -> 'QNetworkInterface.InterfaceFlags': ... + def __ror__ (self, other: 'QNetworkInterface.InterfaceFlag') -> 'QNetworkInterface.InterfaceFlags': ... + def __rand__(self, other: 'QNetworkInterface.InterfaceFlag') -> 'QNetworkInterface.InterfaceFlags': ... + def __rxor__(self, other: 'QNetworkInterface.InterfaceFlag') -> 'QNetworkInterface.InterfaceFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py b/tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py new file mode 100644 index 00000000..c9ff917e --- /dev/null +++ b/tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QNetworkInterface.InterfaceFlags" and flag class "QNetworkInterface.InterfaceFlag" +from PyQt5 import QtNetwork + +OneFlagClass = QtNetwork.QNetworkInterface.InterfaceFlag +MultiFlagClass = QtNetwork.QNetworkInterface.InterfaceFlags + +oneFlagRefValue1 = QtNetwork.QNetworkInterface.InterfaceFlag.IsUp +oneFlagRefValue2 = QtNetwork.QNetworkInterface.InterfaceFlag.IsRunning + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From e194110d4ccae3d8bd2045d4deb569889192cd58 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:54:54 +0200 Subject: [PATCH 140/421] QFlag operations for QSsl.SslOptions, QSsl.SslOption in module QtNetwork --- PyQt5-stubs/QtNetwork.pyi | 11 + .../test_QtNetwork_SslOptions_SslOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtNetwork_SslOptions_SslOption.py diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 1c6424a5..a94225fc 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -1923,6 +1923,9 @@ class QPasswordDigestor(sip.simplewrapper): class QSsl(sip.simplewrapper): class SslOption(int): + def __or__ (self, other: 'QSsl.SslOption') -> 'QSsl.SslOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSsl.SslOptions': ... # type: ignore[override, misc] + SslOptionDisableEmptyFragments = ... # type: QSsl.SslOption SslOptionDisableSessionTickets = ... # type: QSsl.SslOption SslOptionDisableCompression = ... # type: QSsl.SslOption @@ -2024,12 +2027,20 @@ class QSsl(sip.simplewrapper): def __init__(self, f: typing.Union['QSsl.SslOptions', 'QSsl.SslOption']) -> None: ... @typing.overload def __init__(self, a0: 'QSsl.SslOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSsl.SslOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSsl.SslOptions', 'QSsl.SslOption', int]) -> 'QSsl.SslOptions': ... + def __and__(self, other: typing.Union['QSsl.SslOptions', 'QSsl.SslOption', int]) -> 'QSsl.SslOptions': ... + def __xor__(self, other: typing.Union['QSsl.SslOptions', 'QSsl.SslOption', int]) -> 'QSsl.SslOptions': ... + def __ror__ (self, other: 'QSsl.SslOption') -> 'QSsl.SslOptions': ... + def __rand__(self, other: 'QSsl.SslOption') -> 'QSsl.SslOptions': ... + def __rxor__(self, other: 'QSsl.SslOption') -> 'QSsl.SslOptions': ... class QSslCertificate(sip.simplewrapper): diff --git a/tests/qflags/test_QtNetwork_SslOptions_SslOption.py b/tests/qflags/test_QtNetwork_SslOptions_SslOption.py new file mode 100644 index 00000000..e47684c2 --- /dev/null +++ b/tests/qflags/test_QtNetwork_SslOptions_SslOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSsl.SslOptions" and flag class "QSsl.SslOption" +from PyQt5 import QtNetwork + +OneFlagClass = QtNetwork.QSsl.SslOption +MultiFlagClass = QtNetwork.QSsl.SslOptions + +oneFlagRefValue1 = QtNetwork.QSsl.SslOption.SslOptionDisableEmptyFragments +oneFlagRefValue2 = QtNetwork.QSsl.SslOption.SslOptionDisableSessionTickets + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 01a7a1b602c3faad1f48865de6eaa6ffcde4c733 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:56:08 +0200 Subject: [PATCH 141/421] QFlag operations for QByteArray.Base64Options, QByteArray.Base64Option in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_Base64Options_Base64Option.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtCore_Base64Options_Base64Option.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index fde1a6dd..5b3d6bb5 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -3917,6 +3917,9 @@ class QByteArray(sip.simplewrapper): IllegalPadding = ... # type: QByteArray.Base64DecodingStatus class Base64Option(int): + def __or__ (self, other: 'QByteArray.Base64Option') -> 'QByteArray.Base64Options': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QByteArray.Base64Options': ... # type: ignore[override, misc] + Base64Encoding = ... # type: QByteArray.Base64Option Base64UrlEncoding = ... # type: QByteArray.Base64Option KeepTrailingEquals = ... # type: QByteArray.Base64Option @@ -3939,12 +3942,20 @@ class QByteArray(sip.simplewrapper): def __init__(self, f: typing.Union['QByteArray.Base64Options', 'QByteArray.Base64Option']) -> None: ... @typing.overload def __init__(self, a0: 'QByteArray.Base64Options') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QByteArray.Base64Options': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QByteArray.Base64Options', 'QByteArray.Base64Option', int]) -> 'QByteArray.Base64Options': ... + def __and__(self, other: typing.Union['QByteArray.Base64Options', 'QByteArray.Base64Option', int]) -> 'QByteArray.Base64Options': ... + def __xor__(self, other: typing.Union['QByteArray.Base64Options', 'QByteArray.Base64Option', int]) -> 'QByteArray.Base64Options': ... + def __ror__ (self, other: 'QByteArray.Base64Option') -> 'QByteArray.Base64Options': ... + def __rand__(self, other: 'QByteArray.Base64Option') -> 'QByteArray.Base64Options': ... + def __rxor__(self, other: 'QByteArray.Base64Option') -> 'QByteArray.Base64Options': ... class FromBase64Result(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_Base64Options_Base64Option.py b/tests/qflags/test_QtCore_Base64Options_Base64Option.py new file mode 100644 index 00000000..6bac0d47 --- /dev/null +++ b/tests/qflags/test_QtCore_Base64Options_Base64Option.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QByteArray.Base64Options" and flag class "QByteArray.Base64Option" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QByteArray.Base64Option +MultiFlagClass = QtCore.QByteArray.Base64Options + +oneFlagRefValue1 = QtCore.QByteArray.Base64Option.Base64Encoding +oneFlagRefValue2 = QtCore.QByteArray.Base64Option.Base64UrlEncoding + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From b0013f7ad16397b1c2f52a1f0efc7a3528cd3463 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:57:14 +0200 Subject: [PATCH 142/421] QFlag operations for QLocale.NumberOptions, QLocale.NumberOption in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_NumberOptions_NumberOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtCore_NumberOptions_NumberOption.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 5b3d6bb5..18d0bc79 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -7338,6 +7338,9 @@ class QLocale(sip.simplewrapper): NarrowFormat = ... # type: QLocale.FormatType class NumberOption(int): + def __or__ (self, other: 'QLocale.NumberOption') -> 'QLocale.NumberOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QLocale.NumberOptions': ... # type: ignore[override, misc] + OmitGroupSeparator = ... # type: QLocale.NumberOption RejectGroupSeparator = ... # type: QLocale.NumberOption DefaultNumberOptions = ... # type: QLocale.NumberOption @@ -8682,12 +8685,20 @@ class QLocale(sip.simplewrapper): def __init__(self, f: typing.Union['QLocale.NumberOptions', 'QLocale.NumberOption']) -> None: ... @typing.overload def __init__(self, a0: 'QLocale.NumberOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QLocale.NumberOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QLocale.NumberOptions', 'QLocale.NumberOption', int]) -> 'QLocale.NumberOptions': ... + def __and__(self, other: typing.Union['QLocale.NumberOptions', 'QLocale.NumberOption', int]) -> 'QLocale.NumberOptions': ... + def __xor__(self, other: typing.Union['QLocale.NumberOptions', 'QLocale.NumberOption', int]) -> 'QLocale.NumberOptions': ... + def __ror__ (self, other: 'QLocale.NumberOption') -> 'QLocale.NumberOptions': ... + def __rand__(self, other: 'QLocale.NumberOption') -> 'QLocale.NumberOptions': ... + def __rxor__(self, other: 'QLocale.NumberOption') -> 'QLocale.NumberOptions': ... class DataSizeFormats(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_NumberOptions_NumberOption.py b/tests/qflags/test_QtCore_NumberOptions_NumberOption.py new file mode 100644 index 00000000..0ac07dd1 --- /dev/null +++ b/tests/qflags/test_QtCore_NumberOptions_NumberOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QLocale.NumberOptions" and flag class "QLocale.NumberOption" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QLocale.NumberOption +MultiFlagClass = QtCore.QLocale.NumberOptions + +oneFlagRefValue1 = QtCore.QLocale.NumberOption.OmitGroupSeparator +oneFlagRefValue2 = QtCore.QLocale.NumberOption.RejectGroupSeparator + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From d3c16b760c4fbca83ae47dbd28cde9312cdd0e95 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 10:59:00 +0200 Subject: [PATCH 143/421] QFlag operations for QDateTimeEdit.Sections, QDateTimeEdit.Section in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../qflags/test_QtWidgets_Sections_Section.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_Sections_Section.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 03c1db2b..8fd89835 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -3364,6 +3364,9 @@ class QDataWidgetMapper(QtCore.QObject): class QDateTimeEdit(QAbstractSpinBox): class Section(int): + def __or__ (self, other: 'QDateTimeEdit.Section') -> 'QDateTimeEdit.Sections': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QDateTimeEdit.Sections': ... # type: ignore[override, misc] + NoSection = ... # type: QDateTimeEdit.Section AmPmSection = ... # type: QDateTimeEdit.Section MSecSection = ... # type: QDateTimeEdit.Section @@ -3396,12 +3399,20 @@ class QDateTimeEdit(QAbstractSpinBox): def __init__(self, f: typing.Union['QDateTimeEdit.Sections', 'QDateTimeEdit.Section']) -> None: ... @typing.overload def __init__(self, a0: 'QDateTimeEdit.Sections') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QDateTimeEdit.Sections': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QDateTimeEdit.Sections', 'QDateTimeEdit.Section', int]) -> 'QDateTimeEdit.Sections': ... + def __and__(self, other: typing.Union['QDateTimeEdit.Sections', 'QDateTimeEdit.Section', int]) -> 'QDateTimeEdit.Sections': ... + def __xor__(self, other: typing.Union['QDateTimeEdit.Sections', 'QDateTimeEdit.Section', int]) -> 'QDateTimeEdit.Sections': ... + def __ror__ (self, other: 'QDateTimeEdit.Section') -> 'QDateTimeEdit.Sections': ... + def __rand__(self, other: 'QDateTimeEdit.Section') -> 'QDateTimeEdit.Sections': ... + def __rxor__(self, other: 'QDateTimeEdit.Section') -> 'QDateTimeEdit.Sections': ... @typing.overload def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_Sections_Section.py b/tests/qflags/test_QtWidgets_Sections_Section.py new file mode 100644 index 00000000..3eb4aedc --- /dev/null +++ b/tests/qflags/test_QtWidgets_Sections_Section.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QDateTimeEdit.Sections" and flag class "QDateTimeEdit.Section" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QDateTimeEdit.Section +MultiFlagClass = QtWidgets.QDateTimeEdit.Sections + +oneFlagRefValue1 = QtWidgets.QDateTimeEdit.Section.NoSection +oneFlagRefValue2 = QtWidgets.QDateTimeEdit.Section.AmPmSection + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 757b0392081f87a5ffc996349f3607c6f6c8846d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:00:04 +0200 Subject: [PATCH 144/421] QFlag operations for QRegularExpression.PatternOptions, QRegularExpression.PatternOption in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...est_QtCore_PatternOptions_PatternOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtCore_PatternOptions_PatternOption.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 18d0bc79..e8da8145 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -10261,6 +10261,9 @@ class QRegularExpression(sip.simplewrapper): NoMatch = ... # type: QRegularExpression.MatchType class PatternOption(int): + def __or__ (self, other: 'QRegularExpression.PatternOption') -> 'QRegularExpression.PatternOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QRegularExpression.PatternOptions': ... # type: ignore[override, misc] + NoPatternOption = ... # type: QRegularExpression.PatternOption CaseInsensitiveOption = ... # type: QRegularExpression.PatternOption DotMatchesEverythingOption = ... # type: QRegularExpression.PatternOption @@ -10291,12 +10294,20 @@ class QRegularExpression(sip.simplewrapper): def __init__(self, f: typing.Union['QRegularExpression.PatternOptions', 'QRegularExpression.PatternOption']) -> None: ... @typing.overload def __init__(self, a0: 'QRegularExpression.PatternOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QRegularExpression.PatternOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QRegularExpression.PatternOptions', 'QRegularExpression.PatternOption', int]) -> 'QRegularExpression.PatternOptions': ... + def __and__(self, other: typing.Union['QRegularExpression.PatternOptions', 'QRegularExpression.PatternOption', int]) -> 'QRegularExpression.PatternOptions': ... + def __xor__(self, other: typing.Union['QRegularExpression.PatternOptions', 'QRegularExpression.PatternOption', int]) -> 'QRegularExpression.PatternOptions': ... + def __ror__ (self, other: 'QRegularExpression.PatternOption') -> 'QRegularExpression.PatternOptions': ... + def __rand__(self, other: 'QRegularExpression.PatternOption') -> 'QRegularExpression.PatternOptions': ... + def __rxor__(self, other: 'QRegularExpression.PatternOption') -> 'QRegularExpression.PatternOptions': ... class MatchOptions(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_PatternOptions_PatternOption.py b/tests/qflags/test_QtCore_PatternOptions_PatternOption.py new file mode 100644 index 00000000..6760357e --- /dev/null +++ b/tests/qflags/test_QtCore_PatternOptions_PatternOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QRegularExpression.PatternOptions" and flag class "QRegularExpression.PatternOption" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QRegularExpression.PatternOption +MultiFlagClass = QtCore.QRegularExpression.PatternOptions + +oneFlagRefValue1 = QtCore.QRegularExpression.PatternOption.NoPatternOption +oneFlagRefValue2 = QtCore.QRegularExpression.PatternOption.CaseInsensitiveOption + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a4c8b34ff374f28fe9e7e100ca3358ae842a8eae Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:01:06 +0200 Subject: [PATCH 145/421] QFlag operations for QRegularExpression.MatchOptions, QRegularExpression.MatchOption in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_MatchOptions_MatchOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtCore_MatchOptions_MatchOption.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index e8da8145..10364625 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -10241,6 +10241,9 @@ class QRegExp(sip.simplewrapper): class QRegularExpression(sip.simplewrapper): class MatchOption(int): + def __or__ (self, other: 'QRegularExpression.MatchOption') -> 'QRegularExpression.MatchOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QRegularExpression.MatchOptions': ... # type: ignore[override, misc] + NoMatchOption = ... # type: QRegularExpression.MatchOption AnchoredMatchOption = ... # type: QRegularExpression.MatchOption DontCheckSubjectStringMatchOption = ... # type: QRegularExpression.MatchOption @@ -10317,12 +10320,20 @@ class QRegularExpression(sip.simplewrapper): def __init__(self, f: typing.Union['QRegularExpression.MatchOptions', 'QRegularExpression.MatchOption']) -> None: ... @typing.overload def __init__(self, a0: 'QRegularExpression.MatchOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QRegularExpression.MatchOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QRegularExpression.MatchOptions', 'QRegularExpression.MatchOption', int]) -> 'QRegularExpression.MatchOptions': ... + def __and__(self, other: typing.Union['QRegularExpression.MatchOptions', 'QRegularExpression.MatchOption', int]) -> 'QRegularExpression.MatchOptions': ... + def __xor__(self, other: typing.Union['QRegularExpression.MatchOptions', 'QRegularExpression.MatchOption', int]) -> 'QRegularExpression.MatchOptions': ... + def __ror__ (self, other: 'QRegularExpression.MatchOption') -> 'QRegularExpression.MatchOptions': ... + def __rand__(self, other: 'QRegularExpression.MatchOption') -> 'QRegularExpression.MatchOptions': ... + def __rxor__(self, other: 'QRegularExpression.MatchOption') -> 'QRegularExpression.MatchOptions': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtCore_MatchOptions_MatchOption.py b/tests/qflags/test_QtCore_MatchOptions_MatchOption.py new file mode 100644 index 00000000..14b84b77 --- /dev/null +++ b/tests/qflags/test_QtCore_MatchOptions_MatchOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QRegularExpression.MatchOptions" and flag class "QRegularExpression.MatchOption" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QRegularExpression.MatchOption +MultiFlagClass = QtCore.QRegularExpression.MatchOptions + +oneFlagRefValue1 = QtCore.QRegularExpression.MatchOption.NoMatchOption +oneFlagRefValue2 = QtCore.QRegularExpression.MatchOption.AnchoredMatchOption + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a077857106ccafda6a2371a174e7fba4e91ad4a1 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:02:09 +0200 Subject: [PATCH 146/421] QFlag operations for QTextStream.NumberFlags, QTextStream.NumberFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + .../test_QtCore_NumberFlags_NumberFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtCore_NumberFlags_NumberFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 10364625..747612fa 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -11419,6 +11419,9 @@ class QTextStream(sip.simplewrapper): WriteFailed = ... # type: QTextStream.Status class NumberFlag(int): + def __or__ (self, other: 'QTextStream.NumberFlag') -> 'QTextStream.NumberFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QTextStream.NumberFlags': ... # type: ignore[override, misc] + ShowBase = ... # type: QTextStream.NumberFlag ForcePoint = ... # type: QTextStream.NumberFlag ForceSign = ... # type: QTextStream.NumberFlag @@ -11459,12 +11462,20 @@ class QTextStream(sip.simplewrapper): def __init__(self, f: typing.Union['QTextStream.NumberFlags', 'QTextStream.NumberFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QTextStream.NumberFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTextStream.NumberFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTextStream.NumberFlags', 'QTextStream.NumberFlag', int]) -> 'QTextStream.NumberFlags': ... + def __and__(self, other: typing.Union['QTextStream.NumberFlags', 'QTextStream.NumberFlag', int]) -> 'QTextStream.NumberFlags': ... + def __xor__(self, other: typing.Union['QTextStream.NumberFlags', 'QTextStream.NumberFlag', int]) -> 'QTextStream.NumberFlags': ... + def __ror__ (self, other: 'QTextStream.NumberFlag') -> 'QTextStream.NumberFlags': ... + def __rand__(self, other: 'QTextStream.NumberFlag') -> 'QTextStream.NumberFlags': ... + def __rxor__(self, other: 'QTextStream.NumberFlag') -> 'QTextStream.NumberFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtCore_NumberFlags_NumberFlag.py b/tests/qflags/test_QtCore_NumberFlags_NumberFlag.py new file mode 100644 index 00000000..3cb73855 --- /dev/null +++ b/tests/qflags/test_QtCore_NumberFlags_NumberFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTextStream.NumberFlags" and flag class "QTextStream.NumberFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QTextStream.NumberFlag +MultiFlagClass = QtCore.QTextStream.NumberFlags + +oneFlagRefValue1 = QtCore.QTextStream.NumberFlag.ShowBase +oneFlagRefValue2 = QtCore.QTextStream.NumberFlag.ForcePoint + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 5b0194fdacfe83c8bb3a2febee1c9e2fdc4314b4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:03:15 +0200 Subject: [PATCH 147/421] QFlag operations for QTextBoundaryFinder.BoundaryReasons, QTextBoundaryFinder.BoundaryReason in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...t_QtCore_BoundaryReasons_BoundaryReason.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 747612fa..64002da2 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -11247,6 +11247,9 @@ class QTextBoundaryFinder(sip.simplewrapper): Sentence = ... # type: QTextBoundaryFinder.BoundaryType class BoundaryReason(int): + def __or__ (self, other: 'QTextBoundaryFinder.BoundaryReason') -> 'QTextBoundaryFinder.BoundaryReasons': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QTextBoundaryFinder.BoundaryReasons': ... # type: ignore[override, misc] + NotAtBoundary = ... # type: QTextBoundaryFinder.BoundaryReason SoftHyphen = ... # type: QTextBoundaryFinder.BoundaryReason BreakOpportunity = ... # type: QTextBoundaryFinder.BoundaryReason @@ -11269,12 +11272,20 @@ class QTextBoundaryFinder(sip.simplewrapper): def __init__(self, f: typing.Union['QTextBoundaryFinder.BoundaryReasons', 'QTextBoundaryFinder.BoundaryReason']) -> None: ... @typing.overload def __init__(self, a0: 'QTextBoundaryFinder.BoundaryReasons') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTextBoundaryFinder.BoundaryReasons': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTextBoundaryFinder.BoundaryReasons', 'QTextBoundaryFinder.BoundaryReason', int]) -> 'QTextBoundaryFinder.BoundaryReasons': ... + def __and__(self, other: typing.Union['QTextBoundaryFinder.BoundaryReasons', 'QTextBoundaryFinder.BoundaryReason', int]) -> 'QTextBoundaryFinder.BoundaryReasons': ... + def __xor__(self, other: typing.Union['QTextBoundaryFinder.BoundaryReasons', 'QTextBoundaryFinder.BoundaryReason', int]) -> 'QTextBoundaryFinder.BoundaryReasons': ... + def __ror__ (self, other: 'QTextBoundaryFinder.BoundaryReason') -> 'QTextBoundaryFinder.BoundaryReasons': ... + def __rand__(self, other: 'QTextBoundaryFinder.BoundaryReason') -> 'QTextBoundaryFinder.BoundaryReasons': ... + def __rxor__(self, other: 'QTextBoundaryFinder.BoundaryReason') -> 'QTextBoundaryFinder.BoundaryReasons': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py b/tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py new file mode 100644 index 00000000..82664d50 --- /dev/null +++ b/tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTextBoundaryFinder.BoundaryReasons" and flag class "QTextBoundaryFinder.BoundaryReason" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QTextBoundaryFinder.BoundaryReason +MultiFlagClass = QtCore.QTextBoundaryFinder.BoundaryReasons + +oneFlagRefValue1 = QtCore.QTextBoundaryFinder.BoundaryReason.NotAtBoundary +oneFlagRefValue2 = QtCore.QTextBoundaryFinder.BoundaryReason.SoftHyphen + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 1d7381f2afc98f216aa9b23029b42b7b7158754a Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:03:41 +0200 Subject: [PATCH 148/421] QFlag operations for QSql.ParamType, QSql.ParamTypeFlag in module QtSql --- PyQt5-stubs/QtSql.pyi | 11 + .../test_QtSql_ParamType_ParamTypeFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py diff --git a/PyQt5-stubs/QtSql.pyi b/PyQt5-stubs/QtSql.pyi index 160fcf4e..fa9bf39a 100644 --- a/PyQt5-stubs/QtSql.pyi +++ b/PyQt5-stubs/QtSql.pyi @@ -715,6 +715,9 @@ class QSql(sip.simplewrapper): AllTables = ... # type: QSql.TableType class ParamTypeFlag(int): + def __or__ (self, other: 'QSql.ParamTypeFlag') -> 'QSql.ParamType': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSql.ParamType': ... # type: ignore[override, misc] + In = ... # type: QSql.ParamTypeFlag Out = ... # type: QSql.ParamTypeFlag InOut = ... # type: QSql.ParamTypeFlag @@ -740,9 +743,17 @@ class QSql(sip.simplewrapper): def __init__(self, f: typing.Union['QSql.ParamType', 'QSql.ParamTypeFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QSql.ParamType') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSql.ParamType': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSql.ParamType', 'QSql.ParamTypeFlag', int]) -> 'QSql.ParamType': ... + def __and__(self, other: typing.Union['QSql.ParamType', 'QSql.ParamTypeFlag', int]) -> 'QSql.ParamType': ... + def __xor__(self, other: typing.Union['QSql.ParamType', 'QSql.ParamTypeFlag', int]) -> 'QSql.ParamType': ... + def __ror__ (self, other: 'QSql.ParamTypeFlag') -> 'QSql.ParamType': ... + def __rand__(self, other: 'QSql.ParamTypeFlag') -> 'QSql.ParamType': ... + def __rxor__(self, other: 'QSql.ParamTypeFlag') -> 'QSql.ParamType': ... diff --git a/tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py b/tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py new file mode 100644 index 00000000..c6236bf9 --- /dev/null +++ b/tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSql.ParamType" and flag class "QSql.ParamTypeFlag" +from PyQt5 import QtSql + +OneFlagClass = QtSql.QSql.ParamTypeFlag +MultiFlagClass = QtSql.QSql.ParamType + +oneFlagRefValue1 = QtSql.QSql.ParamTypeFlag.In +oneFlagRefValue2 = QtSql.QSql.ParamTypeFlag.Out + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 09408e3688136f75581f7673a453d9878da65869 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:04:50 +0200 Subject: [PATCH 149/421] QFlag operations for QFileDialog.Options, QFileDialog.Option in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + tests/qflags/test_QtWidgets_Options_Option.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_Options_Option.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 8fd89835..29a507c4 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -3828,6 +3828,9 @@ class QErrorMessage(QDialog): class QFileDialog(QDialog): class Option(int): + def __or__ (self, other: 'QFileDialog.Option') -> 'QFileDialog.Options': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QFileDialog.Options': ... # type: ignore[override, misc] + ShowDirsOnly = ... # type: QFileDialog.Option DontResolveSymlinks = ... # type: QFileDialog.Option DontConfirmOverwrite = ... # type: QFileDialog.Option @@ -3894,12 +3897,20 @@ class QFileDialog(QDialog): def __init__(self, f: typing.Union['QFileDialog.Options', 'QFileDialog.Option']) -> None: ... @typing.overload def __init__(self, a0: 'QFileDialog.Options') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QFileDialog.Options': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QFileDialog.Options', 'QFileDialog.Option', int]) -> 'QFileDialog.Options': ... + def __and__(self, other: typing.Union['QFileDialog.Options', 'QFileDialog.Option', int]) -> 'QFileDialog.Options': ... + def __xor__(self, other: typing.Union['QFileDialog.Options', 'QFileDialog.Option', int]) -> 'QFileDialog.Options': ... + def __ror__ (self, other: 'QFileDialog.Option') -> 'QFileDialog.Options': ... + def __rand__(self, other: 'QFileDialog.Option') -> 'QFileDialog.Options': ... + def __rxor__(self, other: 'QFileDialog.Option') -> 'QFileDialog.Options': ... @typing.overload def __init__(self, parent: QWidget, f: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType]) -> None: ... diff --git a/tests/qflags/test_QtWidgets_Options_Option.py b/tests/qflags/test_QtWidgets_Options_Option.py new file mode 100644 index 00000000..f00ef520 --- /dev/null +++ b/tests/qflags/test_QtWidgets_Options_Option.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QFileDialog.Options" and flag class "QFileDialog.Option" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QFileDialog.Option +MultiFlagClass = QtWidgets.QFileDialog.Options + +oneFlagRefValue1 = QtWidgets.QFileDialog.Option.ShowDirsOnly +oneFlagRefValue2 = QtWidgets.QFileDialog.Option.DontResolveSymlinks + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 47576e1374b8d30518261c8bef4ce89960c12622 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:05:57 +0200 Subject: [PATCH 150/421] QFlag operations for QFileIconProvider.Options, QFileIconProvider.Option in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 +++++++++++ tests/qflags/test_QtWidgets_Options_Option.py | 10 +++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 29a507c4..f1087b85 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -4007,6 +4007,9 @@ class QFileDialog(QDialog): class QFileIconProvider(sip.simplewrapper): class Option(int): + def __or__ (self, other: 'QFileIconProvider.Option') -> 'QFileIconProvider.Options': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QFileIconProvider.Options': ... # type: ignore[override, misc] + DontUseCustomDirectoryIcons = ... # type: QFileIconProvider.Option DontUseCustomDirectoryIcons = ... # type: QFileIconProvider.Option @@ -4036,12 +4039,20 @@ class QFileIconProvider(sip.simplewrapper): def __init__(self, f: typing.Union['QFileIconProvider.Options', 'QFileIconProvider.Option']) -> None: ... @typing.overload def __init__(self, a0: 'QFileIconProvider.Options') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QFileIconProvider.Options': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QFileIconProvider.Options', 'QFileIconProvider.Option', int]) -> 'QFileIconProvider.Options': ... + def __and__(self, other: typing.Union['QFileIconProvider.Options', 'QFileIconProvider.Option', int]) -> 'QFileIconProvider.Options': ... + def __xor__(self, other: typing.Union['QFileIconProvider.Options', 'QFileIconProvider.Option', int]) -> 'QFileIconProvider.Options': ... + def __ror__ (self, other: 'QFileIconProvider.Option') -> 'QFileIconProvider.Options': ... + def __rand__(self, other: 'QFileIconProvider.Option') -> 'QFileIconProvider.Options': ... + def __rxor__(self, other: 'QFileIconProvider.Option') -> 'QFileIconProvider.Options': ... def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtWidgets_Options_Option.py b/tests/qflags/test_QtWidgets_Options_Option.py index f00ef520..63839b79 100644 --- a/tests/qflags/test_QtWidgets_Options_Option.py +++ b/tests/qflags/test_QtWidgets_Options_Option.py @@ -2,14 +2,14 @@ import pytest ### Specific part -# file generated from qflags_test_template.py for QFlags class "QFileDialog.Options" and flag class "QFileDialog.Option" +# file generated from qflags_test_template.py for QFlags class "QFileIconProvider.Options" and flag class "QFileIconProvider.Option" from PyQt5 import QtWidgets -OneFlagClass = QtWidgets.QFileDialog.Option -MultiFlagClass = QtWidgets.QFileDialog.Options +OneFlagClass = QtWidgets.QFileIconProvider.Option +MultiFlagClass = QtWidgets.QFileIconProvider.Options -oneFlagRefValue1 = QtWidgets.QFileDialog.Option.ShowDirsOnly -oneFlagRefValue2 = QtWidgets.QFileDialog.Option.DontResolveSymlinks +oneFlagRefValue1 = QtWidgets.QFileIconProvider.Option.DontUseCustomDirectoryIcons +oneFlagRefValue2 = QtWidgets.QFileIconProvider.Option.DontUseCustomDirectoryIcons OR_CONVERTS_TO_MULTI = True OR_INT_CONVERTS_TO_MULTI = False From 0e7e035ab34c4528542236402553f3e75b79ac27 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:07:03 +0200 Subject: [PATCH 151/421] QFlag operations for QFileSystemModel.Options, QFileSystemModel.Option in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 +++++++++++ tests/qflags/test_QtWidgets_Options_Option.py | 10 +++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index f1087b85..d1d4c1c2 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -4068,6 +4068,9 @@ class QFileIconProvider(sip.simplewrapper): class QFileSystemModel(QtCore.QAbstractItemModel): class Option(int): + def __or__ (self, other: 'QFileSystemModel.Option') -> 'QFileSystemModel.Options': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QFileSystemModel.Options': ... # type: ignore[override, misc] + DontWatchForChanges = ... # type: QFileSystemModel.Option DontResolveSymlinks = ... # type: QFileSystemModel.Option DontUseCustomDirectoryIcons = ... # type: QFileSystemModel.Option @@ -4095,12 +4098,20 @@ class QFileSystemModel(QtCore.QAbstractItemModel): def __init__(self, f: typing.Union['QFileSystemModel.Options', 'QFileSystemModel.Option']) -> None: ... @typing.overload def __init__(self, a0: 'QFileSystemModel.Options') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QFileSystemModel.Options': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QFileSystemModel.Options', 'QFileSystemModel.Option', int]) -> 'QFileSystemModel.Options': ... + def __and__(self, other: typing.Union['QFileSystemModel.Options', 'QFileSystemModel.Option', int]) -> 'QFileSystemModel.Options': ... + def __xor__(self, other: typing.Union['QFileSystemModel.Options', 'QFileSystemModel.Option', int]) -> 'QFileSystemModel.Options': ... + def __ror__ (self, other: 'QFileSystemModel.Option') -> 'QFileSystemModel.Options': ... + def __rand__(self, other: 'QFileSystemModel.Option') -> 'QFileSystemModel.Options': ... + def __rxor__(self, other: 'QFileSystemModel.Option') -> 'QFileSystemModel.Options': ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_Options_Option.py b/tests/qflags/test_QtWidgets_Options_Option.py index 63839b79..8ff1a357 100644 --- a/tests/qflags/test_QtWidgets_Options_Option.py +++ b/tests/qflags/test_QtWidgets_Options_Option.py @@ -2,14 +2,14 @@ import pytest ### Specific part -# file generated from qflags_test_template.py for QFlags class "QFileIconProvider.Options" and flag class "QFileIconProvider.Option" +# file generated from qflags_test_template.py for QFlags class "QFileSystemModel.Options" and flag class "QFileSystemModel.Option" from PyQt5 import QtWidgets -OneFlagClass = QtWidgets.QFileIconProvider.Option -MultiFlagClass = QtWidgets.QFileIconProvider.Options +OneFlagClass = QtWidgets.QFileSystemModel.Option +MultiFlagClass = QtWidgets.QFileSystemModel.Options -oneFlagRefValue1 = QtWidgets.QFileIconProvider.Option.DontUseCustomDirectoryIcons -oneFlagRefValue2 = QtWidgets.QFileIconProvider.Option.DontUseCustomDirectoryIcons +oneFlagRefValue1 = QtWidgets.QFileSystemModel.Option.DontWatchForChanges +oneFlagRefValue2 = QtWidgets.QFileSystemModel.Option.DontResolveSymlinks OR_CONVERTS_TO_MULTI = True OR_INT_CONVERTS_TO_MULTI = False From b2ec7b64d1e4b750c26ac955ac597fc51dee3522 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:08:47 +0200 Subject: [PATCH 152/421] QFlag operations for QGraphicsEffect.ChangeFlags, QGraphicsEffect.ChangeFlag in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../test_QtWidgets_ChangeFlags_ChangeFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index d1d4c1c2..147ad8db 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -4746,6 +4746,9 @@ class QGraphicsEffect(QtCore.QObject): PadToEffectiveBoundingRect = ... # type: QGraphicsEffect.PixmapPadMode class ChangeFlag(int): + def __or__ (self, other: 'QGraphicsEffect.ChangeFlag') -> 'QGraphicsEffect.ChangeFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGraphicsEffect.ChangeFlags': ... # type: ignore[override, misc] + SourceAttached = ... # type: QGraphicsEffect.ChangeFlag SourceDetached = ... # type: QGraphicsEffect.ChangeFlag SourceBoundingRectChanged = ... # type: QGraphicsEffect.ChangeFlag @@ -4764,12 +4767,20 @@ class QGraphicsEffect(QtCore.QObject): def __init__(self, f: typing.Union['QGraphicsEffect.ChangeFlags', 'QGraphicsEffect.ChangeFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QGraphicsEffect.ChangeFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGraphicsEffect.ChangeFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGraphicsEffect.ChangeFlags', 'QGraphicsEffect.ChangeFlag', int]) -> 'QGraphicsEffect.ChangeFlags': ... + def __and__(self, other: typing.Union['QGraphicsEffect.ChangeFlags', 'QGraphicsEffect.ChangeFlag', int]) -> 'QGraphicsEffect.ChangeFlags': ... + def __xor__(self, other: typing.Union['QGraphicsEffect.ChangeFlags', 'QGraphicsEffect.ChangeFlag', int]) -> 'QGraphicsEffect.ChangeFlags': ... + def __ror__ (self, other: 'QGraphicsEffect.ChangeFlag') -> 'QGraphicsEffect.ChangeFlags': ... + def __rand__(self, other: 'QGraphicsEffect.ChangeFlag') -> 'QGraphicsEffect.ChangeFlags': ... + def __rxor__(self, other: 'QGraphicsEffect.ChangeFlag') -> 'QGraphicsEffect.ChangeFlags': ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py b/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py new file mode 100644 index 00000000..10d43d3a --- /dev/null +++ b/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGraphicsEffect.ChangeFlags" and flag class "QGraphicsEffect.ChangeFlag" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QGraphicsEffect.ChangeFlag +MultiFlagClass = QtWidgets.QGraphicsEffect.ChangeFlags + +oneFlagRefValue1 = QtWidgets.QGraphicsEffect.ChangeFlag.SourceAttached +oneFlagRefValue2 = QtWidgets.QGraphicsEffect.ChangeFlag.SourceDetached + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 0ca37f7d258f63d9c20552ce843dbaadcb4534bd Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:09:58 +0200 Subject: [PATCH 153/421] QFlag operations for QGraphicsBlurEffect.BlurHints, QGraphicsBlurEffect.BlurHint in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../test_QtWidgets_BlurHints_BlurHint.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_BlurHints_BlurHint.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 147ad8db..a4633aff 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -4815,6 +4815,9 @@ class QGraphicsColorizeEffect(QGraphicsEffect): class QGraphicsBlurEffect(QGraphicsEffect): class BlurHint(int): + def __or__ (self, other: 'QGraphicsBlurEffect.BlurHint') -> 'QGraphicsBlurEffect.BlurHints': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGraphicsBlurEffect.BlurHints': ... # type: ignore[override, misc] + PerformanceHint = ... # type: QGraphicsBlurEffect.BlurHint QualityHint = ... # type: QGraphicsBlurEffect.BlurHint AnimationHint = ... # type: QGraphicsBlurEffect.BlurHint @@ -4831,12 +4834,20 @@ class QGraphicsBlurEffect(QGraphicsEffect): def __init__(self, f: typing.Union['QGraphicsBlurEffect.BlurHints', 'QGraphicsBlurEffect.BlurHint']) -> None: ... @typing.overload def __init__(self, a0: 'QGraphicsBlurEffect.BlurHints') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGraphicsBlurEffect.BlurHints': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGraphicsBlurEffect.BlurHints', 'QGraphicsBlurEffect.BlurHint', int]) -> 'QGraphicsBlurEffect.BlurHints': ... + def __and__(self, other: typing.Union['QGraphicsBlurEffect.BlurHints', 'QGraphicsBlurEffect.BlurHint', int]) -> 'QGraphicsBlurEffect.BlurHints': ... + def __xor__(self, other: typing.Union['QGraphicsBlurEffect.BlurHints', 'QGraphicsBlurEffect.BlurHint', int]) -> 'QGraphicsBlurEffect.BlurHints': ... + def __ror__ (self, other: 'QGraphicsBlurEffect.BlurHint') -> 'QGraphicsBlurEffect.BlurHints': ... + def __rand__(self, other: 'QGraphicsBlurEffect.BlurHint') -> 'QGraphicsBlurEffect.BlurHints': ... + def __rxor__(self, other: 'QGraphicsBlurEffect.BlurHint') -> 'QGraphicsBlurEffect.BlurHints': ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_BlurHints_BlurHint.py b/tests/qflags/test_QtWidgets_BlurHints_BlurHint.py new file mode 100644 index 00000000..9dfba3da --- /dev/null +++ b/tests/qflags/test_QtWidgets_BlurHints_BlurHint.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGraphicsBlurEffect.BlurHints" and flag class "QGraphicsBlurEffect.BlurHint" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QGraphicsBlurEffect.BlurHint +MultiFlagClass = QtWidgets.QGraphicsBlurEffect.BlurHints + +oneFlagRefValue1 = QtWidgets.QGraphicsBlurEffect.BlurHint.PerformanceHint +oneFlagRefValue2 = QtWidgets.QGraphicsBlurEffect.BlurHint.QualityHint + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 92a08340f742caadd0f467c47aa348d3cc02bbf7 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:11:05 +0200 Subject: [PATCH 154/421] QFlag operations for QInputDialog.InputDialogOptions, QInputDialog.InputDialogOption in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...ts_InputDialogOptions_InputDialogOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index a4633aff..3f24a2f6 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -6581,6 +6581,9 @@ class QInputDialog(QDialog): DoubleInput = ... # type: QInputDialog.InputMode class InputDialogOption(int): + def __or__ (self, other: 'QInputDialog.InputDialogOption') -> 'QInputDialog.InputDialogOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QInputDialog.InputDialogOptions': ... # type: ignore[override, misc] + NoButtons = ... # type: QInputDialog.InputDialogOption UseListViewForComboBoxItems = ... # type: QInputDialog.InputDialogOption UsePlainTextEditForTextInput = ... # type: QInputDialog.InputDialogOption @@ -6597,12 +6600,20 @@ class QInputDialog(QDialog): def __init__(self, f: typing.Union['QInputDialog.InputDialogOptions', 'QInputDialog.InputDialogOption']) -> None: ... @typing.overload def __init__(self, a0: 'QInputDialog.InputDialogOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QInputDialog.InputDialogOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QInputDialog.InputDialogOptions', 'QInputDialog.InputDialogOption', int]) -> 'QInputDialog.InputDialogOptions': ... + def __and__(self, other: typing.Union['QInputDialog.InputDialogOptions', 'QInputDialog.InputDialogOption', int]) -> 'QInputDialog.InputDialogOptions': ... + def __xor__(self, other: typing.Union['QInputDialog.InputDialogOptions', 'QInputDialog.InputDialogOption', int]) -> 'QInputDialog.InputDialogOptions': ... + def __ror__ (self, other: 'QInputDialog.InputDialogOption') -> 'QInputDialog.InputDialogOptions': ... + def __rand__(self, other: 'QInputDialog.InputDialogOption') -> 'QInputDialog.InputDialogOptions': ... + def __rxor__(self, other: 'QInputDialog.InputDialogOption') -> 'QInputDialog.InputDialogOptions': ... def __init__(self, parent: typing.Optional[QWidget] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py b/tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py new file mode 100644 index 00000000..0ef29d4b --- /dev/null +++ b/tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QInputDialog.InputDialogOptions" and flag class "QInputDialog.InputDialogOption" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QInputDialog.InputDialogOption +MultiFlagClass = QtWidgets.QInputDialog.InputDialogOptions + +oneFlagRefValue1 = QtWidgets.QInputDialog.InputDialogOption.NoButtons +oneFlagRefValue2 = QtWidgets.QInputDialog.InputDialogOption.UseListViewForComboBoxItems + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 3fab7aaf2a360bf9e25c03201473fa2158e3e823 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:12:07 +0200 Subject: [PATCH 155/421] QFlag operations for QWizard.WizardOptions, QWizard.WizardOption in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...st_QtWidgets_WizardOptions_WizardOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 3f24a2f6..0a58cd4e 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -11417,6 +11417,9 @@ class QWidgetAction(QAction): class QWizard(QDialog): class WizardOption(int): + def __or__ (self, other: 'QWizard.WizardOption') -> 'QWizard.WizardOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QWizard.WizardOptions': ... # type: ignore[override, misc] + IndependentPages = ... # type: QWizard.WizardOption IgnoreSubTitles = ... # type: QWizard.WizardOption ExtendedWatermarkPixmap = ... # type: QWizard.WizardOption @@ -11506,12 +11509,20 @@ class QWizard(QDialog): def __init__(self, f: typing.Union['QWizard.WizardOptions', 'QWizard.WizardOption']) -> None: ... @typing.overload def __init__(self, a0: 'QWizard.WizardOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QWizard.WizardOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QWizard.WizardOptions', 'QWizard.WizardOption', int]) -> 'QWizard.WizardOptions': ... + def __and__(self, other: typing.Union['QWizard.WizardOptions', 'QWizard.WizardOption', int]) -> 'QWizard.WizardOptions': ... + def __xor__(self, other: typing.Union['QWizard.WizardOptions', 'QWizard.WizardOption', int]) -> 'QWizard.WizardOptions': ... + def __ror__ (self, other: 'QWizard.WizardOption') -> 'QWizard.WizardOptions': ... + def __rand__(self, other: 'QWizard.WizardOption') -> 'QWizard.WizardOptions': ... + def __rxor__(self, other: 'QWizard.WizardOption') -> 'QWizard.WizardOptions': ... def __init__(self, parent: typing.Optional[QWidget] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py b/tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py new file mode 100644 index 00000000..6cd263b9 --- /dev/null +++ b/tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QWizard.WizardOptions" and flag class "QWizard.WizardOption" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QWizard.WizardOption +MultiFlagClass = QtWidgets.QWizard.WizardOptions + +oneFlagRefValue1 = QtWidgets.QWizard.WizardOption.IndependentPages +oneFlagRefValue2 = QtWidgets.QWizard.WizardOption.IgnoreSubTitles + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 768e4733dbd1defe183eb553b1c334a84ba7b8e4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:13:04 +0200 Subject: [PATCH 156/421] QFlag operations for QAbstractItemView.EditTriggers, QAbstractItemView.EditTrigger in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...test_QtWidgets_EditTriggers_EditTrigger.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 0a58cd4e..39ad1aa8 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -701,6 +701,9 @@ class QAbstractItemView(QAbstractScrollArea): PositionAtCenter = ... # type: QAbstractItemView.ScrollHint class EditTrigger(int): + def __or__ (self, other: 'QAbstractItemView.EditTrigger') -> 'QAbstractItemView.EditTriggers': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QAbstractItemView.EditTriggers': ... # type: ignore[override, misc] + NoEditTriggers = ... # type: QAbstractItemView.EditTrigger CurrentChanged = ... # type: QAbstractItemView.EditTrigger DoubleClicked = ... # type: QAbstractItemView.EditTrigger @@ -738,12 +741,20 @@ class QAbstractItemView(QAbstractScrollArea): def __init__(self, f: typing.Union['QAbstractItemView.EditTriggers', 'QAbstractItemView.EditTrigger']) -> None: ... @typing.overload def __init__(self, a0: 'QAbstractItemView.EditTriggers') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QAbstractItemView.EditTriggers': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QAbstractItemView.EditTriggers', 'QAbstractItemView.EditTrigger', int]) -> 'QAbstractItemView.EditTriggers': ... + def __and__(self, other: typing.Union['QAbstractItemView.EditTriggers', 'QAbstractItemView.EditTrigger', int]) -> 'QAbstractItemView.EditTriggers': ... + def __xor__(self, other: typing.Union['QAbstractItemView.EditTriggers', 'QAbstractItemView.EditTrigger', int]) -> 'QAbstractItemView.EditTriggers': ... + def __ror__ (self, other: 'QAbstractItemView.EditTrigger') -> 'QAbstractItemView.EditTriggers': ... + def __rand__(self, other: 'QAbstractItemView.EditTrigger') -> 'QAbstractItemView.EditTriggers': ... + def __rxor__(self, other: 'QAbstractItemView.EditTrigger') -> 'QAbstractItemView.EditTriggers': ... def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py b/tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py new file mode 100644 index 00000000..224c5e95 --- /dev/null +++ b/tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QAbstractItemView.EditTriggers" and flag class "QAbstractItemView.EditTrigger" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QAbstractItemView.EditTrigger +MultiFlagClass = QtWidgets.QAbstractItemView.EditTriggers + +oneFlagRefValue1 = QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers +oneFlagRefValue2 = QtWidgets.QAbstractItemView.EditTrigger.CurrentChanged + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From f32379dcb35ae1b47d4d2f76d53ee0ad4a331eb8 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:14:16 +0200 Subject: [PATCH 157/421] QFlag operations for QGraphicsItem.GraphicsItemFlags, QGraphicsItem.GraphicsItemFlag in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...gets_GraphicsItemFlags_GraphicsItemFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 39ad1aa8..edcd6e3a 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -4978,6 +4978,9 @@ class QGraphicsItem(sip.wrapper): SceneModal = ... # type: QGraphicsItem.PanelModality class GraphicsItemFlag(int): + def __or__ (self, other: 'QGraphicsItem.GraphicsItemFlag') -> 'QGraphicsItem.GraphicsItemFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGraphicsItem.GraphicsItemFlags': ... # type: ignore[override, misc] + ItemIsMovable = ... # type: QGraphicsItem.GraphicsItemFlag ItemIsSelectable = ... # type: QGraphicsItem.GraphicsItemFlag ItemIsFocusable = ... # type: QGraphicsItem.GraphicsItemFlag @@ -5102,12 +5105,20 @@ class QGraphicsItem(sip.wrapper): def __init__(self, f: typing.Union['QGraphicsItem.GraphicsItemFlags', 'QGraphicsItem.GraphicsItemFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QGraphicsItem.GraphicsItemFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGraphicsItem.GraphicsItemFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGraphicsItem.GraphicsItemFlags', 'QGraphicsItem.GraphicsItemFlag', int]) -> 'QGraphicsItem.GraphicsItemFlags': ... + def __and__(self, other: typing.Union['QGraphicsItem.GraphicsItemFlags', 'QGraphicsItem.GraphicsItemFlag', int]) -> 'QGraphicsItem.GraphicsItemFlags': ... + def __xor__(self, other: typing.Union['QGraphicsItem.GraphicsItemFlags', 'QGraphicsItem.GraphicsItemFlag', int]) -> 'QGraphicsItem.GraphicsItemFlags': ... + def __ror__ (self, other: 'QGraphicsItem.GraphicsItemFlag') -> 'QGraphicsItem.GraphicsItemFlags': ... + def __rand__(self, other: 'QGraphicsItem.GraphicsItemFlag') -> 'QGraphicsItem.GraphicsItemFlags': ... + def __rxor__(self, other: 'QGraphicsItem.GraphicsItemFlag') -> 'QGraphicsItem.GraphicsItemFlags': ... Type = ... # type: int UserType = ... # type: int diff --git a/tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py b/tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py new file mode 100644 index 00000000..d70277e9 --- /dev/null +++ b/tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGraphicsItem.GraphicsItemFlags" and flag class "QGraphicsItem.GraphicsItemFlag" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QGraphicsItem.GraphicsItemFlag +MultiFlagClass = QtWidgets.QGraphicsItem.GraphicsItemFlags + +oneFlagRefValue1 = QtWidgets.QGraphicsItem.GraphicsItemFlag.ItemIsMovable +oneFlagRefValue2 = QtWidgets.QGraphicsItem.GraphicsItemFlag.ItemIsSelectable + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 49e322490b55b82dca9e95a5027033dacedc1d4e Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:15:12 +0200 Subject: [PATCH 158/421] QFlag operations for QGestureRecognizer.Result, QGestureRecognizer.ResultFlag in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../test_QtWidgets_Result_ResultFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_Result_ResultFlag.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index edcd6e3a..932c48b1 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -4602,6 +4602,9 @@ class QGestureEvent(QtCore.QEvent): class QGestureRecognizer(sip.wrapper): class ResultFlag(int): + def __or__ (self, other: 'QGestureRecognizer.ResultFlag') -> 'QGestureRecognizer.Result': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGestureRecognizer.Result': ... # type: ignore[override, misc] + Ignore = ... # type: QGestureRecognizer.ResultFlag MayBeGesture = ... # type: QGestureRecognizer.ResultFlag TriggerGesture = ... # type: QGestureRecognizer.ResultFlag @@ -4624,12 +4627,20 @@ class QGestureRecognizer(sip.wrapper): def __init__(self, f: typing.Union['QGestureRecognizer.Result', 'QGestureRecognizer.ResultFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QGestureRecognizer.Result') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGestureRecognizer.Result': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGestureRecognizer.Result', 'QGestureRecognizer.ResultFlag', int]) -> 'QGestureRecognizer.Result': ... + def __and__(self, other: typing.Union['QGestureRecognizer.Result', 'QGestureRecognizer.ResultFlag', int]) -> 'QGestureRecognizer.Result': ... + def __xor__(self, other: typing.Union['QGestureRecognizer.Result', 'QGestureRecognizer.ResultFlag', int]) -> 'QGestureRecognizer.Result': ... + def __ror__ (self, other: 'QGestureRecognizer.ResultFlag') -> 'QGestureRecognizer.Result': ... + def __rand__(self, other: 'QGestureRecognizer.ResultFlag') -> 'QGestureRecognizer.Result': ... + def __rxor__(self, other: 'QGestureRecognizer.ResultFlag') -> 'QGestureRecognizer.Result': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtWidgets_Result_ResultFlag.py b/tests/qflags/test_QtWidgets_Result_ResultFlag.py new file mode 100644 index 00000000..4a72efa2 --- /dev/null +++ b/tests/qflags/test_QtWidgets_Result_ResultFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGestureRecognizer.Result" and flag class "QGestureRecognizer.ResultFlag" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QGestureRecognizer.ResultFlag +MultiFlagClass = QtWidgets.QGestureRecognizer.Result + +oneFlagRefValue1 = QtWidgets.QGestureRecognizer.ResultFlag.Ignore +oneFlagRefValue2 = QtWidgets.QGestureRecognizer.ResultFlag.MayBeGesture + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 3d35da7ea7b15f8d3a10d904ab85fc0daeeee52a Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 11:16:07 +0200 Subject: [PATCH 159/421] QFlag operations for QGraphicsScene.SceneLayers, QGraphicsScene.SceneLayer in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../test_QtWidgets_SceneLayers_SceneLayer.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 932c48b1..350fb92e 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -5839,6 +5839,9 @@ class QGraphicsProxyWidget(QGraphicsWidget): class QGraphicsScene(QtCore.QObject): class SceneLayer(int): + def __or__ (self, other: 'QGraphicsScene.SceneLayer') -> 'QGraphicsScene.SceneLayers': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGraphicsScene.SceneLayers': ... # type: ignore[override, misc] + ItemLayer = ... # type: QGraphicsScene.SceneLayer BackgroundLayer = ... # type: QGraphicsScene.SceneLayer ForegroundLayer = ... # type: QGraphicsScene.SceneLayer @@ -5864,12 +5867,20 @@ class QGraphicsScene(QtCore.QObject): def __init__(self, f: typing.Union['QGraphicsScene.SceneLayers', 'QGraphicsScene.SceneLayer']) -> None: ... @typing.overload def __init__(self, a0: 'QGraphicsScene.SceneLayers') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGraphicsScene.SceneLayers': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGraphicsScene.SceneLayers', 'QGraphicsScene.SceneLayer', int]) -> 'QGraphicsScene.SceneLayers': ... + def __and__(self, other: typing.Union['QGraphicsScene.SceneLayers', 'QGraphicsScene.SceneLayer', int]) -> 'QGraphicsScene.SceneLayers': ... + def __xor__(self, other: typing.Union['QGraphicsScene.SceneLayers', 'QGraphicsScene.SceneLayer', int]) -> 'QGraphicsScene.SceneLayers': ... + def __ror__ (self, other: 'QGraphicsScene.SceneLayer') -> 'QGraphicsScene.SceneLayers': ... + def __rand__(self, other: 'QGraphicsScene.SceneLayer') -> 'QGraphicsScene.SceneLayers': ... + def __rxor__(self, other: 'QGraphicsScene.SceneLayer') -> 'QGraphicsScene.SceneLayers': ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py b/tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py new file mode 100644 index 00000000..d699c57a --- /dev/null +++ b/tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGraphicsScene.SceneLayers" and flag class "QGraphicsScene.SceneLayer" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QGraphicsScene.SceneLayer +MultiFlagClass = QtWidgets.QGraphicsScene.SceneLayers + +oneFlagRefValue1 = QtWidgets.QGraphicsScene.SceneLayer.ItemLayer +oneFlagRefValue2 = QtWidgets.QGraphicsScene.SceneLayer.BackgroundLayer + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 4d28b8bf44f3d1441ec9324c17c154d40b2d23b9 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Fri, 10 Sep 2021 11:01:22 -0400 Subject: [PATCH 160/421] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6352036e..21f3e367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * [#138](https://github.com/python-qt-tools/PyQt5-stubs/pull/138) update to PyQt5 5.15.3 * [#144](https://github.com/python-qt-tools/PyQt5-stubs/pull/144) add `QTreeWidgetItem.__lt__()` to allow sorting of items in a QTreeWidget +### Changed +* [#152](https://github.com/python-qt-tools/PyQt5-stubs/pull/152) `.__or__()` for `QDialogButtonBox.StandardButton` and `QDialogButtonBox.StandardButtons` + ## 5.15.2.0 ### Added From 241e67a49047dc606bd316b1f2815d74080cc23a Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Fri, 10 Sep 2021 11:08:18 -0400 Subject: [PATCH 161/421] update requirements/production.in to 5.15.* --- requirements/develop.txt | 4 ++-- requirements/production.in | 2 +- requirements/production.txt | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/requirements/develop.txt b/requirements/develop.txt index f129f3cb..b12fe1ef 100644 --- a/requirements/develop.txt +++ b/requirements/develop.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with python 3.9 # To update, run: # -# pip-compile --output-file=develop.txt requirements/develop.in +# pip-compile --output-file=requirements/develop.txt requirements/develop.in # attrs==21.2.0 # via pytest @@ -22,7 +22,7 @@ pyparsing==2.4.7 # via packaging pyqt5==5.14.2 # via -r requirements/production.txt -pyqt5-sip==12.7.0 +pyqt5-sip==12.9.0 # via # -r requirements/production.txt # pyqt5 diff --git a/requirements/production.in b/requirements/production.in index a5292533..927b7660 100644 --- a/requirements/production.in +++ b/requirements/production.in @@ -1 +1 @@ -PyQt5==5.14.* +PyQt5==5.15.* diff --git a/requirements/production.txt b/requirements/production.txt index 6b6d5ad9..c66b0197 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -2,9 +2,11 @@ # This file is autogenerated by pip-compile with python 3.9 # To update, run: # -# pip-compile --output-file=production.txt requirements/production.in +# pip-compile --output-file=requirements/production.txt requirements/production.in # -pyqt5==5.14.2 +pyqt5==5.15.4 # via -r requirements/production.in +pyqt5-qt5==5.15.2 + # via pyqt5 pyqt5-sip==12.9.0 # via pyqt5 From ae6f07a04216baa01f0fd47d34c298cf55d50bce Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Fri, 10 Sep 2021 11:48:39 -0400 Subject: [PATCH 162/421] Update CHANGELOG.md --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a586c39a..607226ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * [#138](https://github.com/python-qt-tools/PyQt5-stubs/pull/138) update to PyQt5 5.15.3 * [#144](https://github.com/python-qt-tools/PyQt5-stubs/pull/144) add `QTreeWidgetItem.__lt__()` to allow sorting of items in a QTreeWidget * [#143](https://github.com/python-qt-tools/PyQt5-stubs/pull/143) make `bytes(QByteArray())` valid by incorrectly adding `.__bytes__()` until a proper solution is developed upstream - -### Changed -* [#152](https://github.com/python-qt-tools/PyQt5-stubs/pull/152) `.__or__()` for `QDialogButtonBox.StandardButton` and `QDialogButtonBox.StandardButtons` +* [#152](https://github.com/python-qt-tools/PyQt5-stubs/pull/152) add `.__or__()` for `QDialogButtonBox.StandardButton` and `QDialogButtonBox.StandardButtons` +* [#156](https://github.com/python-qt-tools/PyQt5-stubs/pull/156) add operators to `QSize` and `QSizeF` ## 5.15.2.0 From 77d082b3b8eac4f9122cd926b1219e501e849730 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Fri, 10 Sep 2021 11:53:10 -0400 Subject: [PATCH 163/421] Correct QSize[F] __eq__ and __ne__ hints --- PyQt5-stubs/QtCore.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 781eeaab..9b3acaee 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -10366,12 +10366,12 @@ class QSize(sip.simplewrapper): def __init__(self, a0: 'QSize') -> None: ... def __add__(self, value: 'QSize') -> 'QSize': ... - def __eq__(self, value: 'QSize') -> 'QSize': ... + def __eq__(self, value: object) -> bool: ... def __iadd__(self, value: 'QSize') -> 'QSize': ... def __imul__(self, value: float) -> 'QSize': ... def __isub__(self, value: 'QSize') -> 'QSize': ... def __mul__(self, value: float) -> 'QSize': ... - def __ne__(self, value: 'QSize') -> 'QSize': ... + def __ne__(self, value: object) -> bool: ... def __sub__(self, value: 'QSize') -> 'QSize': ... def shrunkBy(self, m: QMargins) -> 'QSize': ... @@ -10411,12 +10411,12 @@ class QSizeF(sip.simplewrapper): def __init__(self, a0: 'QSizeF') -> None: ... def __add__(self, value: 'QSizeF') -> 'QSizeF': ... - def __eq__(self, value: 'QSizeF') -> 'QSizeF': ... + def __eq__(self, value: object) -> bool: ... def __iadd__(self, value: 'QSizeF') -> 'QSizeF': ... def __imul__(self, value: float) -> 'QSizeF': ... def __isub__(self, value: 'QSizeF') -> 'QSizeF': ... def __mul__(self, value: float) -> 'QSizeF': ... - def __ne__(self, value: 'QSizeF') -> 'QSizeF': ... + def __ne__(self, value: object) -> bool: ... def __sub__(self, value: 'QSizeF') -> 'QSizeF': ... def shrunkBy(self, m: QMarginsF) -> 'QSizeF': ... From d74989142871d369f56878b68b8b78b5b5c0f19e Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:28:15 +0200 Subject: [PATCH 164/421] Propagate the full class names to the final output --- tests/qflags/generate_qflags_stubs_and_tests.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index b31433c7..8c1b54fa 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -293,6 +293,7 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: # check that the qflag is actually in the module gen_result, error_msg, old_mod_content = generate_missing_stubs(flag_info) + flag_info_dict = dataclasses.asdict(flag_info) test_qflag_fname = gen_test_fname(flag_info) # Note that flag_info has been modified in-place with additional info: @@ -441,6 +442,13 @@ class not found, class found multiple times, ... flag_info.module_count, flag_info.module_idx) mod_cst.visit(visitor) + # storing the enum_values + full class name for further usage + flag_info.enum_full_class_name = visitor.enum_class_full_name + flag_info.enum_value1 = visitor.enum_value1 + flag_info.enum_value2 = visitor.enum_value2 + flag_info.qflag_full_class_name = visitor.qflag_class_full_name + + if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): return (QFlagGenResult.CodeAlreadyModified, visitor.error_msg, '') @@ -453,14 +461,6 @@ class not found, class found multiple times, ... if visitor.error_msg: return (QFlagGenResult.ErrorDuringProcessing, visitor.error_msg, '') - assert visitor.enum_methods_present == MethodPresent.Not - assert visitor.qflag_method_present == MethodPresent.Not - - # storing the enum_values for further usage - flag_info.enum_full_class_name = visitor.enum_class_full_name - flag_info.enum_value1 = visitor.enum_value1 - flag_info.enum_value2 = visitor.enum_value2 - flag_info.qflag_full_class_name = visitor.qflag_class_full_name log_progress('Found %s and %s' % (flag_info.qflag_full_class_name, flag_info.enum_full_class_name)) log_progress('Updating module %s by adding new methods' % flag_info.module_name) From 637dab760a021812b51686cbe87b2a78df3ca6c2 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:31:25 +0200 Subject: [PATCH 165/421] QFlag operations for QGraphicsView.OptimizationFlags, QGraphicsView.OptimizationFlag in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...gets_OptimizationFlags_OptimizationFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 350fb92e..544783ec 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -6168,6 +6168,9 @@ class QGraphicsRotation(QGraphicsTransform): class QGraphicsView(QAbstractScrollArea): class OptimizationFlag(int): + def __or__ (self, other: 'QGraphicsView.OptimizationFlag') -> 'QGraphicsView.OptimizationFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGraphicsView.OptimizationFlags': ... # type: ignore[override, misc] + DontClipPainter = ... # type: QGraphicsView.OptimizationFlag DontSavePainterState = ... # type: QGraphicsView.OptimizationFlag DontAdjustForAntialiasing = ... # type: QGraphicsView.OptimizationFlag @@ -6237,12 +6240,20 @@ class QGraphicsView(QAbstractScrollArea): def __init__(self, f: typing.Union['QGraphicsView.OptimizationFlags', 'QGraphicsView.OptimizationFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QGraphicsView.OptimizationFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGraphicsView.OptimizationFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGraphicsView.OptimizationFlags', 'QGraphicsView.OptimizationFlag', int]) -> 'QGraphicsView.OptimizationFlags': ... + def __and__(self, other: typing.Union['QGraphicsView.OptimizationFlags', 'QGraphicsView.OptimizationFlag', int]) -> 'QGraphicsView.OptimizationFlags': ... + def __xor__(self, other: typing.Union['QGraphicsView.OptimizationFlags', 'QGraphicsView.OptimizationFlag', int]) -> 'QGraphicsView.OptimizationFlags': ... + def __ror__ (self, other: 'QGraphicsView.OptimizationFlag') -> 'QGraphicsView.OptimizationFlags': ... + def __rand__(self, other: 'QGraphicsView.OptimizationFlag') -> 'QGraphicsView.OptimizationFlags': ... + def __rxor__(self, other: 'QGraphicsView.OptimizationFlag') -> 'QGraphicsView.OptimizationFlags': ... @typing.overload def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py b/tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py new file mode 100644 index 00000000..c93f625b --- /dev/null +++ b/tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGraphicsView.OptimizationFlags" and flag class "QGraphicsView.OptimizationFlag" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QGraphicsView.OptimizationFlag +MultiFlagClass = QtWidgets.QGraphicsView.OptimizationFlags + +oneFlagRefValue1 = QtWidgets.QGraphicsView.OptimizationFlag.DontClipPainter +oneFlagRefValue2 = QtWidgets.QGraphicsView.OptimizationFlag.DontSavePainterState + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 2d113a92aeb32a4f1c1be26c9b590e319cf14a4a Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:42:12 +0200 Subject: [PATCH 166/421] QFlag operations for QStyle.SubControls, QStyle.SubControl in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../test_QtWidgets_SubControls_SubControl.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_SubControls_SubControl.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 544783ec..b2b18ed1 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -2654,6 +2654,9 @@ class QStyle(QtCore.QObject): PM_CustomBase = ... # type: QStyle.PixelMetric class SubControl(int): + def __or__ (self, other: 'QStyle.SubControl') -> 'QStyle.SubControls': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QStyle.SubControls': ... # type: ignore[override, misc] + SC_None = ... # type: QStyle.SubControl SC_ScrollBarAddLine = ... # type: QStyle.SubControl SC_ScrollBarSubLine = ... # type: QStyle.SubControl @@ -3182,12 +3185,20 @@ class QStyle(QtCore.QObject): def __init__(self, f: typing.Union['QStyle.SubControls', 'QStyle.SubControl']) -> None: ... @typing.overload def __init__(self, a0: 'QStyle.SubControls') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QStyle.SubControls': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QStyle.SubControls', 'QStyle.SubControl', int]) -> 'QStyle.SubControls': ... + def __and__(self, other: typing.Union['QStyle.SubControls', 'QStyle.SubControl', int]) -> 'QStyle.SubControls': ... + def __xor__(self, other: typing.Union['QStyle.SubControls', 'QStyle.SubControl', int]) -> 'QStyle.SubControls': ... + def __ror__ (self, other: 'QStyle.SubControl') -> 'QStyle.SubControls': ... + def __rand__(self, other: 'QStyle.SubControl') -> 'QStyle.SubControls': ... + def __rxor__(self, other: 'QStyle.SubControl') -> 'QStyle.SubControls': ... def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtWidgets_SubControls_SubControl.py b/tests/qflags/test_QtWidgets_SubControls_SubControl.py new file mode 100644 index 00000000..69ef2a53 --- /dev/null +++ b/tests/qflags/test_QtWidgets_SubControls_SubControl.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QStyle.SubControls" and flag class "QStyle.SubControl" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QStyle.SubControl +MultiFlagClass = QtWidgets.QStyle.SubControls + +oneFlagRefValue1 = QtWidgets.QStyle.SubControl.SC_None +oneFlagRefValue2 = QtWidgets.QStyle.SubControl.SC_ScrollBarAddLine + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 55ab3a5af80d083a4b3ac20d7a21d0f25b06eab7 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:43:17 +0200 Subject: [PATCH 167/421] QFlag operations for QAbstractSpinBox.StepEnabled, QAbstractSpinBox.StepEnabledFlag in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...t_QtWidgets_StepEnabled_StepEnabledFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index b2b18ed1..8ab214e8 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -996,6 +996,9 @@ class QAbstractSpinBox(QWidget): NoButtons = ... # type: QAbstractSpinBox.ButtonSymbols class StepEnabledFlag(int): + def __or__ (self, other: 'QAbstractSpinBox.StepEnabledFlag') -> 'QAbstractSpinBox.StepEnabled': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QAbstractSpinBox.StepEnabled': ... # type: ignore[override, misc] + StepNone = ... # type: QAbstractSpinBox.StepEnabledFlag StepUpEnabled = ... # type: QAbstractSpinBox.StepEnabledFlag StepDownEnabled = ... # type: QAbstractSpinBox.StepEnabledFlag @@ -1012,12 +1015,20 @@ class QAbstractSpinBox(QWidget): def __init__(self, f: typing.Union['QAbstractSpinBox.StepEnabled', 'QAbstractSpinBox.StepEnabledFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QAbstractSpinBox.StepEnabled') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QAbstractSpinBox.StepEnabled': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QAbstractSpinBox.StepEnabled', 'QAbstractSpinBox.StepEnabledFlag', int]) -> 'QAbstractSpinBox.StepEnabled': ... + def __and__(self, other: typing.Union['QAbstractSpinBox.StepEnabled', 'QAbstractSpinBox.StepEnabledFlag', int]) -> 'QAbstractSpinBox.StepEnabled': ... + def __xor__(self, other: typing.Union['QAbstractSpinBox.StepEnabled', 'QAbstractSpinBox.StepEnabledFlag', int]) -> 'QAbstractSpinBox.StepEnabled': ... + def __ror__ (self, other: 'QAbstractSpinBox.StepEnabledFlag') -> 'QAbstractSpinBox.StepEnabled': ... + def __rand__(self, other: 'QAbstractSpinBox.StepEnabledFlag') -> 'QAbstractSpinBox.StepEnabled': ... + def __rxor__(self, other: 'QAbstractSpinBox.StepEnabledFlag') -> 'QAbstractSpinBox.StepEnabled': ... def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py b/tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py new file mode 100644 index 00000000..6af3957c --- /dev/null +++ b/tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QAbstractSpinBox.StepEnabled" and flag class "QAbstractSpinBox.StepEnabledFlag" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QAbstractSpinBox.StepEnabledFlag +MultiFlagClass = QtWidgets.QAbstractSpinBox.StepEnabled + +oneFlagRefValue1 = QtWidgets.QAbstractSpinBox.StepEnabledFlag.StepNone +oneFlagRefValue2 = QtWidgets.QAbstractSpinBox.StepEnabledFlag.StepUpEnabled + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 12fbeeea7839fd0401dd06c6b43643a77d74493a Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:44:16 +0200 Subject: [PATCH 168/421] QFlag operations for QStyleOptionFrame.FrameFeatures, QStyleOptionFrame.FrameFeature in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...st_QtWidgets_FrameFeatures_FrameFeature.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 8ab214e8..ec7cf7d0 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -9101,6 +9101,9 @@ class QStyleOptionFocusRect(QStyleOption): class QStyleOptionFrame(QStyleOption): class FrameFeature(int): + def __or__ (self, other: 'QStyleOptionFrame.FrameFeature') -> 'QStyleOptionFrame.FrameFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QStyleOptionFrame.FrameFeatures': ... # type: ignore[override, misc] + None_ = ... # type: QStyleOptionFrame.FrameFeature Flat = ... # type: QStyleOptionFrame.FrameFeature Rounded = ... # type: QStyleOptionFrame.FrameFeature @@ -9127,12 +9130,20 @@ class QStyleOptionFrame(QStyleOption): def __init__(self, f: typing.Union['QStyleOptionFrame.FrameFeatures', 'QStyleOptionFrame.FrameFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QStyleOptionFrame.FrameFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QStyleOptionFrame.FrameFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QStyleOptionFrame.FrameFeatures', 'QStyleOptionFrame.FrameFeature', int]) -> 'QStyleOptionFrame.FrameFeatures': ... + def __and__(self, other: typing.Union['QStyleOptionFrame.FrameFeatures', 'QStyleOptionFrame.FrameFeature', int]) -> 'QStyleOptionFrame.FrameFeatures': ... + def __xor__(self, other: typing.Union['QStyleOptionFrame.FrameFeatures', 'QStyleOptionFrame.FrameFeature', int]) -> 'QStyleOptionFrame.FrameFeatures': ... + def __ror__ (self, other: 'QStyleOptionFrame.FrameFeature') -> 'QStyleOptionFrame.FrameFeatures': ... + def __rand__(self, other: 'QStyleOptionFrame.FrameFeature') -> 'QStyleOptionFrame.FrameFeatures': ... + def __rxor__(self, other: 'QStyleOptionFrame.FrameFeature') -> 'QStyleOptionFrame.FrameFeatures': ... features = ... # type: typing.Union['QStyleOptionFrame.FrameFeatures', 'QStyleOptionFrame.FrameFeature'] frameShape = ... # type: QFrame.Shape diff --git a/tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py b/tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py new file mode 100644 index 00000000..bac73155 --- /dev/null +++ b/tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QStyleOptionFrame.FrameFeatures" and flag class "QStyleOptionFrame.FrameFeature" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QStyleOptionFrame.FrameFeature +MultiFlagClass = QtWidgets.QStyleOptionFrame.FrameFeatures + +oneFlagRefValue1 = QtWidgets.QStyleOptionFrame.FrameFeature.None_ +oneFlagRefValue2 = QtWidgets.QStyleOptionFrame.FrameFeature.Flat + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From c17832110467dff5685580c3ae1a10a5f12e6d13 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:45:25 +0200 Subject: [PATCH 169/421] QFlag operations for QStyleOptionButton.ButtonFeatures, QStyleOptionButton.ButtonFeature in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ..._QtWidgets_ButtonFeatures_ButtonFeature.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index ec7cf7d0..a3224151 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -9268,6 +9268,9 @@ class QStyleOptionHeader(QStyleOption): class QStyleOptionButton(QStyleOption): class ButtonFeature(int): + def __or__ (self, other: 'QStyleOptionButton.ButtonFeature') -> 'QStyleOptionButton.ButtonFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QStyleOptionButton.ButtonFeatures': ... # type: ignore[override, misc] + None_ = ... # type: QStyleOptionButton.ButtonFeature Flat = ... # type: QStyleOptionButton.ButtonFeature HasMenu = ... # type: QStyleOptionButton.ButtonFeature @@ -9300,12 +9303,20 @@ class QStyleOptionButton(QStyleOption): def __init__(self, f: typing.Union['QStyleOptionButton.ButtonFeatures', 'QStyleOptionButton.ButtonFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QStyleOptionButton.ButtonFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QStyleOptionButton.ButtonFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QStyleOptionButton.ButtonFeatures', 'QStyleOptionButton.ButtonFeature', int]) -> 'QStyleOptionButton.ButtonFeatures': ... + def __and__(self, other: typing.Union['QStyleOptionButton.ButtonFeatures', 'QStyleOptionButton.ButtonFeature', int]) -> 'QStyleOptionButton.ButtonFeatures': ... + def __xor__(self, other: typing.Union['QStyleOptionButton.ButtonFeatures', 'QStyleOptionButton.ButtonFeature', int]) -> 'QStyleOptionButton.ButtonFeatures': ... + def __ror__ (self, other: 'QStyleOptionButton.ButtonFeature') -> 'QStyleOptionButton.ButtonFeatures': ... + def __rand__(self, other: 'QStyleOptionButton.ButtonFeature') -> 'QStyleOptionButton.ButtonFeatures': ... + def __rxor__(self, other: 'QStyleOptionButton.ButtonFeature') -> 'QStyleOptionButton.ButtonFeatures': ... features = ... # type: typing.Union['QStyleOptionButton.ButtonFeatures', 'QStyleOptionButton.ButtonFeature'] icon = ... # type: QtGui.QIcon diff --git a/tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py b/tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py new file mode 100644 index 00000000..4c84f921 --- /dev/null +++ b/tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QStyleOptionButton.ButtonFeatures" and flag class "QStyleOptionButton.ButtonFeature" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QStyleOptionButton.ButtonFeature +MultiFlagClass = QtWidgets.QStyleOptionButton.ButtonFeatures + +oneFlagRefValue1 = QtWidgets.QStyleOptionButton.ButtonFeature.None_ +oneFlagRefValue2 = QtWidgets.QStyleOptionButton.ButtonFeature.Flat + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 449ae036d86a89e90af2470846bed679b3915d9b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:46:35 +0200 Subject: [PATCH 170/421] QFlag operations for QStyleOptionTab.CornerWidgets, QStyleOptionTab.CornerWidget in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...st_QtWidgets_CornerWidgets_CornerWidget.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index a3224151..6222efbc 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -9339,6 +9339,9 @@ class QStyleOptionTab(QStyleOption): HasFrame = ... # type: QStyleOptionTab.TabFeature class CornerWidget(int): + def __or__ (self, other: 'QStyleOptionTab.CornerWidget') -> 'QStyleOptionTab.CornerWidgets': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QStyleOptionTab.CornerWidgets': ... # type: ignore[override, misc] + NoCornerWidgets = ... # type: QStyleOptionTab.CornerWidget LeftCornerWidget = ... # type: QStyleOptionTab.CornerWidget RightCornerWidget = ... # type: QStyleOptionTab.CornerWidget @@ -9385,12 +9388,20 @@ class QStyleOptionTab(QStyleOption): def __init__(self, f: typing.Union['QStyleOptionTab.CornerWidgets', 'QStyleOptionTab.CornerWidget']) -> None: ... @typing.overload def __init__(self, a0: 'QStyleOptionTab.CornerWidgets') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QStyleOptionTab.CornerWidgets': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QStyleOptionTab.CornerWidgets', 'QStyleOptionTab.CornerWidget', int]) -> 'QStyleOptionTab.CornerWidgets': ... + def __and__(self, other: typing.Union['QStyleOptionTab.CornerWidgets', 'QStyleOptionTab.CornerWidget', int]) -> 'QStyleOptionTab.CornerWidgets': ... + def __xor__(self, other: typing.Union['QStyleOptionTab.CornerWidgets', 'QStyleOptionTab.CornerWidget', int]) -> 'QStyleOptionTab.CornerWidgets': ... + def __ror__ (self, other: 'QStyleOptionTab.CornerWidget') -> 'QStyleOptionTab.CornerWidgets': ... + def __rand__(self, other: 'QStyleOptionTab.CornerWidget') -> 'QStyleOptionTab.CornerWidgets': ... + def __rxor__(self, other: 'QStyleOptionTab.CornerWidget') -> 'QStyleOptionTab.CornerWidgets': ... class TabFeatures(sip.simplewrapper): diff --git a/tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py b/tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py new file mode 100644 index 00000000..8492b9ff --- /dev/null +++ b/tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QStyleOptionTab.CornerWidgets" and flag class "QStyleOptionTab.CornerWidget" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QStyleOptionTab.CornerWidget +MultiFlagClass = QtWidgets.QStyleOptionTab.CornerWidgets + +oneFlagRefValue1 = QtWidgets.QStyleOptionTab.CornerWidget.NoCornerWidgets +oneFlagRefValue2 = QtWidgets.QStyleOptionTab.CornerWidget.LeftCornerWidget + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 27f19689a5b13d50d354b26ec1ca7b6459e05e88 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:48:31 +0200 Subject: [PATCH 171/421] QFlag operations for QStyleOptionToolBar.ToolBarFeatures, QStyleOptionToolBar.ToolBarFeature in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...tWidgets_ToolBarFeatures_ToolBarFeature.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 6222efbc..840be168 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -9946,6 +9946,9 @@ class QStyleHintReturnMask(QStyleHintReturn): class QStyleOptionToolBar(QStyleOption): class ToolBarFeature(int): + def __or__ (self, other: 'QStyleOptionToolBar.ToolBarFeature') -> 'QStyleOptionToolBar.ToolBarFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QStyleOptionToolBar.ToolBarFeatures': ... # type: ignore[override, misc] + None_ = ... # type: QStyleOptionToolBar.ToolBarFeature Movable = ... # type: QStyleOptionToolBar.ToolBarFeature @@ -9981,12 +9984,20 @@ class QStyleOptionToolBar(QStyleOption): def __init__(self, f: typing.Union['QStyleOptionToolBar.ToolBarFeatures', 'QStyleOptionToolBar.ToolBarFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QStyleOptionToolBar.ToolBarFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QStyleOptionToolBar.ToolBarFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QStyleOptionToolBar.ToolBarFeatures', 'QStyleOptionToolBar.ToolBarFeature', int]) -> 'QStyleOptionToolBar.ToolBarFeatures': ... + def __and__(self, other: typing.Union['QStyleOptionToolBar.ToolBarFeatures', 'QStyleOptionToolBar.ToolBarFeature', int]) -> 'QStyleOptionToolBar.ToolBarFeatures': ... + def __xor__(self, other: typing.Union['QStyleOptionToolBar.ToolBarFeatures', 'QStyleOptionToolBar.ToolBarFeature', int]) -> 'QStyleOptionToolBar.ToolBarFeatures': ... + def __ror__ (self, other: 'QStyleOptionToolBar.ToolBarFeature') -> 'QStyleOptionToolBar.ToolBarFeatures': ... + def __rand__(self, other: 'QStyleOptionToolBar.ToolBarFeature') -> 'QStyleOptionToolBar.ToolBarFeatures': ... + def __rxor__(self, other: 'QStyleOptionToolBar.ToolBarFeature') -> 'QStyleOptionToolBar.ToolBarFeatures': ... features = ... # type: typing.Union['QStyleOptionToolBar.ToolBarFeatures', 'QStyleOptionToolBar.ToolBarFeature'] lineWidth = ... # type: int diff --git a/tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py b/tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py new file mode 100644 index 00000000..2410a89f --- /dev/null +++ b/tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QStyleOptionToolBar.ToolBarFeatures" and flag class "QStyleOptionToolBar.ToolBarFeature" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QStyleOptionToolBar.ToolBarFeature +MultiFlagClass = QtWidgets.QStyleOptionToolBar.ToolBarFeatures + +oneFlagRefValue1 = QtWidgets.QStyleOptionToolBar.ToolBarFeature.None_ +oneFlagRefValue2 = QtWidgets.QStyleOptionToolBar.ToolBarFeature.Movable + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 102ac89fb8cdbff68f8f6c381313c0ba4eda2d1d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:49:47 +0200 Subject: [PATCH 172/421] QFlag operations for QStyleOptionViewItem.ViewItemFeatures, QStyleOptionViewItem.ViewItemFeature in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...idgets_ViewItemFeatures_ViewItemFeature.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 840be168..912cf1a7 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -9577,6 +9577,9 @@ class QStyleOptionViewItem(QStyleOption): OnlyOne = ... # type: QStyleOptionViewItem.ViewItemPosition class ViewItemFeature(int): + def __or__ (self, other: 'QStyleOptionViewItem.ViewItemFeature') -> 'QStyleOptionViewItem.ViewItemFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QStyleOptionViewItem.ViewItemFeatures': ... # type: ignore[override, misc] + None_ = ... # type: QStyleOptionViewItem.ViewItemFeature WrapText = ... # type: QStyleOptionViewItem.ViewItemFeature Alternate = ... # type: QStyleOptionViewItem.ViewItemFeature @@ -9620,12 +9623,20 @@ class QStyleOptionViewItem(QStyleOption): def __init__(self, f: typing.Union['QStyleOptionViewItem.ViewItemFeatures', 'QStyleOptionViewItem.ViewItemFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QStyleOptionViewItem.ViewItemFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QStyleOptionViewItem.ViewItemFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QStyleOptionViewItem.ViewItemFeatures', 'QStyleOptionViewItem.ViewItemFeature', int]) -> 'QStyleOptionViewItem.ViewItemFeatures': ... + def __and__(self, other: typing.Union['QStyleOptionViewItem.ViewItemFeatures', 'QStyleOptionViewItem.ViewItemFeature', int]) -> 'QStyleOptionViewItem.ViewItemFeatures': ... + def __xor__(self, other: typing.Union['QStyleOptionViewItem.ViewItemFeatures', 'QStyleOptionViewItem.ViewItemFeature', int]) -> 'QStyleOptionViewItem.ViewItemFeatures': ... + def __ror__ (self, other: 'QStyleOptionViewItem.ViewItemFeature') -> 'QStyleOptionViewItem.ViewItemFeatures': ... + def __rand__(self, other: 'QStyleOptionViewItem.ViewItemFeature') -> 'QStyleOptionViewItem.ViewItemFeatures': ... + def __rxor__(self, other: 'QStyleOptionViewItem.ViewItemFeature') -> 'QStyleOptionViewItem.ViewItemFeatures': ... backgroundBrush = ... # type: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient] checkState = ... # type: QtCore.Qt.CheckState diff --git a/tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py b/tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py new file mode 100644 index 00000000..22051315 --- /dev/null +++ b/tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QStyleOptionViewItem.ViewItemFeatures" and flag class "QStyleOptionViewItem.ViewItemFeature" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QStyleOptionViewItem.ViewItemFeature +MultiFlagClass = QtWidgets.QStyleOptionViewItem.ViewItemFeatures + +oneFlagRefValue1 = QtWidgets.QStyleOptionViewItem.ViewItemFeature.None_ +oneFlagRefValue2 = QtWidgets.QStyleOptionViewItem.ViewItemFeature.WrapText + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From ce9e30056e21f23b01352575c7ec0a82c116c984 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:52:08 +0200 Subject: [PATCH 173/421] QFlag operations for QStyleOptionToolButton.ToolButtonFeatures, QStyleOptionToolButton.ToolButtonFeature in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...ts_ToolButtonFeatures_ToolButtonFeature.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 912cf1a7..a7ff70a4 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -9802,6 +9802,9 @@ class QStyleOptionSpinBox(QStyleOptionComplex): class QStyleOptionToolButton(QStyleOptionComplex): class ToolButtonFeature(int): + def __or__ (self, other: 'QStyleOptionToolButton.ToolButtonFeature') -> 'QStyleOptionToolButton.ToolButtonFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QStyleOptionToolButton.ToolButtonFeatures': ... # type: ignore[override, misc] + None_ = ... # type: QStyleOptionToolButton.ToolButtonFeature Arrow = ... # type: QStyleOptionToolButton.ToolButtonFeature Menu = ... # type: QStyleOptionToolButton.ToolButtonFeature @@ -9834,12 +9837,20 @@ class QStyleOptionToolButton(QStyleOptionComplex): def __init__(self, f: typing.Union['QStyleOptionToolButton.ToolButtonFeatures', 'QStyleOptionToolButton.ToolButtonFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QStyleOptionToolButton.ToolButtonFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QStyleOptionToolButton.ToolButtonFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QStyleOptionToolButton.ToolButtonFeatures', 'QStyleOptionToolButton.ToolButtonFeature', int]) -> 'QStyleOptionToolButton.ToolButtonFeatures': ... + def __and__(self, other: typing.Union['QStyleOptionToolButton.ToolButtonFeatures', 'QStyleOptionToolButton.ToolButtonFeature', int]) -> 'QStyleOptionToolButton.ToolButtonFeatures': ... + def __xor__(self, other: typing.Union['QStyleOptionToolButton.ToolButtonFeatures', 'QStyleOptionToolButton.ToolButtonFeature', int]) -> 'QStyleOptionToolButton.ToolButtonFeatures': ... + def __ror__ (self, other: 'QStyleOptionToolButton.ToolButtonFeature') -> 'QStyleOptionToolButton.ToolButtonFeatures': ... + def __rand__(self, other: 'QStyleOptionToolButton.ToolButtonFeature') -> 'QStyleOptionToolButton.ToolButtonFeatures': ... + def __rxor__(self, other: 'QStyleOptionToolButton.ToolButtonFeature') -> 'QStyleOptionToolButton.ToolButtonFeatures': ... arrowType = ... # type: QtCore.Qt.ArrowType features = ... # type: typing.Union['QStyleOptionToolButton.ToolButtonFeatures', 'QStyleOptionToolButton.ToolButtonFeature'] diff --git a/tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py b/tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py new file mode 100644 index 00000000..c9d46645 --- /dev/null +++ b/tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QStyleOptionToolButton.ToolButtonFeatures" and flag class "QStyleOptionToolButton.ToolButtonFeature" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QStyleOptionToolButton.ToolButtonFeature +MultiFlagClass = QtWidgets.QStyleOptionToolButton.ToolButtonFeatures + +oneFlagRefValue1 = QtWidgets.QStyleOptionToolButton.ToolButtonFeature.None_ +oneFlagRefValue2 = QtWidgets.QStyleOptionToolButton.ToolButtonFeature.Arrow + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From e237a24451217d683b541c42fff8531bd9fc2e54 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:53:16 +0200 Subject: [PATCH 174/421] QFlag operations for QDockWidget.DockWidgetFeatures, QDockWidget.DockWidgetFeature in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...ts_DockWidgetFeatures_DockWidgetFeature.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index a7ff70a4..9157f5ab 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -3786,6 +3786,9 @@ class QDirModel(QtCore.QAbstractItemModel): class QDockWidget(QWidget): class DockWidgetFeature(int): + def __or__ (self, other: 'QDockWidget.DockWidgetFeature') -> 'QDockWidget.DockWidgetFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QDockWidget.DockWidgetFeatures': ... # type: ignore[override, misc] + DockWidgetClosable = ... # type: QDockWidget.DockWidgetFeature DockWidgetMovable = ... # type: QDockWidget.DockWidgetFeature DockWidgetFloatable = ... # type: QDockWidget.DockWidgetFeature @@ -3808,12 +3811,20 @@ class QDockWidget(QWidget): def __init__(self, f: typing.Union['QDockWidget.DockWidgetFeatures', 'QDockWidget.DockWidgetFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QDockWidget.DockWidgetFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QDockWidget.DockWidgetFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QDockWidget.DockWidgetFeatures', 'QDockWidget.DockWidgetFeature', int]) -> 'QDockWidget.DockWidgetFeatures': ... + def __and__(self, other: typing.Union['QDockWidget.DockWidgetFeatures', 'QDockWidget.DockWidgetFeature', int]) -> 'QDockWidget.DockWidgetFeatures': ... + def __xor__(self, other: typing.Union['QDockWidget.DockWidgetFeatures', 'QDockWidget.DockWidgetFeature', int]) -> 'QDockWidget.DockWidgetFeatures': ... + def __ror__ (self, other: 'QDockWidget.DockWidgetFeature') -> 'QDockWidget.DockWidgetFeatures': ... + def __rand__(self, other: 'QDockWidget.DockWidgetFeature') -> 'QDockWidget.DockWidgetFeatures': ... + def __rxor__(self, other: 'QDockWidget.DockWidgetFeature') -> 'QDockWidget.DockWidgetFeatures': ... @typing.overload def __init__(self, title: str, parent: typing.Optional[QWidget] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py b/tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py new file mode 100644 index 00000000..5f941f67 --- /dev/null +++ b/tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QDockWidget.DockWidgetFeatures" and flag class "QDockWidget.DockWidgetFeature" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QDockWidget.DockWidgetFeature +MultiFlagClass = QtWidgets.QDockWidget.DockWidgetFeatures + +oneFlagRefValue1 = QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetClosable +oneFlagRefValue2 = QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From e91147a05bd34bd3a33104661b41c28a2922ad98 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:54:18 +0200 Subject: [PATCH 175/421] QFlag operations for QFontComboBox.FontFilters, QFontComboBox.FontFilter in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../test_QtWidgets_FontFilters_FontFilter.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_FontFilters_FontFilter.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 9157f5ab..e8b15ae0 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -4233,6 +4233,9 @@ class QFocusFrame(QWidget): class QFontComboBox(QComboBox): class FontFilter(int): + def __or__ (self, other: 'QFontComboBox.FontFilter') -> 'QFontComboBox.FontFilters': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QFontComboBox.FontFilters': ... # type: ignore[override, misc] + AllFonts = ... # type: QFontComboBox.FontFilter ScalableFonts = ... # type: QFontComboBox.FontFilter NonScalableFonts = ... # type: QFontComboBox.FontFilter @@ -4253,12 +4256,20 @@ class QFontComboBox(QComboBox): def __init__(self, f: typing.Union['QFontComboBox.FontFilters', 'QFontComboBox.FontFilter']) -> None: ... @typing.overload def __init__(self, a0: 'QFontComboBox.FontFilters') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QFontComboBox.FontFilters': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QFontComboBox.FontFilters', 'QFontComboBox.FontFilter', int]) -> 'QFontComboBox.FontFilters': ... + def __and__(self, other: typing.Union['QFontComboBox.FontFilters', 'QFontComboBox.FontFilter', int]) -> 'QFontComboBox.FontFilters': ... + def __xor__(self, other: typing.Union['QFontComboBox.FontFilters', 'QFontComboBox.FontFilter', int]) -> 'QFontComboBox.FontFilters': ... + def __ror__ (self, other: 'QFontComboBox.FontFilter') -> 'QFontComboBox.FontFilters': ... + def __rand__(self, other: 'QFontComboBox.FontFilter') -> 'QFontComboBox.FontFilters': ... + def __rxor__(self, other: 'QFontComboBox.FontFilter') -> 'QFontComboBox.FontFilters': ... def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_FontFilters_FontFilter.py b/tests/qflags/test_QtWidgets_FontFilters_FontFilter.py new file mode 100644 index 00000000..f706786d --- /dev/null +++ b/tests/qflags/test_QtWidgets_FontFilters_FontFilter.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QFontComboBox.FontFilters" and flag class "QFontComboBox.FontFilter" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QFontComboBox.FontFilter +MultiFlagClass = QtWidgets.QFontComboBox.FontFilters + +oneFlagRefValue1 = QtWidgets.QFontComboBox.FontFilter.AllFonts +oneFlagRefValue2 = QtWidgets.QFontComboBox.FontFilter.ScalableFonts + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 46128642ccf01b0de7769db0bac64ff2d2d0efd0 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:55:19 +0200 Subject: [PATCH 176/421] QFlag operations for QMdiArea.AreaOptions, QMdiArea.AreaOption in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../test_QtWidgets_AreaOptions_AreaOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index e8b15ae0..d39caa48 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -7503,6 +7503,9 @@ class QMdiArea(QAbstractScrollArea): TabbedView = ... # type: QMdiArea.ViewMode class AreaOption(int): + def __or__ (self, other: 'QMdiArea.AreaOption') -> 'QMdiArea.AreaOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QMdiArea.AreaOptions': ... # type: ignore[override, misc] + DontMaximizeSubWindowOnActivation = ... # type: QMdiArea.AreaOption DontMaximizeSubWindowOnActivation = ... # type: QMdiArea.AreaOption @@ -7515,12 +7518,20 @@ class QMdiArea(QAbstractScrollArea): def __init__(self, f: typing.Union['QMdiArea.AreaOptions', 'QMdiArea.AreaOption']) -> None: ... @typing.overload def __init__(self, a0: 'QMdiArea.AreaOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QMdiArea.AreaOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QMdiArea.AreaOptions', 'QMdiArea.AreaOption', int]) -> 'QMdiArea.AreaOptions': ... + def __and__(self, other: typing.Union['QMdiArea.AreaOptions', 'QMdiArea.AreaOption', int]) -> 'QMdiArea.AreaOptions': ... + def __xor__(self, other: typing.Union['QMdiArea.AreaOptions', 'QMdiArea.AreaOption', int]) -> 'QMdiArea.AreaOptions': ... + def __ror__ (self, other: 'QMdiArea.AreaOption') -> 'QMdiArea.AreaOptions': ... + def __rand__(self, other: 'QMdiArea.AreaOption') -> 'QMdiArea.AreaOptions': ... + def __rxor__(self, other: 'QMdiArea.AreaOption') -> 'QMdiArea.AreaOptions': ... def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py b/tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py new file mode 100644 index 00000000..c7d56011 --- /dev/null +++ b/tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QMdiArea.AreaOptions" and flag class "QMdiArea.AreaOption" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QMdiArea.AreaOption +MultiFlagClass = QtWidgets.QMdiArea.AreaOptions + +oneFlagRefValue1 = QtWidgets.QMdiArea.AreaOption.DontMaximizeSubWindowOnActivation +oneFlagRefValue2 = QtWidgets.QMdiArea.AreaOption.DontMaximizeSubWindowOnActivation + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 6ec65724b9ea875fcde2a96db6c6775b0ca6fddb Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:56:22 +0200 Subject: [PATCH 177/421] QFlag operations for QMdiSubWindow.SubWindowOptions, QMdiSubWindow.SubWindowOption in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...idgets_SubWindowOptions_SubWindowOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index d39caa48..6fe321d6 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -7583,6 +7583,9 @@ class QMdiArea(QAbstractScrollArea): class QMdiSubWindow(QWidget): class SubWindowOption(int): + def __or__ (self, other: 'QMdiSubWindow.SubWindowOption') -> 'QMdiSubWindow.SubWindowOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QMdiSubWindow.SubWindowOptions': ... # type: ignore[override, misc] + RubberBandResize = ... # type: QMdiSubWindow.SubWindowOption RubberBandMove = ... # type: QMdiSubWindow.SubWindowOption @@ -7597,12 +7600,20 @@ class QMdiSubWindow(QWidget): def __init__(self, f: typing.Union['QMdiSubWindow.SubWindowOptions', 'QMdiSubWindow.SubWindowOption']) -> None: ... @typing.overload def __init__(self, a0: 'QMdiSubWindow.SubWindowOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QMdiSubWindow.SubWindowOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QMdiSubWindow.SubWindowOptions', 'QMdiSubWindow.SubWindowOption', int]) -> 'QMdiSubWindow.SubWindowOptions': ... + def __and__(self, other: typing.Union['QMdiSubWindow.SubWindowOptions', 'QMdiSubWindow.SubWindowOption', int]) -> 'QMdiSubWindow.SubWindowOptions': ... + def __xor__(self, other: typing.Union['QMdiSubWindow.SubWindowOptions', 'QMdiSubWindow.SubWindowOption', int]) -> 'QMdiSubWindow.SubWindowOptions': ... + def __ror__ (self, other: 'QMdiSubWindow.SubWindowOption') -> 'QMdiSubWindow.SubWindowOptions': ... + def __rand__(self, other: 'QMdiSubWindow.SubWindowOption') -> 'QMdiSubWindow.SubWindowOptions': ... + def __rxor__(self, other: 'QMdiSubWindow.SubWindowOption') -> 'QMdiSubWindow.SubWindowOptions': ... def __init__(self, parent: typing.Optional[QWidget] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py b/tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py new file mode 100644 index 00000000..cf227eb4 --- /dev/null +++ b/tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QMdiSubWindow.SubWindowOptions" and flag class "QMdiSubWindow.SubWindowOption" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QMdiSubWindow.SubWindowOption +MultiFlagClass = QtWidgets.QMdiSubWindow.SubWindowOptions + +oneFlagRefValue1 = QtWidgets.QMdiSubWindow.SubWindowOption.RubberBandResize +oneFlagRefValue2 = QtWidgets.QMdiSubWindow.SubWindowOption.RubberBandMove + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 28631ec1f5aeb3f71352c81edb331b3cbe26e24e Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:57:23 +0200 Subject: [PATCH 178/421] QFlag operations for QMainWindow.DockOptions, QMainWindow.DockOption in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../test_QtWidgets_DockOptions_DockOption.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_DockOptions_DockOption.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 6fe321d6..16534ac1 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -7389,6 +7389,9 @@ class QListWidget(QListView): class QMainWindow(QWidget): class DockOption(int): + def __or__ (self, other: 'QMainWindow.DockOption') -> 'QMainWindow.DockOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QMainWindow.DockOptions': ... # type: ignore[override, misc] + AnimatedDocks = ... # type: QMainWindow.DockOption AllowNestedDocks = ... # type: QMainWindow.DockOption AllowTabbedDocks = ... # type: QMainWindow.DockOption @@ -7411,12 +7414,20 @@ class QMainWindow(QWidget): def __init__(self, f: typing.Union['QMainWindow.DockOptions', 'QMainWindow.DockOption']) -> None: ... @typing.overload def __init__(self, a0: 'QMainWindow.DockOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QMainWindow.DockOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QMainWindow.DockOptions', 'QMainWindow.DockOption', int]) -> 'QMainWindow.DockOptions': ... + def __and__(self, other: typing.Union['QMainWindow.DockOptions', 'QMainWindow.DockOption', int]) -> 'QMainWindow.DockOptions': ... + def __xor__(self, other: typing.Union['QMainWindow.DockOptions', 'QMainWindow.DockOption', int]) -> 'QMainWindow.DockOptions': ... + def __ror__ (self, other: 'QMainWindow.DockOption') -> 'QMainWindow.DockOptions': ... + def __rand__(self, other: 'QMainWindow.DockOption') -> 'QMainWindow.DockOptions': ... + def __rxor__(self, other: 'QMainWindow.DockOption') -> 'QMainWindow.DockOptions': ... def __init__(self, parent: typing.Optional[QWidget] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_DockOptions_DockOption.py b/tests/qflags/test_QtWidgets_DockOptions_DockOption.py new file mode 100644 index 00000000..ef8704fb --- /dev/null +++ b/tests/qflags/test_QtWidgets_DockOptions_DockOption.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QMainWindow.DockOptions" and flag class "QMainWindow.DockOption" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QMainWindow.DockOption +MultiFlagClass = QtWidgets.QMainWindow.DockOptions + +oneFlagRefValue1 = QtWidgets.QMainWindow.DockOption.AnimatedDocks +oneFlagRefValue2 = QtWidgets.QMainWindow.DockOption.AllowNestedDocks + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 3ce0e9a255fa9e86c94db7f4783ba933822d9ea2 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 10 Sep 2021 18:58:36 +0200 Subject: [PATCH 179/421] QFlag operations for QTextEdit.AutoFormatting, QTextEdit.AutoFormattingFlag in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + ...dgets_AutoFormatting_AutoFormattingFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 16534ac1..717d0c4c 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -10721,6 +10721,9 @@ class QTabWidget(QWidget): class QTextEdit(QAbstractScrollArea): class AutoFormattingFlag(int): + def __or__ (self, other: 'QTextEdit.AutoFormattingFlag') -> 'QTextEdit.AutoFormatting': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QTextEdit.AutoFormatting': ... # type: ignore[override, misc] + AutoNone = ... # type: QTextEdit.AutoFormattingFlag AutoBulletList = ... # type: QTextEdit.AutoFormattingFlag AutoAll = ... # type: QTextEdit.AutoFormattingFlag @@ -10758,12 +10761,20 @@ class QTextEdit(QAbstractScrollArea): def __init__(self, f: typing.Union['QTextEdit.AutoFormatting', 'QTextEdit.AutoFormattingFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QTextEdit.AutoFormatting') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTextEdit.AutoFormatting': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTextEdit.AutoFormatting', 'QTextEdit.AutoFormattingFlag', int]) -> 'QTextEdit.AutoFormatting': ... + def __and__(self, other: typing.Union['QTextEdit.AutoFormatting', 'QTextEdit.AutoFormattingFlag', int]) -> 'QTextEdit.AutoFormatting': ... + def __xor__(self, other: typing.Union['QTextEdit.AutoFormatting', 'QTextEdit.AutoFormattingFlag', int]) -> 'QTextEdit.AutoFormatting': ... + def __ror__ (self, other: 'QTextEdit.AutoFormattingFlag') -> 'QTextEdit.AutoFormatting': ... + def __rand__(self, other: 'QTextEdit.AutoFormattingFlag') -> 'QTextEdit.AutoFormatting': ... + def __rxor__(self, other: 'QTextEdit.AutoFormattingFlag') -> 'QTextEdit.AutoFormatting': ... @typing.overload def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py b/tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py new file mode 100644 index 00000000..eecbb395 --- /dev/null +++ b/tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTextEdit.AutoFormatting" and flag class "QTextEdit.AutoFormattingFlag" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QTextEdit.AutoFormattingFlag +MultiFlagClass = QtWidgets.QTextEdit.AutoFormatting + +oneFlagRefValue1 = QtWidgets.QTextEdit.AutoFormattingFlag.AutoNone +oneFlagRefValue2 = QtWidgets.QTextEdit.AutoFormattingFlag.AutoBulletList + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 2c2a42c2b942b7e4eba7d9d02e715c4a783cfbd8 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 11 Sep 2021 11:15:55 +0200 Subject: [PATCH 180/421] Display number of remaining flags to process --- tests/qflags/generate_qflags_stubs_and_tests.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 8c1b54fa..5a0ab8f7 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -221,7 +221,7 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, json.dump(result, f, indent=4) -def process_qflag(qflag_to_process_json: str, qflag_result_json: str, auto_commit: bool) -> bool: +def process_qflag(qflag_to_process_json: str, qflag_result_json: str, auto_commit: bool) -> int: '''Read the qflags to process from the json file Process one qflag, by either: @@ -237,7 +237,7 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str, auto_commi * auto_commit: if True, a git commit is performed after each successful QFlag validation - Return True when all flags have been processed + Return number of remaining flags to process (0 when everything done) ''' with open(qflag_to_process_json) as f: d = json.load(f) @@ -286,7 +286,7 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: break else: # we have exhausted the list of qflag to process - return False + return 0 log_progress('Processing %s and %s in module %s, index %d' % (flag_info.qflag_class, flag_info.enum_class, flag_info.module_name, flag_info.module_idx)) @@ -364,7 +364,7 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: # return True to indicate that more flags may be processed log_progress('.') - return True + return len(qflags_to_process) @@ -891,10 +891,12 @@ def generate_qflags_to_process(qt_qflag_grep_result_fname): qflags_to_process_json = 'qflags_to_process.json' qflag_result_json = 'qflags_process_result.json' - more_available = True - while (nb > 0 or process_all) and more_available: + more_available = -1 + while (nb > 0 or process_all) and (more_available == -1 or more_available > 0): nb -= 1 more_available = process_qflag(qflags_to_process_json, qflag_result_json, auto_commit) + if more_available: + log_progress('Still %d flags to process' % more_available) elif sys.argv[1] == 'analyse_grep_results': if len(sys.argv) <= 2: From 1657713ad7d8af6a0079d1a855ffa6f60fa48339 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 11 Sep 2021 11:16:26 +0200 Subject: [PATCH 181/421] Also catch errors during transformation of the CST --- tests/qflags/generate_qflags_stubs_and_tests.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 5a0ab8f7..37a837b1 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -355,6 +355,7 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: if gen_result == QFlagGenResult.ErrorDuringProcessing: log_progress('Error during processing of QFlag %s %s' % (flag_info.qflag_class, flag_info.enum_class)) + print(error_msg) flag_info_dict['error'] = error_msg.splitlines() result_json['qflag_process_error'].append(flag_info_dict) @@ -468,6 +469,9 @@ class not found, class found multiple times, ... visitor.qflag_class_name, visitor.qflag_class_full_name, flag_info.module_idx) updated_mod_cst = mod_cst.visit(transformer) + if transformer.error_msg: + return (QFlagGenResult.ErrorDuringProcessing, visitor.error_msg, '') + log_progress('Saving updated module %s' % flag_info.module_name) with open(flag_info.module_path, 'w') as f: f.write(updated_mod_cst.code) @@ -741,7 +745,11 @@ def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.C if nb_init_found == len(init_methods): last_init_idx = i break - assert last_init_idx != 0 + + if last_init_idx == 0: + self.error_msg += 'No __init__ method found in class %s' % self.qflag_full_name + return updated_node + cst_init = cst.parse_statement( '@typing.overload\ndef __init__(self, f: int) -> None: ...' ) updated_node = updated_node.with_changes(body=updated_node.body.with_changes(body= From 733a9337b63a7e0d8e93b7b1fbf025af55828538 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 11 Sep 2021 11:17:03 +0200 Subject: [PATCH 182/421] Remove unneeded init method --- PyQt5-stubs/QtCore.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index a36715ca..4f5f469a 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -2835,8 +2835,6 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.Alignment', 'Qt.AlignmentFlag', int]) -> None: ... @typing.overload def __init__(self, a0: 'Qt.Alignment') -> None: ... - @typing.overload - def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... From 04193aea2723ad22014cfd77d677b8334ffd7da9 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 11 Sep 2021 14:35:50 +0200 Subject: [PATCH 183/421] Add mypy verifications of all qflags tests (and switch to Path API) --- tests/test_stubs.py | 52 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index b56bf85b..74cc9739 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -1,34 +1,62 @@ -import os.path +from pathlib import Path import pytest from mypy import api -TESTS_DIR = os.path.dirname(__file__) +TESTS_DIR = Path(__file__).parent def gen_tests(): - for filename in os.listdir(TESTS_DIR): - if filename.endswith('.py') and not filename.startswith('test_'): - yield filename + '''List of all tests files included in the directory tests''' + for filename in TESTS_DIR.glob('test_*.py'): + yield filename +def gen_abs_qflags_tests(): + '''List of all tests included in the directory qflags''' + for filename in (TESTS_DIR/'qflags').glob('test_*.py'): + yield filename -@pytest.mark.parametrize('filename', list(gen_tests())) -def test_stubs(filename): + +@pytest.mark.parametrize('filename', + list(gen_tests()), + ids=[v.parts[-1] for v in gen_tests()] + ) +def test_stubs(filename: Path) -> None: """Run mypy over example files.""" - path = os.path.join(TESTS_DIR, filename) - stdout, stderr, exitcode = api.run([path]) + stdout, stderr, exitcode = api.run([str(filename)]) + if stdout: + print(stdout) + if stderr: + print(stderr) + + assert stdout.startswith("Success: no issues found") + assert not stderr + assert exitcode == 0 + + +@pytest.mark.parametrize('filename', + list(gen_abs_qflags_tests()), + ids=[v.parts[-1] for v in gen_abs_qflags_tests()]) +def test_stubs_qflags(filename: Path) -> None: + """Run mypy over qflags files.""" + stdout, stderr, exitcode = api.run([str(filename)]) if stdout: print(stdout) + if stderr: + print(stderr) assert stdout.startswith("Success: no issues found") assert not stderr assert exitcode == 0 +# note: no need to run explicitely pytest over qflags, because pytest finds them automatically -@pytest.mark.parametrize('filename', list(gen_tests())) +@pytest.mark.parametrize('filename', + list(gen_tests()), + ids=[v.parts[-1] for v in gen_tests()] + ) def test_files(filename): """Run the test files to make sure they work properly.""" - path = os.path.join(TESTS_DIR, filename) - with open(path, 'r') as f: + with open(str(filename), 'r') as f: code = f.read() exec(compile(code, filename, 'exec'), {}) From 78c599c38393e191d258f2676e7a7e44fd2d9731 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 11 Sep 2021 14:38:45 +0200 Subject: [PATCH 184/421] Accelerate mypy execution by grouping all qflags test files --- tests/test_stubs.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index 74cc9739..e8f8e8e6 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -34,12 +34,9 @@ def test_stubs(filename: Path) -> None: assert exitcode == 0 -@pytest.mark.parametrize('filename', - list(gen_abs_qflags_tests()), - ids=[v.parts[-1] for v in gen_abs_qflags_tests()]) -def test_stubs_qflags(filename: Path) -> None: +def test_stubs_qflags() -> None: """Run mypy over qflags files.""" - stdout, stderr, exitcode = api.run([str(filename)]) + stdout, stderr, exitcode = api.run([str(f) for f in gen_abs_qflags_tests()]) if stdout: print(stdout) if stderr: From b5fd4d2c0d0c6ba21dbe67209879cdc042a967e4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 11 Sep 2021 14:52:03 +0200 Subject: [PATCH 185/421] Do not run mypy on test_stubs.py but on other files. --- tests/test_stubs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index e8f8e8e6..935ab0a0 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -8,8 +8,9 @@ def gen_tests(): '''List of all tests files included in the directory tests''' - for filename in TESTS_DIR.glob('test_*.py'): - yield filename + for filename in TESTS_DIR.glob('*.py'): + if not str(filename).startswith('test_'): + yield filename def gen_abs_qflags_tests(): '''List of all tests included in the directory qflags''' From 50d2170b4b30042ec567039d50a316e475745ce9 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 11 Sep 2021 15:24:13 +0200 Subject: [PATCH 186/421] Check that qflag class inherits from sip.simplewrapper --- .../qflags/generate_qflags_stubs_and_tests.py | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 37a837b1..e0f75b86 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -449,6 +449,11 @@ class not found, class found multiple times, ... flag_info.enum_value2 = visitor.enum_value2 flag_info.qflag_full_class_name = visitor.qflag_class_full_name + if visitor.enum_class_full_name == '': + return (QFlagGenResult.ErrorDuringProcessing, 'Could not locate class %s' % visitor.enum_class_name, '') + + if visitor.qflag_class_full_name == '': + return (QFlagGenResult.ErrorDuringProcessing, 'Could not locate class %s' % visitor.qflag_class_name, '') if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): return (QFlagGenResult.CodeAlreadyModified, visitor.error_msg, '') @@ -534,14 +539,14 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: if node.name.value == self.enum_class_name: self.visit_enum_idx += 1 if self.visit_enum_idx > self.module_count: - self.error_msg = 'class %s found too times: %d\n' % (self.enum_class_name, self.visit_enum_idx) + self.error_msg = 'class %s found too many times: %d\n' % (self.enum_class_name, self.visit_enum_idx) return None if self.visit_enum_idx == self.module_idx: # we found the index we are looking for - self.enum_class_full_name = '.'.join(self.full_name_stack) - self.check_enum_method_present(node) - self.collect_enum_values(node) + if self.check_enum_method_present(node): + self.enum_class_full_name = '.'.join(self.full_name_stack) + self.collect_enum_values(node) return None elif node.name.value == self.qflag_class_name: @@ -552,19 +557,19 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: if self.visit_qflag_idx == self.module_idx: # we found the index we are looking for - self.qflag_class_full_name = '.'.join(self.full_name_stack) - self.check_qflag_method_present(node) + if self.check_qflag_method_present(node): + self.qflag_class_full_name = '.'.join(self.full_name_stack) return None return None - def check_enum_method_present(self, enum_node: cst.ClassDef) -> None: + def check_enum_method_present(self, enum_node: cst.ClassDef) -> bool: '''Check if the class contains method __or__ and __ror__ with one argument and if class inherit from int''' if len(enum_node.bases) == 0 or enum_node.bases[0].value.value != 'int': - self.error_msg += 'Class %s does not inherit from int\n' % self.enum_class_full_name - return + # class does not inherit from int, not the one we are looking for + return False has_or = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__or__'))) has_ror = matchers.findall(enum_node.body, matchers.FunctionDef(name=matchers.Name('__ror__'))) self.enum_methods_present = { @@ -581,6 +586,8 @@ def check_enum_method_present(self, enum_node: cst.ClassDef) -> None: self.error_msg += 'class %s, method %s present without method %s\n' % ((self.enum_class_full_name,)+args) + return True + def collect_enum_values(self, enum_node: cst.ClassDef) -> None: '''Collect two actual values for the enum and store them into self.enum_value1 and enum_value2 @@ -600,7 +607,7 @@ def collect_enum_values(self, enum_node: cst.ClassDef) -> None: self.enum_value2 = self.enum_value1 - def check_qflag_method_present(self, qflag_node: cst.ClassDef) -> None: + def check_qflag_method_present(self, qflag_node: cst.ClassDef) -> bool: '''Check if the class contains method: def __or__ def __and__ @@ -614,6 +621,16 @@ def __rxor__ def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ''' + if (len(qflag_node.bases) == 0 + or not matchers.matches(qflag_node.bases[0], + matchers.Arg(value=matchers.Attribute(value=matchers.Name('sip'), + attr=matchers.Name('simplewrapper') + ) + ) + ) + ): + # 'Class does not inherit from sip.simplewrapper' + return False has_method = [ (m, matchers.findall(qflag_node.body, matchers.FunctionDef(name=matchers.Name(m)))) @@ -623,12 +640,12 @@ def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier' if all(has_info[1] for has_info in has_method): # all method presents self.qflag_method_present = MethodPresent.All - return + return True if all(not has_info[1] for has_info in has_method): # all method absent self.qflag_method_present = MethodPresent.Not - return + return True self.qflag_method_present = MethodPresent.Partial @@ -639,6 +656,7 @@ def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier' else: self.error_msg += 'class %s, method %s missing\n' \ % ((self.qflag_class_full_name, m_name)) + return True def visit_FunctionDef(self, node: cst.FunctionDef) -> Optional[bool]: From c3222a5a8d987503be662bb887a338ebace29d29 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 11 Sep 2021 16:05:36 +0200 Subject: [PATCH 187/421] Ensure filename part does not start with test_ --- tests/test_stubs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index 935ab0a0..84e033ac 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -9,7 +9,7 @@ def gen_tests(): '''List of all tests files included in the directory tests''' for filename in TESTS_DIR.glob('*.py'): - if not str(filename).startswith('test_'): + if not str(filename.parts[-1]).startswith('test_'): yield filename def gen_abs_qflags_tests(): From a88673c34eb8658651822b6a0f4feb3d25c7b56b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 11 Sep 2021 16:46:35 +0200 Subject: [PATCH 188/421] QFlag operations for QStyle.State, QStyle.StateFlag in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../qflags/test_QtWidgets_State_StateFlag.py | 251 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_State_StateFlag.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index a0887fa5..54932e4c 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -3115,6 +3115,9 @@ class QStyle(QtCore.QObject): PE_CustomBase = ... # type: QStyle.PrimitiveElement class StateFlag(int): + def __or__ (self, other: 'QStyle.StateFlag') -> 'QStyle.State': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QStyle.State': ... # type: ignore[override, misc] + State_None = ... # type: QStyle.StateFlag State_Enabled = ... # type: QStyle.StateFlag State_Raised = ... # type: QStyle.StateFlag @@ -3181,12 +3184,20 @@ class QStyle(QtCore.QObject): def __init__(self, f: typing.Union['QStyle.State', 'QStyle.StateFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QStyle.State') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QStyle.State': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QStyle.State', 'QStyle.StateFlag', int]) -> 'QStyle.State': ... + def __and__(self, other: typing.Union['QStyle.State', 'QStyle.StateFlag', int]) -> 'QStyle.State': ... + def __xor__(self, other: typing.Union['QStyle.State', 'QStyle.StateFlag', int]) -> 'QStyle.State': ... + def __ror__ (self, other: 'QStyle.StateFlag') -> 'QStyle.State': ... + def __rand__(self, other: 'QStyle.StateFlag') -> 'QStyle.State': ... + def __rxor__(self, other: 'QStyle.StateFlag') -> 'QStyle.State': ... class SubControls(sip.simplewrapper): diff --git a/tests/qflags/test_QtWidgets_State_StateFlag.py b/tests/qflags/test_QtWidgets_State_StateFlag.py new file mode 100644 index 00000000..7c8551a6 --- /dev/null +++ b/tests/qflags/test_QtWidgets_State_StateFlag.py @@ -0,0 +1,251 @@ +from typing import Union, TypeVar, Type +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QStyle.State" and flag class "QStyle.StateFlag" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QStyle.StateFlag +MultiFlagClass = QtWidgets.QStyle.State + +oneFlagRefValue1 = QtWidgets.QStyle.StateFlag.State_None +oneFlagRefValue2 = QtWidgets.QStyle.StateFlag.State_Enabled + +OR_CONVERTS_TO_MULTI = True +OR_INT_CONVERTS_TO_MULTI = False +INT_OR_CONVERTS_TO_MULTI = True +### End of specific part + +T = TypeVar('T') +def assert_type_of_value(expected_type: Type[T], value: T) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == expected_type + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(OneFlagClass, oneFlagValue2) + assert_type_of_value(OneFlagClass, oneFlagValueTest) + assert_type_of_value(int, intValue) + + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + + assert_type_of_value(int, ~oneFlagValue1) + assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) + assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + else: + assert_type_of_value(int, oneFlagValue1 | 33) + assert_type_of_value(int, oneFlagValue1 & 33) + assert_type_of_value(int, oneFlagValue1 ^ 33) + assert_type_of_value(int, oneFlagValue1 + 33) + assert_type_of_value(int, oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + else: + assert_type_of_value(int, 33 | oneFlagValue1) + assert_type_of_value(int, 33 & oneFlagValue1) + assert_type_of_value(int, 33 ^ oneFlagValue1) + assert_type_of_value(int, 33 + oneFlagValue1) + assert_type_of_value(int, 33 - oneFlagValue1) + + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + if OR_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + assert_type_of_value(int, oneOrMultiFlagValueTest) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + else: + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value(int, oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value(int, oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value(OneFlagClass, oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValue2) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value(int, intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) + assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value(int, intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + # assignments operations with int + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value(MultiFlagClass, multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 7b0ba49cdaccba5bf82979ca279f22031090c7e2 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 13 Sep 2021 09:07:24 +0200 Subject: [PATCH 189/421] Add ability to help finding the right class --- .../qflags/generate_qflags_stubs_and_tests.py | 120 +++++++++++++++--- 1 file changed, 100 insertions(+), 20 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index e0f75b86..e3dd77fb 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -57,6 +57,10 @@ class QFlagLocationInfo: qflag_class: str enum_class: str + # sometimes, human help is needed to identify a qflag/enum pair + human_hint_qflag_full_class_name: str = '' + human_hint_enum_full_class_name: str = '' + # one or more grep lines where this qflag name has been found grep_line: Tuple[str] = dataclasses.field(default_factory=tuple) @@ -439,8 +443,13 @@ class not found, class found multiple times, ... log_progress('Looking for class %s and %s in module %s, index %d' % (flag_info.qflag_class, flag_info.enum_class, flag_info.module_name, flag_info.module_idx)) + if len(flag_info.human_hint_enum_full_class_name) and len(flag_info.human_hint_qflag_full_class_name): + log_progress('Using hints: %s and %s' % (flag_info.human_hint_enum_full_class_name, flag_info.human_hint_qflag_full_class_name)) visitor = QFlagAndEnumFinder(flag_info.enum_class, flag_info.qflag_class, - flag_info.module_count, flag_info.module_idx) + flag_info.module_count, flag_info.module_idx, + flag_info.human_hint_enum_full_class_name, + flag_info.human_hint_qflag_full_class_name, + ) mod_cst.visit(visitor) # storing the enum_values + full class name for further usage @@ -471,7 +480,8 @@ class not found, class found multiple times, ... log_progress('Updating module %s by adding new methods' % flag_info.module_name) transformer = QFlagAndEnumUpdater(visitor.enum_class_name, visitor.enum_class_full_name, - visitor.qflag_class_name, visitor.qflag_class_full_name, flag_info.module_idx) + visitor.qflag_class_name, visitor.qflag_class_full_name, flag_info.module_idx, + flag_info.human_hint_enum_full_class_name, flag_info.human_hint_qflag_full_class_name) updated_mod_cst = mod_cst.visit(transformer) if transformer.error_msg: @@ -495,7 +505,10 @@ class MethodPresent(Enum): class QFlagAndEnumFinder(cst.CSTVisitor): def __init__(self, enum_class: str, qflag_class: str, - module_count: int, module_idx: int) -> None: + module_count: int, module_idx: int, + human_hint_enum_full_class_name: str = '', + human_hint_qflag_full_class_name: str = '', + ) -> None: super().__init__() # used internally to generate the full class name @@ -505,6 +518,17 @@ def __init__(self, enum_class: str, qflag_class: str, self.enum_class_name = enum_class self.qflag_class_name = qflag_class + # human help for finding the class + if human_hint_enum_full_class_name: + self.human_hint_enum_full_class_name = human_hint_enum_full_class_name.split('.') + else: + self.human_hint_enum_full_class_name = '' + + if human_hint_qflag_full_class_name: + self.human_hint_qflag_full_class_name = human_hint_qflag_full_class_name.split('.') + else: + self.human_hint_qflag_full_class_name = human_hint_qflag_full_class_name + # the number of expected occurences in this module of this flag self.module_count = module_count @@ -538,12 +562,20 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: self.full_name_stack.append( node.name.value ) if node.name.value == self.enum_class_name: self.visit_enum_idx += 1 - if self.visit_enum_idx > self.module_count: - self.error_msg = 'class %s found too many times: %d\n' % (self.enum_class_name, self.visit_enum_idx) - return None + found_enum_class = False + if self.human_hint_enum_full_class_name: + if self.human_hint_enum_full_class_name == self.full_name_stack: + found_enum_class = True + else: + if self.visit_enum_idx > self.module_count: + self.error_msg = 'class %s found too many times: %d\n' % (self.enum_class_name, self.visit_enum_idx) + return None - if self.visit_enum_idx == self.module_idx: - # we found the index we are looking for + if self.visit_enum_idx == self.module_idx: + # we found the index we are looking for + found_enum_class = True + + if found_enum_class: if self.check_enum_method_present(node): self.enum_class_full_name = '.'.join(self.full_name_stack) self.collect_enum_values(node) @@ -551,12 +583,20 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: elif node.name.value == self.qflag_class_name: self.visit_qflag_idx += 1 - if self.visit_qflag_idx > self.module_count: - self.error_msg = 'class %s found too times: %d\n' % (self.qflag_class_name, self.visit_qflag_idx) - return None + found_qflag_class = False + if self.human_hint_qflag_full_class_name: + if self.human_hint_qflag_full_class_name == self.full_name_stack: + found_qflag_class = True + else: + if self.visit_qflag_idx > self.module_count: + self.error_msg = 'class %s found too times: %d\n' % (self.qflag_class_name, self.visit_qflag_idx) + return None - if self.visit_qflag_idx == self.module_idx: - # we found the index we are looking for + if self.visit_qflag_idx == self.module_idx: + # we found the index we are looking for + found_qflag_class = True + + if found_qflag_class: if self.check_qflag_method_present(node): self.qflag_class_full_name = '.'.join(self.full_name_stack) return None @@ -673,9 +713,14 @@ def leave_FunctionDef(self, node: cst.FunctionDef) -> None: class QFlagAndEnumUpdater(cst.CSTTransformer): def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag_full_name: str, - module_idx: int) -> None: + module_idx: int, + human_hint_enum_full_class_name: str, + human_hint_qflag_full_class_name: str) -> None: super().__init__() + # used internally to generate the full class name + self.full_name_stack: List[str] = [] + self.error_msg = '' # the class name we are looking for @@ -684,6 +729,10 @@ def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag self.enum_full_name = enum_full_name self.qflag_full_name = qflag_full_name + # human help for finding the class + self.human_hint_enum_full_class_name = human_hint_enum_full_class_name.split('.') + self.human_hint_qflag_full_class_name = human_hint_qflag_full_class_name.split('.') + # the index in this module of the class we are looking for self.module_idx = module_idx @@ -694,16 +743,47 @@ def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag # set when enum_methods_present is set to partial, to add more contect information self.error_msg = '' + def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: + self.full_name_stack.append( node.name.value ) + return None + + def visit_FunctionDef(self, node: cst.FunctionDef) -> Optional[bool]: + self.full_name_stack.append( node.name.value ) + return None + + def leave_FunctionDef(self, node: cst.FunctionDef, updated_node: cst.FunctionDef) -> cst.FunctionDef: + self.full_name_stack.pop() + return updated_node def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: - if original_node.name.value == self.enum_class: - self.visit_enum_idx += 1 - if self.visit_enum_idx == self.module_idx: - return self.transform_enum_class(original_node, updated_node) - elif original_node.name.value == self.qflag_class: + found_enum_class = False + found_qflag_class = False + + if self.human_hint_enum_full_class_name: + if self.human_hint_enum_full_class_name == self.full_name_stack: + found_enum_class = True + else: + if original_node.name.value == self.enum_class: + self.visit_enum_idx += 1 + if self.visit_enum_idx == self.module_idx: + found_enum_class = True + + if self.human_hint_qflag_full_class_name: + if self.human_hint_qflag_full_class_name == self.full_name_stack: + found_qflag_class = True + else: self.visit_qflag_idx += 1 if self.visit_qflag_idx == self.module_idx: - return self.transform_qflag_class(original_node, updated_node) + found_qflag_class = True + + self.full_name_stack.pop() + + if found_enum_class: + return self.transform_enum_class(original_node, updated_node) + + if found_qflag_class: + return self.transform_qflag_class(original_node, updated_node) + return updated_node From 207b46054cf75c1abc8e4d8d5fab9ea44ca18c97 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 13 Sep 2021 09:54:12 +0200 Subject: [PATCH 190/421] Add changelog entry for qflags stubs --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4aa9a400..794a7108 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * [#145](https://github.com/python-qt-tools/PyQt5-stubs/pull/145) Support all implemented arithmetic operations between Qt.WindowType and Qt.WindowFlags and int * [#144](https://github.com/python-qt-tools/PyQt5-stubs/pull/144) add `QTreeWidgetItem.__lt__()` to allow sorting of items in a QTreeWidget * [#143](https://github.com/python-qt-tools/PyQt5-stubs/pull/143) make `bytes(QByteArray())` valid by incorrectly adding `.__bytes__()` until a proper solution is developed upstream +* [#153](https://github.com/python-qt-tools/PyQt5-stubs/pull/153) Support all implemented arithmetic operations for QFlags + based classes in modules QtCore, QtWidgets, QtGui, QtNetwork, QtDBus, QtOpenGL, QtPrintsupport, QtSql, QtTest, QtXml ### Changed * [#152](https://github.com/python-qt-tools/PyQt5-stubs/pull/152) `.__or__()` for `QDialogButtonBox.StandardButton` and `QDialogButtonBox.StandardButtons` From ba6eb2cf8f609e1133c93efb7ca4529aba818f3f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 14 Sep 2021 14:52:47 +0200 Subject: [PATCH 191/421] Adjust template to support more QFlag implementations --- tests/qflags/qflags_test_template.py | 170 ++++++++++++++------------- 1 file changed, 89 insertions(+), 81 deletions(-) diff --git a/tests/qflags/qflags_test_template.py b/tests/qflags/qflags_test_template.py index 322d358f..b8bb1569 100644 --- a/tests/qflags/qflags_test_template.py +++ b/tests/qflags/qflags_test_template.py @@ -1,4 +1,4 @@ -from typing import Union, TypeVar, Type +from typing import Union, TypeVar, Type, Literal import pytest ### Specific part @@ -12,15 +12,23 @@ oneFlagRefValue1 = QtCore.Qt.WindowContextHelpButtonHint oneFlagRefValue2 = QtCore.Qt.WindowMaximizeButtonHint -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -31,12 +39,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -57,69 +59,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 33) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(33 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -130,34 +138,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -166,14 +174,14 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully multiFlagValueTest = 33 # type: ignore @@ -182,30 +190,30 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = MultiFlagClass(33) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) #########################################################3 # From a8ef7698151de42076210e57db0dfec647dc55c2 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 14 Sep 2021 14:53:21 +0200 Subject: [PATCH 192/421] Support more QFlag behaviors --- .../qflags/generate_qflags_stubs_and_tests.py | 51 ++++++++++++++++--- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index e3dd77fb..ad4fd450 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -8,6 +8,8 @@ import subprocess from enum import Enum +from PyQt5 import (QtCore, QtWidgets, QtGui, QtNetwork, QtDBus, QtOpenGL, + QtPrintSupport, QtSql, QtTest, QtXml) try: import libcst as cst import libcst.matchers as matchers @@ -80,6 +82,12 @@ class QFlagLocationInfo: module_name: str = '' module_path: str = '' + # specific behavior of some QFlag classes varies slightly + # this helps to define the exact behavior + or_converts_to_multi = True + or_int_converts_to_multi = False + int_or_converts_to_multi = True + def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[str, Any]]: '''Encode the QFlagClassLoationInfo into a format suitable for json export (a dict)''' @@ -478,10 +486,19 @@ class not found, class found multiple times, ... log_progress('Found %s and %s' % (flag_info.qflag_full_class_name, flag_info.enum_full_class_name)) + # evaluate exact behavior of QFlag + flag_info.or_converts_to_multi = 'int' != eval('''type({value1} | {value2})'''.format(value1=flag_info.enum_value1, value2=flag_info.value2)) + flag_info.or_int_converts_to_multi = 'int' != eval('''type({value1} | 33)'''.format(value1=flag_info.enum_value1)) + flag_info.int_or_converts_to_multi = 'int' != eval('''type(33 | {value1})'''.format(value1=flag_info.enum_value1)) + log_progress('Updating module %s by adding new methods' % flag_info.module_name) transformer = QFlagAndEnumUpdater(visitor.enum_class_name, visitor.enum_class_full_name, visitor.qflag_class_name, visitor.qflag_class_full_name, flag_info.module_idx, - flag_info.human_hint_enum_full_class_name, flag_info.human_hint_qflag_full_class_name) + flag_info.human_hint_enum_full_class_name, + flag_info.human_hint_qflag_full_class_name, + flag_info.or_converts_to_multi, + flag_info.or_int_converts_to_multi, + flag_info.int_or_converts_to_multi) updated_mod_cst = mod_cst.visit(transformer) if transformer.error_msg: @@ -715,7 +732,10 @@ class QFlagAndEnumUpdater(cst.CSTTransformer): def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag_full_name: str, module_idx: int, human_hint_enum_full_class_name: str, - human_hint_qflag_full_class_name: str) -> None: + human_hint_qflag_full_class_name: str, + or_converts_to_multi: bool, + or_int_converts_to_multi: bool, + int_or_converts_to_multi: bool) -> None: super().__init__() # used internally to generate the full class name @@ -740,6 +760,10 @@ def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag self.visit_enum_idx = -1 self.visit_qflag_idx = -1 + self.or_converts_to_multi = or_converts_to_multi + self.or_int_converts_to_multi = or_int_converts_to_multi + self.int_or_converts_to_multi = int_or_converts_to_multi + # set when enum_methods_present is set to partial, to add more contect information self.error_msg = '' @@ -791,10 +815,25 @@ def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.Cl '''Add the two methods __or__ and __ror__ to the class body''' # we keep comments separated to align them properly in the final file - new_methods_parts = ( - ("def __or__ (self, other: '{enum}') -> '{qflag}': ...", "# type: ignore[override]\n"), - ("def __ror__ (self, other: int) -> '{qflag}': ...", "# type: ignore[override, misc]\n\n") - ) + or_behavior = (self.or_converts_to_multi, self.or_int_converts_to_multi, self.int_or_converts_to_multi) + if or_behavior == (True, False, True): + new_methods_parts = ( + ("def __or__ (self, other: '{enum}') -> '{qflag}': ...", "# type: ignore[override]\n"), + ("def __ror__ (self, other: int) -> '{qflag}': ...", "# type: ignore[override, misc]\n\n") + ) + elif or_behavior == (True, True, True): + new_methods_parts = ( + ("def __or__ (self, other: typing.Union[int, '{enum}]') -> '{qflag}': ...", "# type: ignore[override]\n"), + ("def __ror__ (self, other: int) -> '{qflag}': ...", "# type: ignore[override, misc]\n\n") + ) + elif or_behavior == (False, False, False): + new_methods_parts = ( + ("def __or__ (self, other: '{enum}') -> int: ...", "\n"), + ("def __ror__ (self, other: int) -> int: ...", "\n\n") + ) + else: + raise ValueError('Unsupported or behavior:', or_behavior) + # fill the class names new_methods_filled = tuple( From 022c9779b72fb0e06d3008140f98ac0c183f39eb Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Sep 2021 08:50:46 +0200 Subject: [PATCH 193/421] QFlag operations for QImageIOHandler.Transformations, QImageIOHandler.Transformation in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + ...st_QtGui_Transformations_Transformation.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtGui_Transformations_Transformation.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 3077323d..d14d35f7 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -3133,6 +3133,9 @@ class QImage(QPaintDevice): class QImageIOHandler(sip.simplewrapper): class Transformation(int): + def __or__ (self, other: 'QImageIOHandler.Transformation') -> int: ... + def __ror__ (self, other: int) -> int: ... + TransformationNone = ... # type: QImageIOHandler.Transformation TransformationMirror = ... # type: QImageIOHandler.Transformation TransformationFlip = ... # type: QImageIOHandler.Transformation @@ -3200,12 +3203,20 @@ class QImageIOHandler(sip.simplewrapper): def __init__(self, f: typing.Union['QImageIOHandler.Transformations', 'QImageIOHandler.Transformation']) -> None: ... @typing.overload def __init__(self, a0: 'QImageIOHandler.Transformations') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QImageIOHandler.Transformations': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QImageIOHandler.Transformations', 'QImageIOHandler.Transformation', int]) -> 'QImageIOHandler.Transformations': ... + def __and__(self, other: typing.Union['QImageIOHandler.Transformations', 'QImageIOHandler.Transformation', int]) -> 'QImageIOHandler.Transformations': ... + def __xor__(self, other: typing.Union['QImageIOHandler.Transformations', 'QImageIOHandler.Transformation', int]) -> 'QImageIOHandler.Transformations': ... + def __ror__ (self, other: 'QImageIOHandler.Transformation') -> 'QImageIOHandler.Transformations': ... + def __rand__(self, other: 'QImageIOHandler.Transformation') -> 'QImageIOHandler.Transformations': ... + def __rxor__(self, other: 'QImageIOHandler.Transformation') -> 'QImageIOHandler.Transformations': ... def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtGui_Transformations_Transformation.py b/tests/qflags/test_QtGui_Transformations_Transformation.py new file mode 100644 index 00000000..ffd89322 --- /dev/null +++ b/tests/qflags/test_QtGui_Transformations_Transformation.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QImageIOHandler.Transformations" and flag class "QImageIOHandler.Transformation" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QImageIOHandler.Transformation +MultiFlagClass = QtGui.QImageIOHandler.Transformations + +oneFlagRefValue1 = QtGui.QImageIOHandler.Transformation.TransformationNone +oneFlagRefValue2 = QtGui.QImageIOHandler.Transformation.TransformationMirror + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From bb7359c5bbe14f7decc04ad6d4bd2e865359c7cc Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Sep 2021 08:54:26 +0200 Subject: [PATCH 194/421] QFlag operations for QTouchEvent.TouchPoint.InfoFlags, QTouchEvent.TouchPoint.InfoFlag in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + tests/qflags/test_QtGui_InfoFlags_InfoFlag.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtGui_InfoFlags_InfoFlag.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index d14d35f7..6f689eb6 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -1768,6 +1768,9 @@ class QTouchEvent(QInputEvent): class TouchPoint(sip.simplewrapper): class InfoFlag(int): + def __or__ (self, other: typing.Union[int, 'QTouchEvent.TouchPoint.InfoFlag']) -> 'QTouchEvent.TouchPoint.InfoFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QTouchEvent.TouchPoint.InfoFlags': ... # type: ignore[override, misc] + Pen = ... # type: QTouchEvent.TouchPoint.InfoFlag Token = ... # type: QTouchEvent.TouchPoint.InfoFlag @@ -1782,12 +1785,20 @@ class QTouchEvent(QInputEvent): def __init__(self, f: typing.Union['QTouchEvent.TouchPoint.InfoFlags', 'QTouchEvent.TouchPoint.InfoFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QTouchEvent.TouchPoint.InfoFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTouchEvent.TouchPoint.InfoFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTouchEvent.TouchPoint.InfoFlags', 'QTouchEvent.TouchPoint.InfoFlag', int]) -> 'QTouchEvent.TouchPoint.InfoFlags': ... + def __and__(self, other: typing.Union['QTouchEvent.TouchPoint.InfoFlags', 'QTouchEvent.TouchPoint.InfoFlag', int]) -> 'QTouchEvent.TouchPoint.InfoFlags': ... + def __xor__(self, other: typing.Union['QTouchEvent.TouchPoint.InfoFlags', 'QTouchEvent.TouchPoint.InfoFlag', int]) -> 'QTouchEvent.TouchPoint.InfoFlags': ... + def __ror__ (self, other: 'QTouchEvent.TouchPoint.InfoFlag') -> 'QTouchEvent.TouchPoint.InfoFlags': ... + def __rand__(self, other: 'QTouchEvent.TouchPoint.InfoFlag') -> 'QTouchEvent.TouchPoint.InfoFlags': ... + def __rxor__(self, other: 'QTouchEvent.TouchPoint.InfoFlag') -> 'QTouchEvent.TouchPoint.InfoFlags': ... def ellipseDiameters(self) -> QtCore.QSizeF: ... def rotation(self) -> float: ... diff --git a/tests/qflags/test_QtGui_InfoFlags_InfoFlag.py b/tests/qflags/test_QtGui_InfoFlags_InfoFlag.py new file mode 100644 index 00000000..87e91bc8 --- /dev/null +++ b/tests/qflags/test_QtGui_InfoFlags_InfoFlag.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTouchEvent.TouchPoint.InfoFlags" and flag class "QTouchEvent.TouchPoint.InfoFlag" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QTouchEvent.TouchPoint.InfoFlag +MultiFlagClass = QtGui.QTouchEvent.TouchPoint.InfoFlags + +oneFlagRefValue1 = QtGui.QTouchEvent.TouchPoint.InfoFlag.Pen +oneFlagRefValue2 = QtGui.QTouchEvent.TouchPoint.InfoFlag.Token + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[True] = True +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 6d881589b5c5fe341eca8c7c4e525b41a1224368 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Sep 2021 08:55:29 +0200 Subject: [PATCH 195/421] Generates test file and method according to QFlag behavior --- .../qflags/generate_qflags_stubs_and_tests.py | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index ad4fd450..b4e629a0 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -466,6 +466,16 @@ class not found, class found multiple times, ... flag_info.enum_value2 = visitor.enum_value2 flag_info.qflag_full_class_name = visitor.qflag_class_full_name + # evaluate exact behavior of QFlag + flag_info.or_converts_to_multi = not eval('''type({qtmodule}.{oneFlagName}.{value1} | {qtmodule}.{oneFlagName}.{value2}) == int'''.format( + value1=flag_info.enum_value1, value2=flag_info.enum_value2, + qtmodule=flag_info.module_name, + oneFlagName=flag_info.enum_full_class_name)) + flag_info.or_int_converts_to_multi = not eval('''type({qtmodule}.{oneFlagName}.{value1} | 33) == int'''.format( + value1=flag_info.enum_value1, qtmodule = flag_info.module_name, oneFlagName = flag_info.enum_full_class_name)) + flag_info.int_or_converts_to_multi = not eval('''type(33 | {qtmodule}.{oneFlagName}.{value1}) == int'''.format( + value1=flag_info.enum_value1, qtmodule = flag_info.module_name, oneFlagName = flag_info.enum_full_class_name)) + if visitor.enum_class_full_name == '': return (QFlagGenResult.ErrorDuringProcessing, 'Could not locate class %s' % visitor.enum_class_name, '') @@ -486,10 +496,10 @@ class not found, class found multiple times, ... log_progress('Found %s and %s' % (flag_info.qflag_full_class_name, flag_info.enum_full_class_name)) - # evaluate exact behavior of QFlag - flag_info.or_converts_to_multi = 'int' != eval('''type({value1} | {value2})'''.format(value1=flag_info.enum_value1, value2=flag_info.value2)) - flag_info.or_int_converts_to_multi = 'int' != eval('''type({value1} | 33)'''.format(value1=flag_info.enum_value1)) - flag_info.int_or_converts_to_multi = 'int' != eval('''type(33 | {value1})'''.format(value1=flag_info.enum_value1)) + print('OR behavior:') + print('- or_converts_to_multi: ', flag_info.or_converts_to_multi) + print('- or_int_converts_to_multi: ', flag_info.or_int_converts_to_multi) + print('- int_or_converts_to_multi: ', flag_info.int_or_converts_to_multi) log_progress('Updating module %s by adding new methods' % flag_info.module_name) transformer = QFlagAndEnumUpdater(visitor.enum_class_name, visitor.enum_class_full_name, @@ -750,8 +760,12 @@ def __init__(self, enum_class: str, enum_full_name: str, qflag_class: str, qflag self.qflag_full_name = qflag_full_name # human help for finding the class - self.human_hint_enum_full_class_name = human_hint_enum_full_class_name.split('.') - self.human_hint_qflag_full_class_name = human_hint_qflag_full_class_name.split('.') + self.human_hint_enum_full_class_name = '' + if human_hint_enum_full_class_name: + self.human_hint_enum_full_class_name = human_hint_enum_full_class_name.split('.') + self.human_hint_qflag_full_class_name = '' + if human_hint_qflag_full_class_name: + self.human_hint_qflag_full_class_name = human_hint_qflag_full_class_name.split('.') # the index in this module of the class we are looking for self.module_idx = module_idx @@ -796,9 +810,10 @@ def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef if self.human_hint_qflag_full_class_name == self.full_name_stack: found_qflag_class = True else: - self.visit_qflag_idx += 1 - if self.visit_qflag_idx == self.module_idx: - found_qflag_class = True + if original_node.name.value == self.qflag_class: + self.visit_qflag_idx += 1 + if self.visit_qflag_idx == self.module_idx: + found_qflag_class = True self.full_name_stack.pop() @@ -823,7 +838,7 @@ def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.Cl ) elif or_behavior == (True, True, True): new_methods_parts = ( - ("def __or__ (self, other: typing.Union[int, '{enum}]') -> '{qflag}': ...", "# type: ignore[override]\n"), + ("def __or__ (self, other: typing.Union[int, '{enum}']) -> '{qflag}': ...", "# type: ignore[override]\n"), ("def __ror__ (self, other: int) -> '{qflag}': ...", "# type: ignore[override, misc]\n\n") ) elif or_behavior == (False, False, False): @@ -983,15 +998,18 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: oneFlagRefValue1 = {qtmodule}.{oneFlagName}.{oneFlagValue1} oneFlagRefValue2 = {qtmodule}.{oneFlagName}.{oneFlagValue2} -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[{or_converts_to_multi}] = {or_converts_to_multi} +OR_INT_CONVERTS_TO_MULTI: Literal[{or_int_converts_to_multi}] = {or_int_converts_to_multi} +INT_OR_CONVERTS_TO_MULTI: Literal[{int_or_converts_to_multi}] = {int_or_converts_to_multi} '''.format(source=TEMPLATE_QFLAGS_TESTS, multiFlagName=flag_info.qflag_full_class_name, oneFlagName=flag_info.enum_full_class_name, oneFlagValue1=flag_info.enum_value1, oneFlagValue2=flag_info.enum_value2, - qtmodule=flag_info.module_name + qtmodule=flag_info.module_name, + or_converts_to_multi=flag_info.or_converts_to_multi, + or_int_converts_to_multi=flag_info.or_int_converts_to_multi, + int_or_converts_to_multi=flag_info.int_or_converts_to_multi )) f.writelines(generic_part_after) log_progress('Test file generated: %s' % test_qflag_fname) From 4f318549100ec11d9695f1a021f0cb5c33346028 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:33:18 +0200 Subject: [PATCH 196/421] QFlag operations for QNetworkProxy.Capabilities, QNetworkProxy.Capability in module QtNetwork --- PyQt5-stubs/QtNetwork.pyi | 22 ++ .../test_QtNetwork_Capabilities_Capability.py | 259 ++++++++++++++++++ 2 files changed, 281 insertions(+) create mode 100644 tests/qflags/test_QtNetwork_Capabilities_Capability.py diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index a94225fc..e575549f 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -977,6 +977,9 @@ class QNetworkAccessManager(QtCore.QObject): class QNetworkConfigurationManager(QtCore.QObject): class Capability(int): + def __or__ (self, other: typing.Union[int, 'QNetworkConfigurationManager.Capability']) -> 'QNetworkConfigurationManager.Capabilities': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QNetworkConfigurationManager.Capabilities': ... # type: ignore[override, misc] + CanStartAndStopInterfaces = ... # type: QNetworkConfigurationManager.Capability DirectConnectionRouting = ... # type: QNetworkConfigurationManager.Capability SystemSessionSupport = ... # type: QNetworkConfigurationManager.Capability @@ -1001,12 +1004,20 @@ class QNetworkConfigurationManager(QtCore.QObject): def __init__(self, f: typing.Union['QNetworkConfigurationManager.Capabilities', 'QNetworkConfigurationManager.Capability']) -> None: ... @typing.overload def __init__(self, a0: 'QNetworkConfigurationManager.Capabilities') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QNetworkConfigurationManager.Capabilities': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QNetworkConfigurationManager.Capabilities', 'QNetworkConfigurationManager.Capability', int]) -> 'QNetworkConfigurationManager.Capabilities': ... + def __and__(self, other: typing.Union['QNetworkConfigurationManager.Capabilities', 'QNetworkConfigurationManager.Capability', int]) -> 'QNetworkConfigurationManager.Capabilities': ... + def __xor__(self, other: typing.Union['QNetworkConfigurationManager.Capabilities', 'QNetworkConfigurationManager.Capability', int]) -> 'QNetworkConfigurationManager.Capabilities': ... + def __ror__ (self, other: 'QNetworkConfigurationManager.Capability') -> 'QNetworkConfigurationManager.Capabilities': ... + def __rand__(self, other: 'QNetworkConfigurationManager.Capability') -> 'QNetworkConfigurationManager.Capabilities': ... + def __rxor__(self, other: 'QNetworkConfigurationManager.Capability') -> 'QNetworkConfigurationManager.Capabilities': ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @@ -1366,6 +1377,9 @@ class QNetworkInterface(sip.simplewrapper): class QNetworkProxy(sip.simplewrapper): class Capability(int): + def __or__ (self, other: 'QNetworkProxy.Capability') -> int: ... + def __ror__ (self, other: int) -> int: ... + TunnelingCapability = ... # type: QNetworkProxy.Capability ListeningCapability = ... # type: QNetworkProxy.Capability UdpTunnelingCapability = ... # type: QNetworkProxy.Capability @@ -1405,12 +1419,20 @@ class QNetworkProxy(sip.simplewrapper): def __init__(self, f: typing.Union['QNetworkProxy.Capabilities', 'QNetworkProxy.Capability']) -> None: ... @typing.overload def __init__(self, a0: 'QNetworkProxy.Capabilities') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QNetworkProxy.Capabilities': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QNetworkProxy.Capabilities', 'QNetworkProxy.Capability', int]) -> 'QNetworkProxy.Capabilities': ... + def __and__(self, other: typing.Union['QNetworkProxy.Capabilities', 'QNetworkProxy.Capability', int]) -> 'QNetworkProxy.Capabilities': ... + def __xor__(self, other: typing.Union['QNetworkProxy.Capabilities', 'QNetworkProxy.Capability', int]) -> 'QNetworkProxy.Capabilities': ... + def __ror__ (self, other: 'QNetworkProxy.Capability') -> 'QNetworkProxy.Capabilities': ... + def __rand__(self, other: 'QNetworkProxy.Capability') -> 'QNetworkProxy.Capabilities': ... + def __rxor__(self, other: 'QNetworkProxy.Capability') -> 'QNetworkProxy.Capabilities': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtNetwork_Capabilities_Capability.py b/tests/qflags/test_QtNetwork_Capabilities_Capability.py new file mode 100644 index 00000000..de973296 --- /dev/null +++ b/tests/qflags/test_QtNetwork_Capabilities_Capability.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QNetworkProxy.Capabilities" and flag class "QNetworkProxy.Capability" +from PyQt5 import QtNetwork + +OneFlagClass = QtNetwork.QNetworkProxy.Capability +MultiFlagClass = QtNetwork.QNetworkProxy.Capabilities + +oneFlagRefValue1 = QtNetwork.QNetworkProxy.Capability.TunnelingCapability +oneFlagRefValue2 = QtNetwork.QNetworkProxy.Capability.ListeningCapability + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 50247b1de26e6ea0e6f2418f5f42761aa1ca8322 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:37:24 +0200 Subject: [PATCH 197/421] QFlag operations for QDBusConnection.RegisterOptions, QDBusConnection.RegisterOption in module QtDBus --- PyQt5-stubs/QtDBus.pyi | 11 + ...t_QtDBus_RegisterOptions_RegisterOption.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py diff --git a/PyQt5-stubs/QtDBus.pyi b/PyQt5-stubs/QtDBus.pyi index 8952bc43..2678dcf9 100644 --- a/PyQt5-stubs/QtDBus.pyi +++ b/PyQt5-stubs/QtDBus.pyi @@ -121,6 +121,9 @@ class QDBusConnection(sip.simplewrapper): UnregisterTree = ... # type: QDBusConnection.UnregisterMode class RegisterOption(int): + def __or__ (self, other: typing.Union[int, 'QDBusConnection.RegisterOption']) -> 'QDBusConnection.RegisterOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QDBusConnection.RegisterOptions': ... # type: ignore[override, misc] + ExportAdaptors = ... # type: QDBusConnection.RegisterOption ExportScriptableSlots = ... # type: QDBusConnection.RegisterOption ExportScriptableSignals = ... # type: QDBusConnection.RegisterOption @@ -176,12 +179,20 @@ class QDBusConnection(sip.simplewrapper): def __init__(self, f: typing.Union['QDBusConnection.RegisterOptions', 'QDBusConnection.RegisterOption']) -> None: ... @typing.overload def __init__(self, a0: 'QDBusConnection.RegisterOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QDBusConnection.RegisterOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QDBusConnection.RegisterOptions', 'QDBusConnection.RegisterOption', int]) -> 'QDBusConnection.RegisterOptions': ... + def __and__(self, other: typing.Union['QDBusConnection.RegisterOptions', 'QDBusConnection.RegisterOption', int]) -> 'QDBusConnection.RegisterOptions': ... + def __xor__(self, other: typing.Union['QDBusConnection.RegisterOptions', 'QDBusConnection.RegisterOption', int]) -> 'QDBusConnection.RegisterOptions': ... + def __ror__ (self, other: 'QDBusConnection.RegisterOption') -> 'QDBusConnection.RegisterOptions': ... + def __rand__(self, other: 'QDBusConnection.RegisterOption') -> 'QDBusConnection.RegisterOptions': ... + def __rxor__(self, other: 'QDBusConnection.RegisterOption') -> 'QDBusConnection.RegisterOptions': ... class ConnectionCapabilities(sip.simplewrapper): diff --git a/tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py b/tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py new file mode 100644 index 00000000..632b40d3 --- /dev/null +++ b/tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QDBusConnection.RegisterOptions" and flag class "QDBusConnection.RegisterOption" +from PyQt5 import QtDBus + +OneFlagClass = QtDBus.QDBusConnection.RegisterOption +MultiFlagClass = QtDBus.QDBusConnection.RegisterOptions + +oneFlagRefValue1 = QtDBus.QDBusConnection.RegisterOption.ExportAdaptors +oneFlagRefValue2 = QtDBus.QDBusConnection.RegisterOption.ExportScriptableSlots + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[True] = True +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From d88f8c71f7721523e031a1baa31dcb3f4ca1f451 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:38:19 +0200 Subject: [PATCH 198/421] QFlag operations for QDBusServiceWatcher.WatchMode, QDBusServiceWatcher.WatchModeFlag in module QtDBus --- PyQt5-stubs/QtDBus.pyi | 11 + .../test_QtDBus_WatchMode_WatchModeFlag.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py diff --git a/PyQt5-stubs/QtDBus.pyi b/PyQt5-stubs/QtDBus.pyi index 2678dcf9..0023ea4a 100644 --- a/PyQt5-stubs/QtDBus.pyi +++ b/PyQt5-stubs/QtDBus.pyi @@ -528,6 +528,9 @@ class QDBusPendingCallWatcher(QtCore.QObject, QDBusPendingCall): class QDBusServiceWatcher(QtCore.QObject): class WatchModeFlag(int): + def __or__ (self, other: typing.Union[int, 'QDBusServiceWatcher.WatchModeFlag']) -> 'QDBusServiceWatcher.WatchMode': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QDBusServiceWatcher.WatchMode': ... # type: ignore[override, misc] + WatchForRegistration = ... # type: QDBusServiceWatcher.WatchModeFlag WatchForUnregistration = ... # type: QDBusServiceWatcher.WatchModeFlag WatchForOwnerChange = ... # type: QDBusServiceWatcher.WatchModeFlag @@ -544,12 +547,20 @@ class QDBusServiceWatcher(QtCore.QObject): def __init__(self, f: typing.Union['QDBusServiceWatcher.WatchMode', 'QDBusServiceWatcher.WatchModeFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QDBusServiceWatcher.WatchMode') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QDBusServiceWatcher.WatchMode': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QDBusServiceWatcher.WatchMode', 'QDBusServiceWatcher.WatchModeFlag', int]) -> 'QDBusServiceWatcher.WatchMode': ... + def __and__(self, other: typing.Union['QDBusServiceWatcher.WatchMode', 'QDBusServiceWatcher.WatchModeFlag', int]) -> 'QDBusServiceWatcher.WatchMode': ... + def __xor__(self, other: typing.Union['QDBusServiceWatcher.WatchMode', 'QDBusServiceWatcher.WatchModeFlag', int]) -> 'QDBusServiceWatcher.WatchMode': ... + def __ror__ (self, other: 'QDBusServiceWatcher.WatchModeFlag') -> 'QDBusServiceWatcher.WatchMode': ... + def __rand__(self, other: 'QDBusServiceWatcher.WatchModeFlag') -> 'QDBusServiceWatcher.WatchMode': ... + def __rxor__(self, other: 'QDBusServiceWatcher.WatchModeFlag') -> 'QDBusServiceWatcher.WatchMode': ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py b/tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py new file mode 100644 index 00000000..c01d3da4 --- /dev/null +++ b/tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QDBusServiceWatcher.WatchMode" and flag class "QDBusServiceWatcher.WatchModeFlag" +from PyQt5 import QtDBus + +OneFlagClass = QtDBus.QDBusServiceWatcher.WatchModeFlag +MultiFlagClass = QtDBus.QDBusServiceWatcher.WatchMode + +oneFlagRefValue1 = QtDBus.QDBusServiceWatcher.WatchModeFlag.WatchForRegistration +oneFlagRefValue2 = QtDBus.QDBusServiceWatcher.WatchModeFlag.WatchForUnregistration + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[True] = True +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From c54b8a1201c8c5ad1ae31cf72b44d1b49a114c00 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:42:11 +0200 Subject: [PATCH 199/421] QFlag operations for QFileDevice.FileHandleFlags, QFileDevice.FileHandleFlag in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...t_QtCore_FileHandleFlags_FileHandleFlag.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 4f5f469a..029ee556 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -6067,6 +6067,9 @@ class QFileDevice(QIODevice): MapPrivateOption = ... # type: QFileDevice.MemoryMapFlags class FileHandleFlag(int): + def __or__ (self, other: 'QFileDevice.FileHandleFlag') -> int: ... + def __ror__ (self, other: int) -> int: ... + AutoCloseHandle = ... # type: QFileDevice.FileHandleFlag DontCloseHandle = ... # type: QFileDevice.FileHandleFlag @@ -6167,12 +6170,20 @@ class QFileDevice(QIODevice): def __init__(self, f: typing.Union['QFileDevice.FileHandleFlags', 'QFileDevice.FileHandleFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QFileDevice.FileHandleFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QFileDevice.FileHandleFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QFileDevice.FileHandleFlags', 'QFileDevice.FileHandleFlag', int]) -> 'QFileDevice.FileHandleFlags': ... + def __and__(self, other: typing.Union['QFileDevice.FileHandleFlags', 'QFileDevice.FileHandleFlag', int]) -> 'QFileDevice.FileHandleFlags': ... + def __xor__(self, other: typing.Union['QFileDevice.FileHandleFlags', 'QFileDevice.FileHandleFlag', int]) -> 'QFileDevice.FileHandleFlags': ... + def __ror__ (self, other: 'QFileDevice.FileHandleFlag') -> 'QFileDevice.FileHandleFlags': ... + def __rand__(self, other: 'QFileDevice.FileHandleFlag') -> 'QFileDevice.FileHandleFlags': ... + def __rxor__(self, other: 'QFileDevice.FileHandleFlag') -> 'QFileDevice.FileHandleFlags': ... def setFileTime(self, newDate: typing.Union[QDateTime, datetime.datetime], fileTime: 'QFileDevice.FileTime') -> bool: ... def fileTime(self, time: 'QFileDevice.FileTime') -> QDateTime: ... diff --git a/tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py b/tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py new file mode 100644 index 00000000..2d5fc658 --- /dev/null +++ b/tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QFileDevice.FileHandleFlags" and flag class "QFileDevice.FileHandleFlag" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QFileDevice.FileHandleFlag +MultiFlagClass = QtCore.QFileDevice.FileHandleFlags + +oneFlagRefValue1 = QtCore.QFileDevice.FileHandleFlag.AutoCloseHandle +oneFlagRefValue2 = QtCore.QFileDevice.FileHandleFlag.DontCloseHandle + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 169c3ffcda1865bc2ebafc02ba8834ee60d927a9 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:44:52 +0200 Subject: [PATCH 200/421] QFlag operations for Qt.ApplicationStates, Qt.ApplicationState in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...Core_ApplicationStates_ApplicationState.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 029ee556..7bb2675e 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -241,6 +241,9 @@ class Qt(sip.simplewrapper): BottomEdge = ... # type: Qt.Edge class ApplicationState(int): + def __or__ (self, other: 'Qt.ApplicationState') -> int: ... + def __ror__ (self, other: int) -> int: ... + ApplicationSuspended = ... # type: Qt.ApplicationState ApplicationHidden = ... # type: Qt.ApplicationState ApplicationInactive = ... # type: Qt.ApplicationState @@ -3191,12 +3194,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.ApplicationStates', 'Qt.ApplicationState']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.ApplicationStates') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.ApplicationStates': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.ApplicationStates', 'Qt.ApplicationState', int]) -> 'Qt.ApplicationStates': ... + def __and__(self, other: typing.Union['Qt.ApplicationStates', 'Qt.ApplicationState', int]) -> 'Qt.ApplicationStates': ... + def __xor__(self, other: typing.Union['Qt.ApplicationStates', 'Qt.ApplicationState', int]) -> 'Qt.ApplicationStates': ... + def __ror__ (self, other: 'Qt.ApplicationState') -> 'Qt.ApplicationStates': ... + def __rand__(self, other: 'Qt.ApplicationState') -> 'Qt.ApplicationStates': ... + def __rxor__(self, other: 'Qt.ApplicationState') -> 'Qt.ApplicationStates': ... class Edges(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py b/tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py new file mode 100644 index 00000000..6186de3b --- /dev/null +++ b/tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.ApplicationStates" and flag class "Qt.ApplicationState" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.ApplicationState +MultiFlagClass = QtCore.Qt.ApplicationStates + +oneFlagRefValue1 = QtCore.Qt.ApplicationState.ApplicationSuspended +oneFlagRefValue2 = QtCore.Qt.ApplicationState.ApplicationHidden + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 7d5b47108513c0b40e36b57763c26dbdb7fd1775 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:47:33 +0200 Subject: [PATCH 201/421] QFlag operations for Qt.FindChildOptions, Qt.FindChildOption in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...QtCore_FindChildOptions_FindChildOption.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 7bb2675e..95c0bd09 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -273,6 +273,9 @@ class Qt(sip.simplewrapper): WhiteSpaceModeUndefined = ... # type: Qt.WhiteSpaceMode class FindChildOption(int): + def __or__ (self, other: 'Qt.FindChildOption') -> int: ... + def __ror__ (self, other: int) -> int: ... + FindDirectChildrenOnly = ... # type: Qt.FindChildOption FindChildrenRecursively = ... # type: Qt.FindChildOption @@ -3179,12 +3182,20 @@ class Qt(sip.simplewrapper): def __init__(self, f: typing.Union['Qt.FindChildOptions', 'Qt.FindChildOption']) -> None: ... @typing.overload def __init__(self, a0: 'Qt.FindChildOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'Qt.FindChildOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['Qt.FindChildOptions', 'Qt.FindChildOption', int]) -> 'Qt.FindChildOptions': ... + def __and__(self, other: typing.Union['Qt.FindChildOptions', 'Qt.FindChildOption', int]) -> 'Qt.FindChildOptions': ... + def __xor__(self, other: typing.Union['Qt.FindChildOptions', 'Qt.FindChildOption', int]) -> 'Qt.FindChildOptions': ... + def __ror__ (self, other: 'Qt.FindChildOption') -> 'Qt.FindChildOptions': ... + def __rand__(self, other: 'Qt.FindChildOption') -> 'Qt.FindChildOptions': ... + def __rxor__(self, other: 'Qt.FindChildOption') -> 'Qt.FindChildOptions': ... class ApplicationStates(sip.simplewrapper): diff --git a/tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py b/tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py new file mode 100644 index 00000000..73cecb4a --- /dev/null +++ b/tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "Qt.FindChildOptions" and flag class "Qt.FindChildOption" +from PyQt5 import QtCore + +OneFlagClass = QtCore.Qt.FindChildOption +MultiFlagClass = QtCore.Qt.FindChildOptions + +oneFlagRefValue1 = QtCore.Qt.FindChildOption.FindDirectChildrenOnly +oneFlagRefValue2 = QtCore.Qt.FindChildOption.FindChildrenRecursively + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 9867de5c8a30dc10aa75f930dee469b7dbf1b6cd Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:54:34 +0200 Subject: [PATCH 202/421] QFlag operations for QUrl.UserInputResolutionOptions, QUrl.UserInputResolutionOption in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...lutionOptions_UserInputResolutionOption.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 95c0bd09..3f561711 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -11915,6 +11915,9 @@ class QTransposeProxyModel(QAbstractProxyModel): class QUrl(sip.simplewrapper): class UserInputResolutionOption(int): + def __or__ (self, other: 'QUrl.UserInputResolutionOption') -> int: ... + def __ror__ (self, other: int) -> int: ... + DefaultResolution = ... # type: QUrl.UserInputResolutionOption AssumeLocalFile = ... # type: QUrl.UserInputResolutionOption @@ -12017,12 +12020,20 @@ class QUrl(sip.simplewrapper): def __init__(self, f: typing.Union['QUrl.UserInputResolutionOptions', 'QUrl.UserInputResolutionOption']) -> None: ... @typing.overload def __init__(self, a0: 'QUrl.UserInputResolutionOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QUrl.UserInputResolutionOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QUrl.UserInputResolutionOptions', 'QUrl.UserInputResolutionOption', int]) -> 'QUrl.UserInputResolutionOptions': ... + def __and__(self, other: typing.Union['QUrl.UserInputResolutionOptions', 'QUrl.UserInputResolutionOption', int]) -> 'QUrl.UserInputResolutionOptions': ... + def __xor__(self, other: typing.Union['QUrl.UserInputResolutionOptions', 'QUrl.UserInputResolutionOption', int]) -> 'QUrl.UserInputResolutionOptions': ... + def __ror__ (self, other: 'QUrl.UserInputResolutionOption') -> 'QUrl.UserInputResolutionOptions': ... + def __rand__(self, other: 'QUrl.UserInputResolutionOption') -> 'QUrl.UserInputResolutionOptions': ... + def __rxor__(self, other: 'QUrl.UserInputResolutionOption') -> 'QUrl.UserInputResolutionOptions': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py b/tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py new file mode 100644 index 00000000..12ffaeba --- /dev/null +++ b/tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QUrl.UserInputResolutionOptions" and flag class "QUrl.UserInputResolutionOption" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QUrl.UserInputResolutionOption +MultiFlagClass = QtCore.QUrl.UserInputResolutionOptions + +oneFlagRefValue1 = QtCore.QUrl.UserInputResolutionOption.DefaultResolution +oneFlagRefValue2 = QtCore.QUrl.UserInputResolutionOption.AssumeLocalFile + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From f18082c52a50749bc0b9e1375b1d2d39bcd1367d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:54:55 +0200 Subject: [PATCH 203/421] QFlag operations for QNetworkConfiguration.StateFlags, QNetworkConfiguration.StateFlag in module QtNetwork --- PyQt5-stubs/QtNetwork.pyi | 11 + .../test_QtNetwork_StateFlags_StateFlag.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtNetwork_StateFlags_StateFlag.py diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index e575549f..8140317d 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -1066,6 +1066,9 @@ class QNetworkConfiguration(sip.simplewrapper): Bearer4G = ... # type: QNetworkConfiguration.BearerType class StateFlag(int): + def __or__ (self, other: 'QNetworkConfiguration.StateFlag') -> int: ... + def __ror__ (self, other: int) -> int: ... + Undefined = ... # type: QNetworkConfiguration.StateFlag Defined = ... # type: QNetworkConfiguration.StateFlag Discovered = ... # type: QNetworkConfiguration.StateFlag @@ -1106,12 +1109,20 @@ class QNetworkConfiguration(sip.simplewrapper): def __init__(self, f: typing.Union['QNetworkConfiguration.StateFlags', 'QNetworkConfiguration.StateFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QNetworkConfiguration.StateFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QNetworkConfiguration.StateFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QNetworkConfiguration.StateFlags', 'QNetworkConfiguration.StateFlag', int]) -> 'QNetworkConfiguration.StateFlags': ... + def __and__(self, other: typing.Union['QNetworkConfiguration.StateFlags', 'QNetworkConfiguration.StateFlag', int]) -> 'QNetworkConfiguration.StateFlags': ... + def __xor__(self, other: typing.Union['QNetworkConfiguration.StateFlags', 'QNetworkConfiguration.StateFlag', int]) -> 'QNetworkConfiguration.StateFlags': ... + def __ror__ (self, other: 'QNetworkConfiguration.StateFlag') -> 'QNetworkConfiguration.StateFlags': ... + def __rand__(self, other: 'QNetworkConfiguration.StateFlag') -> 'QNetworkConfiguration.StateFlags': ... + def __rxor__(self, other: 'QNetworkConfiguration.StateFlag') -> 'QNetworkConfiguration.StateFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtNetwork_StateFlags_StateFlag.py b/tests/qflags/test_QtNetwork_StateFlags_StateFlag.py new file mode 100644 index 00000000..3028a0af --- /dev/null +++ b/tests/qflags/test_QtNetwork_StateFlags_StateFlag.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QNetworkConfiguration.StateFlags" and flag class "QNetworkConfiguration.StateFlag" +from PyQt5 import QtNetwork + +OneFlagClass = QtNetwork.QNetworkConfiguration.StateFlag +MultiFlagClass = QtNetwork.QNetworkConfiguration.StateFlags + +oneFlagRefValue1 = QtNetwork.QNetworkConfiguration.StateFlag.Undefined +oneFlagRefValue2 = QtNetwork.QNetworkConfiguration.StateFlag.Defined + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From fae94de94bbe05d1ecf4c7e4da1f68a5a2919a5c Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:55:19 +0200 Subject: [PATCH 204/421] QFlag operations for QNetworkSession.UsagePolicies, QNetworkSession.UsagePolicy in module QtNetwork --- PyQt5-stubs/QtNetwork.pyi | 11 + ...est_QtNetwork_UsagePolicies_UsagePolicy.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 8140317d..24649918 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -1846,6 +1846,9 @@ class QNetworkRequest(sip.simplewrapper): class QNetworkSession(QtCore.QObject): class UsagePolicy(int): + def __or__ (self, other: 'QNetworkSession.UsagePolicy') -> int: ... + def __ror__ (self, other: int) -> int: ... + NoPolicy = ... # type: QNetworkSession.UsagePolicy NoBackgroundTrafficPolicy = ... # type: QNetworkSession.UsagePolicy @@ -1890,12 +1893,20 @@ class QNetworkSession(QtCore.QObject): def __init__(self, f: typing.Union['QNetworkSession.UsagePolicies', 'QNetworkSession.UsagePolicy']) -> None: ... @typing.overload def __init__(self, a0: 'QNetworkSession.UsagePolicies') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QNetworkSession.UsagePolicies': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QNetworkSession.UsagePolicies', 'QNetworkSession.UsagePolicy', int]) -> 'QNetworkSession.UsagePolicies': ... + def __and__(self, other: typing.Union['QNetworkSession.UsagePolicies', 'QNetworkSession.UsagePolicy', int]) -> 'QNetworkSession.UsagePolicies': ... + def __xor__(self, other: typing.Union['QNetworkSession.UsagePolicies', 'QNetworkSession.UsagePolicy', int]) -> 'QNetworkSession.UsagePolicies': ... + def __ror__ (self, other: 'QNetworkSession.UsagePolicy') -> 'QNetworkSession.UsagePolicies': ... + def __rand__(self, other: 'QNetworkSession.UsagePolicy') -> 'QNetworkSession.UsagePolicies': ... + def __rxor__(self, other: 'QNetworkSession.UsagePolicy') -> 'QNetworkSession.UsagePolicies': ... def __init__(self, connConfig: QNetworkConfiguration, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py b/tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py new file mode 100644 index 00000000..17d18678 --- /dev/null +++ b/tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QNetworkSession.UsagePolicies" and flag class "QNetworkSession.UsagePolicy" +from PyQt5 import QtNetwork + +OneFlagClass = QtNetwork.QNetworkSession.UsagePolicy +MultiFlagClass = QtNetwork.QNetworkSession.UsagePolicies + +oneFlagRefValue1 = QtNetwork.QNetworkSession.UsagePolicy.NoPolicy +oneFlagRefValue2 = QtNetwork.QNetworkSession.UsagePolicy.NoBackgroundTrafficPolicy + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 037ed194bb10fb98a75068573dca69f832dd6192 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:57:02 +0200 Subject: [PATCH 205/421] QFlag operations for QPaintEngine.DirtyFlags, QPaintEngine.DirtyFlag in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + .../qflags/test_QtGui_DirtyFlags_DirtyFlag.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 6f689eb6..894c1228 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -6970,6 +6970,9 @@ class QPaintEngine(sip.simplewrapper): PolylineMode = ... # type: QPaintEngine.PolygonDrawMode class DirtyFlag(int): + def __or__ (self, other: 'QPaintEngine.DirtyFlag') -> int: ... + def __ror__ (self, other: int) -> int: ... + DirtyPen = ... # type: QPaintEngine.DirtyFlag DirtyBrush = ... # type: QPaintEngine.DirtyFlag DirtyBrushOrigin = ... # type: QPaintEngine.DirtyFlag @@ -7077,12 +7080,20 @@ class QPaintEngine(sip.simplewrapper): def __init__(self, f: typing.Union['QPaintEngine.DirtyFlags', 'QPaintEngine.DirtyFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QPaintEngine.DirtyFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QPaintEngine.DirtyFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QPaintEngine.DirtyFlags', 'QPaintEngine.DirtyFlag', int]) -> 'QPaintEngine.DirtyFlags': ... + def __and__(self, other: typing.Union['QPaintEngine.DirtyFlags', 'QPaintEngine.DirtyFlag', int]) -> 'QPaintEngine.DirtyFlags': ... + def __xor__(self, other: typing.Union['QPaintEngine.DirtyFlags', 'QPaintEngine.DirtyFlag', int]) -> 'QPaintEngine.DirtyFlags': ... + def __ror__ (self, other: 'QPaintEngine.DirtyFlag') -> 'QPaintEngine.DirtyFlags': ... + def __rand__(self, other: 'QPaintEngine.DirtyFlag') -> 'QPaintEngine.DirtyFlags': ... + def __rxor__(self, other: 'QPaintEngine.DirtyFlag') -> 'QPaintEngine.DirtyFlags': ... def __init__(self, features: typing.Union['QPaintEngine.PaintEngineFeatures', 'QPaintEngine.PaintEngineFeature'] = ...) -> None: ... diff --git a/tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py b/tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py new file mode 100644 index 00000000..f5bcb13a --- /dev/null +++ b/tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QPaintEngine.DirtyFlags" and flag class "QPaintEngine.DirtyFlag" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QPaintEngine.DirtyFlag +MultiFlagClass = QtGui.QPaintEngine.DirtyFlags + +oneFlagRefValue1 = QtGui.QPaintEngine.DirtyFlag.DirtyPen +oneFlagRefValue2 = QtGui.QPaintEngine.DirtyFlag.DirtyBrush + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 0eab5676e2b25c93ddf5e2d5828bab18cbe146f7 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:58:40 +0200 Subject: [PATCH 206/421] QFlag operations for QPainter.PixmapFragmentHints, QPainter.PixmapFragmentHint in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + ..._PixmapFragmentHints_PixmapFragmentHint.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 894c1228..54c92da0 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -6368,6 +6368,9 @@ class QPageSize(sip.simplewrapper): class QPainter(sip.simplewrapper): class PixmapFragmentHint(int): + def __or__ (self, other: 'QPainter.PixmapFragmentHint') -> int: ... + def __ror__ (self, other: int) -> int: ... + OpaqueHint = ... # type: QPainter.PixmapFragmentHint OpaqueHint = ... # type: QPainter.PixmapFragmentHint @@ -6523,12 +6526,20 @@ class QPainter(sip.simplewrapper): def __init__(self, f: typing.Union['QPainter.PixmapFragmentHints', 'QPainter.PixmapFragmentHint']) -> None: ... @typing.overload def __init__(self, a0: 'QPainter.PixmapFragmentHints') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QPainter.PixmapFragmentHints': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QPainter.PixmapFragmentHints', 'QPainter.PixmapFragmentHint', int]) -> 'QPainter.PixmapFragmentHints': ... + def __and__(self, other: typing.Union['QPainter.PixmapFragmentHints', 'QPainter.PixmapFragmentHint', int]) -> 'QPainter.PixmapFragmentHints': ... + def __xor__(self, other: typing.Union['QPainter.PixmapFragmentHints', 'QPainter.PixmapFragmentHint', int]) -> 'QPainter.PixmapFragmentHints': ... + def __ror__ (self, other: 'QPainter.PixmapFragmentHint') -> 'QPainter.PixmapFragmentHints': ... + def __rand__(self, other: 'QPainter.PixmapFragmentHint') -> 'QPainter.PixmapFragmentHints': ... + def __rxor__(self, other: 'QPainter.PixmapFragmentHint') -> 'QPainter.PixmapFragmentHints': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py b/tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py new file mode 100644 index 00000000..21abb21c --- /dev/null +++ b/tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QPainter.PixmapFragmentHints" and flag class "QPainter.PixmapFragmentHint" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QPainter.PixmapFragmentHint +MultiFlagClass = QtGui.QPainter.PixmapFragmentHints + +oneFlagRefValue1 = QtGui.QPainter.PixmapFragmentHint.OpaqueHint +oneFlagRefValue2 = QtGui.QPainter.PixmapFragmentHint.OpaqueHint + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From df0d1173df0271b1d2ea567737f468e6b666805b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 15:59:56 +0200 Subject: [PATCH 207/421] QFlag operations for QGlyphRun.GlyphRunFlags, QGlyphRun.GlyphRunFlag in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + .../test_QtGui_GlyphRunFlags_GlyphRunFlag.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 54c92da0..99de8cb3 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -2600,6 +2600,9 @@ class QMatrix2x2(sip.simplewrapper): class QGlyphRun(sip.simplewrapper): class GlyphRunFlag(int): + def __or__ (self, other: 'QGlyphRun.GlyphRunFlag') -> int: ... + def __ror__ (self, other: int) -> int: ... + Overline = ... # type: QGlyphRun.GlyphRunFlag Underline = ... # type: QGlyphRun.GlyphRunFlag StrikeOut = ... # type: QGlyphRun.GlyphRunFlag @@ -2620,12 +2623,20 @@ class QGlyphRun(sip.simplewrapper): def __init__(self, f: typing.Union['QGlyphRun.GlyphRunFlags', 'QGlyphRun.GlyphRunFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QGlyphRun.GlyphRunFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGlyphRun.GlyphRunFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGlyphRun.GlyphRunFlags', 'QGlyphRun.GlyphRunFlag', int]) -> 'QGlyphRun.GlyphRunFlags': ... + def __and__(self, other: typing.Union['QGlyphRun.GlyphRunFlags', 'QGlyphRun.GlyphRunFlag', int]) -> 'QGlyphRun.GlyphRunFlags': ... + def __xor__(self, other: typing.Union['QGlyphRun.GlyphRunFlags', 'QGlyphRun.GlyphRunFlag', int]) -> 'QGlyphRun.GlyphRunFlags': ... + def __ror__ (self, other: 'QGlyphRun.GlyphRunFlag') -> 'QGlyphRun.GlyphRunFlags': ... + def __rand__(self, other: 'QGlyphRun.GlyphRunFlag') -> 'QGlyphRun.GlyphRunFlags': ... + def __rxor__(self, other: 'QGlyphRun.GlyphRunFlag') -> 'QGlyphRun.GlyphRunFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py b/tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py new file mode 100644 index 00000000..586b4b60 --- /dev/null +++ b/tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGlyphRun.GlyphRunFlags" and flag class "QGlyphRun.GlyphRunFlag" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QGlyphRun.GlyphRunFlag +MultiFlagClass = QtGui.QGlyphRun.GlyphRunFlags + +oneFlagRefValue1 = QtGui.QGlyphRun.GlyphRunFlag.Overline +oneFlagRefValue2 = QtGui.QGlyphRun.GlyphRunFlag.Underline + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From fb6ac6f382032f5593d7417ea276f5b9eb091edf Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 16:01:07 +0200 Subject: [PATCH 208/421] QFlag operations for QTextDocument.MarkdownFeatures, QTextDocument.MarkdownFeature in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 + ..._QtGui_MarkdownFeatures_MarkdownFeature.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 99de8cb3..1576be50 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -8913,6 +8913,9 @@ class QTextCursor(sip.simplewrapper): class QTextDocument(QtCore.QObject): class MarkdownFeature(int): + def __or__ (self, other: 'QTextDocument.MarkdownFeature') -> int: ... + def __ror__ (self, other: int) -> int: ... + MarkdownNoHTML = ... # type: QTextDocument.MarkdownFeature MarkdownDialectCommonMark = ... # type: QTextDocument.MarkdownFeature MarkdownDialectGitHub = ... # type: QTextDocument.MarkdownFeature @@ -8995,12 +8998,20 @@ class QTextDocument(QtCore.QObject): def __init__(self, f: typing.Union['QTextDocument.MarkdownFeatures', 'QTextDocument.MarkdownFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QTextDocument.MarkdownFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QTextDocument.MarkdownFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QTextDocument.MarkdownFeatures', 'QTextDocument.MarkdownFeature', int]) -> 'QTextDocument.MarkdownFeatures': ... + def __and__(self, other: typing.Union['QTextDocument.MarkdownFeatures', 'QTextDocument.MarkdownFeature', int]) -> 'QTextDocument.MarkdownFeatures': ... + def __xor__(self, other: typing.Union['QTextDocument.MarkdownFeatures', 'QTextDocument.MarkdownFeature', int]) -> 'QTextDocument.MarkdownFeatures': ... + def __ror__ (self, other: 'QTextDocument.MarkdownFeature') -> 'QTextDocument.MarkdownFeatures': ... + def __rand__(self, other: 'QTextDocument.MarkdownFeature') -> 'QTextDocument.MarkdownFeatures': ... + def __rxor__(self, other: 'QTextDocument.MarkdownFeature') -> 'QTextDocument.MarkdownFeatures': ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py b/tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py new file mode 100644 index 00000000..4f1f5fdf --- /dev/null +++ b/tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QTextDocument.MarkdownFeatures" and flag class "QTextDocument.MarkdownFeature" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QTextDocument.MarkdownFeature +MultiFlagClass = QtGui.QTextDocument.MarkdownFeatures + +oneFlagRefValue1 = QtGui.QTextDocument.MarkdownFeature.MarkdownNoHTML +oneFlagRefValue2 = QtGui.QTextDocument.MarkdownFeature.MarkdownDialectCommonMark + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 2baa9c77049de0786ebe00854cb13a5c37d28109 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 16:03:33 +0200 Subject: [PATCH 209/421] QFlag operations for QLocale.DataSizeFormats, QLocale.DataSizeFormat in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 + ...t_QtCore_DataSizeFormats_DataSizeFormat.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 3f561711..723fd1c2 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -7037,6 +7037,9 @@ class QLineF(sip.simplewrapper): class QLocale(sip.simplewrapper): class DataSizeFormat(int): + def __or__ (self, other: 'QLocale.DataSizeFormat') -> int: ... + def __ror__ (self, other: int) -> int: ... + DataSizeIecFormat = ... # type: QLocale.DataSizeFormat DataSizeTraditionalFormat = ... # type: QLocale.DataSizeFormat DataSizeSIFormat = ... # type: QLocale.DataSizeFormat @@ -8748,12 +8751,20 @@ class QLocale(sip.simplewrapper): def __init__(self, f: typing.Union['QLocale.DataSizeFormats', 'QLocale.DataSizeFormat']) -> None: ... @typing.overload def __init__(self, a0: 'QLocale.DataSizeFormats') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QLocale.DataSizeFormats': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QLocale.DataSizeFormats', 'QLocale.DataSizeFormat', int]) -> 'QLocale.DataSizeFormats': ... + def __and__(self, other: typing.Union['QLocale.DataSizeFormats', 'QLocale.DataSizeFormat', int]) -> 'QLocale.DataSizeFormats': ... + def __xor__(self, other: typing.Union['QLocale.DataSizeFormats', 'QLocale.DataSizeFormat', int]) -> 'QLocale.DataSizeFormats': ... + def __ror__ (self, other: 'QLocale.DataSizeFormat') -> 'QLocale.DataSizeFormats': ... + def __rand__(self, other: 'QLocale.DataSizeFormat') -> 'QLocale.DataSizeFormats': ... + def __rxor__(self, other: 'QLocale.DataSizeFormat') -> 'QLocale.DataSizeFormats': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py b/tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py new file mode 100644 index 00000000..03c22353 --- /dev/null +++ b/tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QLocale.DataSizeFormats" and flag class "QLocale.DataSizeFormat" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QLocale.DataSizeFormat +MultiFlagClass = QtCore.QLocale.DataSizeFormats + +oneFlagRefValue1 = QtCore.QLocale.DataSizeFormat.DataSizeIecFormat +oneFlagRefValue2 = QtCore.QLocale.DataSizeFormat.DataSizeTraditionalFormat + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 5a34c9b40fb867d7a32800fc05cad8a1164253c7 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 17:31:44 +0200 Subject: [PATCH 210/421] QFlag operations for QAbstractPrintDialog.PrintDialogOptions, QAbstractPrintDialog.PrintDialogOption in module QtPrintSupport --- PyQt5-stubs/QtPrintSupport.pyi | 11 + ...rt_PrintDialogOptions_PrintDialogOption.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py diff --git a/PyQt5-stubs/QtPrintSupport.pyi b/PyQt5-stubs/QtPrintSupport.pyi index c49a0efa..0bc4133e 100644 --- a/PyQt5-stubs/QtPrintSupport.pyi +++ b/PyQt5-stubs/QtPrintSupport.pyi @@ -44,6 +44,9 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], class QAbstractPrintDialog(QtWidgets.QDialog): class PrintDialogOption(int): + def __or__ (self, other: 'QAbstractPrintDialog.PrintDialogOption') -> 'QAbstractPrintDialog.PrintDialogOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QAbstractPrintDialog.PrintDialogOptions': ... # type: ignore[override, misc] + None_ = ... # type: QAbstractPrintDialog.PrintDialogOption PrintToFile = ... # type: QAbstractPrintDialog.PrintDialogOption PrintSelection = ... # type: QAbstractPrintDialog.PrintDialogOption @@ -79,12 +82,20 @@ class QAbstractPrintDialog(QtWidgets.QDialog): def __init__(self, f: typing.Union['QAbstractPrintDialog.PrintDialogOptions', 'QAbstractPrintDialog.PrintDialogOption']) -> None: ... @typing.overload def __init__(self, a0: 'QAbstractPrintDialog.PrintDialogOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QAbstractPrintDialog.PrintDialogOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QAbstractPrintDialog.PrintDialogOptions', 'QAbstractPrintDialog.PrintDialogOption', int]) -> 'QAbstractPrintDialog.PrintDialogOptions': ... + def __and__(self, other: typing.Union['QAbstractPrintDialog.PrintDialogOptions', 'QAbstractPrintDialog.PrintDialogOption', int]) -> 'QAbstractPrintDialog.PrintDialogOptions': ... + def __xor__(self, other: typing.Union['QAbstractPrintDialog.PrintDialogOptions', 'QAbstractPrintDialog.PrintDialogOption', int]) -> 'QAbstractPrintDialog.PrintDialogOptions': ... + def __ror__ (self, other: 'QAbstractPrintDialog.PrintDialogOption') -> 'QAbstractPrintDialog.PrintDialogOptions': ... + def __rand__(self, other: 'QAbstractPrintDialog.PrintDialogOption') -> 'QAbstractPrintDialog.PrintDialogOptions': ... + def __rxor__(self, other: 'QAbstractPrintDialog.PrintDialogOption') -> 'QAbstractPrintDialog.PrintDialogOptions': ... def __init__(self, printer: 'QPrinter', parent: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py b/tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py new file mode 100644 index 00000000..531bd338 --- /dev/null +++ b/tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QAbstractPrintDialog.PrintDialogOptions" and flag class "QAbstractPrintDialog.PrintDialogOption" +from PyQt5 import QtPrintSupport + +OneFlagClass = QtPrintSupport.QAbstractPrintDialog.PrintDialogOption +MultiFlagClass = QtPrintSupport.QAbstractPrintDialog.PrintDialogOptions + +oneFlagRefValue1 = QtPrintSupport.QAbstractPrintDialog.PrintDialogOption.None_ +oneFlagRefValue2 = QtPrintSupport.QAbstractPrintDialog.PrintDialogOption.PrintToFile + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From b0ca33b5c255de0cd70e54955fc1a9f92be814a9 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 17:33:39 +0200 Subject: [PATCH 211/421] QFlag operations for QPinchGesture.ChangeFlags, QPinchGesture.ChangeFlag in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 ++ .../test_QtWidgets_ChangeFlags_ChangeFlag.py | 180 +++++++++--------- 2 files changed, 105 insertions(+), 86 deletions(-) diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 54932e4c..f830af8c 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -4529,6 +4529,9 @@ class QPanGesture(QGesture): class QPinchGesture(QGesture): class ChangeFlag(int): + def __or__ (self, other: 'QPinchGesture.ChangeFlag') -> int: ... + def __ror__ (self, other: int) -> int: ... + ScaleFactorChanged = ... # type: QPinchGesture.ChangeFlag RotationAngleChanged = ... # type: QPinchGesture.ChangeFlag CenterPointChanged = ... # type: QPinchGesture.ChangeFlag @@ -4545,12 +4548,20 @@ class QPinchGesture(QGesture): def __init__(self, f: typing.Union['QPinchGesture.ChangeFlags', 'QPinchGesture.ChangeFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QPinchGesture.ChangeFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QPinchGesture.ChangeFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QPinchGesture.ChangeFlags', 'QPinchGesture.ChangeFlag', int]) -> 'QPinchGesture.ChangeFlags': ... + def __and__(self, other: typing.Union['QPinchGesture.ChangeFlags', 'QPinchGesture.ChangeFlag', int]) -> 'QPinchGesture.ChangeFlags': ... + def __xor__(self, other: typing.Union['QPinchGesture.ChangeFlags', 'QPinchGesture.ChangeFlag', int]) -> 'QPinchGesture.ChangeFlags': ... + def __ror__ (self, other: 'QPinchGesture.ChangeFlag') -> 'QPinchGesture.ChangeFlags': ... + def __rand__(self, other: 'QPinchGesture.ChangeFlag') -> 'QPinchGesture.ChangeFlags': ... + def __rxor__(self, other: 'QPinchGesture.ChangeFlag') -> 'QPinchGesture.ChangeFlags': ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py b/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py index 10d43d3a..7135487f 100644 --- a/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py +++ b/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py @@ -1,25 +1,33 @@ -from typing import Union, TypeVar, Type +from typing import Union, TypeVar, Type, Literal import pytest ### Specific part -# file generated from qflags_test_template.py for QFlags class "QGraphicsEffect.ChangeFlags" and flag class "QGraphicsEffect.ChangeFlag" +# file generated from qflags_test_template.py for QFlags class "QPinchGesture.ChangeFlags" and flag class "QPinchGesture.ChangeFlag" from PyQt5 import QtWidgets -OneFlagClass = QtWidgets.QGraphicsEffect.ChangeFlag -MultiFlagClass = QtWidgets.QGraphicsEffect.ChangeFlags +OneFlagClass = QtWidgets.QPinchGesture.ChangeFlag +MultiFlagClass = QtWidgets.QPinchGesture.ChangeFlags -oneFlagRefValue1 = QtWidgets.QGraphicsEffect.ChangeFlag.SourceAttached -oneFlagRefValue2 = QtWidgets.QGraphicsEffect.ChangeFlag.SourceDetached +oneFlagRefValue1 = QtWidgets.QPinchGesture.ChangeFlag.ScaleFactorChanged +oneFlagRefValue2 = QtWidgets.QPinchGesture.ChangeFlag.RotationAngleChanged -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -30,12 +38,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -56,69 +58,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 33) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(33 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -129,34 +137,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -165,14 +173,14 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully multiFlagValueTest = 33 # type: ignore @@ -181,30 +189,30 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = MultiFlagClass(33) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) #########################################################3 # From 953fe00e933078d1f127a8ed226d5c4fef9296f5 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 17 Sep 2021 17:38:30 +0200 Subject: [PATCH 212/421] QFlag operations for QStyleOptionTab.TabFeatures, QStyleOptionTab.TabFeature in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + .../test_QtWidgets_TabFeatures_TabFeature.py | 259 ++++++++++++++++++ 2 files changed, 270 insertions(+) create mode 100644 tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index f830af8c..199ea048 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -9415,6 +9415,9 @@ class QStyleOptionButton(QStyleOption): class QStyleOptionTab(QStyleOption): class TabFeature(int): + def __or__ (self, other: 'QStyleOptionTab.TabFeature') -> int: ... + def __ror__ (self, other: int) -> int: ... + None_ = ... # type: QStyleOptionTab.TabFeature HasFrame = ... # type: QStyleOptionTab.TabFeature @@ -9494,12 +9497,20 @@ class QStyleOptionTab(QStyleOption): def __init__(self, f: typing.Union['QStyleOptionTab.TabFeatures', 'QStyleOptionTab.TabFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QStyleOptionTab.TabFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QStyleOptionTab.TabFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QStyleOptionTab.TabFeatures', 'QStyleOptionTab.TabFeature', int]) -> 'QStyleOptionTab.TabFeatures': ... + def __and__(self, other: typing.Union['QStyleOptionTab.TabFeatures', 'QStyleOptionTab.TabFeature', int]) -> 'QStyleOptionTab.TabFeatures': ... + def __xor__(self, other: typing.Union['QStyleOptionTab.TabFeatures', 'QStyleOptionTab.TabFeature', int]) -> 'QStyleOptionTab.TabFeatures': ... + def __ror__ (self, other: 'QStyleOptionTab.TabFeature') -> 'QStyleOptionTab.TabFeatures': ... + def __rand__(self, other: 'QStyleOptionTab.TabFeature') -> 'QStyleOptionTab.TabFeatures': ... + def __rxor__(self, other: 'QStyleOptionTab.TabFeature') -> 'QStyleOptionTab.TabFeatures': ... cornerWidgets = ... # type: typing.Union['QStyleOptionTab.CornerWidgets', 'QStyleOptionTab.CornerWidget'] documentMode = ... # type: bool diff --git a/tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py b/tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py new file mode 100644 index 00000000..d3c30e97 --- /dev/null +++ b/tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QStyleOptionTab.TabFeatures" and flag class "QStyleOptionTab.TabFeature" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QStyleOptionTab.TabFeature +MultiFlagClass = QtWidgets.QStyleOptionTab.TabFeatures + +oneFlagRefValue1 = QtWidgets.QStyleOptionTab.TabFeature.None_ +oneFlagRefValue2 = QtWidgets.QStyleOptionTab.TabFeature.HasFrame + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 33 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 33 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 33 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(33) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 33 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################3 + # + # Exploring errors + # + #########################################################3 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 33 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 33 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 59bca9955e9c45af11fa2987cdde27a4ce1b5c08 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 18 Sep 2021 13:34:53 +0200 Subject: [PATCH 213/421] Fix dataclass incorrectly declared --- tests/qflags/generate_qflags_stubs_and_tests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index b4e629a0..65ecaa5f 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -84,9 +84,9 @@ class QFlagLocationInfo: # specific behavior of some QFlag classes varies slightly # this helps to define the exact behavior - or_converts_to_multi = True - or_int_converts_to_multi = False - int_or_converts_to_multi = True + or_converts_to_multi: bool = True + or_int_converts_to_multi: bool = False + int_or_converts_to_multi: bool = True def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[str, Any]]: From dd2e4064bb16034021be73fe680456aaf94fa7e2 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 18 Sep 2021 13:35:08 +0200 Subject: [PATCH 214/421] wip: test file regeneration --- .../qflags/generate_qflags_stubs_and_tests.py | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 65ecaa5f..33a88761 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -43,7 +43,7 @@ 'QtNetwork': '../../PyQt5-stubs/QtNetwork.pyi', 'QtDBus': '../../PyQt5-stubs/QtDBus.pyi', 'QtOpenGL': '../../PyQt5-stubs/QtOpenGL.pyi', - 'QtPrintsupport': '../../PyQt5-stubs/QtPrintsupport.pyi', + 'QtPrintsupport': '../../PyQt5-stubs/QtPrintSupport.pyi', 'QtSql': '../../PyQt5-stubs/QtSql.pyi', 'QtTest': '../../PyQt5-stubs/QtTest.pyi', 'QtXml': '../../PyQt5-stubs/QtXml.pyi', @@ -251,6 +251,7 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str, auto_commi Return number of remaining flags to process (0 when everything done) ''' + with open(qflag_to_process_json) as f: d = json.load(f) @@ -1032,6 +1033,22 @@ def generate_qflags_to_process(qt_qflag_grep_result_fname): extract_qflags_to_process(qflags_modules_analysis_json, qflags_to_process_json) log_progress('qflag file ready to process: %s' % qflags_to_process_json) + +def regen_test_files(qflag_process_results: str) -> None: + with open(qflag_process_results) as f: + results_content = f.read() + results = json.loads(results_content) + + flags_to_process = results['qflag_processed_done'] + results['qflag_already_done'] + log_progress('%d test files to regenerate' % len(flags_to_process)) + for flag_info_dict in flags_to_process: + flag_info = QFlagLocationInfo(**flag_info_dict) + test_qflag_fname = gen_test_fname(flag_info) + print('Updating', test_qflag_fname) + generate_qflag_test_file(flag_info) + + + if __name__ == '__main__': if len(sys.argv) <= 1: @@ -1070,6 +1087,17 @@ def generate_qflags_to_process(qt_qflag_grep_result_fname): grep_fname = sys.argv[2] generate_qflags_to_process(grep_fname) + + elif sys.argv[1] == 'regen_test_files': + + if len(sys.argv) <= 2: + print('Error, you must provide the filename of the qflag-process-results\n') + print(USAGE) + sys.exit(1) + + qflag_process_results = sys.argv[2] + regen_test_files(qflag_process_results) + else: print('Error, invalid command line arguments\n') print(USAGE) From 0c805f392c34d2df19973d58af20538602f59fd5 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 18 Sep 2021 13:42:40 +0200 Subject: [PATCH 215/421] QFlag operations for QDialogButtonBox.StandardButtons, QDialogButtonBox.StandardButton in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 17 +- ...tWidgets_StandardButtons_StandardButton.py | 186 ++++++++++-------- 2 files changed, 118 insertions(+), 85 deletions(-) diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 199ea048..8f3fa5ef 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -3607,11 +3607,9 @@ class QDial(QAbstractSlider): class QDialogButtonBox(QWidget): class StandardButton(int): - @typing.overload # type: ignore[override] - def __or__(self, other: typing.Union['QDialogButtonBox.StandardButton', 'QDialogButtonBox.StandardButtons']) -> 'QDialogButtonBox.StandardButtons': ... # type: ignore[misc] - @typing.overload - def __or__(self, other: int) -> int: ... - + def __or__ (self, other: 'QDialogButtonBox.StandardButton') -> 'QDialogButtonBox.StandardButtons': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QDialogButtonBox.StandardButtons': ... # type: ignore[override, misc] + NoButton = ... # type: QDialogButtonBox.StandardButton Ok = ... # type: QDialogButtonBox.StandardButton Save = ... # type: QDialogButtonBox.StandardButton @@ -3696,13 +3694,20 @@ class QDialogButtonBox(QWidget): def __init__(self, f: typing.Union['QDialogButtonBox.StandardButtons', 'QDialogButtonBox.StandardButton']) -> None: ... @typing.overload def __init__(self, a0: 'QDialogButtonBox.StandardButtons') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QDialogButtonBox.StandardButtons': ... def __index__(self) -> int: ... def __int__(self) -> int: ... - def __or__(self, other: typing.Union[int, 'QDialogButtonBox.StandardButtons', 'QDialogButtonBox.StandardButton']) -> 'QDialogButtonBox.StandardButtons': ... + def __or__ (self, other: typing.Union['QDialogButtonBox.StandardButtons', 'QDialogButtonBox.StandardButton', int]) -> 'QDialogButtonBox.StandardButtons': ... + def __and__(self, other: typing.Union['QDialogButtonBox.StandardButtons', 'QDialogButtonBox.StandardButton', int]) -> 'QDialogButtonBox.StandardButtons': ... + def __xor__(self, other: typing.Union['QDialogButtonBox.StandardButtons', 'QDialogButtonBox.StandardButton', int]) -> 'QDialogButtonBox.StandardButtons': ... + def __ror__ (self, other: 'QDialogButtonBox.StandardButton') -> 'QDialogButtonBox.StandardButtons': ... + def __rand__(self, other: 'QDialogButtonBox.StandardButton') -> 'QDialogButtonBox.StandardButtons': ... + def __rxor__(self, other: 'QDialogButtonBox.StandardButton') -> 'QDialogButtonBox.StandardButtons': ... @typing.overload def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py b/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py index a21ee5ad..38797e2b 100644 --- a/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py +++ b/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py @@ -1,21 +1,33 @@ -from typing import Union, TypeVar, Type +from typing import Union, TypeVar, Type, Literal import pytest ### Specific part -# file generated from qflags_test_template.py for QFlags class "QMessageBox.StandardButtons" and flag class "QMessageBox.StandardButton" +# file generated from qflags_test_template.py for QFlags class "QDialogButtonBox.StandardButtons" and flag class "QDialogButtonBox.StandardButton" from PyQt5 import QtWidgets -OneFlagClass = QtWidgets.QMessageBox.StandardButton -MultiFlagClass = QtWidgets.QMessageBox.StandardButtons +OneFlagClass = QtWidgets.QDialogButtonBox.StandardButton +MultiFlagClass = QtWidgets.QDialogButtonBox.StandardButtons -oneFlagRefValue1 = QtWidgets.QMessageBox.StandardButton.NoButton -oneFlagRefValue2 = QtWidgets.QMessageBox.StandardButton.Ok +oneFlagRefValue1 = QtWidgets.QDialogButtonBox.StandardButton.NoButton +oneFlagRefValue2 = QtWidgets.QDialogButtonBox.StandardButton.Ok + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -26,12 +38,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -51,54 +57,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 33) + else: + assert_type_of_value_int(oneFlagValue1 | 33) + assert_type_of_value_int(oneFlagValue1 & 33) + assert_type_of_value_int(oneFlagValue1 ^ 33) + assert_type_of_value_int(oneFlagValue1 + 33) + assert_type_of_value_int(oneFlagValue1 - 33) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(33 | oneFlagValue1) + else: + assert_type_of_value_int(33 | oneFlagValue1) + assert_type_of_value_int(33 & oneFlagValue1) + assert_type_of_value_int(33 ^ oneFlagValue1) + assert_type_of_value_int(33 + oneFlagValue1) + assert_type_of_value_int(33 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 33 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 33 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -109,34 +137,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 33) + assert_type_of_value_multiFlag(multiFlagValue1 & 33) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -145,14 +173,14 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully multiFlagValueTest = 33 # type: ignore @@ -161,30 +189,30 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = MultiFlagClass(33) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) #########################################################3 # From 36acbc19948663614fb16a3c977a31584405a1f6 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 9 Nov 2021 21:38:13 +0100 Subject: [PATCH 216/421] Removing QtWebEngineCore.QtWebEngineCore The class is no longer present for PyQtWebEngine5.15.5 in QtWebEngineCore.pyd . The presence of this class was very probably an implementation detail which should not have made it to the stubs. --- PyQt5-stubs/QtWebEngineCore.pyi | 3 --- 1 file changed, 3 deletions(-) diff --git a/PyQt5-stubs/QtWebEngineCore.pyi b/PyQt5-stubs/QtWebEngineCore.pyi index 4fd28480..9ded0abd 100644 --- a/PyQt5-stubs/QtWebEngineCore.pyi +++ b/PyQt5-stubs/QtWebEngineCore.pyi @@ -40,9 +40,6 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], typing.Sequence[float], sip.Buffer, int, None] -class QtWebEngineCore(sip.simplewrapper): ... - - class QWebEngineClientCertificateStore(sip.simplewrapper): def clear(self) -> None: ... From b2512c79589ae0178757d941d40e8b6f24ad9a59 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 11 Nov 2021 09:31:24 +0100 Subject: [PATCH 217/421] Use a low value 1 for testing QFlag conversion from value --- tests/qflags/qflags_test_template.py | 80 ++++++++++++++-------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/qflags/qflags_test_template.py b/tests/qflags/qflags_test_template.py index b8bb1569..25af28ca 100644 --- a/tests/qflags/qflags_test_template.py +++ b/tests/qflags/qflags_test_template.py @@ -46,17 +46,17 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) # Note that this breaks Liskov principle # 2. everything else returns int: & ^ &= ^= - # 3. operations with int return int. + # 1. operations with int return int. if OR_CONVERTS_TO_MULTI: assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) @@ -69,23 +69,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -101,17 +101,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -121,7 +121,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -163,9 +163,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -184,10 +184,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -204,57 +204,57 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] - def f3() -> None: + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) - pytest.raises(TypeError, f3) + pytest.raises(TypeError, f1) pytest.raises(TypeError, f4) From 6e78b721ccabce0dc147a0598234045e2de7c1b4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 11 Nov 2021 21:50:11 +0100 Subject: [PATCH 218/421] Result of processing the grep results. Basis for processing flags. --- tests/qflags/qflags_to_process.json | 1947 +++++++++++++++++++++++++++ 1 file changed, 1947 insertions(+) create mode 100644 tests/qflags/qflags_to_process.json diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json new file mode 100644 index 00000000..e9ff9545 --- /dev/null +++ b/tests/qflags/qflags_to_process.json @@ -0,0 +1,1947 @@ +{ + "__": "This file can be adjusted manually by a human prior to being processed by the tool", + "qflags_to_process": [ + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "RegisterOptions", + "enum_class": "RegisterOption", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi" + }, + { + "qflag_class": "ConnectionCapabilities", + "enum_class": "ConnectionCapability", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi" + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" + }, + { + "qflag_class": "OpenGLVersionFlags", + "enum_class": "OpenGLVersionFlag", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" + }, + { + "qflag_class": "BindOptions", + "enum_class": "BindOption", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption)", + "src\\gui\\opengl\\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" + }, + { + "qflag_class": "ShaderType", + "enum_class": "ShaderTypeBit", + "grep_line": [ + "src\\opengl\\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)", + "src\\gui\\opengl\\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "WatchMode", + "enum_class": "WatchModeFlag", + "grep_line": [ + "src\\dbus\\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi" + }, + { + "qflag_class": "ConversionFlags", + "enum_class": "ConversionFlag", + "grep_line": [ + "src\\corelib\\codecs\\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)", + "src\\corelib\\codecs\\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "CheckIndexOptions", + "enum_class": "CheckIndexOption", + "grep_line": [ + "src\\corelib\\itemmodels\\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Filters", + "enum_class": "Filter", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(Filters, Filter)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "SortFlags", + "enum_class": "SortFlag", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Permissions", + "enum_class": "Permission", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "FileHandleFlags", + "enum_class": "FileHandleFlag", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "SelectionFlags", + "enum_class": "SelectionFlag", + "grep_line": [ + "src\\corelib\\itemmodels\\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "KeyboardModifiers", + "enum_class": "KeyboardModifier", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MouseButtons", + "enum_class": "MouseButton", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Orientations", + "enum_class": "Orientation", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Alignment", + "enum_class": "AlignmentFlag", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "WindowFlags", + "enum_class": "WindowType", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "WindowStates", + "enum_class": "WindowState", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ApplicationStates", + "enum_class": "ApplicationState", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ScreenOrientations", + "enum_class": "ScreenOrientation", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ImageConversionFlags", + "enum_class": "ImageConversionFlag", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "DockWidgetAreas", + "enum_class": "DockWidgetArea", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ToolBarAreas", + "enum_class": "ToolBarArea", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Edges", + "enum_class": "Edge", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "InputMethodQueries", + "enum_class": "InputMethodQuery", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "InputMethodHints", + "enum_class": "InputMethodHint", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "FindChildOptions", + "enum_class": "FindChildOption", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "DropActions", + "enum_class": "DropAction", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ItemFlags", + "enum_class": "ItemFlag", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MatchFlags", + "enum_class": "MatchFlag", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "TextInteractionFlags", + "enum_class": "TextInteractionFlag", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "TouchPointStates", + "enum_class": "TouchPointState", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "GestureFlags", + "enum_class": "GestureFlag", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MouseEventFlags", + "enum_class": "MouseEventFlag", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Transformations", + "enum_class": "Transformation", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "ProcessEventsFlags", + "enum_class": "ProcessEventsFlag", + "grep_line": [ + "src\\corelib\\kernel\\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "OpenMode", + "enum_class": "OpenModeFlag", + "grep_line": [ + "src\\corelib\\io\\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "InfoFlags", + "enum_class": "InfoFlag", + "grep_line": [ + "src\\gui\\kernel\\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "LoadHints", + "enum_class": "LoadHint", + "grep_line": [ + "src\\corelib\\plugin\\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "RangeAccessFlags", + "enum_class": "RangeAccessFlag", + "grep_line": [ + "src\\gui\\opengl\\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Sources", + "enum_class": "Source", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Types", + "enum_class": "Type", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Severities", + "enum_class": "Severity", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "TypeFlags", + "enum_class": "TypeFlag", + "grep_line": [ + "src\\corelib\\kernel\\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "LocateOptions", + "enum_class": "LocateOption", + "grep_line": [ + "src\\corelib\\io\\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "PolicyFlags", + "enum_class": "PolicyFlag", + "grep_line": [ + "src\\network\\access\\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "ColorDialogOptions", + "enum_class": "ColorDialogOption", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)", + "src\\widgets\\dialogs\\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "FontDialogOptions", + "enum_class": "FontDialogOption", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)", + "src\\widgets\\dialogs\\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ComponentFormattingOptions", + "enum_class": "ComponentFormattingOption", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "FormattingOptions", + "enum_class": "UrlFormattingOption", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "UserInputResolutionOptions", + "enum_class": "UserInputResolutionOption", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "StateFlags", + "enum_class": "StateFlag", + "grep_line": [ + "src\\network\\bearer\\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "UsagePolicies", + "enum_class": "UsagePolicy", + "grep_line": [ + "src\\network\\bearer\\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "PaintEngineFeatures", + "enum_class": "PaintEngineFeature", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "DirtyFlags", + "enum_class": "DirtyFlag", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Capabilities", + "enum_class": "CapabilityFlag", + "grep_line": [ + "src\\gui\\kernel\\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Features", + "enum_class": "Feature", + "grep_line": [ + "src\\gui\\opengl\\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature)", + "src\\gui\\text\\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "RenderHints", + "enum_class": "RenderHint", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "PixmapFragmentHints", + "enum_class": "PixmapFragmentHint", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "ControlTypes", + "enum_class": "ControlType", + "grep_line": [ + "src\\gui\\util\\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)", + "src\\widgets\\kernel\\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "GlyphRunFlags", + "enum_class": "GlyphRunFlag", + "grep_line": [ + "src\\gui\\text\\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "LayoutFlags", + "enum_class": "LayoutFlag", + "grep_line": [ + "src\\gui\\text\\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "MarkdownFeatures", + "enum_class": "MarkdownFeature", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "FindFlags", + "enum_class": "FindFlag", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "ConversionMode", + "enum_class": "ConversionModeFlag", + "grep_line": [ + "src\\network\\kernel\\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "BindMode", + "enum_class": "BindFlag", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "PauseModes", + "enum_class": "PauseMode", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "PageBreakFlags", + "enum_class": "PageBreakFlag", + "grep_line": [ + "src\\gui\\text\\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "SocketOptions", + "enum_class": "SocketOption", + "grep_line": [ + "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "InterfaceFlags", + "enum_class": "InterfaceFlag", + "grep_line": [ + "src\\network\\kernel\\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "SslOptions", + "enum_class": "SslOption", + "grep_line": [ + "src\\network\\ssl\\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "Base64Options", + "enum_class": "Base64Option", + "grep_line": [ + "src\\corelib\\text\\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "NumberOptions", + "enum_class": "NumberOption", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "DataSizeFormats", + "enum_class": "DataSizeFormat", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Sections", + "enum_class": "Section", + "grep_line": [ + "src\\corelib\\time\\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section)", + "src\\widgets\\widgets\\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "PatternOptions", + "enum_class": "PatternOption", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MatchOptions", + "enum_class": "MatchOption", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "NumberFlags", + "enum_class": "NumberFlag", + "grep_line": [ + "src\\corelib\\serialization\\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "BoundaryReasons", + "enum_class": "BoundaryReason", + "grep_line": [ + "src\\corelib\\text\\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "PrintDialogOptions", + "enum_class": "PrintDialogOption", + "grep_line": [ + "src\\printsupport\\dialogs\\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPrintSupport", + "module_path": "../../PyQt5-stubs/QtPrintSupport.pyi" + }, + { + "qflag_class": "ParamType", + "enum_class": "ParamTypeFlag", + "grep_line": [ + "src\\sql\\kernel\\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSql", + "module_path": "../../PyQt5-stubs/QtSql.pyi" + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 3, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 3, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 3, + "module_idx": 2, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "BlurHints", + "enum_class": "BlurHint", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "InputDialogOptions", + "enum_class": "InputDialogOption", + "grep_line": [ + "src\\widgets\\dialogs\\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "WizardOptions", + "enum_class": "WizardOption", + "grep_line": [ + "src\\widgets\\dialogs\\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "EditTriggers", + "enum_class": "EditTrigger", + "grep_line": [ + "src\\widgets\\itemviews\\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "GraphicsItemFlags", + "enum_class": "GraphicsItemFlag", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Result", + "enum_class": "ResultFlag", + "grep_line": [ + "src\\widgets\\kernel\\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "SceneLayers", + "enum_class": "SceneLayer", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "OptimizationFlags", + "enum_class": "OptimizationFlag", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "State", + "enum_class": "StateFlag", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" + ], + "human_hint_qflag_full_class_name": "QStyle.State", + "human_hint_enum_full_class_name": "QStyle.StateFlag", + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "State", + "enum_class": "StateFlag", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "SubControls", + "enum_class": "SubControl", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "StepEnabled", + "enum_class": "StepEnabledFlag", + "grep_line": [ + "src\\widgets\\widgets\\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "FrameFeatures", + "enum_class": "FrameFeature", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ButtonFeatures", + "enum_class": "ButtonFeature", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "CornerWidgets", + "enum_class": "CornerWidget", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "TabFeatures", + "enum_class": "TabFeature", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ToolBarFeatures", + "enum_class": "ToolBarFeature", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ViewItemFeatures", + "enum_class": "ViewItemFeature", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ToolButtonFeatures", + "enum_class": "ToolButtonFeature", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "DockWidgetFeatures", + "enum_class": "DockWidgetFeature", + "grep_line": [ + "src\\widgets\\widgets\\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "FontFilters", + "enum_class": "FontFilter", + "grep_line": [ + "src\\widgets\\widgets\\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "AreaOptions", + "enum_class": "AreaOption", + "grep_line": [ + "src\\widgets\\widgets\\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "SubWindowOptions", + "enum_class": "SubWindowOption", + "grep_line": [ + "src\\widgets\\widgets\\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "DockOptions", + "enum_class": "DockOption", + "grep_line": [ + "src\\widgets\\widgets\\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "AutoFormatting", + "enum_class": "AutoFormattingFlag", + "grep_line": [ + "src\\widgets\\widgets\\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + } + ], + "qflags_to_skip": [] +} \ No newline at end of file From e48275838bf7db8928755c892ab981f9e858002f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 11 Nov 2021 22:10:09 +0100 Subject: [PATCH 219/421] Regenerate grep results --- tests/qflags/qflags_to_process.json | 407 +++++++++++++++++++++++----- 1 file changed, 335 insertions(+), 72 deletions(-) diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index e9ff9545..321854f4 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -1,81 +1,11 @@ { "__": "This file can be adjusted manually by a human prior to being processed by the tool", "qflags_to_process": [ - { - "qflag_class": "StandardButtons", - "enum_class": "StandardButton", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "StandardButtons", - "enum_class": "StandardButton", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "Capabilities", - "enum_class": "Capability", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", - "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "Capabilities", - "enum_class": "Capability", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", - "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 1, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, { "qflag_class": "RegisterOptions", "enum_class": "RegisterOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)" ], @@ -91,6 +21,8 @@ { "qflag_class": "ConnectionCapabilities", "enum_class": "ConnectionCapability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)" ], @@ -106,6 +38,8 @@ { "qflag_class": "FormatOptions", "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" @@ -122,6 +56,8 @@ { "qflag_class": "FormatOptions", "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" @@ -138,6 +74,8 @@ { "qflag_class": "OpenGLVersionFlags", "enum_class": "OpenGLVersionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)" ], @@ -153,6 +91,8 @@ { "qflag_class": "BindOptions", "enum_class": "BindOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption)", "src\\gui\\opengl\\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption)" @@ -169,6 +109,8 @@ { "qflag_class": "ShaderType", "enum_class": "ShaderTypeBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\opengl\\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)", "src\\gui\\opengl\\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)" @@ -185,6 +127,8 @@ { "qflag_class": "WatchMode", "enum_class": "WatchModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\dbus\\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)" ], @@ -200,6 +144,8 @@ { "qflag_class": "ConversionFlags", "enum_class": "ConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\codecs\\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)", "src\\corelib\\codecs\\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)" @@ -216,6 +162,8 @@ { "qflag_class": "CheckIndexOptions", "enum_class": "CheckIndexOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\itemmodels\\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)" ], @@ -231,6 +179,8 @@ { "qflag_class": "Filters", "enum_class": "Filter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(Filters, Filter)" ], @@ -246,6 +196,8 @@ { "qflag_class": "SortFlags", "enum_class": "SortFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag)" ], @@ -261,6 +213,8 @@ { "qflag_class": "IteratorFlags", "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", @@ -278,6 +232,8 @@ { "qflag_class": "IteratorFlags", "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", @@ -295,6 +251,8 @@ { "qflag_class": "Permissions", "enum_class": "Permission", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission)" ], @@ -310,6 +268,8 @@ { "qflag_class": "FileHandleFlags", "enum_class": "FileHandleFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)" ], @@ -325,6 +285,8 @@ { "qflag_class": "SelectionFlags", "enum_class": "SelectionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\itemmodels\\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" ], @@ -340,6 +302,8 @@ { "qflag_class": "KeyboardModifiers", "enum_class": "KeyboardModifier", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)" ], @@ -355,6 +319,8 @@ { "qflag_class": "MouseButtons", "enum_class": "MouseButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton)" ], @@ -370,6 +336,8 @@ { "qflag_class": "Orientations", "enum_class": "Orientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation)" ], @@ -385,6 +353,8 @@ { "qflag_class": "Alignment", "enum_class": "AlignmentFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag)" ], @@ -400,6 +370,8 @@ { "qflag_class": "WindowFlags", "enum_class": "WindowType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType)" ], @@ -415,6 +387,8 @@ { "qflag_class": "WindowStates", "enum_class": "WindowState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState)" ], @@ -430,6 +404,8 @@ { "qflag_class": "ApplicationStates", "enum_class": "ApplicationState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState)" ], @@ -445,6 +421,8 @@ { "qflag_class": "ScreenOrientations", "enum_class": "ScreenOrientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation)" ], @@ -460,6 +438,8 @@ { "qflag_class": "ImageConversionFlags", "enum_class": "ImageConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag)" ], @@ -475,6 +455,8 @@ { "qflag_class": "DockWidgetAreas", "enum_class": "DockWidgetArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)" ], @@ -490,6 +472,8 @@ { "qflag_class": "ToolBarAreas", "enum_class": "ToolBarArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)" ], @@ -505,6 +489,8 @@ { "qflag_class": "Edges", "enum_class": "Edge", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge)" ], @@ -520,6 +506,8 @@ { "qflag_class": "InputMethodQueries", "enum_class": "InputMethodQuery", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery)" ], @@ -535,6 +523,8 @@ { "qflag_class": "InputMethodHints", "enum_class": "InputMethodHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)" ], @@ -550,6 +540,8 @@ { "qflag_class": "FindChildOptions", "enum_class": "FindChildOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)" ], @@ -565,6 +557,8 @@ { "qflag_class": "DropActions", "enum_class": "DropAction", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction)" ], @@ -580,6 +574,8 @@ { "qflag_class": "ItemFlags", "enum_class": "ItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag)" ], @@ -595,6 +591,8 @@ { "qflag_class": "MatchFlags", "enum_class": "MatchFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag)" ], @@ -610,6 +608,8 @@ { "qflag_class": "TextInteractionFlags", "enum_class": "TextInteractionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag)" ], @@ -625,6 +625,8 @@ { "qflag_class": "TouchPointStates", "enum_class": "TouchPointState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)" ], @@ -640,6 +642,8 @@ { "qflag_class": "GestureFlags", "enum_class": "GestureFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag)" ], @@ -655,6 +659,8 @@ { "qflag_class": "MouseEventFlags", "enum_class": "MouseEventFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)" ], @@ -670,6 +676,8 @@ { "qflag_class": "Transformations", "enum_class": "Transformation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation)" ], @@ -682,9 +690,53 @@ "module_name": "QtGui", "module_path": "../../PyQt5-stubs/QtGui.pyi" }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, { "qflag_class": "ProcessEventsFlags", "enum_class": "ProcessEventsFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\kernel\\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)" ], @@ -700,6 +752,8 @@ { "qflag_class": "OpenMode", "enum_class": "OpenModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\io\\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)" ], @@ -715,6 +769,8 @@ { "qflag_class": "InfoFlags", "enum_class": "InfoFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\kernel\\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag)" ], @@ -730,6 +786,8 @@ { "qflag_class": "LoadHints", "enum_class": "LoadHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\plugin\\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint)" ], @@ -745,6 +803,8 @@ { "qflag_class": "RangeAccessFlags", "enum_class": "RangeAccessFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\opengl\\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)" ], @@ -760,6 +820,8 @@ { "qflag_class": "Sources", "enum_class": "Source", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source)" ], @@ -775,6 +837,8 @@ { "qflag_class": "Types", "enum_class": "Type", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" ], @@ -790,6 +854,8 @@ { "qflag_class": "Severities", "enum_class": "Severity", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity)" ], @@ -805,6 +871,8 @@ { "qflag_class": "TypeFlags", "enum_class": "TypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\kernel\\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag)" ], @@ -820,6 +888,8 @@ { "qflag_class": "LocateOptions", "enum_class": "LocateOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\io\\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption)" ], @@ -835,6 +905,8 @@ { "qflag_class": "Flags", "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", @@ -867,6 +939,8 @@ { "qflag_class": "Flags", "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", @@ -899,6 +973,8 @@ { "qflag_class": "PolicyFlags", "enum_class": "PolicyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\network\\access\\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)" ], @@ -911,9 +987,49 @@ "module_name": "QtNetwork", "module_path": "../../PyQt5-stubs/QtNetwork.pyi" }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, { "qflag_class": "ColorDialogOptions", "enum_class": "ColorDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)", "src\\widgets\\dialogs\\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)" @@ -930,6 +1046,8 @@ { "qflag_class": "FontDialogOptions", "enum_class": "FontDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)", "src\\widgets\\dialogs\\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)" @@ -946,6 +1064,8 @@ { "qflag_class": "ComponentFormattingOptions", "enum_class": "ComponentFormattingOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)" ], @@ -961,6 +1081,8 @@ { "qflag_class": "FormattingOptions", "enum_class": "UrlFormattingOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)" ], @@ -976,6 +1098,8 @@ { "qflag_class": "UserInputResolutionOptions", "enum_class": "UserInputResolutionOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption)" ], @@ -991,6 +1115,8 @@ { "qflag_class": "StateFlags", "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\network\\bearer\\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" ], @@ -1006,6 +1132,8 @@ { "qflag_class": "UsagePolicies", "enum_class": "UsagePolicy", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\network\\bearer\\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)" ], @@ -1021,6 +1149,8 @@ { "qflag_class": "RenderFlags", "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" @@ -1037,6 +1167,8 @@ { "qflag_class": "RenderFlags", "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" @@ -1053,6 +1185,8 @@ { "qflag_class": "PaintEngineFeatures", "enum_class": "PaintEngineFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)" ], @@ -1068,6 +1202,8 @@ { "qflag_class": "DirtyFlags", "enum_class": "DirtyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" ], @@ -1083,6 +1219,8 @@ { "qflag_class": "Capabilities", "enum_class": "CapabilityFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\kernel\\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" ], @@ -1098,6 +1236,8 @@ { "qflag_class": "Features", "enum_class": "Feature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\opengl\\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature)", "src\\gui\\text\\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature)" @@ -1114,6 +1254,8 @@ { "qflag_class": "RenderHints", "enum_class": "RenderHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint)" ], @@ -1129,6 +1271,8 @@ { "qflag_class": "PixmapFragmentHints", "enum_class": "PixmapFragmentHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)" ], @@ -1144,6 +1288,8 @@ { "qflag_class": "ControlTypes", "enum_class": "ControlType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\util\\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)", "src\\widgets\\kernel\\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)" @@ -1160,6 +1306,8 @@ { "qflag_class": "GlyphRunFlags", "enum_class": "GlyphRunFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\text\\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag)" ], @@ -1175,6 +1323,8 @@ { "qflag_class": "LayoutFlags", "enum_class": "LayoutFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\text\\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)" ], @@ -1190,6 +1340,8 @@ { "qflag_class": "MarkdownFeatures", "enum_class": "MarkdownFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)" ], @@ -1205,6 +1357,8 @@ { "qflag_class": "FindFlags", "enum_class": "FindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag)" ], @@ -1220,6 +1374,8 @@ { "qflag_class": "ConversionMode", "enum_class": "ConversionModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\network\\kernel\\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)" ], @@ -1235,6 +1391,8 @@ { "qflag_class": "BindMode", "enum_class": "BindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag)" ], @@ -1250,6 +1408,8 @@ { "qflag_class": "PauseModes", "enum_class": "PauseMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode)" ], @@ -1265,6 +1425,8 @@ { "qflag_class": "PageBreakFlags", "enum_class": "PageBreakFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\gui\\text\\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)" ], @@ -1280,6 +1442,8 @@ { "qflag_class": "SocketOptions", "enum_class": "SocketOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" ], @@ -1295,6 +1459,8 @@ { "qflag_class": "InterfaceFlags", "enum_class": "InterfaceFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\network\\kernel\\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)" ], @@ -1310,6 +1476,8 @@ { "qflag_class": "SslOptions", "enum_class": "SslOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\network\\ssl\\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption)" ], @@ -1325,6 +1493,8 @@ { "qflag_class": "Base64Options", "enum_class": "Base64Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\text\\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option)" ], @@ -1340,6 +1510,8 @@ { "qflag_class": "NumberOptions", "enum_class": "NumberOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption)" ], @@ -1355,6 +1527,8 @@ { "qflag_class": "DataSizeFormats", "enum_class": "DataSizeFormat", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat)" ], @@ -1370,6 +1544,8 @@ { "qflag_class": "Sections", "enum_class": "Section", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\time\\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section)", "src\\widgets\\widgets\\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section)" @@ -1386,6 +1562,8 @@ { "qflag_class": "PatternOptions", "enum_class": "PatternOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption)" ], @@ -1401,6 +1579,8 @@ { "qflag_class": "MatchOptions", "enum_class": "MatchOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption)" ], @@ -1416,6 +1596,8 @@ { "qflag_class": "NumberFlags", "enum_class": "NumberFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\serialization\\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag)" ], @@ -1431,6 +1613,8 @@ { "qflag_class": "BoundaryReasons", "enum_class": "BoundaryReason", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\corelib\\text\\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )" ], @@ -1446,6 +1630,8 @@ { "qflag_class": "PrintDialogOptions", "enum_class": "PrintDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\printsupport\\dialogs\\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)" ], @@ -1461,6 +1647,8 @@ { "qflag_class": "ParamType", "enum_class": "ParamTypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\sql\\kernel\\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag)" ], @@ -1476,6 +1664,8 @@ { "qflag_class": "Options", "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", @@ -1496,6 +1686,8 @@ { "qflag_class": "Options", "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", @@ -1516,6 +1708,8 @@ { "qflag_class": "Options", "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", @@ -1536,6 +1730,8 @@ { "qflag_class": "ChangeFlags", "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" @@ -1552,6 +1748,8 @@ { "qflag_class": "ChangeFlags", "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" @@ -1568,6 +1766,8 @@ { "qflag_class": "BlurHints", "enum_class": "BlurHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint)" ], @@ -1583,6 +1783,8 @@ { "qflag_class": "InputDialogOptions", "enum_class": "InputDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\dialogs\\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)" ], @@ -1598,6 +1800,8 @@ { "qflag_class": "WizardOptions", "enum_class": "WizardOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\dialogs\\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption)" ], @@ -1613,6 +1817,8 @@ { "qflag_class": "EditTriggers", "enum_class": "EditTrigger", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\itemviews\\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger)" ], @@ -1628,6 +1834,8 @@ { "qflag_class": "GraphicsItemFlags", "enum_class": "GraphicsItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\graphicsview\\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)" ], @@ -1643,6 +1851,8 @@ { "qflag_class": "Result", "enum_class": "ResultFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\kernel\\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag)" ], @@ -1658,6 +1868,8 @@ { "qflag_class": "SceneLayers", "enum_class": "SceneLayer", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\graphicsview\\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer)" ], @@ -1670,9 +1882,28 @@ "module_name": "QtWidgets", "module_path": "../../PyQt5-stubs/QtWidgets.pyi" }, + { + "qflag_class": "CacheMode", + "enum_class": "CacheModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, { "qflag_class": "OptimizationFlags", "enum_class": "OptimizationFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)" ], @@ -1705,6 +1936,8 @@ { "qflag_class": "State", "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" ], @@ -1720,6 +1953,8 @@ { "qflag_class": "SubControls", "enum_class": "SubControl", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl)" ], @@ -1735,6 +1970,8 @@ { "qflag_class": "StepEnabled", "enum_class": "StepEnabledFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\widgets\\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)" ], @@ -1750,6 +1987,8 @@ { "qflag_class": "FrameFeatures", "enum_class": "FrameFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)" ], @@ -1765,6 +2004,8 @@ { "qflag_class": "ButtonFeatures", "enum_class": "ButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)" ], @@ -1780,6 +2021,8 @@ { "qflag_class": "CornerWidgets", "enum_class": "CornerWidget", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)" ], @@ -1795,6 +2038,8 @@ { "qflag_class": "TabFeatures", "enum_class": "TabFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature)" ], @@ -1810,6 +2055,8 @@ { "qflag_class": "ToolBarFeatures", "enum_class": "ToolBarFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)" ], @@ -1825,6 +2072,8 @@ { "qflag_class": "ViewItemFeatures", "enum_class": "ViewItemFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)" ], @@ -1840,6 +2089,8 @@ { "qflag_class": "ToolButtonFeatures", "enum_class": "ToolButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)" ], @@ -1855,6 +2106,8 @@ { "qflag_class": "DockWidgetFeatures", "enum_class": "DockWidgetFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\widgets\\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)" ], @@ -1870,6 +2123,8 @@ { "qflag_class": "FontFilters", "enum_class": "FontFilter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\widgets\\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter)" ], @@ -1885,6 +2140,8 @@ { "qflag_class": "AreaOptions", "enum_class": "AreaOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\widgets\\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption)" ], @@ -1900,6 +2157,8 @@ { "qflag_class": "SubWindowOptions", "enum_class": "SubWindowOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\widgets\\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)" ], @@ -1915,6 +2174,8 @@ { "qflag_class": "DockOptions", "enum_class": "DockOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\widgets\\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption)" ], @@ -1930,6 +2191,8 @@ { "qflag_class": "AutoFormatting", "enum_class": "AutoFormattingFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", "grep_line": [ "src\\widgets\\widgets\\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)" ], From 1cabba9154124b59102b6814c92dc72487ec54c1 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 11 Nov 2021 22:13:51 +0100 Subject: [PATCH 220/421] Fix and improve grep results analysis --- tests/qflags/generate_qflags_stubs_and_tests.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 33a88761..a68bb9bb 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -43,7 +43,7 @@ 'QtNetwork': '../../PyQt5-stubs/QtNetwork.pyi', 'QtDBus': '../../PyQt5-stubs/QtDBus.pyi', 'QtOpenGL': '../../PyQt5-stubs/QtOpenGL.pyi', - 'QtPrintsupport': '../../PyQt5-stubs/QtPrintSupport.pyi', + 'QtPrintSupport': '../../PyQt5-stubs/QtPrintSupport.pyi', 'QtSql': '../../PyQt5-stubs/QtSql.pyi', 'QtTest': '../../PyQt5-stubs/QtTest.pyi', 'QtXml': '../../PyQt5-stubs/QtXml.pyi', @@ -95,7 +95,14 @@ def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[s # oups, we don't know how to encode that return flag_loc_info - return dataclasses.asdict(flag_loc_info) + d = dataclasses.asdict(flag_loc_info) + # when returning the result of the grep analysis, we want only a specific subset + # of the datablass fields + del d["or_converts_to_multi"] + del d["or_int_converts_to_multi"] + del d["int_or_converts_to_multi"] + + return d def identify_qflag_location(fname_grep_result: str, @@ -127,7 +134,7 @@ def identify_qflag_location(fname_grep_result: str, # just extend the grep line then parsed_qflags[(qflag_class, enum_class)].grep_line += (grep_line,) else: - parsed_qflags[(qflag_class, enum_class)] = QFlagLocationInfo(qflag_class, enum_class, (grep_line,)) + parsed_qflags[(qflag_class, enum_class)] = QFlagLocationInfo(qflag_class, enum_class, grep_line=(grep_line,)) # fill up modules with content qt_modules_content = [ (mod_name, open(mod_stub_path, encoding='utf8').read()) @@ -137,8 +144,8 @@ def identify_qflag_location(fname_grep_result: str, module_mapping: Dict[ Tuple[str, str], Dict[str, QFlagLocationInfo]] = {} for qflag_key, flag_info in parsed_qflags.items(): - decl_qflag_class = 'class %s(' % flag_info.qflag_class - decl_enum_class = 'class %s(' % flag_info.enum_class + decl_qflag_class = 'class %s(sip.simplewrapper' % flag_info.qflag_class + decl_enum_class = 'class %s(int' % flag_info.enum_class for mod_name, mod_content in qt_modules_content: if decl_qflag_class in mod_content and decl_enum_class in mod_content: From b69eba63fe8c30cce28537b084da4c528628ea82 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 11 Nov 2021 22:14:43 +0100 Subject: [PATCH 221/421] Better handling of missing expected attributes in classes --- tests/qflags/generate_qflags_stubs_and_tests.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index a68bb9bb..eeee1b94 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -6,6 +6,7 @@ import os import sys import subprocess +import traceback from enum import Enum from PyQt5 import (QtCore, QtWidgets, QtGui, QtNetwork, QtDBus, QtOpenGL, @@ -475,10 +476,14 @@ class not found, class found multiple times, ... flag_info.qflag_full_class_name = visitor.qflag_class_full_name # evaluate exact behavior of QFlag - flag_info.or_converts_to_multi = not eval('''type({qtmodule}.{oneFlagName}.{value1} | {qtmodule}.{oneFlagName}.{value2}) == int'''.format( - value1=flag_info.enum_value1, value2=flag_info.enum_value2, - qtmodule=flag_info.module_name, - oneFlagName=flag_info.enum_full_class_name)) + try: + flag_info.or_converts_to_multi = not eval('''type({qtmodule}.{oneFlagName}.{value1} | {qtmodule}.{oneFlagName}.{value2}) == int'''.format( + value1=flag_info.enum_value1, value2=flag_info.enum_value2, + qtmodule=flag_info.module_name, + oneFlagName=flag_info.enum_full_class_name)) + except Exception as exc: + return (QFlagGenResult.ErrorDuringProcessing, traceback.format_exc(), '') + flag_info.or_int_converts_to_multi = not eval('''type({qtmodule}.{oneFlagName}.{value1} | 33) == int'''.format( value1=flag_info.enum_value1, qtmodule = flag_info.module_name, oneFlagName = flag_info.enum_full_class_name)) flag_info.int_or_converts_to_multi = not eval('''type(33 | {qtmodule}.{oneFlagName}.{value1}) == int'''.format( From bc1ce9ac9cdef6571d68fef2b68a91c63297c8cc Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 11 Nov 2021 22:15:09 +0100 Subject: [PATCH 222/421] Improved grep results --- tests/qflags/qflags_to_process.json | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index 321854f4..0a3ec5c5 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -1916,23 +1916,6 @@ "module_name": "QtWidgets", "module_path": "../../PyQt5-stubs/QtWidgets.pyi" }, - { - "qflag_class": "State", - "enum_class": "StateFlag", - "grep_line": [ - "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" - ], - "human_hint_qflag_full_class_name": "QStyle.State", - "human_hint_enum_full_class_name": "QStyle.StateFlag", - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, { "qflag_class": "State", "enum_class": "StateFlag", @@ -1947,8 +1930,8 @@ "enum_value2": "", "module_count": 1, "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" }, { "qflag_class": "SubControls", From 9484b71daee7db20d8f3ac8aea2a51aaeac28863 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 11 Nov 2021 22:54:16 +0100 Subject: [PATCH 223/421] Fix typo --- tests/qflags/qflags_test_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qflags/qflags_test_template.py b/tests/qflags/qflags_test_template.py index 25af28ca..71678a9b 100644 --- a/tests/qflags/qflags_test_template.py +++ b/tests/qflags/qflags_test_template.py @@ -246,7 +246,7 @@ def f1() -> None: def f2() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += 1 # type: ignore[assignment, operator] - def f1() -> None: + def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: From d8116eada04b2b3cad79af907361d6b7e4fbb93e Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 11 Nov 2021 22:56:03 +0100 Subject: [PATCH 224/421] QFlag operations for QOpenGLDebugMessage.Types, QOpenGLDebugMessage.Type in module QtGui --- PyQt5-stubs/QtGui.pyi | 11 ++ tests/qflags/qflags_to_process.json | 4 +- tests/qflags/test_QtGui_Types_Type.py | 259 ++++++++++++++++++++++++++ 3 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 tests/qflags/test_QtGui_Types_Type.py diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 1576be50..855e1a6c 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -4053,6 +4053,9 @@ class QOpenGLDebugMessage(sip.simplewrapper): AnySeverity = ... # type: QOpenGLDebugMessage.Severity class Type(int): + def __or__ (self, other: 'QOpenGLDebugMessage.Type') -> 'QOpenGLDebugMessage.Types': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QOpenGLDebugMessage.Types': ... # type: ignore[override, misc] + InvalidType = ... # type: QOpenGLDebugMessage.Type ErrorType = ... # type: QOpenGLDebugMessage.Type DeprecatedBehaviorType = ... # type: QOpenGLDebugMessage.Type @@ -4130,12 +4133,20 @@ class QOpenGLDebugMessage(sip.simplewrapper): def __init__(self, f: typing.Union['QOpenGLDebugMessage.Types', 'QOpenGLDebugMessage.Type']) -> None: ... @typing.overload def __init__(self, a0: 'QOpenGLDebugMessage.Types') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QOpenGLDebugMessage.Types': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QOpenGLDebugMessage.Types', 'QOpenGLDebugMessage.Type', int]) -> 'QOpenGLDebugMessage.Types': ... + def __and__(self, other: typing.Union['QOpenGLDebugMessage.Types', 'QOpenGLDebugMessage.Type', int]) -> 'QOpenGLDebugMessage.Types': ... + def __xor__(self, other: typing.Union['QOpenGLDebugMessage.Types', 'QOpenGLDebugMessage.Type', int]) -> 'QOpenGLDebugMessage.Types': ... + def __ror__ (self, other: 'QOpenGLDebugMessage.Type') -> 'QOpenGLDebugMessage.Types': ... + def __rand__(self, other: 'QOpenGLDebugMessage.Type') -> 'QOpenGLDebugMessage.Types': ... + def __rxor__(self, other: 'QOpenGLDebugMessage.Type') -> 'QOpenGLDebugMessage.Types': ... class Severities(sip.simplewrapper): diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index 0a3ec5c5..6a621326 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -837,8 +837,8 @@ { "qflag_class": "Types", "enum_class": "Type", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", + "human_hint_qflag_full_class_name": "QOpenGLDebugMessage.Types", + "human_hint_enum_full_class_name": "QOpenGLDebugMessage.Type", "grep_line": [ "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" ], diff --git a/tests/qflags/test_QtGui_Types_Type.py b/tests/qflags/test_QtGui_Types_Type.py new file mode 100644 index 00000000..4188d7ca --- /dev/null +++ b/tests/qflags/test_QtGui_Types_Type.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QOpenGLDebugMessage.Types" and flag class "QOpenGLDebugMessage.Type" +from PyQt5 import QtGui + +OneFlagClass = QtGui.QOpenGLDebugMessage.Type +MultiFlagClass = QtGui.QOpenGLDebugMessage.Types + +oneFlagRefValue1 = QtGui.QOpenGLDebugMessage.Type.InvalidType +oneFlagRefValue2 = QtGui.QOpenGLDebugMessage.Type.ErrorType + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 1. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f4) + From 93b8ff7973d3c922a63cf4f5ec715243c0de5b18 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 12 Nov 2021 09:29:06 +0100 Subject: [PATCH 225/421] QFlag operations for QLocalServer.SocketOptions, QLocalServer.SocketOption in module QtNetwork --- PyQt5-stubs/QtNetwork.pyi | 11 + tests/qflags/qflags_to_process.json | 4 +- ...st_QtNetwork_SocketOptions_SocketOption.py | 259 ++++++++++++++++++ 3 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 24649918..23d6e6bd 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -752,6 +752,9 @@ class QHttpMultiPart(QtCore.QObject): class QLocalServer(QtCore.QObject): class SocketOption(int): + def __or__ (self, other: 'QLocalServer.SocketOption') -> 'QLocalServer.SocketOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QLocalServer.SocketOptions': ... # type: ignore[override, misc] + UserAccessOption = ... # type: QLocalServer.SocketOption GroupAccessOption = ... # type: QLocalServer.SocketOption OtherAccessOption = ... # type: QLocalServer.SocketOption @@ -770,12 +773,20 @@ class QLocalServer(QtCore.QObject): def __init__(self, f: typing.Union['QLocalServer.SocketOptions', 'QLocalServer.SocketOption']) -> None: ... @typing.overload def __init__(self, a0: 'QLocalServer.SocketOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QLocalServer.SocketOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QLocalServer.SocketOptions', 'QLocalServer.SocketOption', int]) -> 'QLocalServer.SocketOptions': ... + def __and__(self, other: typing.Union['QLocalServer.SocketOptions', 'QLocalServer.SocketOption', int]) -> 'QLocalServer.SocketOptions': ... + def __xor__(self, other: typing.Union['QLocalServer.SocketOptions', 'QLocalServer.SocketOption', int]) -> 'QLocalServer.SocketOptions': ... + def __ror__ (self, other: 'QLocalServer.SocketOption') -> 'QLocalServer.SocketOptions': ... + def __rand__(self, other: 'QLocalServer.SocketOption') -> 'QLocalServer.SocketOptions': ... + def __rxor__(self, other: 'QLocalServer.SocketOption') -> 'QLocalServer.SocketOptions': ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index 6a621326..d873f043 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -1442,8 +1442,8 @@ { "qflag_class": "SocketOptions", "enum_class": "SocketOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", + "human_hint_qflag_full_class_name": "QLocalServer.SocketOptions", + "human_hint_enum_full_class_name": "QLocalServer.SocketOption", "grep_line": [ "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" ], diff --git a/tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py b/tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py new file mode 100644 index 00000000..edb4793f --- /dev/null +++ b/tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QLocalServer.SocketOptions" and flag class "QLocalServer.SocketOption" +from PyQt5 import QtNetwork + +OneFlagClass = QtNetwork.QLocalServer.SocketOption +MultiFlagClass = QtNetwork.QLocalServer.SocketOptions + +oneFlagRefValue1 = QtNetwork.QLocalServer.SocketOption.UserAccessOption +oneFlagRefValue2 = QtNetwork.QLocalServer.SocketOption.GroupAccessOption + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 1. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f4) + From 6c64e76189fa9a7b6fb296ff64caa7162eae1655 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 12 Nov 2021 09:50:16 +0100 Subject: [PATCH 226/421] QFlag operations for QGraphicsView.CacheMode, QGraphicsView.CacheModeFlag in module QtWidgets --- PyQt5-stubs/QtWidgets.pyi | 11 + tests/qflags/qflags_to_process.json | 4 +- .../test_QtWidgets_CacheMode_CacheModeFlag.py | 259 ++++++++++++++++++ 3 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 8f3fa5ef..c9eec091 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -6288,6 +6288,9 @@ class QGraphicsView(QAbstractScrollArea): RubberBandDrag = ... # type: QGraphicsView.DragMode class CacheModeFlag(int): + def __or__ (self, other: 'QGraphicsView.CacheModeFlag') -> 'QGraphicsView.CacheMode': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGraphicsView.CacheMode': ... # type: ignore[override, misc] + CacheNone = ... # type: QGraphicsView.CacheModeFlag CacheBackground = ... # type: QGraphicsView.CacheModeFlag @@ -6302,12 +6305,20 @@ class QGraphicsView(QAbstractScrollArea): def __init__(self, f: typing.Union['QGraphicsView.CacheMode', 'QGraphicsView.CacheModeFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QGraphicsView.CacheMode') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGraphicsView.CacheMode': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGraphicsView.CacheMode', 'QGraphicsView.CacheModeFlag', int]) -> 'QGraphicsView.CacheMode': ... + def __and__(self, other: typing.Union['QGraphicsView.CacheMode', 'QGraphicsView.CacheModeFlag', int]) -> 'QGraphicsView.CacheMode': ... + def __xor__(self, other: typing.Union['QGraphicsView.CacheMode', 'QGraphicsView.CacheModeFlag', int]) -> 'QGraphicsView.CacheMode': ... + def __ror__ (self, other: 'QGraphicsView.CacheModeFlag') -> 'QGraphicsView.CacheMode': ... + def __rand__(self, other: 'QGraphicsView.CacheModeFlag') -> 'QGraphicsView.CacheMode': ... + def __rxor__(self, other: 'QGraphicsView.CacheModeFlag') -> 'QGraphicsView.CacheMode': ... class OptimizationFlags(sip.simplewrapper): diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index d873f043..9c7e56b7 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -1885,8 +1885,8 @@ { "qflag_class": "CacheMode", "enum_class": "CacheModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", + "human_hint_qflag_full_class_name": "QGraphicsView.CacheMode", + "human_hint_enum_full_class_name": "QGraphicsView.CacheModeFlag", "grep_line": [ "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)" ], diff --git a/tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py b/tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py new file mode 100644 index 00000000..7cc5639d --- /dev/null +++ b/tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGraphicsView.CacheMode" and flag class "QGraphicsView.CacheModeFlag" +from PyQt5 import QtWidgets + +OneFlagClass = QtWidgets.QGraphicsView.CacheModeFlag +MultiFlagClass = QtWidgets.QGraphicsView.CacheMode + +oneFlagRefValue1 = QtWidgets.QGraphicsView.CacheModeFlag.CacheNone +oneFlagRefValue2 = QtWidgets.QGraphicsView.CacheModeFlag.CacheBackground + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 1. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f4) + From e0f4ac15c33283d316358db14839491c226c32e5 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 12 Nov 2021 10:15:47 +0100 Subject: [PATCH 227/421] QFlag operations for QUrl.FormattingOptions, QUrl.UrlFormattingOption in module QtCore Note that QUrl.FormattingOptions has a very limited implementation. --- PyQt5-stubs/QtCore.pyi | 3 + ...e_FormattingOptions_UrlFormattingOption.py | 262 ++++++++++++++++++ 2 files changed, 265 insertions(+) create mode 100644 tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 723fd1c2..9c67a5e4 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -11958,6 +11958,9 @@ class QUrl(sip.simplewrapper): FullyDecoded = ... # type: QUrl.ComponentFormattingOption class UrlFormattingOption(int): + def __or__(self, other: 'QUrl.UrlFormattingOption') -> 'QUrl.FormattingOptions': ... # type: ignore[override] + def __ror__(self, other: int) -> 'QUrl.FormattingOptions': ... # type: ignore[override, misc] + None_ = ... # type: QUrl.UrlFormattingOption RemoveScheme = ... # type: QUrl.UrlFormattingOption RemovePassword = ... # type: QUrl.UrlFormattingOption diff --git a/tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py b/tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py new file mode 100644 index 00000000..79565f36 --- /dev/null +++ b/tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py @@ -0,0 +1,262 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# This file is used as a source to generate all qflags related tests. The specific part +# changes for each test but the rest of the file is totally identical +from PyQt5 import QtCore + +OneFlagClass = QtCore.QUrl.UrlFormattingOption +MultiFlagClass = QtCore.QUrl.FormattingOptions + +oneFlagRefValue1 = QtCore.QUrl.None_ +oneFlagRefValue2 = QtCore.QUrl.RemoveScheme + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 1. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + +### Disable the tests on multiflag for QUrl.FormattingOptions because the implementation does not support anything. +''' +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass(oneFlagValue1 | oneFlagValue1) + multiFlagValue2 = MultiFlagClass(oneFlagValue1 | oneFlagValue1) + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f4) +''' + From b622b9f14b58a596965068f3379f7ebde71a77ec Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 12 Nov 2021 13:14:06 +0100 Subject: [PATCH 228/421] Add qflag support for CheckIndexOption in QtCore --- ...Core_CheckIndexOptions_CheckIndexOption.py | 259 ++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py diff --git a/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py b/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py new file mode 100644 index 00000000..6497e8cd --- /dev/null +++ b/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py @@ -0,0 +1,259 @@ +from typing import Union, TypeVar, Type, Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QAbstractItemModel.CheckIndexOptions" and flag class "QAbstractItemModel.CheckIndexOption" +from PyQt5 import QtCore + +OneFlagClass = QtCore.QAbstractItemModel.CheckIndexOption +MultiFlagClass = QtCore.QAbstractItemModel.CheckIndexOptions + +oneFlagRefValue1 = QtCore.QAbstractItemModel.CheckIndexOption.NoOption +oneFlagRefValue2 = QtCore.QAbstractItemModel.CheckIndexOption.IndexIsValid + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 1. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From f60e5d149fa8a1047904d87b90a131887dd4cb25 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 12 Nov 2021 13:23:37 +0100 Subject: [PATCH 229/421] README clarifications --- tests/qflags/README_qflags.md | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/qflags/README_qflags.md b/tests/qflags/README_qflags.md index 5087f483..16725c22 100644 --- a/tests/qflags/README_qflags.md +++ b/tests/qflags/README_qflags.md @@ -6,15 +6,15 @@ This directory is dedicated to helping with the generation of stubs related to a The general idea of the generation is: * Grep Qt sources, looking for all QFlag based classes and store the result in a text file -* Process the grep text file to identify the QFlag names and their module. Generates a qflags_modules_analysis.json -* Using qflags_modules_analysis.json , extract the QFlags where the module is cleary identified and put - them into a qflags_to_process.json file. -* Process each flag one by one from qflags_to_process.json and output a qflags_process_result.json . For +* Process the grep text file to identify the QFlag names and their module. Generates a `qflags_modules_analysis.json` +* Using `qflags_modules_analysis.json` , extract the QFlags where the module is cleary identified and put + them into a `qflags_to_process.json` file. +* Process each flag one by one from `qflags_to_process.json` and output a `qflags_process_result.json` . For each QFlag: ** verify with code analysis if the QFlag is indeed present in this module ** check if the stubs for all qflags operation are already present. If yes, stops. ** if not, add the missing stubs to the module and generate a test file in the form test__.py - ** run pytest and mypy on the generated test file + ** run `pytest` and `mypy` on the generated test file ** if successful, stage the changes to git ** if there is any error in the process, stops. @@ -41,8 +41,10 @@ You get two files: * qflags_modules_analysis.json * qflags_to_process.json -With human verification, you can add more QFlags to the qflags_to_process.json file. - +With human verification, you can add more QFlags to the `qflags_to_process.json` file. You +can also point the exact full class name for the QFlags in case where this program does +not identify it correctly. The fields `human_hint_qflag_full_class_name` and +`human_hint_enum_full_class_name` are available for this purpose. ### Generate and test the new stubs @@ -50,12 +52,19 @@ Run: python generate_qflags_stubs_and_tests.py gen_qflag_stub 5 --auto-commit This will process 5 QFlags from qflags_to_process.json . The result of the processing is: -* the file qflags_process_result.json is updated +* the file `qflags_to_process.json` is read to find the list of items to process +* the list is compared with the already processed items in `qflags_process_result.json` + to find the items needing processing. +* the file `qflags_process_result.json` is updated with the results of the processing. * when the generation and test is successful: ** the qt module is updated ** a new test file is added in the format test__.py ** a git commit with the test file and updated module is performed (only if you specifed --auto-commit) +To process all qflags: + + python generate_qflags_stubs_and_tests.py gen_qflag_stub all --auto-commit + ## Conclusion The process is semi-manual at the moment. The tool will process QFlags in batches and let the user perform From 8518722bf95c85d7e9ddf81b24fa23951b4f8bab Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 12 Nov 2021 13:24:16 +0100 Subject: [PATCH 230/421] Add result of our processing for history archiving --- tests/qflags/qflags_process_result.json | 2569 +++++++++++++++++++++++ 1 file changed, 2569 insertions(+) create mode 100644 tests/qflags/qflags_process_result.json diff --git a/tests/qflags/qflags_process_result.json b/tests/qflags/qflags_process_result.json new file mode 100644 index 00000000..1ca0cf68 --- /dev/null +++ b/tests/qflags/qflags_process_result.json @@ -0,0 +1,2569 @@ +{ + "qflag_already_done": [ + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "QDialogButtonBox.StandardButtons", + "enum_full_class_name": "QDialogButtonBox.StandardButton", + "enum_value1": "NoButton", + "enum_value2": "Ok", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "QMessageBox.StandardButtons", + "enum_full_class_name": "QMessageBox.StandardButton", + "enum_value1": "NoButton", + "enum_value2": "Ok", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "QNetworkConfigurationManager.Capabilities", + "enum_full_class_name": "QNetworkConfigurationManager.Capability", + "enum_value1": "CanStartAndStopInterfaces", + "enum_value2": "DirectConnectionRouting", + "module_count": 2, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "QNetworkProxy.Capabilities", + "enum_full_class_name": "QNetworkProxy.Capability", + "enum_value1": "TunnelingCapability", + "enum_value2": "ListeningCapability", + "module_count": 2, + "module_idx": 1, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "RegisterOptions", + "enum_class": "RegisterOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)" + ], + "qflag_full_class_name": "QDBusConnection.RegisterOptions", + "enum_full_class_name": "QDBusConnection.RegisterOption", + "enum_value1": "ExportAdaptors", + "enum_value2": "ExportScriptableSlots", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ConnectionCapabilities", + "enum_class": "ConnectionCapability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)" + ], + "qflag_full_class_name": "QDBusConnection.ConnectionCapabilities", + "enum_full_class_name": "QDBusConnection.ConnectionCapability", + "enum_value1": "UnixFileDescriptorPassing", + "enum_value2": "UnixFileDescriptorPassing", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "QSurfaceFormat.FormatOptions", + "enum_full_class_name": "QSurfaceFormat.FormatOption", + "enum_value1": "StereoBuffers", + "enum_value2": "DebugContext", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "QGL.FormatOptions", + "enum_full_class_name": "QGL.FormatOption", + "enum_value1": "DoubleBuffer", + "enum_value2": "DepthBuffer", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "OpenGLVersionFlags", + "enum_class": "OpenGLVersionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)" + ], + "qflag_full_class_name": "QGLFormat.OpenGLVersionFlags", + "enum_full_class_name": "QGLFormat.OpenGLVersionFlag", + "enum_value1": "OpenGL_Version_None", + "enum_value2": "OpenGL_Version_1_1", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BindOptions", + "enum_class": "BindOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption)", + "src\\gui\\opengl\\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption)" + ], + "qflag_full_class_name": "QGLContext.BindOptions", + "enum_full_class_name": "QGLContext.BindOption", + "enum_value1": "NoBindOption", + "enum_value2": "InvertedYBindOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ShaderType", + "enum_class": "ShaderTypeBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)", + "src\\gui\\opengl\\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)" + ], + "qflag_full_class_name": "QOpenGLShader.ShaderType", + "enum_full_class_name": "QOpenGLShader.ShaderTypeBit", + "enum_value1": "Vertex", + "enum_value2": "Fragment", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WatchMode", + "enum_class": "WatchModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)" + ], + "qflag_full_class_name": "QDBusServiceWatcher.WatchMode", + "enum_full_class_name": "QDBusServiceWatcher.WatchModeFlag", + "enum_value1": "WatchForRegistration", + "enum_value2": "WatchForUnregistration", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ConversionFlags", + "enum_class": "ConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\codecs\\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)", + "src\\corelib\\codecs\\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)" + ], + "qflag_full_class_name": "QTextCodec.ConversionFlags", + "enum_full_class_name": "QTextCodec.ConversionFlag", + "enum_value1": "DefaultConversion", + "enum_value2": "ConvertInvalidToNull", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "CheckIndexOptions", + "enum_class": "CheckIndexOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\itemmodels\\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)" + ], + "qflag_full_class_name": "QAbstractItemModel.CheckIndexOptions", + "enum_full_class_name": "QAbstractItemModel.CheckIndexOption", + "enum_value1": "NoOption", + "enum_value2": "IndexIsValid", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "Filters", + "enum_class": "Filter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(Filters, Filter)" + ], + "qflag_full_class_name": "QDir.Filters", + "enum_full_class_name": "QDir.Filter", + "enum_value1": "Dirs", + "enum_value2": "Files", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SortFlags", + "enum_class": "SortFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag)" + ], + "qflag_full_class_name": "QDir.SortFlags", + "enum_full_class_name": "QDir.SortFlag", + "enum_value1": "Name", + "enum_value2": "Time", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "QDirIterator.IteratorFlags", + "enum_full_class_name": "QDirIterator.IteratorFlag", + "enum_value1": "NoIteratorFlags", + "enum_value2": "FollowSymlinks", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "QTreeWidgetItemIterator.IteratorFlags", + "enum_full_class_name": "QTreeWidgetItemIterator.IteratorFlag", + "enum_value1": "All", + "enum_value2": "Hidden", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Permissions", + "enum_class": "Permission", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission)" + ], + "qflag_full_class_name": "QFileDevice.Permissions", + "enum_full_class_name": "QFileDevice.Permission", + "enum_value1": "ReadOwner", + "enum_value2": "WriteOwner", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FileHandleFlags", + "enum_class": "FileHandleFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)" + ], + "qflag_full_class_name": "QFileDevice.FileHandleFlags", + "enum_full_class_name": "QFileDevice.FileHandleFlag", + "enum_value1": "AutoCloseHandle", + "enum_value2": "DontCloseHandle", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "SelectionFlags", + "enum_class": "SelectionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\itemmodels\\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" + ], + "qflag_full_class_name": "QItemSelectionModel.SelectionFlags", + "enum_full_class_name": "QItemSelectionModel.SelectionFlag", + "enum_value1": "NoUpdate", + "enum_value2": "Clear", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "KeyboardModifiers", + "enum_class": "KeyboardModifier", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)" + ], + "qflag_full_class_name": "Qt.KeyboardModifiers", + "enum_full_class_name": "Qt.KeyboardModifier", + "enum_value1": "NoModifier", + "enum_value2": "ShiftModifier", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MouseButtons", + "enum_class": "MouseButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton)" + ], + "qflag_full_class_name": "Qt.MouseButtons", + "enum_full_class_name": "Qt.MouseButton", + "enum_value1": "NoButton", + "enum_value2": "AllButtons", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Orientations", + "enum_class": "Orientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation)" + ], + "qflag_full_class_name": "Qt.Orientations", + "enum_full_class_name": "Qt.Orientation", + "enum_value1": "Horizontal", + "enum_value2": "Vertical", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Alignment", + "enum_class": "AlignmentFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag)" + ], + "qflag_full_class_name": "Qt.Alignment", + "enum_full_class_name": "Qt.AlignmentFlag", + "enum_value1": "AlignLeft", + "enum_value2": "AlignLeading", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WindowFlags", + "enum_class": "WindowType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType)" + ], + "qflag_full_class_name": "Qt.WindowFlags", + "enum_full_class_name": "Qt.WindowType", + "enum_value1": "Widget", + "enum_value2": "Window", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WindowStates", + "enum_class": "WindowState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState)" + ], + "qflag_full_class_name": "Qt.WindowStates", + "enum_full_class_name": "Qt.WindowState", + "enum_value1": "WindowNoState", + "enum_value2": "WindowMinimized", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ApplicationStates", + "enum_class": "ApplicationState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState)" + ], + "qflag_full_class_name": "Qt.ApplicationStates", + "enum_full_class_name": "Qt.ApplicationState", + "enum_value1": "ApplicationSuspended", + "enum_value2": "ApplicationHidden", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "ScreenOrientations", + "enum_class": "ScreenOrientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation)" + ], + "qflag_full_class_name": "Qt.ScreenOrientations", + "enum_full_class_name": "Qt.ScreenOrientation", + "enum_value1": "PrimaryOrientation", + "enum_value2": "PortraitOrientation", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ImageConversionFlags", + "enum_class": "ImageConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag)" + ], + "qflag_full_class_name": "Qt.ImageConversionFlags", + "enum_full_class_name": "Qt.ImageConversionFlag", + "enum_value1": "AutoColor", + "enum_value2": "ColorOnly", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DockWidgetAreas", + "enum_class": "DockWidgetArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)" + ], + "qflag_full_class_name": "Qt.DockWidgetAreas", + "enum_full_class_name": "Qt.DockWidgetArea", + "enum_value1": "LeftDockWidgetArea", + "enum_value2": "RightDockWidgetArea", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ToolBarAreas", + "enum_class": "ToolBarArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)" + ], + "qflag_full_class_name": "Qt.ToolBarAreas", + "enum_full_class_name": "Qt.ToolBarArea", + "enum_value1": "LeftToolBarArea", + "enum_value2": "RightToolBarArea", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Edges", + "enum_class": "Edge", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge)" + ], + "qflag_full_class_name": "Qt.Edges", + "enum_full_class_name": "Qt.Edge", + "enum_value1": "TopEdge", + "enum_value2": "LeftEdge", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InputMethodQueries", + "enum_class": "InputMethodQuery", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery)" + ], + "qflag_full_class_name": "Qt.InputMethodQueries", + "enum_full_class_name": "Qt.InputMethodQuery", + "enum_value1": "ImMicroFocus", + "enum_value2": "ImFont", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InputMethodHints", + "enum_class": "InputMethodHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)" + ], + "qflag_full_class_name": "Qt.InputMethodHints", + "enum_full_class_name": "Qt.InputMethodHint", + "enum_value1": "ImhNone", + "enum_value2": "ImhHiddenText", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FindChildOptions", + "enum_class": "FindChildOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)" + ], + "qflag_full_class_name": "Qt.FindChildOptions", + "enum_full_class_name": "Qt.FindChildOption", + "enum_value1": "FindDirectChildrenOnly", + "enum_value2": "FindChildrenRecursively", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "DropActions", + "enum_class": "DropAction", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction)" + ], + "qflag_full_class_name": "Qt.DropActions", + "enum_full_class_name": "Qt.DropAction", + "enum_value1": "CopyAction", + "enum_value2": "MoveAction", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ItemFlags", + "enum_class": "ItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag)" + ], + "qflag_full_class_name": "Qt.ItemFlags", + "enum_full_class_name": "Qt.ItemFlag", + "enum_value1": "NoItemFlags", + "enum_value2": "ItemIsSelectable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MatchFlags", + "enum_class": "MatchFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag)" + ], + "qflag_full_class_name": "Qt.MatchFlags", + "enum_full_class_name": "Qt.MatchFlag", + "enum_value1": "MatchExactly", + "enum_value2": "MatchFixedString", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "TextInteractionFlags", + "enum_class": "TextInteractionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag)" + ], + "qflag_full_class_name": "Qt.TextInteractionFlags", + "enum_full_class_name": "Qt.TextInteractionFlag", + "enum_value1": "NoTextInteraction", + "enum_value2": "TextSelectableByMouse", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "TouchPointStates", + "enum_class": "TouchPointState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)" + ], + "qflag_full_class_name": "Qt.TouchPointStates", + "enum_full_class_name": "Qt.TouchPointState", + "enum_value1": "TouchPointPressed", + "enum_value2": "TouchPointMoved", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "GestureFlags", + "enum_class": "GestureFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag)" + ], + "qflag_full_class_name": "Qt.GestureFlags", + "enum_full_class_name": "Qt.GestureFlag", + "enum_value1": "DontStartGestureOnChildren", + "enum_value2": "ReceivePartialGestures", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MouseEventFlags", + "enum_class": "MouseEventFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)" + ], + "qflag_full_class_name": "Qt.MouseEventFlags", + "enum_full_class_name": "Qt.MouseEventFlag", + "enum_value1": "MouseEventCreatedDoubleClick", + "enum_value2": "MouseEventCreatedDoubleClick", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Transformations", + "enum_class": "Transformation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation)" + ], + "qflag_full_class_name": "QImageIOHandler.Transformations", + "enum_full_class_name": "QImageIOHandler.Transformation", + "enum_value1": "TransformationNone", + "enum_value2": "TransformationMirror", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "ProcessEventsFlags", + "enum_class": "ProcessEventsFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)" + ], + "qflag_full_class_name": "QEventLoop.ProcessEventsFlags", + "enum_full_class_name": "QEventLoop.ProcessEventsFlag", + "enum_value1": "AllEvents", + "enum_value2": "ExcludeUserInputEvents", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "OpenMode", + "enum_class": "OpenModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)" + ], + "qflag_full_class_name": "QIODevice.OpenMode", + "enum_full_class_name": "QIODevice.OpenModeFlag", + "enum_value1": "NotOpen", + "enum_value2": "ReadOnly", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InfoFlags", + "enum_class": "InfoFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag)" + ], + "qflag_full_class_name": "QTouchEvent.TouchPoint.InfoFlags", + "enum_full_class_name": "QTouchEvent.TouchPoint.InfoFlag", + "enum_value1": "Pen", + "enum_value2": "Token", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "LoadHints", + "enum_class": "LoadHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\plugin\\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint)" + ], + "qflag_full_class_name": "QLibrary.LoadHints", + "enum_full_class_name": "QLibrary.LoadHint", + "enum_value1": "ResolveAllSymbolsHint", + "enum_value2": "ExportExternalSymbolsHint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "RangeAccessFlags", + "enum_class": "RangeAccessFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)" + ], + "qflag_full_class_name": "QOpenGLBuffer.RangeAccessFlags", + "enum_full_class_name": "QOpenGLBuffer.RangeAccessFlag", + "enum_value1": "RangeRead", + "enum_value2": "RangeWrite", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Sources", + "enum_class": "Source", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source)" + ], + "qflag_full_class_name": "QOpenGLDebugMessage.Sources", + "enum_full_class_name": "QOpenGLDebugMessage.Source", + "enum_value1": "InvalidSource", + "enum_value2": "APISource", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Severities", + "enum_class": "Severity", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity)" + ], + "qflag_full_class_name": "QOpenGLDebugMessage.Severities", + "enum_full_class_name": "QOpenGLDebugMessage.Severity", + "enum_value1": "InvalidSeverity", + "enum_value2": "HighSeverity", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "TypeFlags", + "enum_class": "TypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag)" + ], + "qflag_full_class_name": "QMetaType.TypeFlags", + "enum_full_class_name": "QMetaType.TypeFlag", + "enum_value1": "NeedsConstruction", + "enum_value2": "NeedsDestruction", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "LocateOptions", + "enum_class": "LocateOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption)" + ], + "qflag_full_class_name": "QStandardPaths.LocateOptions", + "enum_full_class_name": "QStandardPaths.LocateOption", + "enum_value1": "LocateFile", + "enum_value2": "LocateDirectory", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QCommandLineOption.Flags", + "enum_full_class_name": "QCommandLineOption.Flag", + "enum_value1": "HiddenFromHelp", + "enum_value2": "ShortOptionStyle", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QTextOption.Flags", + "enum_full_class_name": "QTextOption.Flag", + "enum_value1": "IncludeTrailingSpaces", + "enum_value2": "ShowTabsAndSpaces", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PolicyFlags", + "enum_class": "PolicyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\access\\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)" + ], + "qflag_full_class_name": "QHstsPolicy.PolicyFlags", + "enum_full_class_name": "QHstsPolicy.PolicyFlag", + "enum_value1": "IncludeSubDomains", + "enum_value2": "IncludeSubDomains", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ColorDialogOptions", + "enum_class": "ColorDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)", + "src\\widgets\\dialogs\\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)" + ], + "qflag_full_class_name": "QColorDialog.ColorDialogOptions", + "enum_full_class_name": "QColorDialog.ColorDialogOption", + "enum_value1": "ShowAlphaChannel", + "enum_value2": "NoButtons", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FontDialogOptions", + "enum_class": "FontDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)", + "src\\widgets\\dialogs\\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)" + ], + "qflag_full_class_name": "QFontDialog.FontDialogOptions", + "enum_full_class_name": "QFontDialog.FontDialogOption", + "enum_value1": "NoButtons", + "enum_value2": "DontUseNativeDialog", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ComponentFormattingOptions", + "enum_class": "ComponentFormattingOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)" + ], + "qflag_full_class_name": "QUrl.ComponentFormattingOptions", + "enum_full_class_name": "QUrl.ComponentFormattingOption", + "enum_value1": "PrettyDecoded", + "enum_value2": "EncodeSpaces", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "UserInputResolutionOptions", + "enum_class": "UserInputResolutionOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption)" + ], + "qflag_full_class_name": "QUrl.UserInputResolutionOptions", + "enum_full_class_name": "QUrl.UserInputResolutionOption", + "enum_value1": "DefaultResolution", + "enum_value2": "AssumeLocalFile", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "StateFlags", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\bearer\\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" + ], + "qflag_full_class_name": "QNetworkConfiguration.StateFlags", + "enum_full_class_name": "QNetworkConfiguration.StateFlag", + "enum_value1": "Undefined", + "enum_value2": "Defined", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "UsagePolicies", + "enum_class": "UsagePolicy", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\bearer\\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)" + ], + "qflag_full_class_name": "QNetworkSession.UsagePolicies", + "enum_full_class_name": "QNetworkSession.UsagePolicy", + "enum_value1": "NoPolicy", + "enum_value2": "NoBackgroundTrafficPolicy", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "QWidget.RenderFlags", + "enum_full_class_name": "QWidget.RenderFlag", + "enum_value1": "DrawWindowBackground", + "enum_value2": "DrawChildren", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "QTextItem.RenderFlags", + "enum_full_class_name": "QTextItem.RenderFlag", + "enum_value1": "RightToLeft", + "enum_value2": "Overline", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PaintEngineFeatures", + "enum_class": "PaintEngineFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)" + ], + "qflag_full_class_name": "QPaintEngine.PaintEngineFeatures", + "enum_full_class_name": "QPaintEngine.PaintEngineFeature", + "enum_value1": "PrimitiveTransform", + "enum_value2": "PatternTransform", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DirtyFlags", + "enum_class": "DirtyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" + ], + "qflag_full_class_name": "QPaintEngine.DirtyFlags", + "enum_full_class_name": "QPaintEngine.DirtyFlag", + "enum_value1": "DirtyPen", + "enum_value2": "DirtyBrush", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "Capabilities", + "enum_class": "CapabilityFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" + ], + "qflag_full_class_name": "QTouchDevice.Capabilities", + "enum_full_class_name": "QTouchDevice.CapabilityFlag", + "enum_value1": "Position", + "enum_value2": "Area", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Features", + "enum_class": "Feature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature)", + "src\\gui\\text\\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature)" + ], + "qflag_full_class_name": "QOpenGLTexture.Features", + "enum_full_class_name": "QOpenGLTexture.Feature", + "enum_value1": "ImmutableStorage", + "enum_value2": "ImmutableMultisampleStorage", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "RenderHints", + "enum_class": "RenderHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint)" + ], + "qflag_full_class_name": "QPainter.RenderHints", + "enum_full_class_name": "QPainter.RenderHint", + "enum_value1": "Antialiasing", + "enum_value2": "TextAntialiasing", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PixmapFragmentHints", + "enum_class": "PixmapFragmentHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)" + ], + "qflag_full_class_name": "QPainter.PixmapFragmentHints", + "enum_full_class_name": "QPainter.PixmapFragmentHint", + "enum_value1": "OpaqueHint", + "enum_value2": "OpaqueHint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "ControlTypes", + "enum_class": "ControlType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\util\\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)", + "src\\widgets\\kernel\\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)" + ], + "qflag_full_class_name": "QSizePolicy.ControlTypes", + "enum_full_class_name": "QSizePolicy.ControlType", + "enum_value1": "DefaultType", + "enum_value2": "ButtonBox", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "GlyphRunFlags", + "enum_class": "GlyphRunFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag)" + ], + "qflag_full_class_name": "QGlyphRun.GlyphRunFlags", + "enum_full_class_name": "QGlyphRun.GlyphRunFlag", + "enum_value1": "Overline", + "enum_value2": "Underline", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "LayoutFlags", + "enum_class": "LayoutFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)" + ], + "qflag_full_class_name": "QRawFont.LayoutFlags", + "enum_full_class_name": "QRawFont.LayoutFlag", + "enum_value1": "SeparateAdvances", + "enum_value2": "KernedAdvances", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FindFlags", + "enum_class": "FindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag)" + ], + "qflag_full_class_name": "QTextDocument.FindFlags", + "enum_full_class_name": "QTextDocument.FindFlag", + "enum_value1": "FindBackward", + "enum_value2": "FindCaseSensitively", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ConversionMode", + "enum_class": "ConversionModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\kernel\\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)" + ], + "qflag_full_class_name": "QHostAddress.ConversionMode", + "enum_full_class_name": "QHostAddress.ConversionModeFlag", + "enum_value1": "ConvertV4MappedToIPv4", + "enum_value2": "ConvertV4CompatToIPv4", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BindMode", + "enum_class": "BindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag)" + ], + "qflag_full_class_name": "QAbstractSocket.BindMode", + "enum_full_class_name": "QAbstractSocket.BindFlag", + "enum_value1": "DefaultForPlatform", + "enum_value2": "ShareAddress", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PauseModes", + "enum_class": "PauseMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode)" + ], + "qflag_full_class_name": "QAbstractSocket.PauseModes", + "enum_full_class_name": "QAbstractSocket.PauseMode", + "enum_value1": "PauseNever", + "enum_value2": "PauseOnSslErrors", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PageBreakFlags", + "enum_class": "PageBreakFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)" + ], + "qflag_full_class_name": "QTextFormat.PageBreakFlags", + "enum_full_class_name": "QTextFormat.PageBreakFlag", + "enum_value1": "PageBreak_Auto", + "enum_value2": "PageBreak_AlwaysBefore", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InterfaceFlags", + "enum_class": "InterfaceFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\kernel\\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)" + ], + "qflag_full_class_name": "QNetworkInterface.InterfaceFlags", + "enum_full_class_name": "QNetworkInterface.InterfaceFlag", + "enum_value1": "IsUp", + "enum_value2": "IsRunning", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SslOptions", + "enum_class": "SslOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\ssl\\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption)" + ], + "qflag_full_class_name": "QSsl.SslOptions", + "enum_full_class_name": "QSsl.SslOption", + "enum_value1": "SslOptionDisableEmptyFragments", + "enum_value2": "SslOptionDisableSessionTickets", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Base64Options", + "enum_class": "Base64Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option)" + ], + "qflag_full_class_name": "QByteArray.Base64Options", + "enum_full_class_name": "QByteArray.Base64Option", + "enum_value1": "Base64Encoding", + "enum_value2": "Base64UrlEncoding", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "NumberOptions", + "enum_class": "NumberOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption)" + ], + "qflag_full_class_name": "QLocale.NumberOptions", + "enum_full_class_name": "QLocale.NumberOption", + "enum_value1": "OmitGroupSeparator", + "enum_value2": "RejectGroupSeparator", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DataSizeFormats", + "enum_class": "DataSizeFormat", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat)" + ], + "qflag_full_class_name": "QLocale.DataSizeFormats", + "enum_full_class_name": "QLocale.DataSizeFormat", + "enum_value1": "DataSizeIecFormat", + "enum_value2": "DataSizeTraditionalFormat", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "Sections", + "enum_class": "Section", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\time\\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section)", + "src\\widgets\\widgets\\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section)" + ], + "qflag_full_class_name": "QDateTimeEdit.Sections", + "enum_full_class_name": "QDateTimeEdit.Section", + "enum_value1": "NoSection", + "enum_value2": "AmPmSection", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PatternOptions", + "enum_class": "PatternOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption)" + ], + "qflag_full_class_name": "QRegularExpression.PatternOptions", + "enum_full_class_name": "QRegularExpression.PatternOption", + "enum_value1": "NoPatternOption", + "enum_value2": "CaseInsensitiveOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MatchOptions", + "enum_class": "MatchOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption)" + ], + "qflag_full_class_name": "QRegularExpression.MatchOptions", + "enum_full_class_name": "QRegularExpression.MatchOption", + "enum_value1": "NoMatchOption", + "enum_value2": "AnchoredMatchOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "NumberFlags", + "enum_class": "NumberFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\serialization\\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag)" + ], + "qflag_full_class_name": "QTextStream.NumberFlags", + "enum_full_class_name": "QTextStream.NumberFlag", + "enum_value1": "ShowBase", + "enum_value2": "ForcePoint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BoundaryReasons", + "enum_class": "BoundaryReason", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )" + ], + "qflag_full_class_name": "QTextBoundaryFinder.BoundaryReasons", + "enum_full_class_name": "QTextBoundaryFinder.BoundaryReason", + "enum_value1": "NotAtBoundary", + "enum_value2": "SoftHyphen", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PrintDialogOptions", + "enum_class": "PrintDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\printsupport\\dialogs\\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)" + ], + "qflag_full_class_name": "QAbstractPrintDialog.PrintDialogOptions", + "enum_full_class_name": "QAbstractPrintDialog.PrintDialogOption", + "enum_value1": "None_", + "enum_value2": "PrintToFile", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPrintSupport", + "module_path": "../../PyQt5-stubs/QtPrintSupport.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ParamType", + "enum_class": "ParamTypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\sql\\kernel\\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag)" + ], + "qflag_full_class_name": "QSql.ParamType", + "enum_full_class_name": "QSql.ParamTypeFlag", + "enum_value1": "In", + "enum_value2": "Out", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSql", + "module_path": "../../PyQt5-stubs/QtSql.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "QFileDialog.Options", + "enum_full_class_name": "QFileDialog.Option", + "enum_value1": "ShowDirsOnly", + "enum_value2": "DontResolveSymlinks", + "module_count": 3, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "QFileIconProvider.Options", + "enum_full_class_name": "QFileIconProvider.Option", + "enum_value1": "DontUseCustomDirectoryIcons", + "enum_value2": "DontUseCustomDirectoryIcons", + "module_count": 3, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "QPinchGesture.ChangeFlags", + "enum_full_class_name": "QPinchGesture.ChangeFlag", + "enum_value1": "ScaleFactorChanged", + "enum_value2": "RotationAngleChanged", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "QGraphicsEffect.ChangeFlags", + "enum_full_class_name": "QGraphicsEffect.ChangeFlag", + "enum_value1": "SourceAttached", + "enum_value2": "SourceDetached", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BlurHints", + "enum_class": "BlurHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint)" + ], + "qflag_full_class_name": "QGraphicsBlurEffect.BlurHints", + "enum_full_class_name": "QGraphicsBlurEffect.BlurHint", + "enum_value1": "PerformanceHint", + "enum_value2": "QualityHint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InputDialogOptions", + "enum_class": "InputDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)" + ], + "qflag_full_class_name": "QInputDialog.InputDialogOptions", + "enum_full_class_name": "QInputDialog.InputDialogOption", + "enum_value1": "NoButtons", + "enum_value2": "UseListViewForComboBoxItems", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WizardOptions", + "enum_class": "WizardOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption)" + ], + "qflag_full_class_name": "QWizard.WizardOptions", + "enum_full_class_name": "QWizard.WizardOption", + "enum_value1": "IndependentPages", + "enum_value2": "IgnoreSubTitles", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "EditTriggers", + "enum_class": "EditTrigger", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\itemviews\\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger)" + ], + "qflag_full_class_name": "QAbstractItemView.EditTriggers", + "enum_full_class_name": "QAbstractItemView.EditTrigger", + "enum_value1": "NoEditTriggers", + "enum_value2": "CurrentChanged", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "GraphicsItemFlags", + "enum_class": "GraphicsItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)" + ], + "qflag_full_class_name": "QGraphicsItem.GraphicsItemFlags", + "enum_full_class_name": "QGraphicsItem.GraphicsItemFlag", + "enum_value1": "ItemIsMovable", + "enum_value2": "ItemIsSelectable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Result", + "enum_class": "ResultFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\kernel\\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag)" + ], + "qflag_full_class_name": "QGestureRecognizer.Result", + "enum_full_class_name": "QGestureRecognizer.ResultFlag", + "enum_value1": "Ignore", + "enum_value2": "MayBeGesture", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SceneLayers", + "enum_class": "SceneLayer", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer)" + ], + "qflag_full_class_name": "QGraphicsScene.SceneLayers", + "enum_full_class_name": "QGraphicsScene.SceneLayer", + "enum_value1": "ItemLayer", + "enum_value2": "BackgroundLayer", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "OptimizationFlags", + "enum_class": "OptimizationFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)" + ], + "qflag_full_class_name": "QGraphicsView.OptimizationFlags", + "enum_full_class_name": "QGraphicsView.OptimizationFlag", + "enum_value1": "DontClipPainter", + "enum_value2": "DontSavePainterState", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "State", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "QStyle.State", + "human_hint_enum_full_class_name": "QStyle.StateFlag", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" + ], + "qflag_full_class_name": "QStyle.State", + "enum_full_class_name": "QStyle.StateFlag", + "enum_value1": "State_None", + "enum_value2": "State_Enabled", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SubControls", + "enum_class": "SubControl", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl)" + ], + "qflag_full_class_name": "QStyle.SubControls", + "enum_full_class_name": "QStyle.SubControl", + "enum_value1": "SC_None", + "enum_value2": "SC_ScrollBarAddLine", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "StepEnabled", + "enum_class": "StepEnabledFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)" + ], + "qflag_full_class_name": "QAbstractSpinBox.StepEnabled", + "enum_full_class_name": "QAbstractSpinBox.StepEnabledFlag", + "enum_value1": "StepNone", + "enum_value2": "StepUpEnabled", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FrameFeatures", + "enum_class": "FrameFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)" + ], + "qflag_full_class_name": "QStyleOptionFrame.FrameFeatures", + "enum_full_class_name": "QStyleOptionFrame.FrameFeature", + "enum_value1": "None_", + "enum_value2": "Flat", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ButtonFeatures", + "enum_class": "ButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)" + ], + "qflag_full_class_name": "QStyleOptionButton.ButtonFeatures", + "enum_full_class_name": "QStyleOptionButton.ButtonFeature", + "enum_value1": "None_", + "enum_value2": "Flat", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "CornerWidgets", + "enum_class": "CornerWidget", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)" + ], + "qflag_full_class_name": "QStyleOptionTab.CornerWidgets", + "enum_full_class_name": "QStyleOptionTab.CornerWidget", + "enum_value1": "NoCornerWidgets", + "enum_value2": "LeftCornerWidget", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "TabFeatures", + "enum_class": "TabFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature)" + ], + "qflag_full_class_name": "QStyleOptionTab.TabFeatures", + "enum_full_class_name": "QStyleOptionTab.TabFeature", + "enum_value1": "None_", + "enum_value2": "HasFrame", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "ToolBarFeatures", + "enum_class": "ToolBarFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)" + ], + "qflag_full_class_name": "QStyleOptionToolBar.ToolBarFeatures", + "enum_full_class_name": "QStyleOptionToolBar.ToolBarFeature", + "enum_value1": "None_", + "enum_value2": "Movable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ViewItemFeatures", + "enum_class": "ViewItemFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)" + ], + "qflag_full_class_name": "QStyleOptionViewItem.ViewItemFeatures", + "enum_full_class_name": "QStyleOptionViewItem.ViewItemFeature", + "enum_value1": "None_", + "enum_value2": "WrapText", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ToolButtonFeatures", + "enum_class": "ToolButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)" + ], + "qflag_full_class_name": "QStyleOptionToolButton.ToolButtonFeatures", + "enum_full_class_name": "QStyleOptionToolButton.ToolButtonFeature", + "enum_value1": "None_", + "enum_value2": "Arrow", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DockWidgetFeatures", + "enum_class": "DockWidgetFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)" + ], + "qflag_full_class_name": "QDockWidget.DockWidgetFeatures", + "enum_full_class_name": "QDockWidget.DockWidgetFeature", + "enum_value1": "DockWidgetClosable", + "enum_value2": "DockWidgetMovable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FontFilters", + "enum_class": "FontFilter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter)" + ], + "qflag_full_class_name": "QFontComboBox.FontFilters", + "enum_full_class_name": "QFontComboBox.FontFilter", + "enum_value1": "AllFonts", + "enum_value2": "ScalableFonts", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "AreaOptions", + "enum_class": "AreaOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption)" + ], + "qflag_full_class_name": "QMdiArea.AreaOptions", + "enum_full_class_name": "QMdiArea.AreaOption", + "enum_value1": "DontMaximizeSubWindowOnActivation", + "enum_value2": "DontMaximizeSubWindowOnActivation", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SubWindowOptions", + "enum_class": "SubWindowOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)" + ], + "qflag_full_class_name": "QMdiSubWindow.SubWindowOptions", + "enum_full_class_name": "QMdiSubWindow.SubWindowOption", + "enum_value1": "RubberBandResize", + "enum_value2": "RubberBandMove", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DockOptions", + "enum_class": "DockOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption)" + ], + "qflag_full_class_name": "QMainWindow.DockOptions", + "enum_full_class_name": "QMainWindow.DockOption", + "enum_value1": "AnimatedDocks", + "enum_value2": "AllowNestedDocks", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "AutoFormatting", + "enum_class": "AutoFormattingFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)" + ], + "qflag_full_class_name": "QTextEdit.AutoFormatting", + "enum_full_class_name": "QTextEdit.AutoFormattingFlag", + "enum_value1": "AutoNone", + "enum_value2": "AutoBulletList", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "QFileSystemModel.Options", + "enum_full_class_name": "QFileSystemModel.Option", + "enum_value1": "DontWatchForChanges", + "enum_value2": "DontResolveSymlinks", + "module_count": 3, + "module_idx": 2, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MarkdownFeatures", + "enum_class": "MarkdownFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)" + ], + "qflag_full_class_name": "QTextDocument.MarkdownFeatures", + "enum_full_class_name": "QTextDocument.MarkdownFeature", + "enum_value1": "MarkdownNoHTML", + "enum_value2": "MarkdownDialectCommonMark", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + } + ], + "qflag_processed_done": [ + { + "qflag_class": "Types", + "enum_class": "Type", + "human_hint_qflag_full_class_name": "QOpenGLDebugMessage.Types", + "human_hint_enum_full_class_name": "QOpenGLDebugMessage.Type", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" + ], + "qflag_full_class_name": "QOpenGLDebugMessage.Types", + "enum_full_class_name": "QOpenGLDebugMessage.Type", + "enum_value1": "InvalidType", + "enum_value2": "ErrorType", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SocketOptions", + "enum_class": "SocketOption", + "human_hint_qflag_full_class_name": "QLocalServer.SocketOptions", + "human_hint_enum_full_class_name": "QLocalServer.SocketOption", + "grep_line": [ + "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" + ], + "qflag_full_class_name": "QLocalServer.SocketOptions", + "enum_full_class_name": "QLocalServer.SocketOption", + "enum_value1": "UserAccessOption", + "enum_value2": "GroupAccessOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "CacheMode", + "enum_class": "CacheModeFlag", + "human_hint_qflag_full_class_name": "QGraphicsView.CacheMode", + "human_hint_enum_full_class_name": "QGraphicsView.CacheModeFlag", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)" + ], + "qflag_full_class_name": "QGraphicsView.CacheMode", + "enum_full_class_name": "QGraphicsView.CacheModeFlag", + "enum_value1": "CacheNone", + "enum_value2": "CacheBackground", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FormattingOptions", + "enum_class": "UrlFormattingOption", + "_note_": "PyQt5.15.6 has imcomplete support for FormattingOptions. So the part of the test file is commented out, on purpose", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)" + ], + "qflag_full_class_name": "QUrl.FormattingOptions", + "enum_full_class_name": "QUrl.UrlFormattingOption", + "enum_value1": "None_", + "enum_value2": "RemoveScheme", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "error": [] + } + ], + "qflag_process_error": [ + ] +} \ No newline at end of file From 93b2fe0754d15704eb9270e90e9c1be6347bc273 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 12 Nov 2021 13:30:38 +0100 Subject: [PATCH 231/421] Message when we are finished --- tests/qflags/qflags_process_result.json | 2569 ----------------------- 1 file changed, 2569 deletions(-) delete mode 100644 tests/qflags/qflags_process_result.json diff --git a/tests/qflags/qflags_process_result.json b/tests/qflags/qflags_process_result.json deleted file mode 100644 index 1ca0cf68..00000000 --- a/tests/qflags/qflags_process_result.json +++ /dev/null @@ -1,2569 +0,0 @@ -{ - "qflag_already_done": [ - { - "qflag_class": "StandardButtons", - "enum_class": "StandardButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" - ], - "qflag_full_class_name": "QDialogButtonBox.StandardButtons", - "enum_full_class_name": "QDialogButtonBox.StandardButton", - "enum_value1": "NoButton", - "enum_value2": "Ok", - "module_count": 2, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "StandardButtons", - "enum_class": "StandardButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" - ], - "qflag_full_class_name": "QMessageBox.StandardButtons", - "enum_full_class_name": "QMessageBox.StandardButton", - "enum_value1": "NoButton", - "enum_value2": "Ok", - "module_count": 2, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Capabilities", - "enum_class": "Capability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", - "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" - ], - "qflag_full_class_name": "QNetworkConfigurationManager.Capabilities", - "enum_full_class_name": "QNetworkConfigurationManager.Capability", - "enum_value1": "CanStartAndStopInterfaces", - "enum_value2": "DirectConnectionRouting", - "module_count": 2, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": true, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Capabilities", - "enum_class": "Capability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", - "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" - ], - "qflag_full_class_name": "QNetworkProxy.Capabilities", - "enum_full_class_name": "QNetworkProxy.Capability", - "enum_value1": "TunnelingCapability", - "enum_value2": "ListeningCapability", - "module_count": 2, - "module_idx": 1, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "RegisterOptions", - "enum_class": "RegisterOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)" - ], - "qflag_full_class_name": "QDBusConnection.RegisterOptions", - "enum_full_class_name": "QDBusConnection.RegisterOption", - "enum_value1": "ExportAdaptors", - "enum_value2": "ExportScriptableSlots", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": true, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ConnectionCapabilities", - "enum_class": "ConnectionCapability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)" - ], - "qflag_full_class_name": "QDBusConnection.ConnectionCapabilities", - "enum_full_class_name": "QDBusConnection.ConnectionCapability", - "enum_value1": "UnixFileDescriptorPassing", - "enum_value2": "UnixFileDescriptorPassing", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FormatOptions", - "enum_class": "FormatOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", - "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" - ], - "qflag_full_class_name": "QSurfaceFormat.FormatOptions", - "enum_full_class_name": "QSurfaceFormat.FormatOption", - "enum_value1": "StereoBuffers", - "enum_value2": "DebugContext", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FormatOptions", - "enum_class": "FormatOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", - "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" - ], - "qflag_full_class_name": "QGL.FormatOptions", - "enum_full_class_name": "QGL.FormatOption", - "enum_value1": "DoubleBuffer", - "enum_value2": "DepthBuffer", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "OpenGLVersionFlags", - "enum_class": "OpenGLVersionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)" - ], - "qflag_full_class_name": "QGLFormat.OpenGLVersionFlags", - "enum_full_class_name": "QGLFormat.OpenGLVersionFlag", - "enum_value1": "OpenGL_Version_None", - "enum_value2": "OpenGL_Version_1_1", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "BindOptions", - "enum_class": "BindOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption)", - "src\\gui\\opengl\\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption)" - ], - "qflag_full_class_name": "QGLContext.BindOptions", - "enum_full_class_name": "QGLContext.BindOption", - "enum_value1": "NoBindOption", - "enum_value2": "InvertedYBindOption", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ShaderType", - "enum_class": "ShaderTypeBit", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)", - "src\\gui\\opengl\\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)" - ], - "qflag_full_class_name": "QOpenGLShader.ShaderType", - "enum_full_class_name": "QOpenGLShader.ShaderTypeBit", - "enum_value1": "Vertex", - "enum_value2": "Fragment", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "WatchMode", - "enum_class": "WatchModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)" - ], - "qflag_full_class_name": "QDBusServiceWatcher.WatchMode", - "enum_full_class_name": "QDBusServiceWatcher.WatchModeFlag", - "enum_value1": "WatchForRegistration", - "enum_value2": "WatchForUnregistration", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": true, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ConversionFlags", - "enum_class": "ConversionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\codecs\\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)", - "src\\corelib\\codecs\\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)" - ], - "qflag_full_class_name": "QTextCodec.ConversionFlags", - "enum_full_class_name": "QTextCodec.ConversionFlag", - "enum_value1": "DefaultConversion", - "enum_value2": "ConvertInvalidToNull", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "CheckIndexOptions", - "enum_class": "CheckIndexOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\itemmodels\\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)" - ], - "qflag_full_class_name": "QAbstractItemModel.CheckIndexOptions", - "enum_full_class_name": "QAbstractItemModel.CheckIndexOption", - "enum_value1": "NoOption", - "enum_value2": "IndexIsValid", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "Filters", - "enum_class": "Filter", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(Filters, Filter)" - ], - "qflag_full_class_name": "QDir.Filters", - "enum_full_class_name": "QDir.Filter", - "enum_value1": "Dirs", - "enum_value2": "Files", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SortFlags", - "enum_class": "SortFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag)" - ], - "qflag_full_class_name": "QDir.SortFlags", - "enum_full_class_name": "QDir.SortFlag", - "enum_value1": "Name", - "enum_value2": "Time", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "IteratorFlags", - "enum_class": "IteratorFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" - ], - "qflag_full_class_name": "QDirIterator.IteratorFlags", - "enum_full_class_name": "QDirIterator.IteratorFlag", - "enum_value1": "NoIteratorFlags", - "enum_value2": "FollowSymlinks", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "IteratorFlags", - "enum_class": "IteratorFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" - ], - "qflag_full_class_name": "QTreeWidgetItemIterator.IteratorFlags", - "enum_full_class_name": "QTreeWidgetItemIterator.IteratorFlag", - "enum_value1": "All", - "enum_value2": "Hidden", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Permissions", - "enum_class": "Permission", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission)" - ], - "qflag_full_class_name": "QFileDevice.Permissions", - "enum_full_class_name": "QFileDevice.Permission", - "enum_value1": "ReadOwner", - "enum_value2": "WriteOwner", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FileHandleFlags", - "enum_class": "FileHandleFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)" - ], - "qflag_full_class_name": "QFileDevice.FileHandleFlags", - "enum_full_class_name": "QFileDevice.FileHandleFlag", - "enum_value1": "AutoCloseHandle", - "enum_value2": "DontCloseHandle", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "SelectionFlags", - "enum_class": "SelectionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\itemmodels\\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" - ], - "qflag_full_class_name": "QItemSelectionModel.SelectionFlags", - "enum_full_class_name": "QItemSelectionModel.SelectionFlag", - "enum_value1": "NoUpdate", - "enum_value2": "Clear", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "KeyboardModifiers", - "enum_class": "KeyboardModifier", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)" - ], - "qflag_full_class_name": "Qt.KeyboardModifiers", - "enum_full_class_name": "Qt.KeyboardModifier", - "enum_value1": "NoModifier", - "enum_value2": "ShiftModifier", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "MouseButtons", - "enum_class": "MouseButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton)" - ], - "qflag_full_class_name": "Qt.MouseButtons", - "enum_full_class_name": "Qt.MouseButton", - "enum_value1": "NoButton", - "enum_value2": "AllButtons", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Orientations", - "enum_class": "Orientation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation)" - ], - "qflag_full_class_name": "Qt.Orientations", - "enum_full_class_name": "Qt.Orientation", - "enum_value1": "Horizontal", - "enum_value2": "Vertical", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Alignment", - "enum_class": "AlignmentFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag)" - ], - "qflag_full_class_name": "Qt.Alignment", - "enum_full_class_name": "Qt.AlignmentFlag", - "enum_value1": "AlignLeft", - "enum_value2": "AlignLeading", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "WindowFlags", - "enum_class": "WindowType", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType)" - ], - "qflag_full_class_name": "Qt.WindowFlags", - "enum_full_class_name": "Qt.WindowType", - "enum_value1": "Widget", - "enum_value2": "Window", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "WindowStates", - "enum_class": "WindowState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState)" - ], - "qflag_full_class_name": "Qt.WindowStates", - "enum_full_class_name": "Qt.WindowState", - "enum_value1": "WindowNoState", - "enum_value2": "WindowMinimized", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ApplicationStates", - "enum_class": "ApplicationState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState)" - ], - "qflag_full_class_name": "Qt.ApplicationStates", - "enum_full_class_name": "Qt.ApplicationState", - "enum_value1": "ApplicationSuspended", - "enum_value2": "ApplicationHidden", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "ScreenOrientations", - "enum_class": "ScreenOrientation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation)" - ], - "qflag_full_class_name": "Qt.ScreenOrientations", - "enum_full_class_name": "Qt.ScreenOrientation", - "enum_value1": "PrimaryOrientation", - "enum_value2": "PortraitOrientation", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ImageConversionFlags", - "enum_class": "ImageConversionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag)" - ], - "qflag_full_class_name": "Qt.ImageConversionFlags", - "enum_full_class_name": "Qt.ImageConversionFlag", - "enum_value1": "AutoColor", - "enum_value2": "ColorOnly", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "DockWidgetAreas", - "enum_class": "DockWidgetArea", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)" - ], - "qflag_full_class_name": "Qt.DockWidgetAreas", - "enum_full_class_name": "Qt.DockWidgetArea", - "enum_value1": "LeftDockWidgetArea", - "enum_value2": "RightDockWidgetArea", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ToolBarAreas", - "enum_class": "ToolBarArea", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)" - ], - "qflag_full_class_name": "Qt.ToolBarAreas", - "enum_full_class_name": "Qt.ToolBarArea", - "enum_value1": "LeftToolBarArea", - "enum_value2": "RightToolBarArea", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Edges", - "enum_class": "Edge", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge)" - ], - "qflag_full_class_name": "Qt.Edges", - "enum_full_class_name": "Qt.Edge", - "enum_value1": "TopEdge", - "enum_value2": "LeftEdge", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "InputMethodQueries", - "enum_class": "InputMethodQuery", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery)" - ], - "qflag_full_class_name": "Qt.InputMethodQueries", - "enum_full_class_name": "Qt.InputMethodQuery", - "enum_value1": "ImMicroFocus", - "enum_value2": "ImFont", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "InputMethodHints", - "enum_class": "InputMethodHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)" - ], - "qflag_full_class_name": "Qt.InputMethodHints", - "enum_full_class_name": "Qt.InputMethodHint", - "enum_value1": "ImhNone", - "enum_value2": "ImhHiddenText", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FindChildOptions", - "enum_class": "FindChildOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)" - ], - "qflag_full_class_name": "Qt.FindChildOptions", - "enum_full_class_name": "Qt.FindChildOption", - "enum_value1": "FindDirectChildrenOnly", - "enum_value2": "FindChildrenRecursively", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "DropActions", - "enum_class": "DropAction", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction)" - ], - "qflag_full_class_name": "Qt.DropActions", - "enum_full_class_name": "Qt.DropAction", - "enum_value1": "CopyAction", - "enum_value2": "MoveAction", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ItemFlags", - "enum_class": "ItemFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag)" - ], - "qflag_full_class_name": "Qt.ItemFlags", - "enum_full_class_name": "Qt.ItemFlag", - "enum_value1": "NoItemFlags", - "enum_value2": "ItemIsSelectable", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "MatchFlags", - "enum_class": "MatchFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag)" - ], - "qflag_full_class_name": "Qt.MatchFlags", - "enum_full_class_name": "Qt.MatchFlag", - "enum_value1": "MatchExactly", - "enum_value2": "MatchFixedString", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "TextInteractionFlags", - "enum_class": "TextInteractionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag)" - ], - "qflag_full_class_name": "Qt.TextInteractionFlags", - "enum_full_class_name": "Qt.TextInteractionFlag", - "enum_value1": "NoTextInteraction", - "enum_value2": "TextSelectableByMouse", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "TouchPointStates", - "enum_class": "TouchPointState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)" - ], - "qflag_full_class_name": "Qt.TouchPointStates", - "enum_full_class_name": "Qt.TouchPointState", - "enum_value1": "TouchPointPressed", - "enum_value2": "TouchPointMoved", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "GestureFlags", - "enum_class": "GestureFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag)" - ], - "qflag_full_class_name": "Qt.GestureFlags", - "enum_full_class_name": "Qt.GestureFlag", - "enum_value1": "DontStartGestureOnChildren", - "enum_value2": "ReceivePartialGestures", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "MouseEventFlags", - "enum_class": "MouseEventFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)" - ], - "qflag_full_class_name": "Qt.MouseEventFlags", - "enum_full_class_name": "Qt.MouseEventFlag", - "enum_value1": "MouseEventCreatedDoubleClick", - "enum_value2": "MouseEventCreatedDoubleClick", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Transformations", - "enum_class": "Transformation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation)" - ], - "qflag_full_class_name": "QImageIOHandler.Transformations", - "enum_full_class_name": "QImageIOHandler.Transformation", - "enum_value1": "TransformationNone", - "enum_value2": "TransformationMirror", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "ProcessEventsFlags", - "enum_class": "ProcessEventsFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)" - ], - "qflag_full_class_name": "QEventLoop.ProcessEventsFlags", - "enum_full_class_name": "QEventLoop.ProcessEventsFlag", - "enum_value1": "AllEvents", - "enum_value2": "ExcludeUserInputEvents", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "OpenMode", - "enum_class": "OpenModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)" - ], - "qflag_full_class_name": "QIODevice.OpenMode", - "enum_full_class_name": "QIODevice.OpenModeFlag", - "enum_value1": "NotOpen", - "enum_value2": "ReadOnly", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "InfoFlags", - "enum_class": "InfoFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag)" - ], - "qflag_full_class_name": "QTouchEvent.TouchPoint.InfoFlags", - "enum_full_class_name": "QTouchEvent.TouchPoint.InfoFlag", - "enum_value1": "Pen", - "enum_value2": "Token", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": true, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "LoadHints", - "enum_class": "LoadHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\plugin\\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint)" - ], - "qflag_full_class_name": "QLibrary.LoadHints", - "enum_full_class_name": "QLibrary.LoadHint", - "enum_value1": "ResolveAllSymbolsHint", - "enum_value2": "ExportExternalSymbolsHint", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "RangeAccessFlags", - "enum_class": "RangeAccessFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)" - ], - "qflag_full_class_name": "QOpenGLBuffer.RangeAccessFlags", - "enum_full_class_name": "QOpenGLBuffer.RangeAccessFlag", - "enum_value1": "RangeRead", - "enum_value2": "RangeWrite", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Sources", - "enum_class": "Source", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source)" - ], - "qflag_full_class_name": "QOpenGLDebugMessage.Sources", - "enum_full_class_name": "QOpenGLDebugMessage.Source", - "enum_value1": "InvalidSource", - "enum_value2": "APISource", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Severities", - "enum_class": "Severity", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity)" - ], - "qflag_full_class_name": "QOpenGLDebugMessage.Severities", - "enum_full_class_name": "QOpenGLDebugMessage.Severity", - "enum_value1": "InvalidSeverity", - "enum_value2": "HighSeverity", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "TypeFlags", - "enum_class": "TypeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag)" - ], - "qflag_full_class_name": "QMetaType.TypeFlags", - "enum_full_class_name": "QMetaType.TypeFlag", - "enum_value1": "NeedsConstruction", - "enum_value2": "NeedsDestruction", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "LocateOptions", - "enum_class": "LocateOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption)" - ], - "qflag_full_class_name": "QStandardPaths.LocateOptions", - "enum_full_class_name": "QStandardPaths.LocateOption", - "enum_value1": "LocateFile", - "enum_value2": "LocateDirectory", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Flags", - "enum_class": "Flag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", - "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", - "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" - ], - "qflag_full_class_name": "QCommandLineOption.Flags", - "enum_full_class_name": "QCommandLineOption.Flag", - "enum_value1": "HiddenFromHelp", - "enum_value2": "ShortOptionStyle", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Flags", - "enum_class": "Flag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", - "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", - "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" - ], - "qflag_full_class_name": "QTextOption.Flags", - "enum_full_class_name": "QTextOption.Flag", - "enum_value1": "IncludeTrailingSpaces", - "enum_value2": "ShowTabsAndSpaces", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PolicyFlags", - "enum_class": "PolicyFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\access\\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)" - ], - "qflag_full_class_name": "QHstsPolicy.PolicyFlags", - "enum_full_class_name": "QHstsPolicy.PolicyFlag", - "enum_value1": "IncludeSubDomains", - "enum_value2": "IncludeSubDomains", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ColorDialogOptions", - "enum_class": "ColorDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)", - "src\\widgets\\dialogs\\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)" - ], - "qflag_full_class_name": "QColorDialog.ColorDialogOptions", - "enum_full_class_name": "QColorDialog.ColorDialogOption", - "enum_value1": "ShowAlphaChannel", - "enum_value2": "NoButtons", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FontDialogOptions", - "enum_class": "FontDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)", - "src\\widgets\\dialogs\\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)" - ], - "qflag_full_class_name": "QFontDialog.FontDialogOptions", - "enum_full_class_name": "QFontDialog.FontDialogOption", - "enum_value1": "NoButtons", - "enum_value2": "DontUseNativeDialog", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ComponentFormattingOptions", - "enum_class": "ComponentFormattingOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)" - ], - "qflag_full_class_name": "QUrl.ComponentFormattingOptions", - "enum_full_class_name": "QUrl.ComponentFormattingOption", - "enum_value1": "PrettyDecoded", - "enum_value2": "EncodeSpaces", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "UserInputResolutionOptions", - "enum_class": "UserInputResolutionOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption)" - ], - "qflag_full_class_name": "QUrl.UserInputResolutionOptions", - "enum_full_class_name": "QUrl.UserInputResolutionOption", - "enum_value1": "DefaultResolution", - "enum_value2": "AssumeLocalFile", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "StateFlags", - "enum_class": "StateFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\bearer\\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" - ], - "qflag_full_class_name": "QNetworkConfiguration.StateFlags", - "enum_full_class_name": "QNetworkConfiguration.StateFlag", - "enum_value1": "Undefined", - "enum_value2": "Defined", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "UsagePolicies", - "enum_class": "UsagePolicy", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\bearer\\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)" - ], - "qflag_full_class_name": "QNetworkSession.UsagePolicies", - "enum_full_class_name": "QNetworkSession.UsagePolicy", - "enum_value1": "NoPolicy", - "enum_value2": "NoBackgroundTrafficPolicy", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "RenderFlags", - "enum_class": "RenderFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", - "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" - ], - "qflag_full_class_name": "QWidget.RenderFlags", - "enum_full_class_name": "QWidget.RenderFlag", - "enum_value1": "DrawWindowBackground", - "enum_value2": "DrawChildren", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "RenderFlags", - "enum_class": "RenderFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", - "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" - ], - "qflag_full_class_name": "QTextItem.RenderFlags", - "enum_full_class_name": "QTextItem.RenderFlag", - "enum_value1": "RightToLeft", - "enum_value2": "Overline", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PaintEngineFeatures", - "enum_class": "PaintEngineFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)" - ], - "qflag_full_class_name": "QPaintEngine.PaintEngineFeatures", - "enum_full_class_name": "QPaintEngine.PaintEngineFeature", - "enum_value1": "PrimitiveTransform", - "enum_value2": "PatternTransform", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "DirtyFlags", - "enum_class": "DirtyFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" - ], - "qflag_full_class_name": "QPaintEngine.DirtyFlags", - "enum_full_class_name": "QPaintEngine.DirtyFlag", - "enum_value1": "DirtyPen", - "enum_value2": "DirtyBrush", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "Capabilities", - "enum_class": "CapabilityFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" - ], - "qflag_full_class_name": "QTouchDevice.Capabilities", - "enum_full_class_name": "QTouchDevice.CapabilityFlag", - "enum_value1": "Position", - "enum_value2": "Area", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Features", - "enum_class": "Feature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature)", - "src\\gui\\text\\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature)" - ], - "qflag_full_class_name": "QOpenGLTexture.Features", - "enum_full_class_name": "QOpenGLTexture.Feature", - "enum_value1": "ImmutableStorage", - "enum_value2": "ImmutableMultisampleStorage", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "RenderHints", - "enum_class": "RenderHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint)" - ], - "qflag_full_class_name": "QPainter.RenderHints", - "enum_full_class_name": "QPainter.RenderHint", - "enum_value1": "Antialiasing", - "enum_value2": "TextAntialiasing", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PixmapFragmentHints", - "enum_class": "PixmapFragmentHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)" - ], - "qflag_full_class_name": "QPainter.PixmapFragmentHints", - "enum_full_class_name": "QPainter.PixmapFragmentHint", - "enum_value1": "OpaqueHint", - "enum_value2": "OpaqueHint", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "ControlTypes", - "enum_class": "ControlType", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\util\\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)", - "src\\widgets\\kernel\\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)" - ], - "qflag_full_class_name": "QSizePolicy.ControlTypes", - "enum_full_class_name": "QSizePolicy.ControlType", - "enum_value1": "DefaultType", - "enum_value2": "ButtonBox", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "GlyphRunFlags", - "enum_class": "GlyphRunFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag)" - ], - "qflag_full_class_name": "QGlyphRun.GlyphRunFlags", - "enum_full_class_name": "QGlyphRun.GlyphRunFlag", - "enum_value1": "Overline", - "enum_value2": "Underline", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "LayoutFlags", - "enum_class": "LayoutFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)" - ], - "qflag_full_class_name": "QRawFont.LayoutFlags", - "enum_full_class_name": "QRawFont.LayoutFlag", - "enum_value1": "SeparateAdvances", - "enum_value2": "KernedAdvances", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FindFlags", - "enum_class": "FindFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag)" - ], - "qflag_full_class_name": "QTextDocument.FindFlags", - "enum_full_class_name": "QTextDocument.FindFlag", - "enum_value1": "FindBackward", - "enum_value2": "FindCaseSensitively", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ConversionMode", - "enum_class": "ConversionModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\kernel\\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)" - ], - "qflag_full_class_name": "QHostAddress.ConversionMode", - "enum_full_class_name": "QHostAddress.ConversionModeFlag", - "enum_value1": "ConvertV4MappedToIPv4", - "enum_value2": "ConvertV4CompatToIPv4", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "BindMode", - "enum_class": "BindFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag)" - ], - "qflag_full_class_name": "QAbstractSocket.BindMode", - "enum_full_class_name": "QAbstractSocket.BindFlag", - "enum_value1": "DefaultForPlatform", - "enum_value2": "ShareAddress", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PauseModes", - "enum_class": "PauseMode", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode)" - ], - "qflag_full_class_name": "QAbstractSocket.PauseModes", - "enum_full_class_name": "QAbstractSocket.PauseMode", - "enum_value1": "PauseNever", - "enum_value2": "PauseOnSslErrors", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PageBreakFlags", - "enum_class": "PageBreakFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)" - ], - "qflag_full_class_name": "QTextFormat.PageBreakFlags", - "enum_full_class_name": "QTextFormat.PageBreakFlag", - "enum_value1": "PageBreak_Auto", - "enum_value2": "PageBreak_AlwaysBefore", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "InterfaceFlags", - "enum_class": "InterfaceFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\kernel\\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)" - ], - "qflag_full_class_name": "QNetworkInterface.InterfaceFlags", - "enum_full_class_name": "QNetworkInterface.InterfaceFlag", - "enum_value1": "IsUp", - "enum_value2": "IsRunning", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SslOptions", - "enum_class": "SslOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\ssl\\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption)" - ], - "qflag_full_class_name": "QSsl.SslOptions", - "enum_full_class_name": "QSsl.SslOption", - "enum_value1": "SslOptionDisableEmptyFragments", - "enum_value2": "SslOptionDisableSessionTickets", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Base64Options", - "enum_class": "Base64Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option)" - ], - "qflag_full_class_name": "QByteArray.Base64Options", - "enum_full_class_name": "QByteArray.Base64Option", - "enum_value1": "Base64Encoding", - "enum_value2": "Base64UrlEncoding", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "NumberOptions", - "enum_class": "NumberOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption)" - ], - "qflag_full_class_name": "QLocale.NumberOptions", - "enum_full_class_name": "QLocale.NumberOption", - "enum_value1": "OmitGroupSeparator", - "enum_value2": "RejectGroupSeparator", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "DataSizeFormats", - "enum_class": "DataSizeFormat", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat)" - ], - "qflag_full_class_name": "QLocale.DataSizeFormats", - "enum_full_class_name": "QLocale.DataSizeFormat", - "enum_value1": "DataSizeIecFormat", - "enum_value2": "DataSizeTraditionalFormat", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "Sections", - "enum_class": "Section", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\time\\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section)", - "src\\widgets\\widgets\\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section)" - ], - "qflag_full_class_name": "QDateTimeEdit.Sections", - "enum_full_class_name": "QDateTimeEdit.Section", - "enum_value1": "NoSection", - "enum_value2": "AmPmSection", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PatternOptions", - "enum_class": "PatternOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption)" - ], - "qflag_full_class_name": "QRegularExpression.PatternOptions", - "enum_full_class_name": "QRegularExpression.PatternOption", - "enum_value1": "NoPatternOption", - "enum_value2": "CaseInsensitiveOption", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "MatchOptions", - "enum_class": "MatchOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption)" - ], - "qflag_full_class_name": "QRegularExpression.MatchOptions", - "enum_full_class_name": "QRegularExpression.MatchOption", - "enum_value1": "NoMatchOption", - "enum_value2": "AnchoredMatchOption", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "NumberFlags", - "enum_class": "NumberFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\serialization\\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag)" - ], - "qflag_full_class_name": "QTextStream.NumberFlags", - "enum_full_class_name": "QTextStream.NumberFlag", - "enum_value1": "ShowBase", - "enum_value2": "ForcePoint", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "BoundaryReasons", - "enum_class": "BoundaryReason", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )" - ], - "qflag_full_class_name": "QTextBoundaryFinder.BoundaryReasons", - "enum_full_class_name": "QTextBoundaryFinder.BoundaryReason", - "enum_value1": "NotAtBoundary", - "enum_value2": "SoftHyphen", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PrintDialogOptions", - "enum_class": "PrintDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\printsupport\\dialogs\\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)" - ], - "qflag_full_class_name": "QAbstractPrintDialog.PrintDialogOptions", - "enum_full_class_name": "QAbstractPrintDialog.PrintDialogOption", - "enum_value1": "None_", - "enum_value2": "PrintToFile", - "module_count": 1, - "module_idx": 0, - "module_name": "QtPrintSupport", - "module_path": "../../PyQt5-stubs/QtPrintSupport.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ParamType", - "enum_class": "ParamTypeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\sql\\kernel\\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag)" - ], - "qflag_full_class_name": "QSql.ParamType", - "enum_full_class_name": "QSql.ParamTypeFlag", - "enum_value1": "In", - "enum_value2": "Out", - "module_count": 1, - "module_idx": 0, - "module_name": "QtSql", - "module_path": "../../PyQt5-stubs/QtSql.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "QFileDialog.Options", - "enum_full_class_name": "QFileDialog.Option", - "enum_value1": "ShowDirsOnly", - "enum_value2": "DontResolveSymlinks", - "module_count": 3, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "QFileIconProvider.Options", - "enum_full_class_name": "QFileIconProvider.Option", - "enum_value1": "DontUseCustomDirectoryIcons", - "enum_value2": "DontUseCustomDirectoryIcons", - "module_count": 3, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ChangeFlags", - "enum_class": "ChangeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", - "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" - ], - "qflag_full_class_name": "QPinchGesture.ChangeFlags", - "enum_full_class_name": "QPinchGesture.ChangeFlag", - "enum_value1": "ScaleFactorChanged", - "enum_value2": "RotationAngleChanged", - "module_count": 2, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "ChangeFlags", - "enum_class": "ChangeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", - "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" - ], - "qflag_full_class_name": "QGraphicsEffect.ChangeFlags", - "enum_full_class_name": "QGraphicsEffect.ChangeFlag", - "enum_value1": "SourceAttached", - "enum_value2": "SourceDetached", - "module_count": 2, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "BlurHints", - "enum_class": "BlurHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint)" - ], - "qflag_full_class_name": "QGraphicsBlurEffect.BlurHints", - "enum_full_class_name": "QGraphicsBlurEffect.BlurHint", - "enum_value1": "PerformanceHint", - "enum_value2": "QualityHint", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "InputDialogOptions", - "enum_class": "InputDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)" - ], - "qflag_full_class_name": "QInputDialog.InputDialogOptions", - "enum_full_class_name": "QInputDialog.InputDialogOption", - "enum_value1": "NoButtons", - "enum_value2": "UseListViewForComboBoxItems", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "WizardOptions", - "enum_class": "WizardOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption)" - ], - "qflag_full_class_name": "QWizard.WizardOptions", - "enum_full_class_name": "QWizard.WizardOption", - "enum_value1": "IndependentPages", - "enum_value2": "IgnoreSubTitles", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "EditTriggers", - "enum_class": "EditTrigger", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\itemviews\\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger)" - ], - "qflag_full_class_name": "QAbstractItemView.EditTriggers", - "enum_full_class_name": "QAbstractItemView.EditTrigger", - "enum_value1": "NoEditTriggers", - "enum_value2": "CurrentChanged", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "GraphicsItemFlags", - "enum_class": "GraphicsItemFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)" - ], - "qflag_full_class_name": "QGraphicsItem.GraphicsItemFlags", - "enum_full_class_name": "QGraphicsItem.GraphicsItemFlag", - "enum_value1": "ItemIsMovable", - "enum_value2": "ItemIsSelectable", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Result", - "enum_class": "ResultFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\kernel\\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag)" - ], - "qflag_full_class_name": "QGestureRecognizer.Result", - "enum_full_class_name": "QGestureRecognizer.ResultFlag", - "enum_value1": "Ignore", - "enum_value2": "MayBeGesture", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SceneLayers", - "enum_class": "SceneLayer", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer)" - ], - "qflag_full_class_name": "QGraphicsScene.SceneLayers", - "enum_full_class_name": "QGraphicsScene.SceneLayer", - "enum_value1": "ItemLayer", - "enum_value2": "BackgroundLayer", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "OptimizationFlags", - "enum_class": "OptimizationFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)" - ], - "qflag_full_class_name": "QGraphicsView.OptimizationFlags", - "enum_full_class_name": "QGraphicsView.OptimizationFlag", - "enum_value1": "DontClipPainter", - "enum_value2": "DontSavePainterState", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "State", - "enum_class": "StateFlag", - "human_hint_qflag_full_class_name": "QStyle.State", - "human_hint_enum_full_class_name": "QStyle.StateFlag", - "grep_line": [ - "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" - ], - "qflag_full_class_name": "QStyle.State", - "enum_full_class_name": "QStyle.StateFlag", - "enum_value1": "State_None", - "enum_value2": "State_Enabled", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SubControls", - "enum_class": "SubControl", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl)" - ], - "qflag_full_class_name": "QStyle.SubControls", - "enum_full_class_name": "QStyle.SubControl", - "enum_value1": "SC_None", - "enum_value2": "SC_ScrollBarAddLine", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "StepEnabled", - "enum_class": "StepEnabledFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)" - ], - "qflag_full_class_name": "QAbstractSpinBox.StepEnabled", - "enum_full_class_name": "QAbstractSpinBox.StepEnabledFlag", - "enum_value1": "StepNone", - "enum_value2": "StepUpEnabled", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FrameFeatures", - "enum_class": "FrameFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)" - ], - "qflag_full_class_name": "QStyleOptionFrame.FrameFeatures", - "enum_full_class_name": "QStyleOptionFrame.FrameFeature", - "enum_value1": "None_", - "enum_value2": "Flat", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ButtonFeatures", - "enum_class": "ButtonFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)" - ], - "qflag_full_class_name": "QStyleOptionButton.ButtonFeatures", - "enum_full_class_name": "QStyleOptionButton.ButtonFeature", - "enum_value1": "None_", - "enum_value2": "Flat", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "CornerWidgets", - "enum_class": "CornerWidget", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)" - ], - "qflag_full_class_name": "QStyleOptionTab.CornerWidgets", - "enum_full_class_name": "QStyleOptionTab.CornerWidget", - "enum_value1": "NoCornerWidgets", - "enum_value2": "LeftCornerWidget", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "TabFeatures", - "enum_class": "TabFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature)" - ], - "qflag_full_class_name": "QStyleOptionTab.TabFeatures", - "enum_full_class_name": "QStyleOptionTab.TabFeature", - "enum_value1": "None_", - "enum_value2": "HasFrame", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "ToolBarFeatures", - "enum_class": "ToolBarFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)" - ], - "qflag_full_class_name": "QStyleOptionToolBar.ToolBarFeatures", - "enum_full_class_name": "QStyleOptionToolBar.ToolBarFeature", - "enum_value1": "None_", - "enum_value2": "Movable", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ViewItemFeatures", - "enum_class": "ViewItemFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)" - ], - "qflag_full_class_name": "QStyleOptionViewItem.ViewItemFeatures", - "enum_full_class_name": "QStyleOptionViewItem.ViewItemFeature", - "enum_value1": "None_", - "enum_value2": "WrapText", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ToolButtonFeatures", - "enum_class": "ToolButtonFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)" - ], - "qflag_full_class_name": "QStyleOptionToolButton.ToolButtonFeatures", - "enum_full_class_name": "QStyleOptionToolButton.ToolButtonFeature", - "enum_value1": "None_", - "enum_value2": "Arrow", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "DockWidgetFeatures", - "enum_class": "DockWidgetFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)" - ], - "qflag_full_class_name": "QDockWidget.DockWidgetFeatures", - "enum_full_class_name": "QDockWidget.DockWidgetFeature", - "enum_value1": "DockWidgetClosable", - "enum_value2": "DockWidgetMovable", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FontFilters", - "enum_class": "FontFilter", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter)" - ], - "qflag_full_class_name": "QFontComboBox.FontFilters", - "enum_full_class_name": "QFontComboBox.FontFilter", - "enum_value1": "AllFonts", - "enum_value2": "ScalableFonts", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "AreaOptions", - "enum_class": "AreaOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption)" - ], - "qflag_full_class_name": "QMdiArea.AreaOptions", - "enum_full_class_name": "QMdiArea.AreaOption", - "enum_value1": "DontMaximizeSubWindowOnActivation", - "enum_value2": "DontMaximizeSubWindowOnActivation", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SubWindowOptions", - "enum_class": "SubWindowOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)" - ], - "qflag_full_class_name": "QMdiSubWindow.SubWindowOptions", - "enum_full_class_name": "QMdiSubWindow.SubWindowOption", - "enum_value1": "RubberBandResize", - "enum_value2": "RubberBandMove", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "DockOptions", - "enum_class": "DockOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption)" - ], - "qflag_full_class_name": "QMainWindow.DockOptions", - "enum_full_class_name": "QMainWindow.DockOption", - "enum_value1": "AnimatedDocks", - "enum_value2": "AllowNestedDocks", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "AutoFormatting", - "enum_class": "AutoFormattingFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)" - ], - "qflag_full_class_name": "QTextEdit.AutoFormatting", - "enum_full_class_name": "QTextEdit.AutoFormattingFlag", - "enum_value1": "AutoNone", - "enum_value2": "AutoBulletList", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "QFileSystemModel.Options", - "enum_full_class_name": "QFileSystemModel.Option", - "enum_value1": "DontWatchForChanges", - "enum_value2": "DontResolveSymlinks", - "module_count": 3, - "module_idx": 2, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "MarkdownFeatures", - "enum_class": "MarkdownFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)" - ], - "qflag_full_class_name": "QTextDocument.MarkdownFeatures", - "enum_full_class_name": "QTextDocument.MarkdownFeature", - "enum_value1": "MarkdownNoHTML", - "enum_value2": "MarkdownDialectCommonMark", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - } - ], - "qflag_processed_done": [ - { - "qflag_class": "Types", - "enum_class": "Type", - "human_hint_qflag_full_class_name": "QOpenGLDebugMessage.Types", - "human_hint_enum_full_class_name": "QOpenGLDebugMessage.Type", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" - ], - "qflag_full_class_name": "QOpenGLDebugMessage.Types", - "enum_full_class_name": "QOpenGLDebugMessage.Type", - "enum_value1": "InvalidType", - "enum_value2": "ErrorType", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SocketOptions", - "enum_class": "SocketOption", - "human_hint_qflag_full_class_name": "QLocalServer.SocketOptions", - "human_hint_enum_full_class_name": "QLocalServer.SocketOption", - "grep_line": [ - "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" - ], - "qflag_full_class_name": "QLocalServer.SocketOptions", - "enum_full_class_name": "QLocalServer.SocketOption", - "enum_value1": "UserAccessOption", - "enum_value2": "GroupAccessOption", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "CacheMode", - "enum_class": "CacheModeFlag", - "human_hint_qflag_full_class_name": "QGraphicsView.CacheMode", - "human_hint_enum_full_class_name": "QGraphicsView.CacheModeFlag", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)" - ], - "qflag_full_class_name": "QGraphicsView.CacheMode", - "enum_full_class_name": "QGraphicsView.CacheModeFlag", - "enum_value1": "CacheNone", - "enum_value2": "CacheBackground", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FormattingOptions", - "enum_class": "UrlFormattingOption", - "_note_": "PyQt5.15.6 has imcomplete support for FormattingOptions. So the part of the test file is commented out, on purpose", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)" - ], - "qflag_full_class_name": "QUrl.FormattingOptions", - "enum_full_class_name": "QUrl.UrlFormattingOption", - "enum_value1": "None_", - "enum_value2": "RemoveScheme", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true, - "error": [] - } - ], - "qflag_process_error": [ - ] -} \ No newline at end of file From d2b14c984e6014fc97cd0e28ac9d0187ba3cd6a1 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 12 Nov 2021 13:34:58 +0100 Subject: [PATCH 232/421] QFlag operations for QAbstractItemModel.CheckIndexOptions, QAbstractItemModel.CheckIndexOption in module QtCore --- PyQt5-stubs/QtCore.pyi | 11 +++++++++++ .../test_QtCore_CheckIndexOptions_CheckIndexOption.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 9c67a5e4..38fc571d 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -3483,6 +3483,9 @@ class QPersistentModelIndex(sip.simplewrapper): class QAbstractItemModel(QObject): class CheckIndexOption(int): + def __or__ (self, other: 'QAbstractItemModel.CheckIndexOption') -> int: ... + def __ror__ (self, other: int) -> int: ... + NoOption = ... # type: QAbstractItemModel.CheckIndexOption IndexIsValid = ... # type: QAbstractItemModel.CheckIndexOption DoNotUseParent = ... # type: QAbstractItemModel.CheckIndexOption @@ -3510,12 +3513,20 @@ class QAbstractItemModel(QObject): def __init__(self, f: typing.Union['QAbstractItemModel.CheckIndexOptions', 'QAbstractItemModel.CheckIndexOption']) -> None: ... @typing.overload def __init__(self, a0: 'QAbstractItemModel.CheckIndexOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QAbstractItemModel.CheckIndexOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QAbstractItemModel.CheckIndexOptions', 'QAbstractItemModel.CheckIndexOption', int]) -> 'QAbstractItemModel.CheckIndexOptions': ... + def __and__(self, other: typing.Union['QAbstractItemModel.CheckIndexOptions', 'QAbstractItemModel.CheckIndexOption', int]) -> 'QAbstractItemModel.CheckIndexOptions': ... + def __xor__(self, other: typing.Union['QAbstractItemModel.CheckIndexOptions', 'QAbstractItemModel.CheckIndexOption', int]) -> 'QAbstractItemModel.CheckIndexOptions': ... + def __ror__ (self, other: 'QAbstractItemModel.CheckIndexOption') -> 'QAbstractItemModel.CheckIndexOptions': ... + def __rand__(self, other: 'QAbstractItemModel.CheckIndexOption') -> 'QAbstractItemModel.CheckIndexOptions': ... + def __rxor__(self, other: 'QAbstractItemModel.CheckIndexOption') -> 'QAbstractItemModel.CheckIndexOptions': ... def __init__(self, parent: typing.Optional[QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py b/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py index 6497e8cd..8f5a39b0 100644 --- a/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py +++ b/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py @@ -254,6 +254,6 @@ def f4() -> None: pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) - pytest.raises(TypeError, f3) + pytest.raises(TypeError, f1) pytest.raises(TypeError, f4) From 1df6e54f0461b27d7d552b837543447d78fe8105 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 12 Nov 2021 13:41:22 +0100 Subject: [PATCH 233/421] Notify when everything is finished. --- tests/qflags/generate_qflags_stubs_and_tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index eeee1b94..4baa480d 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -1089,6 +1089,7 @@ def regen_test_files(qflag_process_results: str) -> None: more_available = process_qflag(qflags_to_process_json, qflag_result_json, auto_commit) if more_available: log_progress('Still %d flags to process' % more_available) + log_progress('All qflags are processed.') elif sys.argv[1] == 'analyse_grep_results': if len(sys.argv) <= 2: From 50f769fb1a41fac262a6bf652129c96553ae6480 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 12 Nov 2021 17:58:26 +0100 Subject: [PATCH 234/421] Add proper type: ignore[override] where needed --- PyQt5-stubs/QtCore.pyi | 12 ++++++------ PyQt5-stubs/QtGui.pyi | 10 +++++----- PyQt5-stubs/QtNetwork.pyi | 6 +++--- PyQt5-stubs/QtWidgets.pyi | 4 ++-- tests/qflags/generate_qflags_stubs_and_tests.py | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 38fc571d..30ef7f2b 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -241,7 +241,7 @@ class Qt(sip.simplewrapper): BottomEdge = ... # type: Qt.Edge class ApplicationState(int): - def __or__ (self, other: 'Qt.ApplicationState') -> int: ... + def __or__ (self, other: 'Qt.ApplicationState') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... ApplicationSuspended = ... # type: Qt.ApplicationState @@ -273,7 +273,7 @@ class Qt(sip.simplewrapper): WhiteSpaceModeUndefined = ... # type: Qt.WhiteSpaceMode class FindChildOption(int): - def __or__ (self, other: 'Qt.FindChildOption') -> int: ... + def __or__ (self, other: 'Qt.FindChildOption') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... FindDirectChildrenOnly = ... # type: Qt.FindChildOption @@ -3483,7 +3483,7 @@ class QPersistentModelIndex(sip.simplewrapper): class QAbstractItemModel(QObject): class CheckIndexOption(int): - def __or__ (self, other: 'QAbstractItemModel.CheckIndexOption') -> int: ... + def __or__ (self, other: 'QAbstractItemModel.CheckIndexOption') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... NoOption = ... # type: QAbstractItemModel.CheckIndexOption @@ -6100,7 +6100,7 @@ class QFileDevice(QIODevice): MapPrivateOption = ... # type: QFileDevice.MemoryMapFlags class FileHandleFlag(int): - def __or__ (self, other: 'QFileDevice.FileHandleFlag') -> int: ... + def __or__ (self, other: 'QFileDevice.FileHandleFlag') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... AutoCloseHandle = ... # type: QFileDevice.FileHandleFlag @@ -7048,7 +7048,7 @@ class QLineF(sip.simplewrapper): class QLocale(sip.simplewrapper): class DataSizeFormat(int): - def __or__ (self, other: 'QLocale.DataSizeFormat') -> int: ... + def __or__ (self, other: 'QLocale.DataSizeFormat') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... DataSizeIecFormat = ... # type: QLocale.DataSizeFormat @@ -11937,7 +11937,7 @@ class QTransposeProxyModel(QAbstractProxyModel): class QUrl(sip.simplewrapper): class UserInputResolutionOption(int): - def __or__ (self, other: 'QUrl.UserInputResolutionOption') -> int: ... + def __or__ (self, other: 'QUrl.UserInputResolutionOption') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... DefaultResolution = ... # type: QUrl.UserInputResolutionOption diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 855e1a6c..34c67f80 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -2600,7 +2600,7 @@ class QMatrix2x2(sip.simplewrapper): class QGlyphRun(sip.simplewrapper): class GlyphRunFlag(int): - def __or__ (self, other: 'QGlyphRun.GlyphRunFlag') -> int: ... + def __or__ (self, other: 'QGlyphRun.GlyphRunFlag') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... Overline = ... # type: QGlyphRun.GlyphRunFlag @@ -3155,7 +3155,7 @@ class QImage(QPaintDevice): class QImageIOHandler(sip.simplewrapper): class Transformation(int): - def __or__ (self, other: 'QImageIOHandler.Transformation') -> int: ... + def __or__ (self, other: 'QImageIOHandler.Transformation') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... TransformationNone = ... # type: QImageIOHandler.Transformation @@ -6390,7 +6390,7 @@ class QPageSize(sip.simplewrapper): class QPainter(sip.simplewrapper): class PixmapFragmentHint(int): - def __or__ (self, other: 'QPainter.PixmapFragmentHint') -> int: ... + def __or__ (self, other: 'QPainter.PixmapFragmentHint') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... OpaqueHint = ... # type: QPainter.PixmapFragmentHint @@ -7003,7 +7003,7 @@ class QPaintEngine(sip.simplewrapper): PolylineMode = ... # type: QPaintEngine.PolygonDrawMode class DirtyFlag(int): - def __or__ (self, other: 'QPaintEngine.DirtyFlag') -> int: ... + def __or__ (self, other: 'QPaintEngine.DirtyFlag') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... DirtyPen = ... # type: QPaintEngine.DirtyFlag @@ -8924,7 +8924,7 @@ class QTextCursor(sip.simplewrapper): class QTextDocument(QtCore.QObject): class MarkdownFeature(int): - def __or__ (self, other: 'QTextDocument.MarkdownFeature') -> int: ... + def __or__ (self, other: 'QTextDocument.MarkdownFeature') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... MarkdownNoHTML = ... # type: QTextDocument.MarkdownFeature diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 23d6e6bd..c543840c 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -1077,7 +1077,7 @@ class QNetworkConfiguration(sip.simplewrapper): Bearer4G = ... # type: QNetworkConfiguration.BearerType class StateFlag(int): - def __or__ (self, other: 'QNetworkConfiguration.StateFlag') -> int: ... + def __or__ (self, other: 'QNetworkConfiguration.StateFlag') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... Undefined = ... # type: QNetworkConfiguration.StateFlag @@ -1399,7 +1399,7 @@ class QNetworkInterface(sip.simplewrapper): class QNetworkProxy(sip.simplewrapper): class Capability(int): - def __or__ (self, other: 'QNetworkProxy.Capability') -> int: ... + def __or__ (self, other: 'QNetworkProxy.Capability') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... TunnelingCapability = ... # type: QNetworkProxy.Capability @@ -1857,7 +1857,7 @@ class QNetworkRequest(sip.simplewrapper): class QNetworkSession(QtCore.QObject): class UsagePolicy(int): - def __or__ (self, other: 'QNetworkSession.UsagePolicy') -> int: ... + def __or__ (self, other: 'QNetworkSession.UsagePolicy') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... NoPolicy = ... # type: QNetworkSession.UsagePolicy diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index c9eec091..e012b8b7 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -4534,7 +4534,7 @@ class QPanGesture(QGesture): class QPinchGesture(QGesture): class ChangeFlag(int): - def __or__ (self, other: 'QPinchGesture.ChangeFlag') -> int: ... + def __or__ (self, other: 'QPinchGesture.ChangeFlag') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... ScaleFactorChanged = ... # type: QPinchGesture.ChangeFlag @@ -9431,7 +9431,7 @@ class QStyleOptionButton(QStyleOption): class QStyleOptionTab(QStyleOption): class TabFeature(int): - def __or__ (self, other: 'QStyleOptionTab.TabFeature') -> int: ... + def __or__ (self, other: 'QStyleOptionTab.TabFeature') -> int: ... # type: ignore[override] def __ror__ (self, other: int) -> int: ... None_ = ... # type: QStyleOptionTab.TabFeature diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 4baa480d..0bf45846 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -856,7 +856,7 @@ def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.Cl ) elif or_behavior == (False, False, False): new_methods_parts = ( - ("def __or__ (self, other: '{enum}') -> int: ...", "\n"), + ("def __or__ (self, other: '{enum}') -> int: ...", "# type: ignore[override]\n"), ("def __ror__ (self, other: int) -> int: ...", "\n\n") ) else: From 6223e88271353b9dd756f7d21830aa32a8b71fe1 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 13 Nov 2021 13:29:15 +0100 Subject: [PATCH 235/421] Remove __or__ and __ror__ for enum class --- PyQt5-stubs/QtCore.pyi | 3 --- 1 file changed, 3 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 30ef7f2b..c96f1b15 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -241,9 +241,6 @@ class Qt(sip.simplewrapper): BottomEdge = ... # type: Qt.Edge class ApplicationState(int): - def __or__ (self, other: 'Qt.ApplicationState') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - ApplicationSuspended = ... # type: Qt.ApplicationState ApplicationHidden = ... # type: Qt.ApplicationState ApplicationInactive = ... # type: Qt.ApplicationState From b3cebd5d3b41593515a1048e86fd6078081b31f7 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 13 Nov 2021 16:19:52 +0100 Subject: [PATCH 236/421] Remove __or__ and __ror__ where int base class already does the job. --- PyQt5-stubs/QtCore.pyi | 12 ------------ PyQt5-stubs/QtGui.pyi | 15 --------------- PyQt5-stubs/QtNetwork.pyi | 9 --------- PyQt5-stubs/QtWidgets.pyi | 6 ------ 4 files changed, 42 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index c96f1b15..bd5ba71c 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -270,9 +270,6 @@ class Qt(sip.simplewrapper): WhiteSpaceModeUndefined = ... # type: Qt.WhiteSpaceMode class FindChildOption(int): - def __or__ (self, other: 'Qt.FindChildOption') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - FindDirectChildrenOnly = ... # type: Qt.FindChildOption FindChildrenRecursively = ... # type: Qt.FindChildOption @@ -6097,9 +6094,6 @@ class QFileDevice(QIODevice): MapPrivateOption = ... # type: QFileDevice.MemoryMapFlags class FileHandleFlag(int): - def __or__ (self, other: 'QFileDevice.FileHandleFlag') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - AutoCloseHandle = ... # type: QFileDevice.FileHandleFlag DontCloseHandle = ... # type: QFileDevice.FileHandleFlag @@ -7045,9 +7039,6 @@ class QLineF(sip.simplewrapper): class QLocale(sip.simplewrapper): class DataSizeFormat(int): - def __or__ (self, other: 'QLocale.DataSizeFormat') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - DataSizeIecFormat = ... # type: QLocale.DataSizeFormat DataSizeTraditionalFormat = ... # type: QLocale.DataSizeFormat DataSizeSIFormat = ... # type: QLocale.DataSizeFormat @@ -11934,9 +11925,6 @@ class QTransposeProxyModel(QAbstractProxyModel): class QUrl(sip.simplewrapper): class UserInputResolutionOption(int): - def __or__ (self, other: 'QUrl.UserInputResolutionOption') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - DefaultResolution = ... # type: QUrl.UserInputResolutionOption AssumeLocalFile = ... # type: QUrl.UserInputResolutionOption diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 34c67f80..68332f53 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -2600,9 +2600,6 @@ class QMatrix2x2(sip.simplewrapper): class QGlyphRun(sip.simplewrapper): class GlyphRunFlag(int): - def __or__ (self, other: 'QGlyphRun.GlyphRunFlag') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - Overline = ... # type: QGlyphRun.GlyphRunFlag Underline = ... # type: QGlyphRun.GlyphRunFlag StrikeOut = ... # type: QGlyphRun.GlyphRunFlag @@ -3155,9 +3152,6 @@ class QImage(QPaintDevice): class QImageIOHandler(sip.simplewrapper): class Transformation(int): - def __or__ (self, other: 'QImageIOHandler.Transformation') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - TransformationNone = ... # type: QImageIOHandler.Transformation TransformationMirror = ... # type: QImageIOHandler.Transformation TransformationFlip = ... # type: QImageIOHandler.Transformation @@ -6390,9 +6384,6 @@ class QPageSize(sip.simplewrapper): class QPainter(sip.simplewrapper): class PixmapFragmentHint(int): - def __or__ (self, other: 'QPainter.PixmapFragmentHint') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - OpaqueHint = ... # type: QPainter.PixmapFragmentHint OpaqueHint = ... # type: QPainter.PixmapFragmentHint @@ -7003,9 +6994,6 @@ class QPaintEngine(sip.simplewrapper): PolylineMode = ... # type: QPaintEngine.PolygonDrawMode class DirtyFlag(int): - def __or__ (self, other: 'QPaintEngine.DirtyFlag') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - DirtyPen = ... # type: QPaintEngine.DirtyFlag DirtyBrush = ... # type: QPaintEngine.DirtyFlag DirtyBrushOrigin = ... # type: QPaintEngine.DirtyFlag @@ -8924,9 +8912,6 @@ class QTextCursor(sip.simplewrapper): class QTextDocument(QtCore.QObject): class MarkdownFeature(int): - def __or__ (self, other: 'QTextDocument.MarkdownFeature') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - MarkdownNoHTML = ... # type: QTextDocument.MarkdownFeature MarkdownDialectCommonMark = ... # type: QTextDocument.MarkdownFeature MarkdownDialectGitHub = ... # type: QTextDocument.MarkdownFeature diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index c543840c..7b6e4e58 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -1077,9 +1077,6 @@ class QNetworkConfiguration(sip.simplewrapper): Bearer4G = ... # type: QNetworkConfiguration.BearerType class StateFlag(int): - def __or__ (self, other: 'QNetworkConfiguration.StateFlag') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - Undefined = ... # type: QNetworkConfiguration.StateFlag Defined = ... # type: QNetworkConfiguration.StateFlag Discovered = ... # type: QNetworkConfiguration.StateFlag @@ -1399,9 +1396,6 @@ class QNetworkInterface(sip.simplewrapper): class QNetworkProxy(sip.simplewrapper): class Capability(int): - def __or__ (self, other: 'QNetworkProxy.Capability') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - TunnelingCapability = ... # type: QNetworkProxy.Capability ListeningCapability = ... # type: QNetworkProxy.Capability UdpTunnelingCapability = ... # type: QNetworkProxy.Capability @@ -1857,9 +1851,6 @@ class QNetworkRequest(sip.simplewrapper): class QNetworkSession(QtCore.QObject): class UsagePolicy(int): - def __or__ (self, other: 'QNetworkSession.UsagePolicy') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - NoPolicy = ... # type: QNetworkSession.UsagePolicy NoBackgroundTrafficPolicy = ... # type: QNetworkSession.UsagePolicy diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index e012b8b7..5cfe112f 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -4534,9 +4534,6 @@ class QPanGesture(QGesture): class QPinchGesture(QGesture): class ChangeFlag(int): - def __or__ (self, other: 'QPinchGesture.ChangeFlag') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - ScaleFactorChanged = ... # type: QPinchGesture.ChangeFlag RotationAngleChanged = ... # type: QPinchGesture.ChangeFlag CenterPointChanged = ... # type: QPinchGesture.ChangeFlag @@ -9431,9 +9428,6 @@ class QStyleOptionButton(QStyleOption): class QStyleOptionTab(QStyleOption): class TabFeature(int): - def __or__ (self, other: 'QStyleOptionTab.TabFeature') -> int: ... # type: ignore[override] - def __ror__ (self, other: int) -> int: ... - None_ = ... # type: QStyleOptionTab.TabFeature HasFrame = ... # type: QStyleOptionTab.TabFeature From 5d2e242cc093f4321d0e17b8070c33ca7ae2a0b9 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 13 Nov 2021 17:06:27 +0100 Subject: [PATCH 237/421] Tell mypy to ignore unreachable code. Unreachable code is here by design, because the template is multipurpose. Also make the code 3.6 compatible by using typing_extensions --- tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py b/tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py index d3c30e97..1d22ffd1 100644 --- a/tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py +++ b/tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py @@ -1,4 +1,11 @@ -from typing import Union, TypeVar, Type, Literal +# mypy: no-warn-unreachable + +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part From 82b4a78fdf4dd4d201efb08e9ed0e48bf6fca9b4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 13 Nov 2021 17:07:05 +0100 Subject: [PATCH 238/421] Int compatible enum do not need any changes. --- tests/qflags/generate_qflags_stubs_and_tests.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 0bf45846..8cea63d2 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -502,7 +502,12 @@ class not found, class found multiple times, ... visitor.error_msg += 'Enum methods are present but not QFlag methods\n' if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.Not, MethodPresent.All): - visitor.error_msg += 'QFlag methods are present but not Enum methods\n' + # this is ok if enum does not need any special method + if (flag_info.or_converts_to_multi + or flag_info.int_or_converts_to_multi + or flag_info.or_int_converts_to_multi): + # this means __or__ or __ror__ must be present, we have an error + visitor.error_msg += 'QFlag methods are present but not Enum methods\n' if visitor.error_msg: return (QFlagGenResult.ErrorDuringProcessing, visitor.error_msg, '') @@ -855,10 +860,8 @@ def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.Cl ("def __ror__ (self, other: int) -> '{qflag}': ...", "# type: ignore[override, misc]\n\n") ) elif or_behavior == (False, False, False): - new_methods_parts = ( - ("def __or__ (self, other: '{enum}') -> int: ...", "# type: ignore[override]\n"), - ("def __ror__ (self, other: int) -> int: ...", "\n\n") - ) + # no changes needed + return updated_node else: raise ValueError('Unsupported or behavior:', or_behavior) From 79b9c364465761be4ac68367622647bb9db4c98c Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 13 Nov 2021 17:20:03 +0100 Subject: [PATCH 239/421] Prevent mypy from reporting unreachable code (by design) --- tests/qflags/test_QtCore_Alignment_AlignmentFlag.py | 2 ++ tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py | 2 ++ tests/qflags/test_QtCore_Base64Options_Base64Option.py | 2 ++ tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py | 2 ++ tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py | 2 ++ ...Core_ComponentFormattingOptions_ComponentFormattingOption.py | 2 ++ tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py | 2 ++ tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py | 2 ++ tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py | 2 ++ tests/qflags/test_QtCore_DropActions_DropAction.py | 2 ++ tests/qflags/test_QtCore_Edges_Edge.py | 2 ++ tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py | 2 ++ tests/qflags/test_QtCore_Filters_Filter.py | 2 ++ tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py | 2 ++ tests/qflags/test_QtCore_Flags_Flag.py | 2 ++ .../qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py | 2 ++ tests/qflags/test_QtCore_GestureFlags_GestureFlag.py | 2 ++ .../test_QtCore_ImageConversionFlags_ImageConversionFlag.py | 2 ++ tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py | 2 ++ tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py | 2 ++ tests/qflags/test_QtCore_ItemFlags_ItemFlag.py | 2 ++ tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py | 2 ++ tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py | 2 ++ tests/qflags/test_QtCore_LoadHints_LoadHint.py | 2 ++ tests/qflags/test_QtCore_LocateOptions_LocateOption.py | 2 ++ tests/qflags/test_QtCore_MatchFlags_MatchFlag.py | 2 ++ tests/qflags/test_QtCore_MatchOptions_MatchOption.py | 2 ++ tests/qflags/test_QtCore_MouseButtons_MouseButton.py | 2 ++ tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py | 2 ++ tests/qflags/test_QtCore_NumberFlags_NumberFlag.py | 2 ++ tests/qflags/test_QtCore_NumberOptions_NumberOption.py | 2 ++ tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py | 2 ++ tests/qflags/test_QtCore_Orientations_Orientation.py | 2 ++ tests/qflags/test_QtCore_PatternOptions_PatternOption.py | 2 ++ tests/qflags/test_QtCore_Permissions_Permission.py | 2 ++ .../qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py | 2 ++ .../qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py | 2 ++ tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py | 2 ++ tests/qflags/test_QtCore_SortFlags_SortFlag.py | 2 ++ .../test_QtCore_TextInteractionFlags_TextInteractionFlag.py | 2 ++ tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py | 2 ++ tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py | 2 ++ tests/qflags/test_QtCore_TypeFlags_TypeFlag.py | 2 ++ ...Core_UserInputResolutionOptions_UserInputResolutionOption.py | 2 ++ tests/qflags/test_QtCore_WindowFlags_WindowType.py | 2 ++ tests/qflags/test_QtCore_WindowStates_WindowState.py | 2 ++ .../test_QtDBus_ConnectionCapabilities_ConnectionCapability.py | 2 ++ tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py | 2 ++ tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py | 2 ++ tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py | 2 ++ tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py | 2 ++ tests/qflags/test_QtGui_Features_Feature.py | 2 ++ tests/qflags/test_QtGui_FindFlags_FindFlag.py | 2 ++ tests/qflags/test_QtGui_Flags_Flag.py | 2 ++ tests/qflags/test_QtGui_FormatOptions_FormatOption.py | 2 ++ tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py | 2 ++ tests/qflags/test_QtGui_InfoFlags_InfoFlag.py | 2 ++ tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py | 2 ++ tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py | 2 ++ tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py | 2 ++ .../qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py | 2 ++ .../qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py | 2 ++ tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py | 2 ++ tests/qflags/test_QtGui_RenderFlags_RenderFlag.py | 2 ++ tests/qflags/test_QtGui_RenderHints_RenderHint.py | 2 ++ tests/qflags/test_QtGui_Severities_Severity.py | 2 ++ tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py | 2 ++ tests/qflags/test_QtGui_Sources_Source.py | 2 ++ tests/qflags/test_QtGui_Transformations_Transformation.py | 2 ++ tests/qflags/test_QtGui_Types_Type.py | 2 ++ tests/qflags/test_QtNetwork_BindMode_BindFlag.py | 2 ++ tests/qflags/test_QtNetwork_Capabilities_Capability.py | 2 ++ .../qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py | 2 ++ tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py | 2 ++ tests/qflags/test_QtNetwork_PauseModes_PauseMode.py | 2 ++ tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py | 2 ++ tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py | 2 ++ tests/qflags/test_QtNetwork_SslOptions_SslOption.py | 2 ++ tests/qflags/test_QtNetwork_StateFlags_StateFlag.py | 2 ++ tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py | 2 ++ tests/qflags/test_QtOpenGL_BindOptions_BindOption.py | 2 ++ tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py | 2 ++ .../test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py | 2 ++ .../test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py | 2 ++ tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py | 2 ++ tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py | 2 ++ .../qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py | 2 ++ tests/qflags/test_QtWidgets_BlurHints_BlurHint.py | 2 ++ tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py | 2 ++ tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py | 2 ++ tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py | 2 ++ .../test_QtWidgets_ColorDialogOptions_ColorDialogOption.py | 2 ++ tests/qflags/test_QtWidgets_ControlTypes_ControlType.py | 2 ++ tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py | 2 ++ tests/qflags/test_QtWidgets_DockOptions_DockOption.py | 2 ++ .../test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py | 2 ++ tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py | 2 ++ .../qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py | 2 ++ tests/qflags/test_QtWidgets_FontFilters_FontFilter.py | 2 ++ tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py | 2 ++ .../qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py | 2 ++ .../test_QtWidgets_InputDialogOptions_InputDialogOption.py | 2 ++ tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py | 2 ++ .../qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py | 2 ++ tests/qflags/test_QtWidgets_Options_Option.py | 2 ++ tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py | 2 ++ tests/qflags/test_QtWidgets_Result_ResultFlag.py | 2 ++ tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py | 2 ++ tests/qflags/test_QtWidgets_Sections_Section.py | 2 ++ tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py | 2 ++ tests/qflags/test_QtWidgets_State_StateFlag.py | 2 ++ tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py | 2 ++ tests/qflags/test_QtWidgets_SubControls_SubControl.py | 2 ++ tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py | 2 ++ tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py | 2 ++ .../test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py | 2 ++ tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py | 2 ++ tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py | 2 ++ 118 files changed, 236 insertions(+) diff --git a/tests/qflags/test_QtCore_Alignment_AlignmentFlag.py b/tests/qflags/test_QtCore_Alignment_AlignmentFlag.py index 2a47e21b..7a291196 100644 --- a/tests/qflags/test_QtCore_Alignment_AlignmentFlag.py +++ b/tests/qflags/test_QtCore_Alignment_AlignmentFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py b/tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py index 6186de3b..90674f34 100644 --- a/tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py +++ b/tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtCore_Base64Options_Base64Option.py b/tests/qflags/test_QtCore_Base64Options_Base64Option.py index 6bac0d47..317935de 100644 --- a/tests/qflags/test_QtCore_Base64Options_Base64Option.py +++ b/tests/qflags/test_QtCore_Base64Options_Base64Option.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py b/tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py index 82664d50..bb83c750 100644 --- a/tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py +++ b/tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py b/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py index 8f5a39b0..8ae404cd 100644 --- a/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py +++ b/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py b/tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py index ffe3154e..53b9811d 100644 --- a/tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py +++ b/tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py b/tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py index e9af79fe..654a3552 100644 --- a/tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py +++ b/tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py b/tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py index 03c22353..c0c81707 100644 --- a/tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py +++ b/tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py b/tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py index 6e57153a..796792b9 100644 --- a/tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py +++ b/tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_DropActions_DropAction.py b/tests/qflags/test_QtCore_DropActions_DropAction.py index 2d47cce6..69e72c67 100644 --- a/tests/qflags/test_QtCore_DropActions_DropAction.py +++ b/tests/qflags/test_QtCore_DropActions_DropAction.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_Edges_Edge.py b/tests/qflags/test_QtCore_Edges_Edge.py index edfebbd3..3bdd1e4b 100644 --- a/tests/qflags/test_QtCore_Edges_Edge.py +++ b/tests/qflags/test_QtCore_Edges_Edge.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py b/tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py index 2d5fc658..d9c4d83f 100644 --- a/tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py +++ b/tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtCore_Filters_Filter.py b/tests/qflags/test_QtCore_Filters_Filter.py index fc5a6c26..6a85dc60 100644 --- a/tests/qflags/test_QtCore_Filters_Filter.py +++ b/tests/qflags/test_QtCore_Filters_Filter.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py b/tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py index 73cecb4a..4789b01d 100644 --- a/tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py +++ b/tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtCore_Flags_Flag.py b/tests/qflags/test_QtCore_Flags_Flag.py index 97eed5a2..e43199fe 100644 --- a/tests/qflags/test_QtCore_Flags_Flag.py +++ b/tests/qflags/test_QtCore_Flags_Flag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py b/tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py index 79565f36..c527b374 100644 --- a/tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py +++ b/tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtCore_GestureFlags_GestureFlag.py b/tests/qflags/test_QtCore_GestureFlags_GestureFlag.py index 2878864d..2a1953a9 100644 --- a/tests/qflags/test_QtCore_GestureFlags_GestureFlag.py +++ b/tests/qflags/test_QtCore_GestureFlags_GestureFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py b/tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py index 99113169..d7559021 100644 --- a/tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py +++ b/tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py b/tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py index f3ca9040..899b7346 100644 --- a/tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py +++ b/tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py b/tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py index 0ef994d4..fd12af03 100644 --- a/tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py +++ b/tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_ItemFlags_ItemFlag.py b/tests/qflags/test_QtCore_ItemFlags_ItemFlag.py index 8b5eb24f..c997c8e3 100644 --- a/tests/qflags/test_QtCore_ItemFlags_ItemFlag.py +++ b/tests/qflags/test_QtCore_ItemFlags_ItemFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py b/tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py index 02f2bbc7..04371bdb 100644 --- a/tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py +++ b/tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py b/tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py index 5d0d9729..e716fdbb 100644 --- a/tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py +++ b/tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_LoadHints_LoadHint.py b/tests/qflags/test_QtCore_LoadHints_LoadHint.py index a1dd2280..d829ec7a 100644 --- a/tests/qflags/test_QtCore_LoadHints_LoadHint.py +++ b/tests/qflags/test_QtCore_LoadHints_LoadHint.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_LocateOptions_LocateOption.py b/tests/qflags/test_QtCore_LocateOptions_LocateOption.py index 310379f8..003ac33d 100644 --- a/tests/qflags/test_QtCore_LocateOptions_LocateOption.py +++ b/tests/qflags/test_QtCore_LocateOptions_LocateOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_MatchFlags_MatchFlag.py b/tests/qflags/test_QtCore_MatchFlags_MatchFlag.py index 0952adf8..ab762acd 100644 --- a/tests/qflags/test_QtCore_MatchFlags_MatchFlag.py +++ b/tests/qflags/test_QtCore_MatchFlags_MatchFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_MatchOptions_MatchOption.py b/tests/qflags/test_QtCore_MatchOptions_MatchOption.py index 14b84b77..239f1a9b 100644 --- a/tests/qflags/test_QtCore_MatchOptions_MatchOption.py +++ b/tests/qflags/test_QtCore_MatchOptions_MatchOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_MouseButtons_MouseButton.py b/tests/qflags/test_QtCore_MouseButtons_MouseButton.py index e5870360..61b65997 100644 --- a/tests/qflags/test_QtCore_MouseButtons_MouseButton.py +++ b/tests/qflags/test_QtCore_MouseButtons_MouseButton.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py b/tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py index f9baaf9d..c3021554 100644 --- a/tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py +++ b/tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_NumberFlags_NumberFlag.py b/tests/qflags/test_QtCore_NumberFlags_NumberFlag.py index 3cb73855..a3e11b65 100644 --- a/tests/qflags/test_QtCore_NumberFlags_NumberFlag.py +++ b/tests/qflags/test_QtCore_NumberFlags_NumberFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_NumberOptions_NumberOption.py b/tests/qflags/test_QtCore_NumberOptions_NumberOption.py index 0ac07dd1..e90636ad 100644 --- a/tests/qflags/test_QtCore_NumberOptions_NumberOption.py +++ b/tests/qflags/test_QtCore_NumberOptions_NumberOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py b/tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py index 54d55e14..c0be4fef 100644 --- a/tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py +++ b/tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_Orientations_Orientation.py b/tests/qflags/test_QtCore_Orientations_Orientation.py index ae9922cd..7acebf1d 100644 --- a/tests/qflags/test_QtCore_Orientations_Orientation.py +++ b/tests/qflags/test_QtCore_Orientations_Orientation.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_PatternOptions_PatternOption.py b/tests/qflags/test_QtCore_PatternOptions_PatternOption.py index 6760357e..9dd02b61 100644 --- a/tests/qflags/test_QtCore_PatternOptions_PatternOption.py +++ b/tests/qflags/test_QtCore_PatternOptions_PatternOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_Permissions_Permission.py b/tests/qflags/test_QtCore_Permissions_Permission.py index 581bd29b..f3307258 100644 --- a/tests/qflags/test_QtCore_Permissions_Permission.py +++ b/tests/qflags/test_QtCore_Permissions_Permission.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py b/tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py index 9714a53a..3062f564 100644 --- a/tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py +++ b/tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py b/tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py index fe6b4ba5..1b30c9bb 100644 --- a/tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py +++ b/tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py b/tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py index 266ce297..075bd379 100644 --- a/tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py +++ b/tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_SortFlags_SortFlag.py b/tests/qflags/test_QtCore_SortFlags_SortFlag.py index 2a61d311..788c5887 100644 --- a/tests/qflags/test_QtCore_SortFlags_SortFlag.py +++ b/tests/qflags/test_QtCore_SortFlags_SortFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py b/tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py index e1e3d70e..f4628624 100644 --- a/tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py +++ b/tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py b/tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py index 99a8a43b..0f2352e7 100644 --- a/tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py +++ b/tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py b/tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py index 3caa994f..7f150009 100644 --- a/tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py +++ b/tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_TypeFlags_TypeFlag.py b/tests/qflags/test_QtCore_TypeFlags_TypeFlag.py index 52573b2b..b70764d7 100644 --- a/tests/qflags/test_QtCore_TypeFlags_TypeFlag.py +++ b/tests/qflags/test_QtCore_TypeFlags_TypeFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py b/tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py index 12ffaeba..45a762e3 100644 --- a/tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py +++ b/tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtCore_WindowFlags_WindowType.py b/tests/qflags/test_QtCore_WindowFlags_WindowType.py index 78185e21..6d2516a5 100644 --- a/tests/qflags/test_QtCore_WindowFlags_WindowType.py +++ b/tests/qflags/test_QtCore_WindowFlags_WindowType.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtCore_WindowStates_WindowState.py b/tests/qflags/test_QtCore_WindowStates_WindowState.py index 49d39105..f52e28d5 100644 --- a/tests/qflags/test_QtCore_WindowStates_WindowState.py +++ b/tests/qflags/test_QtCore_WindowStates_WindowState.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py b/tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py index 845e0bed..0986a680 100644 --- a/tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py +++ b/tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py b/tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py index 632b40d3..c448f35b 100644 --- a/tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py +++ b/tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py b/tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py index c01d3da4..20809b4e 100644 --- a/tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py +++ b/tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py b/tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py index bc5edf51..0de617ac 100644 --- a/tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py +++ b/tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py b/tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py index f5bcb13a..345dfbaf 100644 --- a/tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py +++ b/tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtGui_Features_Feature.py b/tests/qflags/test_QtGui_Features_Feature.py index 4ed2f19b..31fa2f3d 100644 --- a/tests/qflags/test_QtGui_Features_Feature.py +++ b/tests/qflags/test_QtGui_Features_Feature.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_FindFlags_FindFlag.py b/tests/qflags/test_QtGui_FindFlags_FindFlag.py index 06e56d28..bc549d9c 100644 --- a/tests/qflags/test_QtGui_FindFlags_FindFlag.py +++ b/tests/qflags/test_QtGui_FindFlags_FindFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_Flags_Flag.py b/tests/qflags/test_QtGui_Flags_Flag.py index 96d514fc..006a7ca1 100644 --- a/tests/qflags/test_QtGui_Flags_Flag.py +++ b/tests/qflags/test_QtGui_Flags_Flag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_FormatOptions_FormatOption.py b/tests/qflags/test_QtGui_FormatOptions_FormatOption.py index e3b18bf1..6856a42c 100644 --- a/tests/qflags/test_QtGui_FormatOptions_FormatOption.py +++ b/tests/qflags/test_QtGui_FormatOptions_FormatOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py b/tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py index 586b4b60..c41b648e 100644 --- a/tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py +++ b/tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtGui_InfoFlags_InfoFlag.py b/tests/qflags/test_QtGui_InfoFlags_InfoFlag.py index 87e91bc8..1c6b7d92 100644 --- a/tests/qflags/test_QtGui_InfoFlags_InfoFlag.py +++ b/tests/qflags/test_QtGui_InfoFlags_InfoFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py b/tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py index b8e270e8..cbaf10cb 100644 --- a/tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py +++ b/tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py b/tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py index 4f1f5fdf..51caa8e1 100644 --- a/tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py +++ b/tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py b/tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py index ca8d1604..c66eea4a 100644 --- a/tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py +++ b/tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py b/tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py index fda44e58..980adbae 100644 --- a/tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py +++ b/tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py b/tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py index 21abb21c..6759021f 100644 --- a/tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py +++ b/tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py b/tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py index 17e4efd4..2f6ecfee 100644 --- a/tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py +++ b/tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_RenderFlags_RenderFlag.py b/tests/qflags/test_QtGui_RenderFlags_RenderFlag.py index 6fb081c9..b7aabd9c 100644 --- a/tests/qflags/test_QtGui_RenderFlags_RenderFlag.py +++ b/tests/qflags/test_QtGui_RenderFlags_RenderFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_RenderHints_RenderHint.py b/tests/qflags/test_QtGui_RenderHints_RenderHint.py index 5fac9393..ef35a680 100644 --- a/tests/qflags/test_QtGui_RenderHints_RenderHint.py +++ b/tests/qflags/test_QtGui_RenderHints_RenderHint.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_Severities_Severity.py b/tests/qflags/test_QtGui_Severities_Severity.py index afbb002e..4967d9c2 100644 --- a/tests/qflags/test_QtGui_Severities_Severity.py +++ b/tests/qflags/test_QtGui_Severities_Severity.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py b/tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py index 3b614810..48df4149 100644 --- a/tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py +++ b/tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_Sources_Source.py b/tests/qflags/test_QtGui_Sources_Source.py index a57f9da8..c0954945 100644 --- a/tests/qflags/test_QtGui_Sources_Source.py +++ b/tests/qflags/test_QtGui_Sources_Source.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtGui_Transformations_Transformation.py b/tests/qflags/test_QtGui_Transformations_Transformation.py index ffd89322..c363011e 100644 --- a/tests/qflags/test_QtGui_Transformations_Transformation.py +++ b/tests/qflags/test_QtGui_Transformations_Transformation.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtGui_Types_Type.py b/tests/qflags/test_QtGui_Types_Type.py index 4188d7ca..f2cf6bae 100644 --- a/tests/qflags/test_QtGui_Types_Type.py +++ b/tests/qflags/test_QtGui_Types_Type.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtNetwork_BindMode_BindFlag.py b/tests/qflags/test_QtNetwork_BindMode_BindFlag.py index 3bd89f20..a7af3938 100644 --- a/tests/qflags/test_QtNetwork_BindMode_BindFlag.py +++ b/tests/qflags/test_QtNetwork_BindMode_BindFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtNetwork_Capabilities_Capability.py b/tests/qflags/test_QtNetwork_Capabilities_Capability.py index de973296..5dad2b0d 100644 --- a/tests/qflags/test_QtNetwork_Capabilities_Capability.py +++ b/tests/qflags/test_QtNetwork_Capabilities_Capability.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py b/tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py index e84df21e..bb0f3b67 100644 --- a/tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py +++ b/tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py b/tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py index c9ff917e..e7e3c480 100644 --- a/tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py +++ b/tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtNetwork_PauseModes_PauseMode.py b/tests/qflags/test_QtNetwork_PauseModes_PauseMode.py index 029e9a5a..5182534a 100644 --- a/tests/qflags/test_QtNetwork_PauseModes_PauseMode.py +++ b/tests/qflags/test_QtNetwork_PauseModes_PauseMode.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py b/tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py index 23cebe88..7252498d 100644 --- a/tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py +++ b/tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py b/tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py index edb4793f..2c524ab4 100644 --- a/tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py +++ b/tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtNetwork_SslOptions_SslOption.py b/tests/qflags/test_QtNetwork_SslOptions_SslOption.py index e47684c2..e0ce895f 100644 --- a/tests/qflags/test_QtNetwork_SslOptions_SslOption.py +++ b/tests/qflags/test_QtNetwork_SslOptions_SslOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtNetwork_StateFlags_StateFlag.py b/tests/qflags/test_QtNetwork_StateFlags_StateFlag.py index 3028a0af..f83fef94 100644 --- a/tests/qflags/test_QtNetwork_StateFlags_StateFlag.py +++ b/tests/qflags/test_QtNetwork_StateFlags_StateFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py b/tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py index 17d18678..682b0b2a 100644 --- a/tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py +++ b/tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtOpenGL_BindOptions_BindOption.py b/tests/qflags/test_QtOpenGL_BindOptions_BindOption.py index b5310fa1..4bd8a78f 100644 --- a/tests/qflags/test_QtOpenGL_BindOptions_BindOption.py +++ b/tests/qflags/test_QtOpenGL_BindOptions_BindOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py b/tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py index 252f1dc9..cb379a87 100644 --- a/tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py +++ b/tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py b/tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py index c8ed0209..d1dd4316 100644 --- a/tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py +++ b/tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py b/tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py index 531bd338..cb1b9672 100644 --- a/tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py +++ b/tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py b/tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py index c6236bf9..1abb11ba 100644 --- a/tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py +++ b/tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py b/tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py index c7d56011..8c366de2 100644 --- a/tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py +++ b/tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py b/tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py index eecbb395..85a5030c 100644 --- a/tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py +++ b/tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_BlurHints_BlurHint.py b/tests/qflags/test_QtWidgets_BlurHints_BlurHint.py index 9dfba3da..208c83fa 100644 --- a/tests/qflags/test_QtWidgets_BlurHints_BlurHint.py +++ b/tests/qflags/test_QtWidgets_BlurHints_BlurHint.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py b/tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py index 4c84f921..e35f36ab 100644 --- a/tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py +++ b/tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py b/tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py index 7cc5639d..d1ecbdab 100644 --- a/tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py +++ b/tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py b/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py index 7135487f..8481e511 100644 --- a/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py +++ b/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py b/tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py index 31c1d510..69b0284f 100644 --- a/tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py +++ b/tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_ControlTypes_ControlType.py b/tests/qflags/test_QtWidgets_ControlTypes_ControlType.py index 94f8c184..3f69d715 100644 --- a/tests/qflags/test_QtWidgets_ControlTypes_ControlType.py +++ b/tests/qflags/test_QtWidgets_ControlTypes_ControlType.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py b/tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py index 8492b9ff..e578503a 100644 --- a/tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py +++ b/tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_DockOptions_DockOption.py b/tests/qflags/test_QtWidgets_DockOptions_DockOption.py index ef8704fb..dc217d14 100644 --- a/tests/qflags/test_QtWidgets_DockOptions_DockOption.py +++ b/tests/qflags/test_QtWidgets_DockOptions_DockOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py b/tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py index 5f941f67..ed4c6648 100644 --- a/tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py +++ b/tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py b/tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py index 224c5e95..35bac3be 100644 --- a/tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py +++ b/tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py b/tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py index 9149125d..af2f7afd 100644 --- a/tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py +++ b/tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_FontFilters_FontFilter.py b/tests/qflags/test_QtWidgets_FontFilters_FontFilter.py index f706786d..020ec33d 100644 --- a/tests/qflags/test_QtWidgets_FontFilters_FontFilter.py +++ b/tests/qflags/test_QtWidgets_FontFilters_FontFilter.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py b/tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py index bac73155..ef2fc93b 100644 --- a/tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py +++ b/tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py b/tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py index d70277e9..f3a3171d 100644 --- a/tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py +++ b/tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py b/tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py index 0ef29d4b..8d605fdf 100644 --- a/tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py +++ b/tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py b/tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py index 9cf9f7cd..2315b179 100644 --- a/tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py +++ b/tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py b/tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py index c93f625b..ac8cbb8b 100644 --- a/tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py +++ b/tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_Options_Option.py b/tests/qflags/test_QtWidgets_Options_Option.py index 8ff1a357..a391184c 100644 --- a/tests/qflags/test_QtWidgets_Options_Option.py +++ b/tests/qflags/test_QtWidgets_Options_Option.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py b/tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py index fe3240d6..fb9bdad3 100644 --- a/tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py +++ b/tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_Result_ResultFlag.py b/tests/qflags/test_QtWidgets_Result_ResultFlag.py index 4a72efa2..554cfaa8 100644 --- a/tests/qflags/test_QtWidgets_Result_ResultFlag.py +++ b/tests/qflags/test_QtWidgets_Result_ResultFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py b/tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py index d699c57a..c3415257 100644 --- a/tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py +++ b/tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_Sections_Section.py b/tests/qflags/test_QtWidgets_Sections_Section.py index 3eb4aedc..2b1c0075 100644 --- a/tests/qflags/test_QtWidgets_Sections_Section.py +++ b/tests/qflags/test_QtWidgets_Sections_Section.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py b/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py index 38797e2b..b53e080d 100644 --- a/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py +++ b/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type, Literal import pytest diff --git a/tests/qflags/test_QtWidgets_State_StateFlag.py b/tests/qflags/test_QtWidgets_State_StateFlag.py index 7c8551a6..fda1de44 100644 --- a/tests/qflags/test_QtWidgets_State_StateFlag.py +++ b/tests/qflags/test_QtWidgets_State_StateFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py b/tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py index 6af3957c..b5457a84 100644 --- a/tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py +++ b/tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_SubControls_SubControl.py b/tests/qflags/test_QtWidgets_SubControls_SubControl.py index 69ef2a53..9c6fdac5 100644 --- a/tests/qflags/test_QtWidgets_SubControls_SubControl.py +++ b/tests/qflags/test_QtWidgets_SubControls_SubControl.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py b/tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py index cf227eb4..155e7785 100644 --- a/tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py +++ b/tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py b/tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py index 2410a89f..db561993 100644 --- a/tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py +++ b/tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py b/tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py index c9d46645..e3740f7a 100644 --- a/tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py +++ b/tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py b/tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py index 22051315..c361911e 100644 --- a/tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py +++ b/tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest diff --git a/tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py b/tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py index 6cd263b9..26166401 100644 --- a/tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py +++ b/tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py @@ -1,3 +1,5 @@ +# mypy: no-warn-unreachable + from typing import Union, TypeVar, Type import pytest From 49c24d6fe514cf007014cae4c751dc44918badf6 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 13 Nov 2021 18:33:09 +0100 Subject: [PATCH 240/421] Regnerate test files to support Python 3.6 - 3.10 --- tests/qflags/qflags_test_template.py | 13 +- .../test_QtCore_Alignment_AlignmentFlag.py | 219 ++++++++++------- ...Core_ApplicationStates_ApplicationState.py | 81 ++++--- .../test_QtCore_Base64Options_Base64Option.py | 213 +++++++++-------- ...t_QtCore_BoundaryReasons_BoundaryReason.py | 213 +++++++++-------- ...Core_CheckIndexOptions_CheckIndexOption.py | 11 +- ...attingOptions_ComponentFormattingOption.py | 213 +++++++++-------- ...t_QtCore_ConversionFlags_ConversionFlag.py | 219 ++++++++++------- ...t_QtCore_DataSizeFormats_DataSizeFormat.py | 81 ++++--- ...t_QtCore_DockWidgetAreas_DockWidgetArea.py | 219 ++++++++++------- .../test_QtCore_DropActions_DropAction.py | 219 ++++++++++------- tests/qflags/test_QtCore_Edges_Edge.py | 219 ++++++++++------- ...t_QtCore_FileHandleFlags_FileHandleFlag.py | 81 ++++--- tests/qflags/test_QtCore_Filters_Filter.py | 219 ++++++++++------- ...QtCore_FindChildOptions_FindChildOption.py | 81 ++++--- tests/qflags/test_QtCore_Flags_Flag.py | 219 ++++++++++------- .../test_QtCore_GestureFlags_GestureFlag.py | 219 ++++++++++------- ...mageConversionFlags_ImageConversionFlag.py | 219 ++++++++++------- ...QtCore_InputMethodHints_InputMethodHint.py | 219 ++++++++++------- ...ore_InputMethodQueries_InputMethodQuery.py | 219 ++++++++++------- .../qflags/test_QtCore_ItemFlags_ItemFlag.py | 219 ++++++++++------- .../test_QtCore_IteratorFlags_IteratorFlag.py | 219 ++++++++++------- ...Core_KeyboardModifiers_KeyboardModifier.py | 219 ++++++++++------- .../qflags/test_QtCore_LoadHints_LoadHint.py | 219 ++++++++++------- .../test_QtCore_LocateOptions_LocateOption.py | 219 ++++++++++------- .../test_QtCore_MatchFlags_MatchFlag.py | 219 ++++++++++------- .../test_QtCore_MatchOptions_MatchOption.py | 213 +++++++++-------- .../test_QtCore_MouseButtons_MouseButton.py | 219 ++++++++++------- ...t_QtCore_MouseEventFlags_MouseEventFlag.py | 219 ++++++++++------- .../test_QtCore_NumberFlags_NumberFlag.py | 213 +++++++++-------- .../test_QtCore_NumberOptions_NumberOption.py | 213 +++++++++-------- .../test_QtCore_OpenMode_OpenModeFlag.py | 219 ++++++++++------- .../test_QtCore_Orientations_Orientation.py | 219 ++++++++++------- ...est_QtCore_PatternOptions_PatternOption.py | 213 +++++++++-------- .../test_QtCore_Permissions_Permission.py | 219 ++++++++++------- ...re_ProcessEventsFlags_ProcessEventsFlag.py | 219 ++++++++++------- ...re_ScreenOrientations_ScreenOrientation.py | 219 ++++++++++------- ...est_QtCore_SelectionFlags_SelectionFlag.py | 219 ++++++++++------- .../qflags/test_QtCore_SortFlags_SortFlag.py | 219 ++++++++++------- ...extInteractionFlags_TextInteractionFlag.py | 219 ++++++++++------- .../test_QtCore_ToolBarAreas_ToolBarArea.py | 219 ++++++++++------- ...QtCore_TouchPointStates_TouchPointState.py | 219 ++++++++++------- .../qflags/test_QtCore_TypeFlags_TypeFlag.py | 219 ++++++++++------- ...lutionOptions_UserInputResolutionOption.py | 81 ++++--- .../test_QtCore_WindowFlags_WindowType.py | 226 ++++++++++-------- .../test_QtCore_WindowStates_WindowState.py | 219 ++++++++++------- ...ectionCapabilities_ConnectionCapability.py | 219 ++++++++++------- ...t_QtDBus_RegisterOptions_RegisterOption.py | 81 ++++--- .../test_QtDBus_WatchMode_WatchModeFlag.py | 81 ++++--- .../test_QtGui_Capabilities_CapabilityFlag.py | 213 +++++++++-------- .../qflags/test_QtGui_DirtyFlags_DirtyFlag.py | 81 ++++--- tests/qflags/test_QtGui_Features_Feature.py | 213 +++++++++-------- tests/qflags/test_QtGui_FindFlags_FindFlag.py | 213 +++++++++-------- tests/qflags/test_QtGui_Flags_Flag.py | 219 ++++++++++------- .../test_QtGui_FormatOptions_FormatOption.py | 219 ++++++++++------- .../test_QtGui_GlyphRunFlags_GlyphRunFlag.py | 81 ++++--- tests/qflags/test_QtGui_InfoFlags_InfoFlag.py | 81 ++++--- .../test_QtGui_LayoutFlags_LayoutFlag.py | 213 +++++++++-------- ..._QtGui_MarkdownFeatures_MarkdownFeature.py | 81 ++++--- ...test_QtGui_PageBreakFlags_PageBreakFlag.py | 213 +++++++++-------- ..._PaintEngineFeatures_PaintEngineFeature.py | 213 +++++++++-------- ..._PixmapFragmentHints_PixmapFragmentHint.py | 81 ++++--- ..._QtGui_RangeAccessFlags_RangeAccessFlag.py | 219 ++++++++++------- .../test_QtGui_RenderFlags_RenderFlag.py | 213 +++++++++-------- .../test_QtGui_RenderHints_RenderHint.py | 213 +++++++++-------- .../qflags/test_QtGui_Severities_Severity.py | 219 ++++++++++------- .../test_QtGui_ShaderType_ShaderTypeBit.py | 219 ++++++++++------- tests/qflags/test_QtGui_Sources_Source.py | 219 ++++++++++------- ...st_QtGui_Transformations_Transformation.py | 81 ++++--- tests/qflags/test_QtGui_Types_Type.py | 11 +- .../test_QtNetwork_BindMode_BindFlag.py | 213 +++++++++-------- .../test_QtNetwork_Capabilities_Capability.py | 81 ++++--- ...twork_ConversionMode_ConversionModeFlag.py | 213 +++++++++-------- ..._QtNetwork_InterfaceFlags_InterfaceFlag.py | 213 +++++++++-------- .../test_QtNetwork_PauseModes_PauseMode.py | 213 +++++++++-------- .../test_QtNetwork_PolicyFlags_PolicyFlag.py | 213 +++++++++-------- ...st_QtNetwork_SocketOptions_SocketOption.py | 11 +- .../test_QtNetwork_SslOptions_SslOption.py | 213 +++++++++-------- .../test_QtNetwork_StateFlags_StateFlag.py | 81 ++++--- ...est_QtNetwork_UsagePolicies_UsagePolicy.py | 81 ++++--- .../test_QtOpenGL_BindOptions_BindOption.py | 219 ++++++++++------- ...est_QtOpenGL_FormatOptions_FormatOption.py | 219 ++++++++++------- ...GL_OpenGLVersionFlags_OpenGLVersionFlag.py | 219 ++++++++++------- ...rt_PrintDialogOptions_PrintDialogOption.py | 81 ++++--- .../test_QtSql_ParamType_ParamTypeFlag.py | 213 +++++++++-------- .../test_QtWidgets_AreaOptions_AreaOption.py | 213 +++++++++-------- ...dgets_AutoFormatting_AutoFormattingFlag.py | 213 +++++++++-------- .../test_QtWidgets_BlurHints_BlurHint.py | 213 +++++++++-------- ..._QtWidgets_ButtonFeatures_ButtonFeature.py | 213 +++++++++-------- .../test_QtWidgets_CacheMode_CacheModeFlag.py | 11 +- .../test_QtWidgets_ChangeFlags_ChangeFlag.py | 95 ++++---- ...ts_ColorDialogOptions_ColorDialogOption.py | 213 +++++++++-------- ...test_QtWidgets_ControlTypes_ControlType.py | 213 +++++++++-------- ...st_QtWidgets_CornerWidgets_CornerWidget.py | 213 +++++++++-------- .../test_QtWidgets_DockOptions_DockOption.py | 213 +++++++++-------- ...ts_DockWidgetFeatures_DockWidgetFeature.py | 213 +++++++++-------- ...test_QtWidgets_EditTriggers_EditTrigger.py | 213 +++++++++-------- ...gets_FontDialogOptions_FontDialogOption.py | 213 +++++++++-------- .../test_QtWidgets_FontFilters_FontFilter.py | 213 +++++++++-------- ...st_QtWidgets_FrameFeatures_FrameFeature.py | 213 +++++++++-------- ...gets_GraphicsItemFlags_GraphicsItemFlag.py | 213 +++++++++-------- ...ts_InputDialogOptions_InputDialogOption.py | 213 +++++++++-------- ...st_QtWidgets_IteratorFlags_IteratorFlag.py | 219 ++++++++++------- ...gets_OptimizationFlags_OptimizationFlag.py | 213 +++++++++-------- tests/qflags/test_QtWidgets_Options_Option.py | 213 +++++++++-------- .../test_QtWidgets_RenderFlags_RenderFlag.py | 213 +++++++++-------- .../test_QtWidgets_Result_ResultFlag.py | 213 +++++++++-------- .../test_QtWidgets_SceneLayers_SceneLayer.py | 213 +++++++++-------- .../qflags/test_QtWidgets_Sections_Section.py | 213 +++++++++-------- ...tWidgets_StandardButtons_StandardButton.py | 91 +++---- ...t_QtWidgets_StepEnabled_StepEnabledFlag.py | 213 +++++++++-------- .../test_QtWidgets_SubControls_SubControl.py | 213 +++++++++-------- ...idgets_SubWindowOptions_SubWindowOption.py | 213 +++++++++-------- .../test_QtWidgets_TabFeatures_TabFeature.py | 74 +++--- ...tWidgets_ToolBarFeatures_ToolBarFeature.py | 213 +++++++++-------- ...ts_ToolButtonFeatures_ToolButtonFeature.py | 213 +++++++++-------- ...idgets_ViewItemFeatures_ViewItemFeature.py | 213 +++++++++-------- ...st_QtWidgets_WizardOptions_WizardOption.py | 213 +++++++++-------- 118 files changed, 11979 insertions(+), 9789 deletions(-) diff --git a/tests/qflags/qflags_test_template.py b/tests/qflags/qflags_test_template.py index 71678a9b..e7af2d73 100644 --- a/tests/qflags/qflags_test_template.py +++ b/tests/qflags/qflags_test_template.py @@ -1,4 +1,11 @@ -from typing import Union, TypeVar, Type, Literal +# mypy: no-warn-unreachable + +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -56,7 +63,7 @@ def test_on_one_flag_class() -> None: # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) # Note that this breaks Liskov principle # 2. everything else returns int: & ^ &= ^= - # 1. operations with int return int. + # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) @@ -255,6 +262,6 @@ def f4() -> None: pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) - pytest.raises(TypeError, f1) + pytest.raises(TypeError, f3) pytest.raises(TypeError, f4) diff --git a/tests/qflags/test_QtCore_Alignment_AlignmentFlag.py b/tests/qflags/test_QtCore_Alignment_AlignmentFlag.py index 7a291196..e1045204 100644 --- a/tests/qflags/test_QtCore_Alignment_AlignmentFlag.py +++ b/tests/qflags/test_QtCore_Alignment_AlignmentFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.AlignmentFlag.AlignLeft oneFlagRefValue2 = QtCore.Qt.AlignmentFlag.AlignLeading + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py b/tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py index 90674f34..fb8e27df 100644 --- a/tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py +++ b/tests/qflags/test_QtCore_ApplicationStates_ApplicationState.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_Base64Options_Base64Option.py b/tests/qflags/test_QtCore_Base64Options_Base64Option.py index 317935de..60534242 100644 --- a/tests/qflags/test_QtCore_Base64Options_Base64Option.py +++ b/tests/qflags/test_QtCore_Base64Options_Base64Option.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtCore.QByteArray.Base64Option.Base64Encoding oneFlagRefValue2 = QtCore.QByteArray.Base64Option.Base64UrlEncoding -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py b/tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py index bb83c750..90eb8dbd 100644 --- a/tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py +++ b/tests/qflags/test_QtCore_BoundaryReasons_BoundaryReason.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtCore.QTextBoundaryFinder.BoundaryReason.NotAtBoundary oneFlagRefValue2 = QtCore.QTextBoundaryFinder.BoundaryReason.SoftHyphen -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py b/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py index 8ae404cd..e6282bdf 100644 --- a/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py +++ b/tests/qflags/test_QtCore_CheckIndexOptions_CheckIndexOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -57,7 +62,7 @@ def test_on_one_flag_class() -> None: # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) # Note that this breaks Liskov principle # 2. everything else returns int: & ^ &= ^= - # 1. operations with int return int. + # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) @@ -256,6 +261,6 @@ def f4() -> None: pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) - pytest.raises(TypeError, f1) + pytest.raises(TypeError, f3) pytest.raises(TypeError, f4) diff --git a/tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py b/tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py index 53b9811d..a461db58 100644 --- a/tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py +++ b/tests/qflags/test_QtCore_ComponentFormattingOptions_ComponentFormattingOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtCore.QUrl.ComponentFormattingOption.PrettyDecoded oneFlagRefValue2 = QtCore.QUrl.ComponentFormattingOption.EncodeSpaces -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py b/tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py index 654a3552..94f556df 100644 --- a/tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py +++ b/tests/qflags/test_QtCore_ConversionFlags_ConversionFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QTextCodec.ConversionFlag.DefaultConversion oneFlagRefValue2 = QtCore.QTextCodec.ConversionFlag.ConvertInvalidToNull + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py b/tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py index c0c81707..0bcf8d1f 100644 --- a/tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py +++ b/tests/qflags/test_QtCore_DataSizeFormats_DataSizeFormat.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py b/tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py index 796792b9..6cce4761 100644 --- a/tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py +++ b/tests/qflags/test_QtCore_DockWidgetAreas_DockWidgetArea.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.DockWidgetArea.LeftDockWidgetArea oneFlagRefValue2 = QtCore.Qt.DockWidgetArea.RightDockWidgetArea + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_DropActions_DropAction.py b/tests/qflags/test_QtCore_DropActions_DropAction.py index 69e72c67..6c5a8ceb 100644 --- a/tests/qflags/test_QtCore_DropActions_DropAction.py +++ b/tests/qflags/test_QtCore_DropActions_DropAction.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.DropAction.CopyAction oneFlagRefValue2 = QtCore.Qt.DropAction.MoveAction + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_Edges_Edge.py b/tests/qflags/test_QtCore_Edges_Edge.py index 3bdd1e4b..05048e21 100644 --- a/tests/qflags/test_QtCore_Edges_Edge.py +++ b/tests/qflags/test_QtCore_Edges_Edge.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.Edge.TopEdge oneFlagRefValue2 = QtCore.Qt.Edge.LeftEdge + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py b/tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py index d9c4d83f..8339fa5d 100644 --- a/tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py +++ b/tests/qflags/test_QtCore_FileHandleFlags_FileHandleFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_Filters_Filter.py b/tests/qflags/test_QtCore_Filters_Filter.py index 6a85dc60..f3a9e61f 100644 --- a/tests/qflags/test_QtCore_Filters_Filter.py +++ b/tests/qflags/test_QtCore_Filters_Filter.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QDir.Filter.Dirs oneFlagRefValue2 = QtCore.QDir.Filter.Files + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py b/tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py index 4789b01d..32efffe3 100644 --- a/tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py +++ b/tests/qflags/test_QtCore_FindChildOptions_FindChildOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_Flags_Flag.py b/tests/qflags/test_QtCore_Flags_Flag.py index e43199fe..389b580f 100644 --- a/tests/qflags/test_QtCore_Flags_Flag.py +++ b/tests/qflags/test_QtCore_Flags_Flag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QCommandLineOption.Flag.HiddenFromHelp oneFlagRefValue2 = QtCore.QCommandLineOption.Flag.ShortOptionStyle + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_GestureFlags_GestureFlag.py b/tests/qflags/test_QtCore_GestureFlags_GestureFlag.py index 2a1953a9..0410daae 100644 --- a/tests/qflags/test_QtCore_GestureFlags_GestureFlag.py +++ b/tests/qflags/test_QtCore_GestureFlags_GestureFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.GestureFlag.DontStartGestureOnChildren oneFlagRefValue2 = QtCore.Qt.GestureFlag.ReceivePartialGestures + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py b/tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py index d7559021..c790de7c 100644 --- a/tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py +++ b/tests/qflags/test_QtCore_ImageConversionFlags_ImageConversionFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.ImageConversionFlag.AutoColor oneFlagRefValue2 = QtCore.Qt.ImageConversionFlag.ColorOnly + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py b/tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py index 899b7346..556c7018 100644 --- a/tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py +++ b/tests/qflags/test_QtCore_InputMethodHints_InputMethodHint.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.InputMethodHint.ImhNone oneFlagRefValue2 = QtCore.Qt.InputMethodHint.ImhHiddenText + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py b/tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py index fd12af03..e3db721e 100644 --- a/tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py +++ b/tests/qflags/test_QtCore_InputMethodQueries_InputMethodQuery.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.InputMethodQuery.ImMicroFocus oneFlagRefValue2 = QtCore.Qt.InputMethodQuery.ImFont + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_ItemFlags_ItemFlag.py b/tests/qflags/test_QtCore_ItemFlags_ItemFlag.py index c997c8e3..dc5b0b7b 100644 --- a/tests/qflags/test_QtCore_ItemFlags_ItemFlag.py +++ b/tests/qflags/test_QtCore_ItemFlags_ItemFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.ItemFlag.NoItemFlags oneFlagRefValue2 = QtCore.Qt.ItemFlag.ItemIsSelectable + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py b/tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py index 04371bdb..3c23bef5 100644 --- a/tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py +++ b/tests/qflags/test_QtCore_IteratorFlags_IteratorFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QDirIterator.IteratorFlag.NoIteratorFlags oneFlagRefValue2 = QtCore.QDirIterator.IteratorFlag.FollowSymlinks + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py b/tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py index e716fdbb..857e2d46 100644 --- a/tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py +++ b/tests/qflags/test_QtCore_KeyboardModifiers_KeyboardModifier.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.KeyboardModifier.NoModifier oneFlagRefValue2 = QtCore.Qt.KeyboardModifier.ShiftModifier + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_LoadHints_LoadHint.py b/tests/qflags/test_QtCore_LoadHints_LoadHint.py index d829ec7a..ec0b54dc 100644 --- a/tests/qflags/test_QtCore_LoadHints_LoadHint.py +++ b/tests/qflags/test_QtCore_LoadHints_LoadHint.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QLibrary.LoadHint.ResolveAllSymbolsHint oneFlagRefValue2 = QtCore.QLibrary.LoadHint.ExportExternalSymbolsHint + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_LocateOptions_LocateOption.py b/tests/qflags/test_QtCore_LocateOptions_LocateOption.py index 003ac33d..9beb26d1 100644 --- a/tests/qflags/test_QtCore_LocateOptions_LocateOption.py +++ b/tests/qflags/test_QtCore_LocateOptions_LocateOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QStandardPaths.LocateOption.LocateFile oneFlagRefValue2 = QtCore.QStandardPaths.LocateOption.LocateDirectory + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_MatchFlags_MatchFlag.py b/tests/qflags/test_QtCore_MatchFlags_MatchFlag.py index ab762acd..649447fb 100644 --- a/tests/qflags/test_QtCore_MatchFlags_MatchFlag.py +++ b/tests/qflags/test_QtCore_MatchFlags_MatchFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.MatchFlag.MatchExactly oneFlagRefValue2 = QtCore.Qt.MatchFlag.MatchFixedString + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_MatchOptions_MatchOption.py b/tests/qflags/test_QtCore_MatchOptions_MatchOption.py index 239f1a9b..ffadbf1a 100644 --- a/tests/qflags/test_QtCore_MatchOptions_MatchOption.py +++ b/tests/qflags/test_QtCore_MatchOptions_MatchOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtCore.QRegularExpression.MatchOption.NoMatchOption oneFlagRefValue2 = QtCore.QRegularExpression.MatchOption.AnchoredMatchOption -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_MouseButtons_MouseButton.py b/tests/qflags/test_QtCore_MouseButtons_MouseButton.py index 61b65997..420131c2 100644 --- a/tests/qflags/test_QtCore_MouseButtons_MouseButton.py +++ b/tests/qflags/test_QtCore_MouseButtons_MouseButton.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.MouseButton.NoButton oneFlagRefValue2 = QtCore.Qt.MouseButton.AllButtons + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py b/tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py index c3021554..3a6485f9 100644 --- a/tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py +++ b/tests/qflags/test_QtCore_MouseEventFlags_MouseEventFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.MouseEventFlag.MouseEventCreatedDoubleClick oneFlagRefValue2 = QtCore.Qt.MouseEventFlag.MouseEventCreatedDoubleClick + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_NumberFlags_NumberFlag.py b/tests/qflags/test_QtCore_NumberFlags_NumberFlag.py index a3e11b65..9dca3d75 100644 --- a/tests/qflags/test_QtCore_NumberFlags_NumberFlag.py +++ b/tests/qflags/test_QtCore_NumberFlags_NumberFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtCore.QTextStream.NumberFlag.ShowBase oneFlagRefValue2 = QtCore.QTextStream.NumberFlag.ForcePoint -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_NumberOptions_NumberOption.py b/tests/qflags/test_QtCore_NumberOptions_NumberOption.py index e90636ad..f40e09bc 100644 --- a/tests/qflags/test_QtCore_NumberOptions_NumberOption.py +++ b/tests/qflags/test_QtCore_NumberOptions_NumberOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtCore.QLocale.NumberOption.OmitGroupSeparator oneFlagRefValue2 = QtCore.QLocale.NumberOption.RejectGroupSeparator -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py b/tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py index c0be4fef..175d2504 100644 --- a/tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py +++ b/tests/qflags/test_QtCore_OpenMode_OpenModeFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QIODevice.OpenModeFlag.NotOpen oneFlagRefValue2 = QtCore.QIODevice.OpenModeFlag.ReadOnly + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_Orientations_Orientation.py b/tests/qflags/test_QtCore_Orientations_Orientation.py index 7acebf1d..0b74b4c0 100644 --- a/tests/qflags/test_QtCore_Orientations_Orientation.py +++ b/tests/qflags/test_QtCore_Orientations_Orientation.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.Orientation.Horizontal oneFlagRefValue2 = QtCore.Qt.Orientation.Vertical + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_PatternOptions_PatternOption.py b/tests/qflags/test_QtCore_PatternOptions_PatternOption.py index 9dd02b61..dba0a118 100644 --- a/tests/qflags/test_QtCore_PatternOptions_PatternOption.py +++ b/tests/qflags/test_QtCore_PatternOptions_PatternOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtCore.QRegularExpression.PatternOption.NoPatternOption oneFlagRefValue2 = QtCore.QRegularExpression.PatternOption.CaseInsensitiveOption -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_Permissions_Permission.py b/tests/qflags/test_QtCore_Permissions_Permission.py index f3307258..97575313 100644 --- a/tests/qflags/test_QtCore_Permissions_Permission.py +++ b/tests/qflags/test_QtCore_Permissions_Permission.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QFileDevice.Permission.ReadOwner oneFlagRefValue2 = QtCore.QFileDevice.Permission.WriteOwner + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py b/tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py index 3062f564..5426fb3a 100644 --- a/tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py +++ b/tests/qflags/test_QtCore_ProcessEventsFlags_ProcessEventsFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QEventLoop.ProcessEventsFlag.AllEvents oneFlagRefValue2 = QtCore.QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py b/tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py index 1b30c9bb..c3bfd0e0 100644 --- a/tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py +++ b/tests/qflags/test_QtCore_ScreenOrientations_ScreenOrientation.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.ScreenOrientation.PrimaryOrientation oneFlagRefValue2 = QtCore.Qt.ScreenOrientation.PortraitOrientation + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py b/tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py index 075bd379..7139ee33 100644 --- a/tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py +++ b/tests/qflags/test_QtCore_SelectionFlags_SelectionFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QItemSelectionModel.SelectionFlag.NoUpdate oneFlagRefValue2 = QtCore.QItemSelectionModel.SelectionFlag.Clear + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_SortFlags_SortFlag.py b/tests/qflags/test_QtCore_SortFlags_SortFlag.py index 788c5887..1a340949 100644 --- a/tests/qflags/test_QtCore_SortFlags_SortFlag.py +++ b/tests/qflags/test_QtCore_SortFlags_SortFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QDir.SortFlag.Name oneFlagRefValue2 = QtCore.QDir.SortFlag.Time + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py b/tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py index f4628624..3108ae97 100644 --- a/tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py +++ b/tests/qflags/test_QtCore_TextInteractionFlags_TextInteractionFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.TextInteractionFlag.NoTextInteraction oneFlagRefValue2 = QtCore.Qt.TextInteractionFlag.TextSelectableByMouse + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py b/tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py index 0f2352e7..3eff8d7b 100644 --- a/tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py +++ b/tests/qflags/test_QtCore_ToolBarAreas_ToolBarArea.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.ToolBarArea.LeftToolBarArea oneFlagRefValue2 = QtCore.Qt.ToolBarArea.RightToolBarArea + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py b/tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py index 7f150009..60e48426 100644 --- a/tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py +++ b/tests/qflags/test_QtCore_TouchPointStates_TouchPointState.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.TouchPointState.TouchPointPressed oneFlagRefValue2 = QtCore.Qt.TouchPointState.TouchPointMoved + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_TypeFlags_TypeFlag.py b/tests/qflags/test_QtCore_TypeFlags_TypeFlag.py index b70764d7..a9516077 100644 --- a/tests/qflags/test_QtCore_TypeFlags_TypeFlag.py +++ b/tests/qflags/test_QtCore_TypeFlags_TypeFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.QMetaType.TypeFlag.NeedsConstruction oneFlagRefValue2 = QtCore.QMetaType.TypeFlag.NeedsDestruction + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py b/tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py index 45a762e3..41d9a397 100644 --- a/tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py +++ b/tests/qflags/test_QtCore_UserInputResolutionOptions_UserInputResolutionOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_WindowFlags_WindowType.py b/tests/qflags/test_QtCore_WindowFlags_WindowType.py index 6d2516a5..7d861d22 100644 --- a/tests/qflags/test_QtCore_WindowFlags_WindowType.py +++ b/tests/qflags/test_QtCore_WindowFlags_WindowType.py @@ -1,24 +1,40 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part -# This file is used as a source to generate all qflags related tests. The specific part -# changes for each test but the rest of the file is totally identical +# file generated from qflags_test_template.py for QFlags class "Qt.WindowFlags" and flag class "Qt.WindowType" from PyQt5 import QtCore OneFlagClass = QtCore.Qt.WindowType MultiFlagClass = QtCore.Qt.WindowFlags -oneFlagRefValue1 = QtCore.Qt.WindowContextHelpButtonHint -oneFlagRefValue2 = QtCore.Qt.WindowMaximizeButtonHint +oneFlagRefValue1 = QtCore.Qt.WindowType.Widget +oneFlagRefValue2 = QtCore.Qt.WindowType.Window + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -29,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -42,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -54,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -112,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -148,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtCore_WindowStates_WindowState.py b/tests/qflags/test_QtCore_WindowStates_WindowState.py index f52e28d5..e8d4b5f4 100644 --- a/tests/qflags/test_QtCore_WindowStates_WindowState.py +++ b/tests/qflags/test_QtCore_WindowStates_WindowState.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtCore.Qt.WindowState.WindowNoState oneFlagRefValue2 = QtCore.Qt.WindowState.WindowMinimized + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py b/tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py index 0986a680..56a682fe 100644 --- a/tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py +++ b/tests/qflags/test_QtDBus_ConnectionCapabilities_ConnectionCapability.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtDBus.QDBusConnection.ConnectionCapability.UnixFileDescriptorPassing oneFlagRefValue2 = QtDBus.QDBusConnection.ConnectionCapability.UnixFileDescriptorPassing + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py b/tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py index c448f35b..fd360243 100644 --- a/tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py +++ b/tests/qflags/test_QtDBus_RegisterOptions_RegisterOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py b/tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py index 20809b4e..035a52b3 100644 --- a/tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py +++ b/tests/qflags/test_QtDBus_WatchMode_WatchModeFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py b/tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py index 0de617ac..9c4555e8 100644 --- a/tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py +++ b/tests/qflags/test_QtGui_Capabilities_CapabilityFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtGui.QTouchDevice.CapabilityFlag.Position oneFlagRefValue2 = QtGui.QTouchDevice.CapabilityFlag.Area -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py b/tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py index 345dfbaf..60ac001f 100644 --- a/tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py +++ b/tests/qflags/test_QtGui_DirtyFlags_DirtyFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_Features_Feature.py b/tests/qflags/test_QtGui_Features_Feature.py index 31fa2f3d..c92b96cd 100644 --- a/tests/qflags/test_QtGui_Features_Feature.py +++ b/tests/qflags/test_QtGui_Features_Feature.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtGui.QOpenGLTexture.Feature.ImmutableStorage oneFlagRefValue2 = QtGui.QOpenGLTexture.Feature.ImmutableMultisampleStorage -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_FindFlags_FindFlag.py b/tests/qflags/test_QtGui_FindFlags_FindFlag.py index bc549d9c..1b66051a 100644 --- a/tests/qflags/test_QtGui_FindFlags_FindFlag.py +++ b/tests/qflags/test_QtGui_FindFlags_FindFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtGui.QTextDocument.FindFlag.FindBackward oneFlagRefValue2 = QtGui.QTextDocument.FindFlag.FindCaseSensitively -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_Flags_Flag.py b/tests/qflags/test_QtGui_Flags_Flag.py index 006a7ca1..418999dd 100644 --- a/tests/qflags/test_QtGui_Flags_Flag.py +++ b/tests/qflags/test_QtGui_Flags_Flag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtGui.QTextOption.Flag.IncludeTrailingSpaces oneFlagRefValue2 = QtGui.QTextOption.Flag.ShowTabsAndSpaces + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_FormatOptions_FormatOption.py b/tests/qflags/test_QtGui_FormatOptions_FormatOption.py index 6856a42c..20624463 100644 --- a/tests/qflags/test_QtGui_FormatOptions_FormatOption.py +++ b/tests/qflags/test_QtGui_FormatOptions_FormatOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtGui.QSurfaceFormat.FormatOption.StereoBuffers oneFlagRefValue2 = QtGui.QSurfaceFormat.FormatOption.DebugContext + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py b/tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py index c41b648e..bfa93edd 100644 --- a/tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py +++ b/tests/qflags/test_QtGui_GlyphRunFlags_GlyphRunFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_InfoFlags_InfoFlag.py b/tests/qflags/test_QtGui_InfoFlags_InfoFlag.py index 1c6b7d92..7c47abbc 100644 --- a/tests/qflags/test_QtGui_InfoFlags_InfoFlag.py +++ b/tests/qflags/test_QtGui_InfoFlags_InfoFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py b/tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py index cbaf10cb..042f9f26 100644 --- a/tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py +++ b/tests/qflags/test_QtGui_LayoutFlags_LayoutFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtGui.QRawFont.LayoutFlag.SeparateAdvances oneFlagRefValue2 = QtGui.QRawFont.LayoutFlag.KernedAdvances -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py b/tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py index 51caa8e1..0610c8f9 100644 --- a/tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py +++ b/tests/qflags/test_QtGui_MarkdownFeatures_MarkdownFeature.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py b/tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py index c66eea4a..25284e63 100644 --- a/tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py +++ b/tests/qflags/test_QtGui_PageBreakFlags_PageBreakFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtGui.QTextFormat.PageBreakFlag.PageBreak_Auto oneFlagRefValue2 = QtGui.QTextFormat.PageBreakFlag.PageBreak_AlwaysBefore -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py b/tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py index 980adbae..f0a6010c 100644 --- a/tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py +++ b/tests/qflags/test_QtGui_PaintEngineFeatures_PaintEngineFeature.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtGui.QPaintEngine.PaintEngineFeature.PrimitiveTransform oneFlagRefValue2 = QtGui.QPaintEngine.PaintEngineFeature.PatternTransform -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py b/tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py index 6759021f..61513f18 100644 --- a/tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py +++ b/tests/qflags/test_QtGui_PixmapFragmentHints_PixmapFragmentHint.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py b/tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py index 2f6ecfee..43a3f008 100644 --- a/tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py +++ b/tests/qflags/test_QtGui_RangeAccessFlags_RangeAccessFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtGui.QOpenGLBuffer.RangeAccessFlag.RangeRead oneFlagRefValue2 = QtGui.QOpenGLBuffer.RangeAccessFlag.RangeWrite + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_RenderFlags_RenderFlag.py b/tests/qflags/test_QtGui_RenderFlags_RenderFlag.py index b7aabd9c..c6df42be 100644 --- a/tests/qflags/test_QtGui_RenderFlags_RenderFlag.py +++ b/tests/qflags/test_QtGui_RenderFlags_RenderFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtGui.QTextItem.RenderFlag.RightToLeft oneFlagRefValue2 = QtGui.QTextItem.RenderFlag.Overline -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_RenderHints_RenderHint.py b/tests/qflags/test_QtGui_RenderHints_RenderHint.py index ef35a680..1c058bc7 100644 --- a/tests/qflags/test_QtGui_RenderHints_RenderHint.py +++ b/tests/qflags/test_QtGui_RenderHints_RenderHint.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtGui.QPainter.RenderHint.Antialiasing oneFlagRefValue2 = QtGui.QPainter.RenderHint.TextAntialiasing -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_Severities_Severity.py b/tests/qflags/test_QtGui_Severities_Severity.py index 4967d9c2..f0d57d58 100644 --- a/tests/qflags/test_QtGui_Severities_Severity.py +++ b/tests/qflags/test_QtGui_Severities_Severity.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtGui.QOpenGLDebugMessage.Severity.InvalidSeverity oneFlagRefValue2 = QtGui.QOpenGLDebugMessage.Severity.HighSeverity + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py b/tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py index 48df4149..0b884ce1 100644 --- a/tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py +++ b/tests/qflags/test_QtGui_ShaderType_ShaderTypeBit.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtGui.QOpenGLShader.ShaderTypeBit.Vertex oneFlagRefValue2 = QtGui.QOpenGLShader.ShaderTypeBit.Fragment + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_Sources_Source.py b/tests/qflags/test_QtGui_Sources_Source.py index c0954945..9e324026 100644 --- a/tests/qflags/test_QtGui_Sources_Source.py +++ b/tests/qflags/test_QtGui_Sources_Source.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtGui.QOpenGLDebugMessage.Source.InvalidSource oneFlagRefValue2 = QtGui.QOpenGLDebugMessage.Source.APISource + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_Transformations_Transformation.py b/tests/qflags/test_QtGui_Transformations_Transformation.py index c363011e..68b403a1 100644 --- a/tests/qflags/test_QtGui_Transformations_Transformation.py +++ b/tests/qflags/test_QtGui_Transformations_Transformation.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtGui_Types_Type.py b/tests/qflags/test_QtGui_Types_Type.py index f2cf6bae..0e7a3b19 100644 --- a/tests/qflags/test_QtGui_Types_Type.py +++ b/tests/qflags/test_QtGui_Types_Type.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -57,7 +62,7 @@ def test_on_one_flag_class() -> None: # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) # Note that this breaks Liskov principle # 2. everything else returns int: & ^ &= ^= - # 1. operations with int return int. + # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) @@ -256,6 +261,6 @@ def f4() -> None: pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) - pytest.raises(TypeError, f1) + pytest.raises(TypeError, f3) pytest.raises(TypeError, f4) diff --git a/tests/qflags/test_QtNetwork_BindMode_BindFlag.py b/tests/qflags/test_QtNetwork_BindMode_BindFlag.py index a7af3938..fce29fac 100644 --- a/tests/qflags/test_QtNetwork_BindMode_BindFlag.py +++ b/tests/qflags/test_QtNetwork_BindMode_BindFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtNetwork.QAbstractSocket.BindFlag.DefaultForPlatform oneFlagRefValue2 = QtNetwork.QAbstractSocket.BindFlag.ShareAddress -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtNetwork_Capabilities_Capability.py b/tests/qflags/test_QtNetwork_Capabilities_Capability.py index 5dad2b0d..150a8949 100644 --- a/tests/qflags/test_QtNetwork_Capabilities_Capability.py +++ b/tests/qflags/test_QtNetwork_Capabilities_Capability.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py b/tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py index bb0f3b67..ae275d5d 100644 --- a/tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py +++ b/tests/qflags/test_QtNetwork_ConversionMode_ConversionModeFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtNetwork.QHostAddress.ConversionModeFlag.ConvertV4MappedToIPv4 oneFlagRefValue2 = QtNetwork.QHostAddress.ConversionModeFlag.ConvertV4CompatToIPv4 -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py b/tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py index e7e3c480..4ab0e7c8 100644 --- a/tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py +++ b/tests/qflags/test_QtNetwork_InterfaceFlags_InterfaceFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtNetwork.QNetworkInterface.InterfaceFlag.IsUp oneFlagRefValue2 = QtNetwork.QNetworkInterface.InterfaceFlag.IsRunning -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtNetwork_PauseModes_PauseMode.py b/tests/qflags/test_QtNetwork_PauseModes_PauseMode.py index 5182534a..724aa9fb 100644 --- a/tests/qflags/test_QtNetwork_PauseModes_PauseMode.py +++ b/tests/qflags/test_QtNetwork_PauseModes_PauseMode.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtNetwork.QAbstractSocket.PauseMode.PauseNever oneFlagRefValue2 = QtNetwork.QAbstractSocket.PauseMode.PauseOnSslErrors -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py b/tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py index 7252498d..35edd3ec 100644 --- a/tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py +++ b/tests/qflags/test_QtNetwork_PolicyFlags_PolicyFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtNetwork.QHstsPolicy.PolicyFlag.IncludeSubDomains oneFlagRefValue2 = QtNetwork.QHstsPolicy.PolicyFlag.IncludeSubDomains -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py b/tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py index 2c524ab4..c117e1c6 100644 --- a/tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py +++ b/tests/qflags/test_QtNetwork_SocketOptions_SocketOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -57,7 +62,7 @@ def test_on_one_flag_class() -> None: # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) # Note that this breaks Liskov principle # 2. everything else returns int: & ^ &= ^= - # 1. operations with int return int. + # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) @@ -256,6 +261,6 @@ def f4() -> None: pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) - pytest.raises(TypeError, f1) + pytest.raises(TypeError, f3) pytest.raises(TypeError, f4) diff --git a/tests/qflags/test_QtNetwork_SslOptions_SslOption.py b/tests/qflags/test_QtNetwork_SslOptions_SslOption.py index e0ce895f..6b801072 100644 --- a/tests/qflags/test_QtNetwork_SslOptions_SslOption.py +++ b/tests/qflags/test_QtNetwork_SslOptions_SslOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtNetwork.QSsl.SslOption.SslOptionDisableEmptyFragments oneFlagRefValue2 = QtNetwork.QSsl.SslOption.SslOptionDisableSessionTickets -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtNetwork_StateFlags_StateFlag.py b/tests/qflags/test_QtNetwork_StateFlags_StateFlag.py index f83fef94..79e175d3 100644 --- a/tests/qflags/test_QtNetwork_StateFlags_StateFlag.py +++ b/tests/qflags/test_QtNetwork_StateFlags_StateFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py b/tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py index 682b0b2a..bf2f4034 100644 --- a/tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py +++ b/tests/qflags/test_QtNetwork_UsagePolicies_UsagePolicy.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtOpenGL_BindOptions_BindOption.py b/tests/qflags/test_QtOpenGL_BindOptions_BindOption.py index 4bd8a78f..6d5753cd 100644 --- a/tests/qflags/test_QtOpenGL_BindOptions_BindOption.py +++ b/tests/qflags/test_QtOpenGL_BindOptions_BindOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtOpenGL.QGLContext.BindOption.NoBindOption oneFlagRefValue2 = QtOpenGL.QGLContext.BindOption.InvertedYBindOption + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py b/tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py index cb379a87..3039902f 100644 --- a/tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py +++ b/tests/qflags/test_QtOpenGL_FormatOptions_FormatOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtOpenGL.QGL.FormatOption.DoubleBuffer oneFlagRefValue2 = QtOpenGL.QGL.FormatOption.DepthBuffer + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py b/tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py index d1dd4316..25400de5 100644 --- a/tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py +++ b/tests/qflags/test_QtOpenGL_OpenGLVersionFlags_OpenGLVersionFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtOpenGL.QGLFormat.OpenGLVersionFlag.OpenGL_Version_None oneFlagRefValue2 = QtOpenGL.QGLFormat.OpenGLVersionFlag.OpenGL_Version_1_1 + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py b/tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py index cb1b9672..7cc178b1 100644 --- a/tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py +++ b/tests/qflags/test_QtPrintSupport_PrintDialogOptions_PrintDialogOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py b/tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py index 1abb11ba..f3fbc3a2 100644 --- a/tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py +++ b/tests/qflags/test_QtSql_ParamType_ParamTypeFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtSql.QSql.ParamTypeFlag.In oneFlagRefValue2 = QtSql.QSql.ParamTypeFlag.Out -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py b/tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py index 8c366de2..aaade60b 100644 --- a/tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py +++ b/tests/qflags/test_QtWidgets_AreaOptions_AreaOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QMdiArea.AreaOption.DontMaximizeSubWindowOnActivation oneFlagRefValue2 = QtWidgets.QMdiArea.AreaOption.DontMaximizeSubWindowOnActivation -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py b/tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py index 85a5030c..c089771c 100644 --- a/tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py +++ b/tests/qflags/test_QtWidgets_AutoFormatting_AutoFormattingFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QTextEdit.AutoFormattingFlag.AutoNone oneFlagRefValue2 = QtWidgets.QTextEdit.AutoFormattingFlag.AutoBulletList -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_BlurHints_BlurHint.py b/tests/qflags/test_QtWidgets_BlurHints_BlurHint.py index 208c83fa..55b225fd 100644 --- a/tests/qflags/test_QtWidgets_BlurHints_BlurHint.py +++ b/tests/qflags/test_QtWidgets_BlurHints_BlurHint.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QGraphicsBlurEffect.BlurHint.PerformanceHint oneFlagRefValue2 = QtWidgets.QGraphicsBlurEffect.BlurHint.QualityHint -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py b/tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py index e35f36ab..7a47e537 100644 --- a/tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py +++ b/tests/qflags/test_QtWidgets_ButtonFeatures_ButtonFeature.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QStyleOptionButton.ButtonFeature.None_ oneFlagRefValue2 = QtWidgets.QStyleOptionButton.ButtonFeature.Flat -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py b/tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py index d1ecbdab..e9c3d889 100644 --- a/tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py +++ b/tests/qflags/test_QtWidgets_CacheMode_CacheModeFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -57,7 +62,7 @@ def test_on_one_flag_class() -> None: # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) # Note that this breaks Liskov principle # 2. everything else returns int: & ^ &= ^= - # 1. operations with int return int. + # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) @@ -256,6 +261,6 @@ def f4() -> None: pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) - pytest.raises(TypeError, f1) + pytest.raises(TypeError, f3) pytest.raises(TypeError, f4) diff --git a/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py b/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py index 8481e511..f62e8683 100644 --- a/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py +++ b/tests/qflags/test_QtWidgets_ChangeFlags_ChangeFlag.py @@ -1,21 +1,26 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part -# file generated from qflags_test_template.py for QFlags class "QPinchGesture.ChangeFlags" and flag class "QPinchGesture.ChangeFlag" +# file generated from qflags_test_template.py for QFlags class "QGraphicsEffect.ChangeFlags" and flag class "QGraphicsEffect.ChangeFlag" from PyQt5 import QtWidgets -OneFlagClass = QtWidgets.QPinchGesture.ChangeFlag -MultiFlagClass = QtWidgets.QPinchGesture.ChangeFlags +OneFlagClass = QtWidgets.QGraphicsEffect.ChangeFlag +MultiFlagClass = QtWidgets.QGraphicsEffect.ChangeFlags -oneFlagRefValue1 = QtWidgets.QPinchGesture.ChangeFlag.ScaleFactorChanged -oneFlagRefValue2 = QtWidgets.QPinchGesture.ChangeFlag.RotationAngleChanged +oneFlagRefValue1 = QtWidgets.QGraphicsEffect.ChangeFlag.SourceAttached +oneFlagRefValue2 = QtWidgets.QGraphicsEffect.ChangeFlag.SourceDetached -OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_CONVERTS_TO_MULTI: Literal[True] = True OR_INT_CONVERTS_TO_MULTI: Literal[False] = False -INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part def assert_type_of_value_int(value: int) -> None: @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py b/tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py index 69b0284f..aa4227dd 100644 --- a/tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py +++ b/tests/qflags/test_QtWidgets_ColorDialogOptions_ColorDialogOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QColorDialog.ColorDialogOption.ShowAlphaChannel oneFlagRefValue2 = QtWidgets.QColorDialog.ColorDialogOption.NoButtons -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_ControlTypes_ControlType.py b/tests/qflags/test_QtWidgets_ControlTypes_ControlType.py index 3f69d715..d649c98a 100644 --- a/tests/qflags/test_QtWidgets_ControlTypes_ControlType.py +++ b/tests/qflags/test_QtWidgets_ControlTypes_ControlType.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QSizePolicy.ControlType.DefaultType oneFlagRefValue2 = QtWidgets.QSizePolicy.ControlType.ButtonBox -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py b/tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py index e578503a..731b71e7 100644 --- a/tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py +++ b/tests/qflags/test_QtWidgets_CornerWidgets_CornerWidget.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QStyleOptionTab.CornerWidget.NoCornerWidgets oneFlagRefValue2 = QtWidgets.QStyleOptionTab.CornerWidget.LeftCornerWidget -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_DockOptions_DockOption.py b/tests/qflags/test_QtWidgets_DockOptions_DockOption.py index dc217d14..2688ed8a 100644 --- a/tests/qflags/test_QtWidgets_DockOptions_DockOption.py +++ b/tests/qflags/test_QtWidgets_DockOptions_DockOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QMainWindow.DockOption.AnimatedDocks oneFlagRefValue2 = QtWidgets.QMainWindow.DockOption.AllowNestedDocks -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py b/tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py index ed4c6648..a8b45ed1 100644 --- a/tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py +++ b/tests/qflags/test_QtWidgets_DockWidgetFeatures_DockWidgetFeature.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetClosable oneFlagRefValue2 = QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py b/tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py index 35bac3be..a0a259c2 100644 --- a/tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py +++ b/tests/qflags/test_QtWidgets_EditTriggers_EditTrigger.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers oneFlagRefValue2 = QtWidgets.QAbstractItemView.EditTrigger.CurrentChanged -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py b/tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py index af2f7afd..e917b5e0 100644 --- a/tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py +++ b/tests/qflags/test_QtWidgets_FontDialogOptions_FontDialogOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QFontDialog.FontDialogOption.NoButtons oneFlagRefValue2 = QtWidgets.QFontDialog.FontDialogOption.DontUseNativeDialog -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_FontFilters_FontFilter.py b/tests/qflags/test_QtWidgets_FontFilters_FontFilter.py index 020ec33d..5d567d86 100644 --- a/tests/qflags/test_QtWidgets_FontFilters_FontFilter.py +++ b/tests/qflags/test_QtWidgets_FontFilters_FontFilter.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QFontComboBox.FontFilter.AllFonts oneFlagRefValue2 = QtWidgets.QFontComboBox.FontFilter.ScalableFonts -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py b/tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py index ef2fc93b..1c6014c9 100644 --- a/tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py +++ b/tests/qflags/test_QtWidgets_FrameFeatures_FrameFeature.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QStyleOptionFrame.FrameFeature.None_ oneFlagRefValue2 = QtWidgets.QStyleOptionFrame.FrameFeature.Flat -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py b/tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py index f3a3171d..179f956b 100644 --- a/tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py +++ b/tests/qflags/test_QtWidgets_GraphicsItemFlags_GraphicsItemFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QGraphicsItem.GraphicsItemFlag.ItemIsMovable oneFlagRefValue2 = QtWidgets.QGraphicsItem.GraphicsItemFlag.ItemIsSelectable -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py b/tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py index 8d605fdf..29819c40 100644 --- a/tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py +++ b/tests/qflags/test_QtWidgets_InputDialogOptions_InputDialogOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QInputDialog.InputDialogOption.NoButtons oneFlagRefValue2 = QtWidgets.QInputDialog.InputDialogOption.UseListViewForComboBoxItems -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py b/tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py index 2315b179..02f40eae 100644 --- a/tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py +++ b/tests/qflags/test_QtWidgets_IteratorFlags_IteratorFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -12,12 +17,24 @@ oneFlagRefValue1 = QtWidgets.QTreeWidgetItemIterator.IteratorFlag.All oneFlagRefValue2 = QtWidgets.QTreeWidgetItemIterator.IteratorFlag.Hidden + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -28,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -41,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -53,54 +64,76 @@ def test_on_one_flag_class() -> None: # 2. everything else returns int: & ^ &= ^= # 3. operations with int return int. - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here - - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 - assert_type_of_value(int, oneFlagOrIntValue) + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -111,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -147,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py b/tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py index ac8cbb8b..735eef27 100644 --- a/tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py +++ b/tests/qflags/test_QtWidgets_OptimizationFlags_OptimizationFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QGraphicsView.OptimizationFlag.DontClipPainter oneFlagRefValue2 = QtWidgets.QGraphicsView.OptimizationFlag.DontSavePainterState -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_Options_Option.py b/tests/qflags/test_QtWidgets_Options_Option.py index a391184c..6731b740 100644 --- a/tests/qflags/test_QtWidgets_Options_Option.py +++ b/tests/qflags/test_QtWidgets_Options_Option.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QFileSystemModel.Option.DontWatchForChanges oneFlagRefValue2 = QtWidgets.QFileSystemModel.Option.DontResolveSymlinks -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py b/tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py index fb9bdad3..fa7a1921 100644 --- a/tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py +++ b/tests/qflags/test_QtWidgets_RenderFlags_RenderFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QWidget.RenderFlag.DrawWindowBackground oneFlagRefValue2 = QtWidgets.QWidget.RenderFlag.DrawChildren -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_Result_ResultFlag.py b/tests/qflags/test_QtWidgets_Result_ResultFlag.py index 554cfaa8..2ec56fb3 100644 --- a/tests/qflags/test_QtWidgets_Result_ResultFlag.py +++ b/tests/qflags/test_QtWidgets_Result_ResultFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QGestureRecognizer.ResultFlag.Ignore oneFlagRefValue2 = QtWidgets.QGestureRecognizer.ResultFlag.MayBeGesture -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py b/tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py index c3415257..ad70e282 100644 --- a/tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py +++ b/tests/qflags/test_QtWidgets_SceneLayers_SceneLayer.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QGraphicsScene.SceneLayer.ItemLayer oneFlagRefValue2 = QtWidgets.QGraphicsScene.SceneLayer.BackgroundLayer -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_Sections_Section.py b/tests/qflags/test_QtWidgets_Sections_Section.py index 2b1c0075..07addbb6 100644 --- a/tests/qflags/test_QtWidgets_Sections_Section.py +++ b/tests/qflags/test_QtWidgets_Sections_Section.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QDateTimeEdit.Section.NoSection oneFlagRefValue2 = QtWidgets.QDateTimeEdit.Section.AmPmSection -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py b/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py index b53e080d..6ef52b8b 100644 --- a/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py +++ b/tests/qflags/test_QtWidgets_StandardButtons_StandardButton.py @@ -1,17 +1,22 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part -# file generated from qflags_test_template.py for QFlags class "QDialogButtonBox.StandardButtons" and flag class "QDialogButtonBox.StandardButton" +# file generated from qflags_test_template.py for QFlags class "QMessageBox.StandardButtons" and flag class "QMessageBox.StandardButton" from PyQt5 import QtWidgets -OneFlagClass = QtWidgets.QDialogButtonBox.StandardButton -MultiFlagClass = QtWidgets.QDialogButtonBox.StandardButtons +OneFlagClass = QtWidgets.QMessageBox.StandardButton +MultiFlagClass = QtWidgets.QMessageBox.StandardButtons -oneFlagRefValue1 = QtWidgets.QDialogButtonBox.StandardButton.NoButton -oneFlagRefValue2 = QtWidgets.QDialogButtonBox.StandardButton.Ok +oneFlagRefValue1 = QtWidgets.QMessageBox.StandardButton.NoButton +oneFlagRefValue2 = QtWidgets.QMessageBox.StandardButton.Ok OR_CONVERTS_TO_MULTI: Literal[True] = True OR_INT_CONVERTS_TO_MULTI: Literal[False] = False @@ -47,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -70,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -102,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -122,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -164,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -185,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -205,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py b/tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py index b5457a84..2bf3f0ad 100644 --- a/tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py +++ b/tests/qflags/test_QtWidgets_StepEnabled_StepEnabledFlag.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QAbstractSpinBox.StepEnabledFlag.StepNone oneFlagRefValue2 = QtWidgets.QAbstractSpinBox.StepEnabledFlag.StepUpEnabled -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_SubControls_SubControl.py b/tests/qflags/test_QtWidgets_SubControls_SubControl.py index 9c6fdac5..68c62de3 100644 --- a/tests/qflags/test_QtWidgets_SubControls_SubControl.py +++ b/tests/qflags/test_QtWidgets_SubControls_SubControl.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QStyle.SubControl.SC_None oneFlagRefValue2 = QtWidgets.QStyle.SubControl.SC_ScrollBarAddLine -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py b/tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py index 155e7785..becbe72c 100644 --- a/tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py +++ b/tests/qflags/test_QtWidgets_SubWindowOptions_SubWindowOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QMdiSubWindow.SubWindowOption.RubberBandResize oneFlagRefValue2 = QtWidgets.QMdiSubWindow.SubWindowOption.RubberBandMove -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py b/tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py index 1d22ffd1..9a206982 100644 --- a/tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py +++ b/tests/qflags/test_QtWidgets_TabFeatures_TabFeature.py @@ -52,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -75,23 +75,23 @@ def test_on_one_flag_class() -> None: # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value_int(oneFlagValue1 | 33) - assert_type_of_value_int(oneFlagValue1 & 33) - assert_type_of_value_int(oneFlagValue1 ^ 33) - assert_type_of_value_int(oneFlagValue1 + 33) - assert_type_of_value_int(oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value_multiFlag(33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value_int(33 | oneFlagValue1) - assert_type_of_value_int(33 & oneFlagValue1) - assert_type_of_value_int(33 ^ oneFlagValue1) - assert_type_of_value_int(33 + oneFlagValue1) - assert_type_of_value_int(33 - oneFlagValue1) + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) if OR_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value @@ -107,17 +107,17 @@ def test_on_one_flag_class() -> None: if OR_INT_CONVERTS_TO_MULTI: oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= 33 + oneOrMultiFlagValueTest |= 1 assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue |= 33 + oneFlagOrIntValue |= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue &= 33 + oneFlagOrIntValue &= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -127,7 +127,7 @@ def test_on_one_flag_class() -> None: oneFlagOrIntValue = oneFlagValue1 # reset type and value assert_type_of_value_oneFlag(oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 + oneFlagOrIntValue ^= 1 assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value @@ -169,9 +169,9 @@ def test_on_multi_flag_class() -> None: # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value_multiFlag(multiFlagValue1 | 33) - assert_type_of_value_multiFlag(multiFlagValue1 & 33) - assert_type_of_value_multiFlag(multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -190,10 +190,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass assert_type_of_value_multiFlag(multiFlagValueTest) @@ -210,54 +210,54 @@ def test_on_multi_flag_class() -> None: # assignments operations with int assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest |= 33 + multiFlagValueTest |= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest &= 33 + multiFlagValueTest &= 1 assert_type_of_value_multiFlag(multiFlagValueTest) assert_type_of_value_multiFlag(multiFlagValueTest) - multiFlagValueTest ^= 33 + multiFlagValueTest ^= 1 assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py b/tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py index db561993..8e4b86c2 100644 --- a/tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py +++ b/tests/qflags/test_QtWidgets_ToolBarFeatures_ToolBarFeature.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QStyleOptionToolBar.ToolBarFeature.None_ oneFlagRefValue2 = QtWidgets.QStyleOptionToolBar.ToolBarFeature.Movable -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py b/tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py index e3740f7a..62aa5042 100644 --- a/tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py +++ b/tests/qflags/test_QtWidgets_ToolButtonFeatures_ToolButtonFeature.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QStyleOptionToolButton.ToolButtonFeature.None_ oneFlagRefValue2 = QtWidgets.QStyleOptionToolButton.ToolButtonFeature.Arrow -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py b/tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py index c361911e..ccf34743 100644 --- a/tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py +++ b/tests/qflags/test_QtWidgets_ViewItemFeatures_ViewItemFeature.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QStyleOptionViewItem.ViewItemFeature.None_ oneFlagRefValue2 = QtWidgets.QStyleOptionViewItem.ViewItemFeature.WrapText -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) diff --git a/tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py b/tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py index 26166401..a169178f 100644 --- a/tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py +++ b/tests/qflags/test_QtWidgets_WizardOptions_WizardOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable +import sys from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part @@ -13,15 +18,23 @@ oneFlagRefValue1 = QtWidgets.QWizard.WizardOption.IndependentPages oneFlagRefValue2 = QtWidgets.QWizard.WizardOption.IgnoreSubTitles -OR_CONVERTS_TO_MULTI = True -OR_INT_CONVERTS_TO_MULTI = False -INT_OR_CONVERTS_TO_MULTI = True +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True ### End of specific part -T = TypeVar('T') -def assert_type_of_value(expected_type: Type[T], value: T) -> None: +def assert_type_of_value_int(value: int) -> None: '''Raise an exception if the value is not of type expected_type''' - assert type(value) == expected_type + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + def test_on_one_flag_class() -> None: @@ -32,12 +45,6 @@ def test_on_one_flag_class() -> None: oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(OneFlagClass, oneFlagValue2) - assert_type_of_value(OneFlagClass, oneFlagValueTest) - assert_type_of_value(int, intValue) - - # upcast from OneFlagClass to int intValue = oneFlagValue1 @@ -45,10 +52,10 @@ def test_on_one_flag_class() -> None: intValue = int(oneFlagValue1) # this is not supported type-safely for a good reason - oneFlagValueTest = 33 # type: ignore + oneFlagValueTest = 1 # type: ignore # correct way to do it - oneFlagValueTest = OneFlagClass(33) + oneFlagValueTest = OneFlagClass(1) oneFlagValueTest = OneFlagClass(oneFlagValue1) # The rules of OneFlagClass conversion defined in PyQt5 are: @@ -58,69 +65,75 @@ def test_on_one_flag_class() -> None: # 3. operations with int return int. if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) else: - assert_type_of_value(int, oneFlagValue1 | oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) - assert_type_of_value(int, ~oneFlagValue1) - assert_type_of_value(int, oneFlagValue1 & oneFlagValue2) - assert_type_of_value(int, oneFlagValue1 ^ oneFlagValue2) + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) # right operand if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagValue1 | 33) + assert_type_of_value_multiFlag(oneFlagValue1 | 1) else: - assert_type_of_value(int, oneFlagValue1 | 33) - assert_type_of_value(int, oneFlagValue1 & 33) - assert_type_of_value(int, oneFlagValue1 ^ 33) - assert_type_of_value(int, oneFlagValue1 + 33) - assert_type_of_value(int, oneFlagValue1 - 33) + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) # left operand if INT_OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, 33 | oneFlagValue1) + assert_type_of_value_multiFlag(1 | oneFlagValue1) else: - assert_type_of_value(int, 33 | oneFlagValue1) - assert_type_of_value(int, 33 & oneFlagValue1) - assert_type_of_value(int, 33 ^ oneFlagValue1) - assert_type_of_value(int, 33 + oneFlagValue1) - assert_type_of_value(int, 33 - oneFlagValue1) - - oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneOrMultiFlagValueTest) - oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + if OR_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneOrMultiFlagValueTest) # nice violation of Liskov principle here + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here else: - assert_type_of_value(int, oneOrMultiFlagValueTest) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) - oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue |= 33 if OR_INT_CONVERTS_TO_MULTI: - assert_type_of_value(MultiFlagClass, oneFlagOrIntValue) + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) else: - assert_type_of_value(int, oneFlagOrIntValue) + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue &= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue &= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) - oneFlagOrIntValue ^= 33 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) oneFlagOrIntValue = oneFlagValue1 # reset type and value - assert_type_of_value(OneFlagClass, oneFlagOrIntValue) + assert_type_of_value_oneFlag(oneFlagOrIntValue) oneFlagOrIntValue ^= oneFlagValue2 - assert_type_of_value(int, oneFlagOrIntValue) + assert_type_of_value_int(oneFlagOrIntValue) @@ -131,34 +144,34 @@ def test_on_multi_flag_class() -> None: multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass intValue = 0 - assert_type_of_value(OneFlagClass, oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValue2) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) # MultiFlagClass may be created by combining MultiFlagClass together - assert_type_of_value(MultiFlagClass, ~multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 | multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & multiFlagValue2 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ multiFlagValue2 ) + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right - assert_type_of_value(MultiFlagClass, multiFlagValue1 | oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value(MultiFlagClass, oneFlagValue1 ^ multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only - assert_type_of_value(MultiFlagClass, multiFlagValue1 | 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 & 33) - assert_type_of_value(MultiFlagClass, multiFlagValue1 ^ 33) + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass @@ -167,84 +180,84 @@ def test_on_multi_flag_class() -> None: # correct way to do it multiFlagValueTest = MultiFlagClass(oneFlagValue1) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # this is rejected for the same reason as for OneFlagClass. intValue = multiFlagValueTest # type: ignore # correct way to do it intValue = int(multiFlagValueTest) - assert_type_of_value(int, intValue) + assert_type_of_value_int(intValue) # rejected by mypy rightfully - multiFlagValueTest = 33 # type: ignore + multiFlagValueTest = 1 # type: ignore # correct way to do it - multiFlagValueTest = MultiFlagClass(33) + multiFlagValueTest = MultiFlagClass(1) # assignments operations with OneFlagClass - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest |= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest &= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) multiFlagValueTest ^= oneFlagValue1 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) # assignments operations with int - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest |= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest &= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - assert_type_of_value(MultiFlagClass, multiFlagValueTest) - multiFlagValueTest ^= 33 - assert_type_of_value(MultiFlagClass, multiFlagValueTest) + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) - #########################################################3 + #########################################################1 # # Exploring errors # - #########################################################3 + #########################################################1 # This checks the following: # + and - operations are not supported on MultiFlagClass # combining int with MultiFlagClass does not work - pytest.raises(TypeError, lambda: 33 | multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 & multiFlagValue1 ) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 ^ multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 + 33) # type: ignore[operator] - pytest.raises(TypeError, lambda: multiFlagValue1 - 33) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 + multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: 33 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] def f1() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] def f2() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest += 33 # type: ignore[assignment, operator] + multiFlagValueTest += 1 # type: ignore[assignment, operator] def f3() -> None: multiFlagValueTest = MultiFlagClass() multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] def f4() -> None: multiFlagValueTest = MultiFlagClass() - multiFlagValueTest -= 33 # type: ignore[assignment, operator] + multiFlagValueTest -= 1 # type: ignore[assignment, operator] pytest.raises(TypeError, f1) pytest.raises(TypeError, f2) From 3bf959ce7ee4110555ed3bc647104c3aa5063aea Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 13 Nov 2021 21:58:50 +0100 Subject: [PATCH 241/421] Regnerate test files to support Python 3.6 - 3.10 --- .../test_QtCore_FormattingOptions_UrlFormattingOption.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py b/tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py index c527b374..6a4cd2dd 100644 --- a/tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py +++ b/tests/qflags/test_QtCore_FormattingOptions_UrlFormattingOption.py @@ -1,6 +1,11 @@ # mypy: no-warn-unreachable -from typing import Union, TypeVar, Type, Literal +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal import pytest ### Specific part From 74be2ec57dbab5ccc0d77ae27b3362158c609bb8 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 17:39:53 +0100 Subject: [PATCH 242/421] Rename --- tests/qflags/qtbase-qflag-grep-result.txt | 227 ++ tests/qflags/qtbase-qflags_to_process.json | 2193 ++++++++++++++++++++ 2 files changed, 2420 insertions(+) create mode 100644 tests/qflags/qtbase-qflag-grep-result.txt create mode 100644 tests/qflags/qtbase-qflags_to_process.json diff --git a/tests/qflags/qtbase-qflag-grep-result.txt b/tests/qflags/qtbase-qflag-grep-result.txt new file mode 100644 index 00000000..e92d42a0 --- /dev/null +++ b/tests/qflags/qtbase-qflag-grep-result.txt @@ -0,0 +1,227 @@ +qmake\library\qmakeevaluator.h: Q_DECLARE_FLAGS(LoadFlags, LoadFlag) +qmake\library\qmakeparser.h: Q_DECLARE_FLAGS(ParseFlags, ParseFlag) +qmake\library\qmakevfs.h: Q_DECLARE_FLAGS(VfsFlags, VfsFlag) +qmake\generators\makefile.h: Q_DECLARE_FLAGS(FileFixifyTypes, FileFixifyType) +src\concurrent\qtconcurrentreducekernel.h:Q_DECLARE_FLAGS(ReduceOptions, ReduceOption) +src\dbus\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption) +src\dbus\qdbusconnection.h: Q_DECLARE_FLAGS(VirtualObjectRegisterOptions, VirtualObjectRegisterOption) +src\dbus\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability) +src\opengl\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption) +src\opengl\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag) +src\opengl\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption) +src\opengl\qglfunctions.h: Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature) +src\opengl\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit) +src\dbus\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag) +examples\network\torrent\peerwireclient.h: Q_DECLARE_FLAGS(PeerWireState, PeerWireStateFlag) +src\corelib\codecs\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag) +src\corelib\codecs\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag) +src\gui\accessible\qaccessible.h: Q_DECLARE_FLAGS(Relation, RelationFlag) +src\corelib\io\qabstractfileengine_p.h: Q_DECLARE_FLAGS(FileFlags, FileFlag) +src\corelib\global\qflags.h:#define Q_DECLARE_FLAGS(Flags, Enum)\ +src\corelib\global\qflags.h:#define Q_DECLARE_FLAGS(Flags, Enum)\ +src\corelib\itemmodels\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption) +src\corelib\io\qdir.h: Q_DECLARE_FLAGS(Filters, Filter) +src\corelib\io\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag) +src\corelib\io\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag) +src\corelib\io\qdir_p.h: Q_DECLARE_FLAGS(PathNormalizations, PathNormalization) +src\corelib\io\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission) +src\corelib\io\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag) +src\corelib\itemmodels\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(SplitBehavior, SplitBehaviorFlags) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag) +src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag) +src\corelib\io\qfilesystemmetadata_p.h: Q_DECLARE_FLAGS(MetaDataFlags, MetaDataFlag) +src\gui\image\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation) +src\gui\image\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability) +src\corelib\kernel\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag) +src\corelib\io\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag) +src\gui\kernel\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag) +src\corelib\io\qloggingregistry_p.h: Q_DECLARE_FLAGS(PatternFlags, PatternFlag) +src\corelib\plugin\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint) +src\gui\opengl\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag) +src\corelib\kernel\qmetaobjectbuilder_p.h: Q_DECLARE_FLAGS(AddMembers, AddMember) +src\corelib\kernel\qmetaobjectbuilder_p.h: Q_DECLARE_FLAGS(MetaObjectFlags, MetaObjectFlag) +src\gui\opengl\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source) +src\gui\opengl\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type) +src\gui\opengl\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity) +src\corelib\kernel\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag) +src\gui\opengl\qopenglextensions_p.h: Q_DECLARE_FLAGS(OpenGLExtensions, OpenGLExtension) +src\corelib\io\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption) +src\gui\opengl\qopenglfunctions.h: Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature) +src\corelib\kernel\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\corelib\kernel\qppsobject_p.h: Q_DECLARE_FLAGS(OpenModes, OpenMode) +src\gui\kernel\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability) +src\network\access\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag) +src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton) +src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption) +src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption) +src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FileDialogOptions, FileDialogOption) +src\gui\kernel\qplatformgraphicsbuffer.h: Q_DECLARE_FLAGS(AccessTypes, AccessType); +src\gui\painting\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability) +src\corelib\io\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption) +src\corelib\io\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption) +src\corelib\io\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption) +src\gui\painting\qcolortransform_p.h: Q_DECLARE_FLAGS(TransformFlags, TransformFlag) +src\gui\kernel\qplatformtheme.h: Q_DECLARE_FLAGS(IconOptions, IconOption) +src\network\bearer\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability) +src\network\bearer\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag) +src\gui\kernel\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption) +src\network\bearer\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy) +src\gui\painting\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag) +src\gui\painting\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature) +src\gui\painting\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag) +src\gui\kernel\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag) +src\gui\opengl\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit) +src\gui\opengl\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature) +src\gui\painting\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint) +src\gui\painting\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint) +src\gui\opengl\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption) +src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(DataFrameFlags, DataFrameFlag) +src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(ControlFrameFlags, ControlFrameFlag) +src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(SETTINGS_Flags, SETTINGS_Flag) +src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(SETTINGS_ID_Flags, SETTINGS_ID_Flag) +src\gui\painting\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\painting\qplatformbackingstore.h: Q_DECLARE_FLAGS(TextureFlags, TextureFlag) +src\gui\text\qfontengine_p.h: Q_DECLARE_FLAGS(ShaperFlags, ShaperFlag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(StageFlags, StageFlag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(UsageFlags, UsageFlag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(BeginFrameFlags, BeginFrameFlag) +src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(EndFrameFlags, EndFrameFlag) +src\gui\rhi\qshaderdescription_p.h: Q_DECLARE_FLAGS(ImageFlags, ImageFlag) +src\gui\vulkan\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\rhi\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\util\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType) +src\gui\vulkan\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag) +src\gui\text\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag) +src\gui\text\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag) +src\gui\text\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature) +src\gui\text\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag) +src\network\kernel\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag) +src\network\socket\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag) +src\network\socket\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode) +src\network\socket\qabstractsocketengine_p.h: Q_DECLARE_FLAGS(PacketHeaderOptions, PacketHeaderOption) +src\gui\text\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag) +src\network\socket\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption) +src\gui\text\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature) +src\network\kernel\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag) +src\gui\text\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag) +src\network\ssl\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption) +src\network\kernel\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability) +src\corelib\text\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option) +src\corelib\text\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption) +src\corelib\text\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat) +src\corelib\serialization\qcborvalue.h: Q_DECLARE_FLAGS(EncodingOptions, EncodingOption) +src\corelib\serialization\qcborvalue.h: Q_DECLARE_FLAGS(DiagnosticNotationOptions, DiagnosticNotationOption) +src\corelib\serialization\qcborvalue_p.h: Q_DECLARE_FLAGS(ValueFlags, ValueFlag) +src\corelib\time\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section) +src\corelib\time\qdatetimeparser_p.h: Q_DECLARE_FLAGS(FieldInfo, FieldInfoFlag) +src\corelib\time\qdatetime_p.h: Q_DECLARE_FLAGS(StatusFlags, StatusFlag) +src\corelib\text\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption) +src\corelib\text\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption) +src\corelib\text\qstring.h: Q_DECLARE_FLAGS(SectionFlags, SectionFlag) +src\corelib\serialization\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag) +src\corelib\text\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason ) +src\corelib\text\qunicodetools_p.h:Q_DECLARE_FLAGS(CharAttributeOptions, CharAttributeOption) +src\corelib\tools\qarraydata.h: Q_DECLARE_FLAGS(AllocationOptions, AllocationOption) +src\corelib\tools\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag) +src\platformheaders\windowsfunctions\qwindowswindowfunctions.h: Q_DECLARE_FLAGS(TouchWindowTouchTypes, TouchWindowTouchType) +src\platformheaders\xcbfunctions\qxcbwindowfunctions.h: Q_DECLARE_FLAGS(WmWindowTypes, WmWindowType) +src\platformsupport\devicediscovery\qdevicediscovery_p.h: Q_DECLARE_FLAGS(QDeviceTypes, QDeviceType) +src\platformsupport\eglconvenience\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\platformsupport\fbconvenience\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\printsupport\dialogs\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption) +src\platformsupport\kmsconvenience\qkmsdevice_p.h: Q_DECLARE_FLAGS(Rotations, Rotation) +src\sql\kernel\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag) +src\widgets\dialogs\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption) +src\widgets\dialogs\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option) +src\widgets\dialogs\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option) +src\widgets\dialogs\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption) +src\widgets\effects\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) +src\widgets\effects\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint) +src\widgets\dialogs\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption) +src\widgets\dialogs\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton) +src\widgets\dialogs\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption) +src\widgets\itemviews\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger) +src\widgets\graphicsview\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag) +src\widgets\itemviews\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option) +src\widgets\kernel\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) +src\widgets\kernel\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag) +src\widgets\graphicsview\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer) +src\widgets\graphicsview\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag) +src\widgets\graphicsview\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag) +src\widgets\kernel\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType) +src\widgets\itemviews\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag) +src\widgets\kernel\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag) +src\widgets\kernel\qwidget_p.h: Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag) +src\widgets\styles\qdrawutil.h: Q_DECLARE_FLAGS(DrawingHints, DrawingHint) +src\widgets\styles\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag) +src\widgets\styles\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl) +src\widgets\widgets\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature) +src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature) +src\widgets\widgets\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton) +src\widgets\widgets\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature) +src\widgets\widgets\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter) +src\widgets\widgets\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section) +src\widgets\widgets\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption) +src\widgets\widgets\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption) +src\widgets\widgets\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption) +tests\manual\diaglib\eventfilter.h: Q_DECLARE_FLAGS(EventCategories, EventCategory) +tests\manual\diaglib\eventfilter.h: Q_DECLARE_FLAGS(ObjectTypes, ObjectType) +src\widgets\widgets\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag) +tests\manual\diaglib\qwindowdump.h:Q_DECLARE_FLAGS(FormatWindowOptions, FormatWindowOption) +src\network\access\http2\http2protocol_p.h:Q_DECLARE_FLAGS(FrameFlags, FrameFlag) +src\plugins\bearer\networkmanager\qnetworkmanagerservice.h: Q_DECLARE_FLAGS(ApFlags, ApFlag) +src\plugins\bearer\networkmanager\qnetworkmanagerservice.h: Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag) +src\plugins\bearer\networkmanager\qnetworkmanagerservice.h: Q_DECLARE_FLAGS(ModemCapabilities, ModemCapability) +src\plugins\platforms\android\qandroidinputcontext.h: Q_DECLARE_FLAGS(HandleModes, HandleMode) +src\plugins\platforms\direct2d\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag) +src\plugins\platforms\cocoa\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option) +src\plugins\platforms\wasm\qwasmcompositor.h: Q_DECLARE_FLAGS(SubControls, QWasmSubControl) +src\plugins\platforms\wasm\qwasmcompositor.h: Q_DECLARE_FLAGS(StateFlags, QWasmStateFlag) +src\plugins\platforms\cocoa\qcocoawindow.h: Q_DECLARE_FLAGS(RecreationReasons, RecreationReason) +src\plugins\platforms\qnx\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option) +src\plugins\platforms\xcb\qxcbeventqueue.h: Q_DECLARE_FLAGS(PeekOptions, PeekOption) +src\plugins\platforms\windows\qwindowsopengltester.h: Q_DECLARE_FLAGS(Renderers, Renderer) +src\plugins\platforms\xcb\qxcbwindow.h: Q_DECLARE_FLAGS(NetWmStates, NetWmState) +tests\auto\other\macgui\guitest.h: Q_DECLARE_FLAGS(Directions, Direction) +tests\auto\tools\moc\cxx11-enums.h: Q_DECLARE_FLAGS(ClassFlags, ClassFlag) +tests\auto\tools\moc\cxx11-enums.h: Q_DECLARE_FLAGS(StructFlags, StructFlag) +tests\auto\tools\moc\cxx11-enums.h: Q_DECLARE_FLAGS(ClassFlags, ClassFlag) +tests\auto\tools\moc\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag ) +src\plugins\platforms\eglfs\api\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag) +tests\auto\corelib\tools\qsharedpointer\externaltests.h: Q_DECLARE_FLAGS(QtModules, QtModule) +tests\benchmarks\corelib\io\qdiriterator\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag) +tests\benchmarks\widgets\graphicsview\functional\GraphicsViewBenchmark\widgets\settings.h: Q_DECLARE_FLAGS(Options, Option) diff --git a/tests/qflags/qtbase-qflags_to_process.json b/tests/qflags/qtbase-qflags_to_process.json new file mode 100644 index 00000000..9c7e56b7 --- /dev/null +++ b/tests/qflags/qtbase-qflags_to_process.json @@ -0,0 +1,2193 @@ +{ + "__": "This file can be adjusted manually by a human prior to being processed by the tool", + "qflags_to_process": [ + { + "qflag_class": "RegisterOptions", + "enum_class": "RegisterOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi" + }, + { + "qflag_class": "ConnectionCapabilities", + "enum_class": "ConnectionCapability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi" + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" + }, + { + "qflag_class": "OpenGLVersionFlags", + "enum_class": "OpenGLVersionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" + }, + { + "qflag_class": "BindOptions", + "enum_class": "BindOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption)", + "src\\gui\\opengl\\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" + }, + { + "qflag_class": "ShaderType", + "enum_class": "ShaderTypeBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)", + "src\\gui\\opengl\\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "WatchMode", + "enum_class": "WatchModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi" + }, + { + "qflag_class": "ConversionFlags", + "enum_class": "ConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\codecs\\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)", + "src\\corelib\\codecs\\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "CheckIndexOptions", + "enum_class": "CheckIndexOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\itemmodels\\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Filters", + "enum_class": "Filter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(Filters, Filter)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "SortFlags", + "enum_class": "SortFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Permissions", + "enum_class": "Permission", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "FileHandleFlags", + "enum_class": "FileHandleFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "SelectionFlags", + "enum_class": "SelectionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\itemmodels\\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "KeyboardModifiers", + "enum_class": "KeyboardModifier", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MouseButtons", + "enum_class": "MouseButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Orientations", + "enum_class": "Orientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Alignment", + "enum_class": "AlignmentFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "WindowFlags", + "enum_class": "WindowType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "WindowStates", + "enum_class": "WindowState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ApplicationStates", + "enum_class": "ApplicationState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ScreenOrientations", + "enum_class": "ScreenOrientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ImageConversionFlags", + "enum_class": "ImageConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "DockWidgetAreas", + "enum_class": "DockWidgetArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ToolBarAreas", + "enum_class": "ToolBarArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Edges", + "enum_class": "Edge", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "InputMethodQueries", + "enum_class": "InputMethodQuery", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "InputMethodHints", + "enum_class": "InputMethodHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "FindChildOptions", + "enum_class": "FindChildOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "DropActions", + "enum_class": "DropAction", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ItemFlags", + "enum_class": "ItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MatchFlags", + "enum_class": "MatchFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "TextInteractionFlags", + "enum_class": "TextInteractionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "TouchPointStates", + "enum_class": "TouchPointState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "GestureFlags", + "enum_class": "GestureFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MouseEventFlags", + "enum_class": "MouseEventFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Transformations", + "enum_class": "Transformation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "ProcessEventsFlags", + "enum_class": "ProcessEventsFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "OpenMode", + "enum_class": "OpenModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "InfoFlags", + "enum_class": "InfoFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "LoadHints", + "enum_class": "LoadHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\plugin\\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "RangeAccessFlags", + "enum_class": "RangeAccessFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Sources", + "enum_class": "Source", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Types", + "enum_class": "Type", + "human_hint_qflag_full_class_name": "QOpenGLDebugMessage.Types", + "human_hint_enum_full_class_name": "QOpenGLDebugMessage.Type", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Severities", + "enum_class": "Severity", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "TypeFlags", + "enum_class": "TypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "LocateOptions", + "enum_class": "LocateOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "PolicyFlags", + "enum_class": "PolicyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\access\\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ColorDialogOptions", + "enum_class": "ColorDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)", + "src\\widgets\\dialogs\\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "FontDialogOptions", + "enum_class": "FontDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)", + "src\\widgets\\dialogs\\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ComponentFormattingOptions", + "enum_class": "ComponentFormattingOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "FormattingOptions", + "enum_class": "UrlFormattingOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "UserInputResolutionOptions", + "enum_class": "UserInputResolutionOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "StateFlags", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\bearer\\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "UsagePolicies", + "enum_class": "UsagePolicy", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\bearer\\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "PaintEngineFeatures", + "enum_class": "PaintEngineFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "DirtyFlags", + "enum_class": "DirtyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Capabilities", + "enum_class": "CapabilityFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Features", + "enum_class": "Feature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature)", + "src\\gui\\text\\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "RenderHints", + "enum_class": "RenderHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "PixmapFragmentHints", + "enum_class": "PixmapFragmentHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "ControlTypes", + "enum_class": "ControlType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\util\\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)", + "src\\widgets\\kernel\\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "GlyphRunFlags", + "enum_class": "GlyphRunFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "LayoutFlags", + "enum_class": "LayoutFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "MarkdownFeatures", + "enum_class": "MarkdownFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "FindFlags", + "enum_class": "FindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "ConversionMode", + "enum_class": "ConversionModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\kernel\\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "BindMode", + "enum_class": "BindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "PauseModes", + "enum_class": "PauseMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "PageBreakFlags", + "enum_class": "PageBreakFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "SocketOptions", + "enum_class": "SocketOption", + "human_hint_qflag_full_class_name": "QLocalServer.SocketOptions", + "human_hint_enum_full_class_name": "QLocalServer.SocketOption", + "grep_line": [ + "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "InterfaceFlags", + "enum_class": "InterfaceFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\kernel\\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "SslOptions", + "enum_class": "SslOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\ssl\\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "Base64Options", + "enum_class": "Base64Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "NumberOptions", + "enum_class": "NumberOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "DataSizeFormats", + "enum_class": "DataSizeFormat", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Sections", + "enum_class": "Section", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\time\\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section)", + "src\\widgets\\widgets\\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "PatternOptions", + "enum_class": "PatternOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MatchOptions", + "enum_class": "MatchOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "NumberFlags", + "enum_class": "NumberFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\serialization\\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "BoundaryReasons", + "enum_class": "BoundaryReason", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "PrintDialogOptions", + "enum_class": "PrintDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\printsupport\\dialogs\\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPrintSupport", + "module_path": "../../PyQt5-stubs/QtPrintSupport.pyi" + }, + { + "qflag_class": "ParamType", + "enum_class": "ParamTypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\sql\\kernel\\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSql", + "module_path": "../../PyQt5-stubs/QtSql.pyi" + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 3, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 3, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 3, + "module_idx": 2, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "BlurHints", + "enum_class": "BlurHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "InputDialogOptions", + "enum_class": "InputDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "WizardOptions", + "enum_class": "WizardOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "EditTriggers", + "enum_class": "EditTrigger", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\itemviews\\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "GraphicsItemFlags", + "enum_class": "GraphicsItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Result", + "enum_class": "ResultFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\kernel\\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "SceneLayers", + "enum_class": "SceneLayer", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "CacheMode", + "enum_class": "CacheModeFlag", + "human_hint_qflag_full_class_name": "QGraphicsView.CacheMode", + "human_hint_enum_full_class_name": "QGraphicsView.CacheModeFlag", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "OptimizationFlags", + "enum_class": "OptimizationFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "State", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "SubControls", + "enum_class": "SubControl", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "StepEnabled", + "enum_class": "StepEnabledFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "FrameFeatures", + "enum_class": "FrameFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ButtonFeatures", + "enum_class": "ButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "CornerWidgets", + "enum_class": "CornerWidget", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "TabFeatures", + "enum_class": "TabFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ToolBarFeatures", + "enum_class": "ToolBarFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ViewItemFeatures", + "enum_class": "ViewItemFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ToolButtonFeatures", + "enum_class": "ToolButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "DockWidgetFeatures", + "enum_class": "DockWidgetFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "FontFilters", + "enum_class": "FontFilter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "AreaOptions", + "enum_class": "AreaOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "SubWindowOptions", + "enum_class": "SubWindowOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "DockOptions", + "enum_class": "DockOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "AutoFormatting", + "enum_class": "AutoFormattingFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + } + ], + "qflags_to_skip": [] +} \ No newline at end of file From 92753d3a5ae5b688eb2aaa6d06011365dfc0d7d7 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 17:55:47 +0100 Subject: [PATCH 243/421] Update develop requirements to match production requirements --- requirements/develop.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/develop.txt b/requirements/develop.txt index b12fe1ef..762963b8 100644 --- a/requirements/develop.txt +++ b/requirements/develop.txt @@ -20,7 +20,7 @@ py==1.10.0 # via pytest pyparsing==2.4.7 # via packaging -pyqt5==5.14.2 +pyqt5==5.15.4 # via -r requirements/production.txt pyqt5-sip==12.9.0 # via From 9b4da9583986a89f01ea39f83f96cbeb08641bd5 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 18:11:44 +0100 Subject: [PATCH 244/421] Add specific stub ignores for windows --- stubtest.allowlist.windows | 34 ++++++++++++++++++++++++++++++++++ tox.ini | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 stubtest.allowlist.windows diff --git a/stubtest.allowlist.windows b/stubtest.allowlist.windows new file mode 100644 index 00000000..f00f0569 --- /dev/null +++ b/stubtest.allowlist.windows @@ -0,0 +1,34 @@ +PyQt5.QtCore.QSysInfo.WV_10_0 +PyQt5.QtCore.QSysInfo.WV_2000 +PyQt5.QtCore.QSysInfo.WV_2003 +PyQt5.QtCore.QSysInfo.WV_32s +PyQt5.QtCore.QSysInfo.WV_4_0 +PyQt5.QtCore.QSysInfo.WV_5_0 +PyQt5.QtCore.QSysInfo.WV_5_1 +PyQt5.QtCore.QSysInfo.WV_5_2 +PyQt5.QtCore.QSysInfo.WV_6_0 +PyQt5.QtCore.QSysInfo.WV_6_1 +PyQt5.QtCore.QSysInfo.WV_6_2 +PyQt5.QtCore.QSysInfo.WV_6_3 +PyQt5.QtCore.QSysInfo.WV_95 +PyQt5.QtCore.QSysInfo.WV_98 +PyQt5.QtCore.QSysInfo.WV_CE +PyQt5.QtCore.QSysInfo.WV_CENET +PyQt5.QtCore.QSysInfo.WV_CE_5 +PyQt5.QtCore.QSysInfo.WV_CE_6 +PyQt5.QtCore.QSysInfo.WV_CE_based +PyQt5.QtCore.QSysInfo.WV_DOS_based +PyQt5.QtCore.QSysInfo.WV_Me +PyQt5.QtCore.QSysInfo.WV_NT +PyQt5.QtCore.QSysInfo.WV_NT_based +PyQt5.QtCore.QSysInfo.WV_VISTA +PyQt5.QtCore.QSysInfo.WV_WINDOWS10 +PyQt5.QtCore.QSysInfo.WV_WINDOWS7 +PyQt5.QtCore.QSysInfo.WV_WINDOWS8 +PyQt5.QtCore.QSysInfo.WV_WINDOWS8_1 +PyQt5.QtCore.QSysInfo.WV_XP +PyQt5.QtCore.QSysInfo.WinVersion +PyQt5.QtCore.QSysInfo.WindowsVersion +PyQt5.QtCore.QSysInfo.windowsVersion +PyQt5.QtCore.QWinEventNotifier + diff --git a/tox.ini b/tox.ini index 12680fec..f8c6473f 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ deps = commands = pip install PyQt5==5.15.* PyQt3D==5.15.* PyQtChart==5.15.* PyQtDataVisualization==5.15.* PyQtNetworkAuth==5.15.* PyQtPurchasing==5.15.* PyQtWebEngine==5.15.* mypy --show-error-codes -p PyQt5-stubs - stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review PyQt5 + stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review --allowlist {toxinidir}/stubtest.allowlist.windows PyQt5 pytest --capture=no --verbose {posargs} [pytest] From 2c93c76a091a2763b0e346812c70b183a93eb842 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 18:15:43 +0100 Subject: [PATCH 245/421] RUN ci for this branch --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82066101..9fb26648 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - run-ci-on-windows tags: - v* pull_request: From 9ce8bc2be9d8dff57d47b5e2856f268102ea9ead Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 18:25:37 +0100 Subject: [PATCH 246/421] More official stuff to ignore on windows --- stubtest.allowlist.windows | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stubtest.allowlist.windows b/stubtest.allowlist.windows index f00f0569..1401731d 100644 --- a/stubtest.allowlist.windows +++ b/stubtest.allowlist.windows @@ -31,4 +31,7 @@ PyQt5.QtCore.QSysInfo.WinVersion PyQt5.QtCore.QSysInfo.WindowsVersion PyQt5.QtCore.QSysInfo.windowsVersion PyQt5.QtCore.QWinEventNotifier +PyQt5.QtCore.QAbstractEventDispatcher.registerEventNotifier +PyQt5.QtCore.QAbstractEventDispatcher.unregisterEventNotifier + From b766e45ad9ba1e94548fdc17f1d011092af6aa15 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 18:25:53 +0100 Subject: [PATCH 247/421] do not complain about unused allowlist --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index f8c6473f..55d96594 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ deps = commands = pip install PyQt5==5.15.* PyQt3D==5.15.* PyQtChart==5.15.* PyQtDataVisualization==5.15.* PyQtNetworkAuth==5.15.* PyQtPurchasing==5.15.* PyQtWebEngine==5.15.* mypy --show-error-codes -p PyQt5-stubs - stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review --allowlist {toxinidir}/stubtest.allowlist.windows PyQt5 + stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review --allowlist {toxinidir}/stubtest.allowlist.windows --ignore-unused-allowlist PyQt5 pytest --capture=no --verbose {posargs} [pytest] From 5aa0d145e1ba3a2651393cec1d2786fed3432046 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 18:29:50 +0100 Subject: [PATCH 248/421] Ingore QtX11Extras on windows --- stubtest.allowlist.windows | 1 + 1 file changed, 1 insertion(+) diff --git a/stubtest.allowlist.windows b/stubtest.allowlist.windows index 1401731d..d61c360b 100644 --- a/stubtest.allowlist.windows +++ b/stubtest.allowlist.windows @@ -34,4 +34,5 @@ PyQt5.QtCore.QWinEventNotifier PyQt5.QtCore.QAbstractEventDispatcher.registerEventNotifier PyQt5.QtCore.QAbstractEventDispatcher.unregisterEventNotifier +PyQt5.QtX11Extras From 68972d10baf7f58b11038eec57b641c2c4f89434 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 18:36:04 +0100 Subject: [PATCH 249/421] Pass the name of the OS to tox and to stubtest invocation --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 55d96594..6c53f422 100644 --- a/tox.ini +++ b/tox.ini @@ -5,10 +5,11 @@ envlist = py3{5,6,7,8,9} deps = -r requirements/develop.txt pip>=20.0 +passenv = RUNNER_OS commands = pip install PyQt5==5.15.* PyQt3D==5.15.* PyQtChart==5.15.* PyQtDataVisualization==5.15.* PyQtNetworkAuth==5.15.* PyQtPurchasing==5.15.* PyQtWebEngine==5.15.* mypy --show-error-codes -p PyQt5-stubs - stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review --allowlist {toxinidir}/stubtest.allowlist.windows --ignore-unused-allowlist PyQt5 + stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review --allowlist {toxinidir}/stubtest.allowlist.{env:RUNNER_OS:} --ignore-unused-allowlist PyQt5 pytest --capture=no --verbose {posargs} [pytest] From ebc5c126c60cc465c1419de1d30c7d3368200492 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 21:03:24 +0100 Subject: [PATCH 250/421] Add per os allowlist --- stubtest.allowlist.Linux | 0 stubtest.allowlist.windows => stubtest.allowlist.Windows | 0 tox.ini | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 stubtest.allowlist.Linux rename stubtest.allowlist.windows => stubtest.allowlist.Windows (100%) diff --git a/stubtest.allowlist.Linux b/stubtest.allowlist.Linux new file mode 100644 index 00000000..e69de29b diff --git a/stubtest.allowlist.windows b/stubtest.allowlist.Windows similarity index 100% rename from stubtest.allowlist.windows rename to stubtest.allowlist.Windows diff --git a/tox.ini b/tox.ini index 6c53f422..b3334f7a 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ passenv = RUNNER_OS commands = pip install PyQt5==5.15.* PyQt3D==5.15.* PyQtChart==5.15.* PyQtDataVisualization==5.15.* PyQtNetworkAuth==5.15.* PyQtPurchasing==5.15.* PyQtWebEngine==5.15.* mypy --show-error-codes -p PyQt5-stubs - stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review --allowlist {toxinidir}/stubtest.allowlist.{env:RUNNER_OS:} --ignore-unused-allowlist PyQt5 + stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review --allowlist {toxinidir}/stubtest.allowlist.{env:RUNNER_OS:} PyQt5 pytest --capture=no --verbose {posargs} [pytest] From 7f844cb0e4a8e06215d103f9c9c8c0c4471c1310 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 21:22:16 +0100 Subject: [PATCH 251/421] Better Windows allowlist --- stubtest.allowlist.Windows | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stubtest.allowlist.Windows b/stubtest.allowlist.Windows index d61c360b..23c85e23 100644 --- a/stubtest.allowlist.Windows +++ b/stubtest.allowlist.Windows @@ -1,3 +1,4 @@ +# stubs which are Windows specific, missing from the stub definition and to be added PyQt5.QtCore.QSysInfo.WV_10_0 PyQt5.QtCore.QSysInfo.WV_2000 PyQt5.QtCore.QSysInfo.WV_2003 @@ -34,5 +35,9 @@ PyQt5.QtCore.QWinEventNotifier PyQt5.QtCore.QAbstractEventDispatcher.registerEventNotifier PyQt5.QtCore.QAbstractEventDispatcher.unregisterEventNotifier +# Stubs which are missing because not supported on Windows PyQt5.QtX11Extras +PyQt5.QtPrintSupport.QPrinter.printerSelectionOption +PyQt5.QtPrintSupport.QPrinter.setPrinterSelectionOption + From 7ae34290fc7a79f74255c404d08ffc2a4c710b4d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 21:45:41 +0100 Subject: [PATCH 252/421] Trigger CI to detect status of QtNetworkAuth implementation --- stubtest.allowlist.Windows | 6 +++++- tox.ini | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/stubtest.allowlist.Windows b/stubtest.allowlist.Windows index 23c85e23..1dcb0c65 100644 --- a/stubtest.allowlist.Windows +++ b/stubtest.allowlist.Windows @@ -40,4 +40,8 @@ PyQt5.QtX11Extras PyQt5.QtPrintSupport.QPrinter.printerSelectionOption PyQt5.QtPrintSupport.QPrinter.setPrinterSelectionOption - +# stubs missing because of pyqt5 bugs +PyQt5.QtNetworkAuth.QAbstractOAuth.callback +PyQt5.QtNetworkAuth.QAbstractOAuth.generateRandomString +PyQt5.QtNetworkAuth.QAbstractOAuth.resourceOwnerAuthorization +PyQt5.QtNetworkAuth.QAbstractOAuth.setStatus diff --git a/tox.ini b/tox.ini index b3334f7a..e8f80343 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,7 @@ passenv = RUNNER_OS commands = pip install PyQt5==5.15.* PyQt3D==5.15.* PyQtChart==5.15.* PyQtDataVisualization==5.15.* PyQtNetworkAuth==5.15.* PyQtPurchasing==5.15.* PyQtWebEngine==5.15.* mypy --show-error-codes -p PyQt5-stubs + python -c "from PyQt5 import QtNetworkAuth; print(dir(QtNetworkAuth.QAbstractOAuth))" stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review --allowlist {toxinidir}/stubtest.allowlist.{env:RUNNER_OS:} PyQt5 pytest --capture=no --verbose {posargs} From 86bb122873173d7152b41b4edf36bdf2f5f81346 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 21:57:20 +0100 Subject: [PATCH 253/421] Ignore properly all missing implementation on Windows --- stubtest.allowlist.Windows | 10 ++++++++-- tox.ini | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/stubtest.allowlist.Windows b/stubtest.allowlist.Windows index 1dcb0c65..92258111 100644 --- a/stubtest.allowlist.Windows +++ b/stubtest.allowlist.Windows @@ -37,11 +37,17 @@ PyQt5.QtCore.QAbstractEventDispatcher.unregisterEventNotifier # Stubs which are missing because not supported on Windows PyQt5.QtX11Extras -PyQt5.QtPrintSupport.QPrinter.printerSelectionOption -PyQt5.QtPrintSupport.QPrinter.setPrinterSelectionOption # stubs missing because of pyqt5 bugs +PyQt5.QtPrintSupport.QPrinter.printerSelectionOption +PyQt5.QtPrintSupport.QPrinter.setPrinterSelectionOption PyQt5.QtNetworkAuth.QAbstractOAuth.callback PyQt5.QtNetworkAuth.QAbstractOAuth.generateRandomString PyQt5.QtNetworkAuth.QAbstractOAuth.resourceOwnerAuthorization PyQt5.QtNetworkAuth.QAbstractOAuth.setStatus +PyQt5.QtGui.QPaintDeviceWindow.paintEvent +PyQt5.Qt3DAnimation.QAbstractAnimation.setDuration +PyQt5.Qt3DExtras.QAbstractCameraController.keyboardDevice +PyQt5.Qt3DExtras.QAbstractCameraController.mouseDevice +PyQt5.Qt3DRender.QAbstractTextureImage.dataGenerator +PyQt5.Qt3DRender.QAbstractTextureImage.notifyDataGeneratorChanged diff --git a/tox.ini b/tox.ini index e8f80343..b3334f7a 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,6 @@ passenv = RUNNER_OS commands = pip install PyQt5==5.15.* PyQt3D==5.15.* PyQtChart==5.15.* PyQtDataVisualization==5.15.* PyQtNetworkAuth==5.15.* PyQtPurchasing==5.15.* PyQtWebEngine==5.15.* mypy --show-error-codes -p PyQt5-stubs - python -c "from PyQt5 import QtNetworkAuth; print(dir(QtNetworkAuth.QAbstractOAuth))" stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review --allowlist {toxinidir}/stubtest.allowlist.{env:RUNNER_OS:} PyQt5 pytest --capture=no --verbose {posargs} From 025c0e5767b15811952ac55bfb53c68944ad4292 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 22:03:28 +0100 Subject: [PATCH 254/421] See if we can define conditional stubs --- PyQt5-stubs/QtPrintSupport.pyi | 6 +++++- stubtest.allowlist.Windows | 2 -- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/PyQt5-stubs/QtPrintSupport.pyi b/PyQt5-stubs/QtPrintSupport.pyi index c49a0efa..0e0b25c8 100644 --- a/PyQt5-stubs/QtPrintSupport.pyi +++ b/PyQt5-stubs/QtPrintSupport.pyi @@ -21,6 +21,7 @@ import typing +import platform from PyQt5 import sip @@ -380,7 +381,10 @@ class QPrinter(QtGui.QPagedPaintDevice): def printerState(self) -> 'QPrinter.PrinterState': ... def abort(self) -> bool: ... def newPage(self) -> bool: ... - def setPrinterSelectionOption(self, a0: str) -> None: ... + + if platform.system() != 'Windows': + def setPrinterSelectionOption(self, a0: str) -> None: ... + def printerSelectionOption(self) -> str: ... @typing.overload def pageRect(self) -> QtCore.QRect: ... diff --git a/stubtest.allowlist.Windows b/stubtest.allowlist.Windows index 92258111..97d9c217 100644 --- a/stubtest.allowlist.Windows +++ b/stubtest.allowlist.Windows @@ -39,8 +39,6 @@ PyQt5.QtCore.QAbstractEventDispatcher.unregisterEventNotifier PyQt5.QtX11Extras # stubs missing because of pyqt5 bugs -PyQt5.QtPrintSupport.QPrinter.printerSelectionOption -PyQt5.QtPrintSupport.QPrinter.setPrinterSelectionOption PyQt5.QtNetworkAuth.QAbstractOAuth.callback PyQt5.QtNetworkAuth.QAbstractOAuth.generateRandomString PyQt5.QtNetworkAuth.QAbstractOAuth.resourceOwnerAuthorization From 9dff9394336bd6abed8fc5c9cfa76d415d048bb5 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 22:22:57 +0100 Subject: [PATCH 255/421] Revert "See if we can define conditional stubs" This reverts commit 025c0e5767b15811952ac55bfb53c68944ad4292. --- PyQt5-stubs/QtPrintSupport.pyi | 6 +----- stubtest.allowlist.Windows | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/PyQt5-stubs/QtPrintSupport.pyi b/PyQt5-stubs/QtPrintSupport.pyi index 0e0b25c8..c49a0efa 100644 --- a/PyQt5-stubs/QtPrintSupport.pyi +++ b/PyQt5-stubs/QtPrintSupport.pyi @@ -21,7 +21,6 @@ import typing -import platform from PyQt5 import sip @@ -381,10 +380,7 @@ class QPrinter(QtGui.QPagedPaintDevice): def printerState(self) -> 'QPrinter.PrinterState': ... def abort(self) -> bool: ... def newPage(self) -> bool: ... - - if platform.system() != 'Windows': - def setPrinterSelectionOption(self, a0: str) -> None: ... - + def setPrinterSelectionOption(self, a0: str) -> None: ... def printerSelectionOption(self) -> str: ... @typing.overload def pageRect(self) -> QtCore.QRect: ... diff --git a/stubtest.allowlist.Windows b/stubtest.allowlist.Windows index 97d9c217..92258111 100644 --- a/stubtest.allowlist.Windows +++ b/stubtest.allowlist.Windows @@ -39,6 +39,8 @@ PyQt5.QtCore.QAbstractEventDispatcher.unregisterEventNotifier PyQt5.QtX11Extras # stubs missing because of pyqt5 bugs +PyQt5.QtPrintSupport.QPrinter.printerSelectionOption +PyQt5.QtPrintSupport.QPrinter.setPrinterSelectionOption PyQt5.QtNetworkAuth.QAbstractOAuth.callback PyQt5.QtNetworkAuth.QAbstractOAuth.generateRandomString PyQt5.QtNetworkAuth.QAbstractOAuth.resourceOwnerAuthorization From 8269c9e1aab643825e1833bce5df0d263da77340 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 22:23:35 +0100 Subject: [PATCH 256/421] Enhance stub coverage on Windows --- PyQt5-stubs/QtCore.pyi | 65 ++++++++++++++++++++++++++++++++++++++ stubtest.allowlist.Linux | 33 +++++++++++++++++++ stubtest.allowlist.Windows | 32 ------------------- 3 files changed, 98 insertions(+), 32 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index e430ea9a..e5fb4a9b 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -12297,6 +12297,67 @@ class QSysInfo(sip.simplewrapper): WordSize = ... # type: QSysInfo.Sizes + class WinVersion(int): + WV_10_0 = ... # type: int + WV_2000 = ... # type: int + WV_2003 = ... # type: int + WV_32s = ... # type: int + WV_4_0 = ... # type: int + WV_5_0 = ... # type: int + WV_5_1 = ... # type: int + WV_5_2 = ... # type: int + WV_6_0 = ... # type: int + WV_6_1 = ... # type: int + WV_6_2 = ... # type: int + WV_6_3 = ... # type: int + WV_95 = ... # type: int + WV_98 = ... # type: int + WV_CE = ... # type: int + WV_CENET = ... # type: int + WV_CE_5 = ... # type: int + WV_CE_6 = ... # type: int + WV_CE_based = ... # type: int + WV_DOS_based = ... # type: int + WV_Me = ... # type: int + WV_NT = ... # type: int + WV_NT_based = ... # type: int + WV_VISTA = ... # type: int + WV_WINDOWS10 = ... # type: int + WV_WINDOWS7 = ... # type: int + WV_WINDOWS8 = ... # type: int + WV_WINDOWS8_1 = ... # type: int + WV_XP = ... # type: int + + WV_10_0 = ... # type: int + WV_2000 = ... # type: int + WV_2003 = ... # type: int + WV_32s = ... # type: int + WV_4_0 = ... # type: int + WV_5_0 = ... # type: int + WV_5_1 = ... # type: int + WV_5_2 = ... # type: int + WV_6_0 = ... # type: int + WV_6_1 = ... # type: int + WV_6_2 = ... # type: int + WV_6_3 = ... # type: int + WV_95 = ... # type: int + WV_98 = ... # type: int + WV_CE = ... # type: int + WV_CENET = ... # type: int + WV_CE_5 = ... # type: int + WV_CE_6 = ... # type: int + WV_CE_based = ... # type: int + WV_DOS_based = ... # type: int + WV_Me = ... # type: int + WV_NT = ... # type: int + WV_NT_based = ... # type: int + WV_VISTA = ... # type: int + WV_WINDOWS10 = ... # type: int + WV_WINDOWS7 = ... # type: int + WV_WINDOWS8 = ... # type: int + WV_WINDOWS8_1 = ... # type: int + WV_XP = ... # type: int + @typing.overload def __init__(self) -> None: ... @typing.overload @@ -12320,6 +12381,10 @@ class QSysInfo(sip.simplewrapper): def buildCpuArchitecture() -> str: ... @staticmethod def buildAbi() -> str: ... + @staticmethod + def windowsVersion() -> 'QSysInfo.WinVersion': ... + + WindowsVersion = ... # type: QSysInfo.WinVersion PYQT_VERSION = ... # type: int diff --git a/stubtest.allowlist.Linux b/stubtest.allowlist.Linux index e69de29b..e0d00268 100644 --- a/stubtest.allowlist.Linux +++ b/stubtest.allowlist.Linux @@ -0,0 +1,33 @@ +# implementation present only on Windows +PyQt5.QtCore.QSysInfo.WV_10_0 +PyQt5.QtCore.QSysInfo.WV_2000 +PyQt5.QtCore.QSysInfo.WV_2003 +PyQt5.QtCore.QSysInfo.WV_32s +PyQt5.QtCore.QSysInfo.WV_4_0 +PyQt5.QtCore.QSysInfo.WV_5_0 +PyQt5.QtCore.QSysInfo.WV_5_1 +PyQt5.QtCore.QSysInfo.WV_5_2 +PyQt5.QtCore.QSysInfo.WV_6_0 +PyQt5.QtCore.QSysInfo.WV_6_1 +PyQt5.QtCore.QSysInfo.WV_6_2 +PyQt5.QtCore.QSysInfo.WV_6_3 +PyQt5.QtCore.QSysInfo.WV_95 +PyQt5.QtCore.QSysInfo.WV_98 +PyQt5.QtCore.QSysInfo.WV_CE +PyQt5.QtCore.QSysInfo.WV_CENET +PyQt5.QtCore.QSysInfo.WV_CE_5 +PyQt5.QtCore.QSysInfo.WV_CE_6 +PyQt5.QtCore.QSysInfo.WV_CE_based +PyQt5.QtCore.QSysInfo.WV_DOS_based +PyQt5.QtCore.QSysInfo.WV_Me +PyQt5.QtCore.QSysInfo.WV_NT +PyQt5.QtCore.QSysInfo.WV_NT_based +PyQt5.QtCore.QSysInfo.WV_VISTA +PyQt5.QtCore.QSysInfo.WV_WINDOWS10 +PyQt5.QtCore.QSysInfo.WV_WINDOWS7 +PyQt5.QtCore.QSysInfo.WV_WINDOWS8 +PyQt5.QtCore.QSysInfo.WV_WINDOWS8_1 +PyQt5.QtCore.QSysInfo.WV_XP +PyQt5.QtCore.QSysInfo.WinVersion +PyQt5.QtCore.QSysInfo.WindowsVersion +PyQt5.QtCore.QSysInfo.windowsVersion diff --git a/stubtest.allowlist.Windows b/stubtest.allowlist.Windows index 92258111..44191d3d 100644 --- a/stubtest.allowlist.Windows +++ b/stubtest.allowlist.Windows @@ -1,36 +1,4 @@ # stubs which are Windows specific, missing from the stub definition and to be added -PyQt5.QtCore.QSysInfo.WV_10_0 -PyQt5.QtCore.QSysInfo.WV_2000 -PyQt5.QtCore.QSysInfo.WV_2003 -PyQt5.QtCore.QSysInfo.WV_32s -PyQt5.QtCore.QSysInfo.WV_4_0 -PyQt5.QtCore.QSysInfo.WV_5_0 -PyQt5.QtCore.QSysInfo.WV_5_1 -PyQt5.QtCore.QSysInfo.WV_5_2 -PyQt5.QtCore.QSysInfo.WV_6_0 -PyQt5.QtCore.QSysInfo.WV_6_1 -PyQt5.QtCore.QSysInfo.WV_6_2 -PyQt5.QtCore.QSysInfo.WV_6_3 -PyQt5.QtCore.QSysInfo.WV_95 -PyQt5.QtCore.QSysInfo.WV_98 -PyQt5.QtCore.QSysInfo.WV_CE -PyQt5.QtCore.QSysInfo.WV_CENET -PyQt5.QtCore.QSysInfo.WV_CE_5 -PyQt5.QtCore.QSysInfo.WV_CE_6 -PyQt5.QtCore.QSysInfo.WV_CE_based -PyQt5.QtCore.QSysInfo.WV_DOS_based -PyQt5.QtCore.QSysInfo.WV_Me -PyQt5.QtCore.QSysInfo.WV_NT -PyQt5.QtCore.QSysInfo.WV_NT_based -PyQt5.QtCore.QSysInfo.WV_VISTA -PyQt5.QtCore.QSysInfo.WV_WINDOWS10 -PyQt5.QtCore.QSysInfo.WV_WINDOWS7 -PyQt5.QtCore.QSysInfo.WV_WINDOWS8 -PyQt5.QtCore.QSysInfo.WV_WINDOWS8_1 -PyQt5.QtCore.QSysInfo.WV_XP -PyQt5.QtCore.QSysInfo.WinVersion -PyQt5.QtCore.QSysInfo.WindowsVersion -PyQt5.QtCore.QSysInfo.windowsVersion PyQt5.QtCore.QWinEventNotifier PyQt5.QtCore.QAbstractEventDispatcher.registerEventNotifier PyQt5.QtCore.QAbstractEventDispatcher.unregisterEventNotifier From 574a334fa6a96342bb7fd1368102d26b3e07eb41 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 22:30:05 +0100 Subject: [PATCH 257/421] Remove non needed allowlist --- stubtest.allowlist.Linux | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/stubtest.allowlist.Linux b/stubtest.allowlist.Linux index e0d00268..e69de29b 100644 --- a/stubtest.allowlist.Linux +++ b/stubtest.allowlist.Linux @@ -1,33 +0,0 @@ -# implementation present only on Windows -PyQt5.QtCore.QSysInfo.WV_10_0 -PyQt5.QtCore.QSysInfo.WV_2000 -PyQt5.QtCore.QSysInfo.WV_2003 -PyQt5.QtCore.QSysInfo.WV_32s -PyQt5.QtCore.QSysInfo.WV_4_0 -PyQt5.QtCore.QSysInfo.WV_5_0 -PyQt5.QtCore.QSysInfo.WV_5_1 -PyQt5.QtCore.QSysInfo.WV_5_2 -PyQt5.QtCore.QSysInfo.WV_6_0 -PyQt5.QtCore.QSysInfo.WV_6_1 -PyQt5.QtCore.QSysInfo.WV_6_2 -PyQt5.QtCore.QSysInfo.WV_6_3 -PyQt5.QtCore.QSysInfo.WV_95 -PyQt5.QtCore.QSysInfo.WV_98 -PyQt5.QtCore.QSysInfo.WV_CE -PyQt5.QtCore.QSysInfo.WV_CENET -PyQt5.QtCore.QSysInfo.WV_CE_5 -PyQt5.QtCore.QSysInfo.WV_CE_6 -PyQt5.QtCore.QSysInfo.WV_CE_based -PyQt5.QtCore.QSysInfo.WV_DOS_based -PyQt5.QtCore.QSysInfo.WV_Me -PyQt5.QtCore.QSysInfo.WV_NT -PyQt5.QtCore.QSysInfo.WV_NT_based -PyQt5.QtCore.QSysInfo.WV_VISTA -PyQt5.QtCore.QSysInfo.WV_WINDOWS10 -PyQt5.QtCore.QSysInfo.WV_WINDOWS7 -PyQt5.QtCore.QSysInfo.WV_WINDOWS8 -PyQt5.QtCore.QSysInfo.WV_WINDOWS8_1 -PyQt5.QtCore.QSysInfo.WV_XP -PyQt5.QtCore.QSysInfo.WinVersion -PyQt5.QtCore.QSysInfo.WindowsVersion -PyQt5.QtCore.QSysInfo.windowsVersion From c85a0f132f18cda6ce421f6e1ba3914b644cfd6a Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 15 Nov 2021 22:33:42 +0100 Subject: [PATCH 258/421] Fix CI on Linux --- stubtest.allowlist.Linux | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stubtest.allowlist.Linux b/stubtest.allowlist.Linux index e69de29b..1eadaceb 100644 --- a/stubtest.allowlist.Linux +++ b/stubtest.allowlist.Linux @@ -0,0 +1,3 @@ +# implementation present only on Windows +PyQt5.QtCore.QSysInfo.WinVersion +PyQt5.QtCore.QSysInfo.windowsVersion From be29e4ae0199f0dcdc372b0653cb27ab1fc3c384 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 16 Nov 2021 13:45:37 +0100 Subject: [PATCH 259/421] Add support for Python 3.10 on Windows and Linux + enable 3.6 on Windows --- .github/workflows/ci.yml | 20 +++++++++++++++----- tox.ini | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9fb26648..926e4984 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,14 +34,24 @@ jobs: - name: CPython 3.9 tox: py39 action: 3.9 + - name: CPython 3.10 + tox: py310 + action: 3.10 include: - - os: + - os: + name: Windows + runs-on: windows-latest + python: + name: CPython 3.6 + tox: py36 + action: 3.6 + - os: name: Windows runs-on: windows-latest - python: - name: CPython 3.9 - tox: py39 - action: 3.9 + python: + name: CPython 3.10 + tox: py310 + action: 3.10 steps: - uses: actions/checkout@v2 - name: Set up ${{ matrix.python.name }} diff --git a/tox.ini b/tox.ini index b3334f7a..c97b4907 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3{5,6,7,8,9} +envlist = py3{6,7,8,9,10} [testenv] deps = From 156f45c8e7c3b9a5407d99cd16432e9063612176 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 16 Nov 2021 13:51:44 +0100 Subject: [PATCH 260/421] Attempt fix for Python 3.10 handling by actions --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 926e4984..b4c34a36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: action: 3.9 - name: CPython 3.10 tox: py310 - action: 3.10 + action: '3.10' include: - os: name: Windows @@ -51,7 +51,7 @@ jobs: python: name: CPython 3.10 tox: py310 - action: 3.10 + action: '3.10' steps: - uses: actions/checkout@v2 - name: Set up ${{ matrix.python.name }} From d854f7c0d7df06556dbaf7eda1f9c107859bf134 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 16 Nov 2021 13:57:32 +0100 Subject: [PATCH 261/421] Stick with Python 3.9 on Windows because it works --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4c34a36..34177b50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,9 +49,9 @@ jobs: name: Windows runs-on: windows-latest python: - name: CPython 3.10 - tox: py310 - action: '3.10' + name: CPython 3.9 + tox: py39 + action: '3.9' steps: - uses: actions/checkout@v2 - name: Set up ${{ matrix.python.name }} From b45b3c669749c12a121f1768a80a3befc2e7e0c0 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 17 Nov 2021 10:13:14 +0100 Subject: [PATCH 262/421] Add all grep results --- .../grep-results/qt3d-qflag-grep-result.txt | 8 + .../qtactiveqt-qflag-grep-result.txt | 0 .../qtandroidextras-qflag-grep-result.txt | 1 + .../qtbase-qflag-grep-result.txt | 0 .../qtcanvas3d-qflag-grep-result.txt | 0 .../qtcharts-qflag-grep-result.txt | 4 + .../qtconnectivity-qflag-grep-result.txt | 12 + .../qtdatavis3d-qflag-grep-result.txt | 6 + .../qtdeclarative-qflag-grep-result.txt | 52 + .../grep-results/qtdoc-qflag-grep-result.txt | 0 .../qtdocgallery-qflag-grep-result.txt | 0 .../qtfeedback-qflag-grep-result.txt | 0 .../qtgamepad-qflag-grep-result.txt | 2 + .../qtgraphicaleffects-qflag-grep-result.txt | 0 .../qtimageformats-qflag-grep-result.txt | 0 .../qtlocation-qflag-grep-result.txt | 35 + .../qtlottie-qflag-grep-result.txt | 0 .../qtmacextras-qflag-grep-result.txt | 0 .../qtmultimedia-qflag-grep-result.txt | 11 + .../qtnetworkauth-qflag-grep-result.txt | 0 .../grep-results/qtpim-qflag-grep-result.txt | 0 .../qtpurchasing-qflag-grep-result.txt | 0 .../grep-results/qtqa-qflag-grep-result.txt | 0 .../qtquick3d-qflag-grep-result.txt | 22 + .../qtquickcontrols-qflag-grep-result.txt | 1 + .../qtquickcontrols2-qflag-grep-result.txt | 2 + .../qtquicktimeline-qflag-grep-result.txt | 0 .../qtremoteobjects-qflag-grep-result.txt | 0 .../qtrepotools-qflag-grep-result.txt | 0 .../qtscript-qflag-grep-result.txt | 4 + .../qtscxml-qflag-grep-result.txt | 0 .../qtsensors-qflag-grep-result.txt | 0 .../qtserialbus-qflag-grep-result.txt | 6 + .../qtserialport-qflag-grep-result.txt | 2 + .../qtspeech-qflag-grep-result.txt | 0 .../grep-results/qtsvg-qflag-grep-result.txt | 0 .../qtsystems-qflag-grep-result.txt | 0 tests/qflags/qt-qflag-grep-result.txt | 227 -- .../qtbase-qflags_modules_analysis.json | 2192 ++++++++++++++ .../qflags/qtbase-qflags_process_result.json | 2573 +++++++++++++++++ 40 files changed, 4933 insertions(+), 227 deletions(-) create mode 100644 tests/qflags/grep-results/qt3d-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtactiveqt-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtandroidextras-qflag-grep-result.txt rename tests/qflags/{ => grep-results}/qtbase-qflag-grep-result.txt (100%) create mode 100644 tests/qflags/grep-results/qtcanvas3d-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtcharts-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtconnectivity-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtdatavis3d-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtdeclarative-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtdoc-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtdocgallery-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtfeedback-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtgamepad-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtgraphicaleffects-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtimageformats-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtlocation-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtlottie-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtmacextras-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtmultimedia-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtnetworkauth-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtpim-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtpurchasing-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtqa-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtquick3d-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtquickcontrols-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtquickcontrols2-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtquicktimeline-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtremoteobjects-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtrepotools-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtscript-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtscxml-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtsensors-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtserialbus-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtserialport-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtspeech-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtsvg-qflag-grep-result.txt create mode 100644 tests/qflags/grep-results/qtsystems-qflag-grep-result.txt delete mode 100644 tests/qflags/qt-qflag-grep-result.txt create mode 100644 tests/qflags/qtbase-qflags_modules_analysis.json create mode 100644 tests/qflags/qtbase-qflags_process_result.json diff --git a/tests/qflags/grep-results/qt3d-qflag-grep-result.txt b/tests/qflags/grep-results/qt3d-qflag-grep-result.txt new file mode 100644 index 00000000..be153459 --- /dev/null +++ b/tests/qflags/grep-results/qt3d-qflag-grep-result.txt @@ -0,0 +1,8 @@ +src\animation\frontend\qanimationcallback.h: Q_DECLARE_FLAGS(Flags, Flag) +src\core\changes\qscenechange.h:Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) +src\core\changes\qscenechange.h: Q_DECLARE_FLAGS(DeliveryFlags, DeliveryFlag) +src\render\backend\abstractrenderer_p.h: Q_DECLARE_FLAGS(BackendNodeDirtySet, BackendNodeDirtyFlag) +src\render\framegraph\qclearbuffers.h: Q_DECLARE_FLAGS(BufferTypeFlags, BufferType) +src\render\framegraph\qmemorybarrier.h: Q_DECLARE_FLAGS(Operations, Operation) +src\render\texture\texture_p.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag) +src\quick3d\imports\scene3d\scene3dview_p.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag) diff --git a/tests/qflags/grep-results/qtactiveqt-qflag-grep-result.txt b/tests/qflags/grep-results/qtactiveqt-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtandroidextras-qflag-grep-result.txt b/tests/qflags/grep-results/qtandroidextras-qflag-grep-result.txt new file mode 100644 index 00000000..6c498bd7 --- /dev/null +++ b/tests/qflags/grep-results/qtandroidextras-qflag-grep-result.txt @@ -0,0 +1 @@ +src\androidextras\android\qandroidfunctions.h: Q_DECLARE_FLAGS(BindFlags, BindFlag) diff --git a/tests/qflags/qtbase-qflag-grep-result.txt b/tests/qflags/grep-results/qtbase-qflag-grep-result.txt similarity index 100% rename from tests/qflags/qtbase-qflag-grep-result.txt rename to tests/qflags/grep-results/qtbase-qflag-grep-result.txt diff --git a/tests/qflags/grep-results/qtcanvas3d-qflag-grep-result.txt b/tests/qflags/grep-results/qtcanvas3d-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtcharts-qflag-grep-result.txt b/tests/qflags/grep-results/qtcharts-qflag-grep-result.txt new file mode 100644 index 00000000..d90b7b22 --- /dev/null +++ b/tests/qflags/grep-results/qtcharts-qflag-grep-result.txt @@ -0,0 +1,4 @@ +src\charts\qchart.h: Q_DECLARE_FLAGS(AnimationOptions, AnimationOption) +src\charts\qchartview.h: Q_DECLARE_FLAGS(RubberBands, RubberBand) +src\charts\qpolarchart.h: Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation) +src\charts\axis\qabstractaxis.h: Q_DECLARE_FLAGS(AxisTypes, AxisType) diff --git a/tests/qflags/grep-results/qtconnectivity-qflag-grep-result.txt b/tests/qflags/grep-results/qtconnectivity-qflag-grep-result.txt new file mode 100644 index 00000000..977ee306 --- /dev/null +++ b/tests/qflags/grep-results/qtconnectivity-qflag-grep-result.txt @@ -0,0 +1,12 @@ +src\bluetooth\qbluetooth.h:Q_DECLARE_FLAGS(SecurityFlags, Security) +src\bluetooth\qbluetooth.h:Q_DECLARE_FLAGS(AttAccessConstraints, AttAccessConstraint) +src\bluetooth\qbluetoothdevicediscoveryagent.h: Q_DECLARE_FLAGS(DiscoveryMethods, DiscoveryMethod) +src\bluetooth\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(ServiceClasses, ServiceClass) +src\bluetooth\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(Fields, Field) +src\bluetooth\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(CoreConfigurations, CoreConfiguration) +src\nfc\qnearfieldmanager.h: Q_DECLARE_FLAGS(TargetAccessModes, TargetAccessMode) +src\nfc\qnearfieldsharemanager.h: Q_DECLARE_FLAGS(ShareModes, ShareMode) +src\nfc\qnearfieldtarget.h: Q_DECLARE_FLAGS(AccessMethods, AccessMethod) +src\bluetooth\qlowenergycharacteristic.h: Q_DECLARE_FLAGS(PropertyTypes, PropertyType) +src\bluetooth\qlowenergycontroller_bluezdbus_p.h: Q_DECLARE_FLAGS(JobFlags, JobFlag) +src\bluetooth\qlowenergyservice.h: Q_DECLARE_FLAGS(ServiceTypes, ServiceType) diff --git a/tests/qflags/grep-results/qtdatavis3d-qflag-grep-result.txt b/tests/qflags/grep-results/qtdatavis3d-qflag-grep-result.txt new file mode 100644 index 00000000..efa8722c --- /dev/null +++ b/tests/qflags/grep-results/qtdatavis3d-qflag-grep-result.txt @@ -0,0 +1,6 @@ +src\datavisualizationqml2\abstractdeclarative_p.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag) +src\datavisualizationqml2\abstractdeclarative_p.h: Q_DECLARE_FLAGS(OptimizationHints, OptimizationHint) +src\datavisualization\data\qsurface3dseries.h: Q_DECLARE_FLAGS(DrawFlags, DrawFlag) +src\datavisualization\engine\qabstract3dgraph.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag) +src\datavisualization\engine\qabstract3dgraph.h: Q_DECLARE_FLAGS(OptimizationHints, OptimizationHint) +src\datavisualization\utils\surfaceobject_p.h: Q_DECLARE_FLAGS(DataDimensions, DataDimension) diff --git a/tests/qflags/grep-results/qtdeclarative-qflag-grep-result.txt b/tests/qflags/grep-results/qtdeclarative-qflag-grep-result.txt new file mode 100644 index 00000000..320342bd --- /dev/null +++ b/tests/qflags/grep-results/qtdeclarative-qflag-grep-result.txt @@ -0,0 +1,52 @@ +src\qmlmodels\qqmlobjectmodel_p.h: Q_DECLARE_FLAGS(ReleaseFlags, ReleaseFlag) +src\quickshapes\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\qml\animations\qabstractanimationjob_p.h: Q_DECLARE_FLAGS(ChangeTypes, ChangeType) +src\qml\jsapi\qjsengine.h: Q_DECLARE_FLAGS(Extensions, Extension) +src\qml\qml\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\qml\qml\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag) +src\qml\jsruntime\qv4global_p.h:Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag) +src\qml\qml\qqmlpropertydata_p.h: Q_DECLARE_FLAGS(WriteFlags, WriteFlag) +src\qml\qml\qqmlproperty_p.h: Q_DECLARE_FLAGS(BindingFlags, BindingFlag) +src\quick\items\qquickanchors_p.h: Q_DECLARE_FLAGS(Anchors, Anchor) +src\quick\handlers\qquickpointerhandler_p.h: Q_DECLARE_FLAGS(GrabPermissions, GrabPermission) +src\quick\items\qquickevents_p_p.h: Q_DECLARE_FLAGS(States, State) +src\quick\items\qquickevents_p_p.h: Q_DECLARE_FLAGS(DeviceTypes, DeviceType) +src\quick\items\qquickevents_p_p.h: Q_DECLARE_FLAGS(PointerTypes, PointerType) +src\quick\items\qquickevents_p_p.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag) +src\quick\items\qquickflickable_p.h: Q_DECLARE_FLAGS(BoundsBehavior, BoundsBehaviorFlag) +src\quick\scenegraph\qsgadaptationlayer_p.h: Q_DECLARE_FLAGS(DirtyShaderFlags, DirtyShaderFlag) +src\quick\scenegraph\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\quick\items\qquickimagebase_p.h: Q_DECLARE_FLAGS(LoadPixmapOptions, LoadPixmapOption) +src\quick\items\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag) +src\quick\util\qquickpixmapcache_p.h: Q_DECLARE_FLAGS(Options, Option) +src\quick\items\qquickitem_p.h: Q_DECLARE_FLAGS(ChangeTypes, ChangeType) +src\quick\items\qquickpainteditem.h: Q_DECLARE_FLAGS(PerformanceHints, PerformanceHint) +src\quick\items\qquicktableview_p_p.h: Q_DECLARE_FLAGS(RebuildOptions, RebuildOption) +src\quick\items\qquicktextnodeengine_p.h: Q_DECLARE_FLAGS(Decorations, Decoration) +src\quick\items\qquickwindow.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption) +src\quick\items\qquickwindow_p.h: Q_DECLARE_FLAGS(FocusOptions, FocusOption) +tests\auto\qml\qmltyperegistrar\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag) +tests\auto\qml\qqmlecmascript\testtypes.h: Q_DECLARE_FLAGS(MyFlags, MyFlag) +tests\auto\qml\qqmllanguage\testtypes.h: Q_DECLARE_FLAGS(MyFlags, MyFlag) +src\plugins\scenegraph\d3d12\qsgd3d12engine_p.h: Q_DECLARE_FLAGS(ClearFlags, ClearFlag) +src\plugins\scenegraph\d3d12\qsgd3d12engine_p.h: Q_DECLARE_FLAGS(TextureCreateFlags, TextureCreateFlag) +src\plugins\scenegraph\d3d12\qsgd3d12engine_p.h: Q_DECLARE_FLAGS(TextureUploadFlags, TextureUploadFlag) +src\plugins\scenegraph\d3d12\qsgd3d12material_p.h: Q_DECLARE_FLAGS(UpdateResults, UpdateResult) +src\quick\scenegraph\coreapi\qsgabstractrenderer.h: Q_DECLARE_FLAGS(ClearMode, ClearModeBit) +src\quick\scenegraph\coreapi\qsgabstractrenderer.h: Q_DECLARE_FLAGS(MatrixTransformFlags, MatrixTransformFlag) +src\quick\scenegraph\coreapi\qsgbatchrenderer_p.h: Q_DECLARE_FLAGS(ClipType, ClipTypeBit) +src\quick\scenegraph\coreapi\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag) +src\quick\scenegraph\coreapi\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent) +src\quick\scenegraph\coreapi\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag) +src\quick\scenegraph\coreapi\qsgmaterialshader.h: Q_DECLARE_FLAGS(DirtyStates, DirtyState) +src\quick\scenegraph\coreapi\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag) +src\quick\scenegraph\coreapi\qsgnode.h: Q_DECLARE_FLAGS(DirtyState, DirtyStateBit) +src\quick\scenegraph\coreapi\qsgrendererinterface.h: Q_DECLARE_FLAGS(ShaderCompilationTypes, ShaderCompilationType) +src\quick\scenegraph\coreapi\qsgrendererinterface.h: Q_DECLARE_FLAGS(ShaderSourceTypes, ShaderSourceType) +src\quick\scenegraph\coreapi\qsgrendernode.h: Q_DECLARE_FLAGS(StateFlags, StateFlag) +src\quick\scenegraph\coreapi\qsgrendernode.h: Q_DECLARE_FLAGS(RenderingFlags, RenderingFlag) +src\quick\scenegraph\util\qsgdepthstencilbuffer_p.h: Q_DECLARE_FLAGS(Attachments, Attachment) +src\quick\scenegraph\util\qsgengine.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption) +src\quick\scenegraph\util\qsgimagenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag) +src\quick\scenegraph\util\qsgsimpletexturenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag) +src\quick\scenegraph\adaptations\software\qsgsoftwareinternalimagenode_p.h: Q_DECLARE_FLAGS(DrawingHints, DrawingHint) diff --git a/tests/qflags/grep-results/qtdoc-qflag-grep-result.txt b/tests/qflags/grep-results/qtdoc-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtdocgallery-qflag-grep-result.txt b/tests/qflags/grep-results/qtdocgallery-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtfeedback-qflag-grep-result.txt b/tests/qflags/grep-results/qtfeedback-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtgamepad-qflag-grep-result.txt b/tests/qflags/grep-results/qtgamepad-qflag-grep-result.txt new file mode 100644 index 00000000..6efa7f77 --- /dev/null +++ b/tests/qflags/grep-results/qtgamepad-qflag-grep-result.txt @@ -0,0 +1,2 @@ +src\gamepad\qgamepadmanager.h: Q_DECLARE_FLAGS(GamepadButtons, GamepadButton) +src\gamepad\qgamepadmanager.h: Q_DECLARE_FLAGS(GamepadAxes, GamepadAxis) diff --git a/tests/qflags/grep-results/qtgraphicaleffects-qflag-grep-result.txt b/tests/qflags/grep-results/qtgraphicaleffects-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtimageformats-qflag-grep-result.txt b/tests/qflags/grep-results/qtimageformats-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtlocation-qflag-grep-result.txt b/tests/qflags/grep-results/qtlocation-qflag-grep-result.txt new file mode 100644 index 00000000..f4ec60a3 --- /dev/null +++ b/tests/qflags/grep-results/qtlocation-qflag-grep-result.txt @@ -0,0 +1,35 @@ +src\location\qlocation.h:Q_DECLARE_FLAGS(VisibilityScope, Visibility) +src\positioningquick\qdeclarativepositionsource_p.h: Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod) +src\positioning\qgeoareamonitorsource.h: Q_DECLARE_FLAGS(AreaMonitorFeatures, AreaMonitorFeature) +src\positioning\qgeopositioninfosource.h: Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod) +src\location\maps\qabstractgeotilecache_p.h: Q_DECLARE_FLAGS(CacheAreas, CacheArea) +src\location\declarativemaps\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(TravelModes, TravelMode) +src\location\declarativemaps\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(FeatureTypes, FeatureType) +src\location\declarativemaps\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(FeatureWeights, FeatureWeight) +src\location\declarativemaps\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(RouteOptimizations, RouteOptimization) +src\location\declarativemaps\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(SegmentDetails, SegmentDetail) +src\location\declarativemaps\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(ManeuverDetails, ManeuverDetail) +src\location\declarativemaps\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature) +src\location\declarativemaps\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature) +src\location\declarativemaps\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(MappingFeatures, MappingFeature) +src\location\declarativemaps\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature) +src\location\declarativemaps\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(NavigationFeatures, NavigationFeature) +src\location\maps\qgeomap_p.h: Q_DECLARE_FLAGS(ItemTypes, ItemType) +src\location\maps\qgeomap_p.h: Q_DECLARE_FLAGS(Capabilities, Capability) +src\location\declarativemaps\qgeomapobject_p.h: Q_DECLARE_FLAGS(Features, Feature) +src\location\declarativemaps\qquickgeomapgesturearea_p.h: Q_DECLARE_FLAGS(AcceptedGestures, GeoMapGesture) +src\location\maps\qgeorouterequest.h: Q_DECLARE_FLAGS(TravelModes, TravelMode) +src\location\maps\qgeorouterequest.h: Q_DECLARE_FLAGS(FeatureTypes, FeatureType) +src\location\maps\qgeorouterequest.h: Q_DECLARE_FLAGS(FeatureWeights, FeatureWeight) +src\location\maps\qgeorouterequest.h: Q_DECLARE_FLAGS(RouteOptimizations, RouteOptimization) +src\location\maps\qgeorouterequest.h: Q_DECLARE_FLAGS(SegmentDetails, SegmentDetail) +src\location\maps\qgeorouterequest.h: Q_DECLARE_FLAGS(ManeuverDetails, ManeuverDetail) +src\location\maps\qgeoserviceprovider.h: Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature) +src\location\maps\qgeoserviceprovider.h: Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature) +src\location\maps\qgeoserviceprovider.h: Q_DECLARE_FLAGS(MappingFeatures, MappingFeature) +src\location\maps\qgeoserviceprovider.h: Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature) +src\location\maps\qgeoserviceprovider.h: Q_DECLARE_FLAGS(NavigationFeatures, NavigationFeature) +src\plugins\geoservices\mapboxgl\qgeomapmapboxgl_p.h: Q_DECLARE_FLAGS(SyncStates, SyncState); +src\plugins\position\geoclue\qgeocluemaster.h: Q_DECLARE_FLAGS(ResourceFlags, ResourceFlag) +src\plugins\position\geoclue\qgeopositioninfosource_geocluemaster.h: Q_DECLARE_FLAGS(PositionFields, PositionField) +src\plugins\position\geoclue\qgeopositioninfosource_geocluemaster.h: Q_DECLARE_FLAGS(VelocityFields, VelocityField) diff --git a/tests/qflags/grep-results/qtlottie-qflag-grep-result.txt b/tests/qflags/grep-results/qtlottie-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtmacextras-qflag-grep-result.txt b/tests/qflags/grep-results/qtmacextras-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtmultimedia-qflag-grep-result.txt b/tests/qflags/grep-results/qtmultimedia-qflag-grep-result.txt new file mode 100644 index 00000000..b883953c --- /dev/null +++ b/tests/qflags/grep-results/qtmultimedia-qflag-grep-result.txt @@ -0,0 +1,11 @@ +src\multimediawidgets\qpaintervideosurface_p.h: Q_DECLARE_FLAGS(ShaderTypes, ShaderType) +src\qtmultimediaquicktools\qsgvideonode_p.h: Q_DECLARE_FLAGS(FrameFlags, FrameFlag) +src\multimedia\qmediaserviceproviderplugin.h: Q_DECLARE_FLAGS(Features, Feature) +src\multimedia\camera\qcamera.h: Q_DECLARE_FLAGS(CaptureModes, CaptureMode) +src\multimedia\camera\qcamera.h: Q_DECLARE_FLAGS(LockTypes, LockType) +src\multimedia\camera\qcameraexposure.h: Q_DECLARE_FLAGS(FlashModes, FlashMode) +src\multimedia\camera\qcamerafocus.h: Q_DECLARE_FLAGS(FocusModes, FocusMode) +src\multimedia\camera\qcameraimagecapture.h: Q_DECLARE_FLAGS(CaptureDestinations, CaptureDestination) +src\multimedia\playback\qmediaplayer.h: Q_DECLARE_FLAGS(Flags, Flag) +src\multimedia\audio\qsoundeffect_pulse_p.h: Q_DECLARE_FLAGS(EmptyStreamOptions, EmptyStreamOption) +src\multimedia\video\qabstractvideofilter.h: Q_DECLARE_FLAGS(RunFlags, RunFlag) diff --git a/tests/qflags/grep-results/qtnetworkauth-qflag-grep-result.txt b/tests/qflags/grep-results/qtnetworkauth-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtpim-qflag-grep-result.txt b/tests/qflags/grep-results/qtpim-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtpurchasing-qflag-grep-result.txt b/tests/qflags/grep-results/qtpurchasing-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtqa-qflag-grep-result.txt b/tests/qflags/grep-results/qtqa-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtquick3d-qflag-grep-result.txt b/tests/qflags/grep-results/qtquick3d-qflag-grep-result.txt new file mode 100644 index 00000000..d6ba3c42 --- /dev/null +++ b/tests/qflags/grep-results/qtquick3d-qflag-grep-result.txt @@ -0,0 +1,22 @@ +src\render\qssgrenderbasetypes_p.h:Q_DECLARE_FLAGS(QSSGRenderContextTypes, QSSGRenderContextType) +src\render\qssgrenderbasetypes_p.h:Q_DECLARE_FLAGS(QSSGRenderClearFlags, QSSGRenderClearValues) +src\render\qssgrenderbasetypes_p.h:Q_DECLARE_FLAGS(QSSGRenderSyncFlags, QSSGRenderSyncValues) +src\render\qssgrenderbasetypes_p.h:Q_DECLARE_FLAGS(QSSGRenderCommandFlushFlags, QSSGRenderCommandFlushValues) +src\render\qssgrenderbasetypes_p.h:Q_DECLARE_FLAGS(QSSGRenderBufferAccessFlags, QSSGRenderBufferAccessTypeValues) +src\render\qssgrenderbasetypes_p.h:Q_DECLARE_FLAGS(QSSGRenderBufferBarrierFlags, QSSGRenderBufferBarrierValues) +src\render\qssgrenderbasetypes_p.h:Q_DECLARE_FLAGS(QSSGRenderShaderTypeFlags, QSSGRenderShaderTypeValue) +src\runtimerender\qssgrenderclippingfrustum_p.h:Q_DECLARE_FLAGS(QSSGRenderBoxEdge, BoxEdgeFlagValues) +src\quick3d\qquick3dabstractlight_p.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag) +src\runtimerender\qssgrendershadercache_p.h:Q_DECLARE_FLAGS(QSSGShaderCacheProgramFlags, ShaderCacheProgramFlagValues) +src\runtimerender\qssgrendershadercodegeneratorv2_p.h:Q_DECLARE_FLAGS(QSSGShaderGeneratorStageFlags, QSSGShaderGeneratorStage) +src\quick3d\qquick3dobject_p.h: Q_DECLARE_FLAGS(ChangeTypes, ChangeType) +src\quick3d\qquick3dshaderutils_p.h: Q_DECLARE_FLAGS(MaterialShaderKeyFlags, MaterialShaderKeyValues) +src\quick3d\qquick3dtexture_p.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag) +src\runtimerender\graphobjects\qssgrendercustommaterial_p.h: Q_DECLARE_FLAGS(MaterialShaderKeyFlags, MaterialShaderKeyValues) +src\runtimerender\graphobjects\qssgrendercustommaterial_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\runtimerender\graphobjects\qssgrendereffect_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\runtimerender\graphobjects\qssgrenderimage_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\runtimerender\graphobjects\qssgrendernode_p.h: Q_DECLARE_FLAGS(Flags, Flag) +src\plugins\assetimporters\uip\uippresentation.h: Q_DECLARE_FLAGS(PropSetFlags, PropSetFlag) +src\plugins\assetimporters\uip\uippresentation.h: Q_DECLARE_FLAGS(Flags, NodeFlag) +src\plugins\assetimporters\uip\uippresentation.h: Q_DECLARE_FLAGS(Flags, Flag) diff --git a/tests/qflags/grep-results/qtquickcontrols-qflag-grep-result.txt b/tests/qflags/grep-results/qtquickcontrols-qflag-grep-result.txt new file mode 100644 index 00000000..e0f4bcdb --- /dev/null +++ b/tests/qflags/grep-results/qtquickcontrols-qflag-grep-result.txt @@ -0,0 +1 @@ +src\dialogs\qquickabstractdialog_p.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton) diff --git a/tests/qflags/grep-results/qtquickcontrols2-qflag-grep-result.txt b/tests/qflags/grep-results/qtquickcontrols2-qflag-grep-result.txt new file mode 100644 index 00000000..e0a46ddb --- /dev/null +++ b/tests/qflags/grep-results/qtquickcontrols2-qflag-grep-result.txt @@ -0,0 +1,2 @@ +src\quicktemplates2\qquickpopup_p.h: Q_DECLARE_FLAGS(ClosePolicy, ClosePolicyFlag) +tests\manual\gifs\eventcapturer.h: Q_DECLARE_FLAGS(MoveEventTrimFlags, MoveEventTrimFlag) diff --git a/tests/qflags/grep-results/qtquicktimeline-qflag-grep-result.txt b/tests/qflags/grep-results/qtquicktimeline-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtremoteobjects-qflag-grep-result.txt b/tests/qflags/grep-results/qtremoteobjects-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtrepotools-qflag-grep-result.txt b/tests/qflags/grep-results/qtrepotools-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtscript-qflag-grep-result.txt b/tests/qflags/grep-results/qtscript-qflag-grep-result.txt new file mode 100644 index 00000000..8a8ebf1f --- /dev/null +++ b/tests/qflags/grep-results/qtscript-qflag-grep-result.txt @@ -0,0 +1,4 @@ +src\script\api\qscriptclass.h: Q_DECLARE_FLAGS(QueryFlags, QueryFlag) +src\script\api\qscriptengine.h: Q_DECLARE_FLAGS(QObjectWrapOptions, QObjectWrapOption) +src\script\api\qscriptvalue.h: Q_DECLARE_FLAGS(ResolveFlags, ResolveFlag) +src\script\api\qscriptvalue.h: Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag) diff --git a/tests/qflags/grep-results/qtscxml-qflag-grep-result.txt b/tests/qflags/grep-results/qtscxml-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtsensors-qflag-grep-result.txt b/tests/qflags/grep-results/qtsensors-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtserialbus-qflag-grep-result.txt b/tests/qflags/grep-results/qtserialbus-qflag-grep-result.txt new file mode 100644 index 00000000..aec2346a --- /dev/null +++ b/tests/qflags/grep-results/qtserialbus-qflag-grep-result.txt @@ -0,0 +1,6 @@ +src\serialbus\qcanbusdevice.h: Q_DECLARE_FLAGS(FormatFilters, FormatFilter) +src\serialbus\qcanbusdevice.h: Q_DECLARE_FLAGS(Directions, Direction) +src\serialbus\qcanbusframe.h: Q_DECLARE_FLAGS(FrameErrors, FrameError) +src\plugins\canbus\passthrucan\j2534passthru.h: Q_DECLARE_FLAGS(RxStatus, RxStatusBit) +src\plugins\canbus\passthrucan\j2534passthru.h: Q_DECLARE_FLAGS(TxFlags, TxFlag) +src\plugins\canbus\passthrucan\j2534passthru.h: Q_DECLARE_FLAGS(ConnectFlags, ConnectFlag) diff --git a/tests/qflags/grep-results/qtserialport-qflag-grep-result.txt b/tests/qflags/grep-results/qtserialport-qflag-grep-result.txt new file mode 100644 index 00000000..45943370 --- /dev/null +++ b/tests/qflags/grep-results/qtserialport-qflag-grep-result.txt @@ -0,0 +1,2 @@ +src\serialport\qserialport.h: Q_DECLARE_FLAGS(Directions, Direction) +src\serialport\qserialport.h: Q_DECLARE_FLAGS(PinoutSignals, PinoutSignal) diff --git a/tests/qflags/grep-results/qtspeech-qflag-grep-result.txt b/tests/qflags/grep-results/qtspeech-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtsvg-qflag-grep-result.txt b/tests/qflags/grep-results/qtsvg-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/grep-results/qtsystems-qflag-grep-result.txt b/tests/qflags/grep-results/qtsystems-qflag-grep-result.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/qflags/qt-qflag-grep-result.txt b/tests/qflags/qt-qflag-grep-result.txt deleted file mode 100644 index e92d42a0..00000000 --- a/tests/qflags/qt-qflag-grep-result.txt +++ /dev/null @@ -1,227 +0,0 @@ -qmake\library\qmakeevaluator.h: Q_DECLARE_FLAGS(LoadFlags, LoadFlag) -qmake\library\qmakeparser.h: Q_DECLARE_FLAGS(ParseFlags, ParseFlag) -qmake\library\qmakevfs.h: Q_DECLARE_FLAGS(VfsFlags, VfsFlag) -qmake\generators\makefile.h: Q_DECLARE_FLAGS(FileFixifyTypes, FileFixifyType) -src\concurrent\qtconcurrentreducekernel.h:Q_DECLARE_FLAGS(ReduceOptions, ReduceOption) -src\dbus\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption) -src\dbus\qdbusconnection.h: Q_DECLARE_FLAGS(VirtualObjectRegisterOptions, VirtualObjectRegisterOption) -src\dbus\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability) -src\opengl\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption) -src\opengl\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag) -src\opengl\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption) -src\opengl\qglfunctions.h: Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature) -src\opengl\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit) -src\dbus\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag) -examples\network\torrent\peerwireclient.h: Q_DECLARE_FLAGS(PeerWireState, PeerWireStateFlag) -src\corelib\codecs\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag) -src\corelib\codecs\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag) -src\gui\accessible\qaccessible.h: Q_DECLARE_FLAGS(Relation, RelationFlag) -src\corelib\io\qabstractfileengine_p.h: Q_DECLARE_FLAGS(FileFlags, FileFlag) -src\corelib\global\qflags.h:#define Q_DECLARE_FLAGS(Flags, Enum)\ -src\corelib\global\qflags.h:#define Q_DECLARE_FLAGS(Flags, Enum)\ -src\corelib\itemmodels\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption) -src\corelib\io\qdir.h: Q_DECLARE_FLAGS(Filters, Filter) -src\corelib\io\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag) -src\corelib\io\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag) -src\corelib\io\qdir_p.h: Q_DECLARE_FLAGS(PathNormalizations, PathNormalization) -src\corelib\io\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission) -src\corelib\io\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag) -src\corelib\itemmodels\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(SplitBehavior, SplitBehaviorFlags) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag) -src\corelib\global\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag) -src\corelib\io\qfilesystemmetadata_p.h: Q_DECLARE_FLAGS(MetaDataFlags, MetaDataFlag) -src\gui\image\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation) -src\gui\image\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability) -src\corelib\kernel\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag) -src\corelib\io\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag) -src\gui\kernel\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag) -src\corelib\io\qloggingregistry_p.h: Q_DECLARE_FLAGS(PatternFlags, PatternFlag) -src\corelib\plugin\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint) -src\gui\opengl\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag) -src\corelib\kernel\qmetaobjectbuilder_p.h: Q_DECLARE_FLAGS(AddMembers, AddMember) -src\corelib\kernel\qmetaobjectbuilder_p.h: Q_DECLARE_FLAGS(MetaObjectFlags, MetaObjectFlag) -src\gui\opengl\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source) -src\gui\opengl\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type) -src\gui\opengl\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity) -src\corelib\kernel\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag) -src\gui\opengl\qopenglextensions_p.h: Q_DECLARE_FLAGS(OpenGLExtensions, OpenGLExtension) -src\corelib\io\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption) -src\gui\opengl\qopenglfunctions.h: Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature) -src\corelib\kernel\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag) -src\corelib\kernel\qppsobject_p.h: Q_DECLARE_FLAGS(OpenModes, OpenMode) -src\gui\kernel\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability) -src\network\access\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag) -src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton) -src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption) -src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption) -src\gui\kernel\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FileDialogOptions, FileDialogOption) -src\gui\kernel\qplatformgraphicsbuffer.h: Q_DECLARE_FLAGS(AccessTypes, AccessType); -src\gui\painting\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability) -src\corelib\io\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption) -src\corelib\io\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption) -src\corelib\io\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption) -src\gui\painting\qcolortransform_p.h: Q_DECLARE_FLAGS(TransformFlags, TransformFlag) -src\gui\kernel\qplatformtheme.h: Q_DECLARE_FLAGS(IconOptions, IconOption) -src\network\bearer\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability) -src\network\bearer\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag) -src\gui\kernel\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption) -src\network\bearer\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy) -src\gui\painting\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag) -src\gui\painting\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature) -src\gui\painting\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag) -src\gui\kernel\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag) -src\gui\opengl\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit) -src\gui\opengl\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature) -src\gui\painting\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint) -src\gui\painting\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint) -src\gui\opengl\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption) -src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(DataFrameFlags, DataFrameFlag) -src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(ControlFrameFlags, ControlFrameFlag) -src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(SETTINGS_Flags, SETTINGS_Flag) -src\network\access\qspdyprotocolhandler_p.h: Q_DECLARE_FLAGS(SETTINGS_ID_Flags, SETTINGS_ID_Flag) -src\gui\painting\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag) -src\gui\painting\qplatformbackingstore.h: Q_DECLARE_FLAGS(TextureFlags, TextureFlag) -src\gui\text\qfontengine_p.h: Q_DECLARE_FLAGS(ShaperFlags, ShaperFlag) -src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(StageFlags, StageFlag) -src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(UsageFlags, UsageFlag) -src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) -src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) -src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) -src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) -src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent) -src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) -src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag) -src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(BeginFrameFlags, BeginFrameFlag) -src\gui\rhi\qrhi_p.h: Q_DECLARE_FLAGS(EndFrameFlags, EndFrameFlag) -src\gui\rhi\qshaderdescription_p.h: Q_DECLARE_FLAGS(ImageFlags, ImageFlag) -src\gui\vulkan\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag) -src\gui\rhi\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag) -src\gui\util\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType) -src\gui\vulkan\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag) -src\gui\text\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag) -src\gui\text\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag) -src\gui\text\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature) -src\gui\text\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag) -src\network\kernel\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag) -src\network\socket\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag) -src\network\socket\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode) -src\network\socket\qabstractsocketengine_p.h: Q_DECLARE_FLAGS(PacketHeaderOptions, PacketHeaderOption) -src\gui\text\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag) -src\network\socket\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption) -src\gui\text\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature) -src\network\kernel\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag) -src\gui\text\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag) -src\network\ssl\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption) -src\network\kernel\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability) -src\corelib\text\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option) -src\corelib\text\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption) -src\corelib\text\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat) -src\corelib\serialization\qcborvalue.h: Q_DECLARE_FLAGS(EncodingOptions, EncodingOption) -src\corelib\serialization\qcborvalue.h: Q_DECLARE_FLAGS(DiagnosticNotationOptions, DiagnosticNotationOption) -src\corelib\serialization\qcborvalue_p.h: Q_DECLARE_FLAGS(ValueFlags, ValueFlag) -src\corelib\time\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section) -src\corelib\time\qdatetimeparser_p.h: Q_DECLARE_FLAGS(FieldInfo, FieldInfoFlag) -src\corelib\time\qdatetime_p.h: Q_DECLARE_FLAGS(StatusFlags, StatusFlag) -src\corelib\text\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption) -src\corelib\text\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption) -src\corelib\text\qstring.h: Q_DECLARE_FLAGS(SectionFlags, SectionFlag) -src\corelib\serialization\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag) -src\corelib\text\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason ) -src\corelib\text\qunicodetools_p.h:Q_DECLARE_FLAGS(CharAttributeOptions, CharAttributeOption) -src\corelib\tools\qarraydata.h: Q_DECLARE_FLAGS(AllocationOptions, AllocationOption) -src\corelib\tools\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag) -src\platformheaders\windowsfunctions\qwindowswindowfunctions.h: Q_DECLARE_FLAGS(TouchWindowTouchTypes, TouchWindowTouchType) -src\platformheaders\xcbfunctions\qxcbwindowfunctions.h: Q_DECLARE_FLAGS(WmWindowTypes, WmWindowType) -src\platformsupport\devicediscovery\qdevicediscovery_p.h: Q_DECLARE_FLAGS(QDeviceTypes, QDeviceType) -src\platformsupport\eglconvenience\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag) -src\platformsupport\fbconvenience\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag) -src\printsupport\dialogs\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption) -src\platformsupport\kmsconvenience\qkmsdevice_p.h: Q_DECLARE_FLAGS(Rotations, Rotation) -src\sql\kernel\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag) -src\widgets\dialogs\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption) -src\widgets\dialogs\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option) -src\widgets\dialogs\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option) -src\widgets\dialogs\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption) -src\widgets\effects\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) -src\widgets\effects\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint) -src\widgets\dialogs\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption) -src\widgets\dialogs\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton) -src\widgets\dialogs\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption) -src\widgets\itemviews\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger) -src\widgets\graphicsview\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag) -src\widgets\itemviews\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option) -src\widgets\kernel\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) -src\widgets\kernel\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag) -src\widgets\graphicsview\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer) -src\widgets\graphicsview\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag) -src\widgets\graphicsview\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag) -src\widgets\kernel\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType) -src\widgets\itemviews\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag) -src\widgets\kernel\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag) -src\widgets\kernel\qwidget_p.h: Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag) -src\widgets\styles\qdrawutil.h: Q_DECLARE_FLAGS(DrawingHints, DrawingHint) -src\widgets\styles\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag) -src\widgets\styles\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl) -src\widgets\widgets\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag) -src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature) -src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature) -src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget) -src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature) -src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature) -src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature) -src\widgets\styles\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature) -src\widgets\widgets\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton) -src\widgets\widgets\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature) -src\widgets\widgets\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter) -src\widgets\widgets\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section) -src\widgets\widgets\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption) -src\widgets\widgets\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption) -src\widgets\widgets\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption) -tests\manual\diaglib\eventfilter.h: Q_DECLARE_FLAGS(EventCategories, EventCategory) -tests\manual\diaglib\eventfilter.h: Q_DECLARE_FLAGS(ObjectTypes, ObjectType) -src\widgets\widgets\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag) -tests\manual\diaglib\qwindowdump.h:Q_DECLARE_FLAGS(FormatWindowOptions, FormatWindowOption) -src\network\access\http2\http2protocol_p.h:Q_DECLARE_FLAGS(FrameFlags, FrameFlag) -src\plugins\bearer\networkmanager\qnetworkmanagerservice.h: Q_DECLARE_FLAGS(ApFlags, ApFlag) -src\plugins\bearer\networkmanager\qnetworkmanagerservice.h: Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag) -src\plugins\bearer\networkmanager\qnetworkmanagerservice.h: Q_DECLARE_FLAGS(ModemCapabilities, ModemCapability) -src\plugins\platforms\android\qandroidinputcontext.h: Q_DECLARE_FLAGS(HandleModes, HandleMode) -src\plugins\platforms\direct2d\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag) -src\plugins\platforms\cocoa\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option) -src\plugins\platforms\wasm\qwasmcompositor.h: Q_DECLARE_FLAGS(SubControls, QWasmSubControl) -src\plugins\platforms\wasm\qwasmcompositor.h: Q_DECLARE_FLAGS(StateFlags, QWasmStateFlag) -src\plugins\platforms\cocoa\qcocoawindow.h: Q_DECLARE_FLAGS(RecreationReasons, RecreationReason) -src\plugins\platforms\qnx\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option) -src\plugins\platforms\xcb\qxcbeventqueue.h: Q_DECLARE_FLAGS(PeekOptions, PeekOption) -src\plugins\platforms\windows\qwindowsopengltester.h: Q_DECLARE_FLAGS(Renderers, Renderer) -src\plugins\platforms\xcb\qxcbwindow.h: Q_DECLARE_FLAGS(NetWmStates, NetWmState) -tests\auto\other\macgui\guitest.h: Q_DECLARE_FLAGS(Directions, Direction) -tests\auto\tools\moc\cxx11-enums.h: Q_DECLARE_FLAGS(ClassFlags, ClassFlag) -tests\auto\tools\moc\cxx11-enums.h: Q_DECLARE_FLAGS(StructFlags, StructFlag) -tests\auto\tools\moc\cxx11-enums.h: Q_DECLARE_FLAGS(ClassFlags, ClassFlag) -tests\auto\tools\moc\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag ) -src\plugins\platforms\eglfs\api\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag) -tests\auto\corelib\tools\qsharedpointer\externaltests.h: Q_DECLARE_FLAGS(QtModules, QtModule) -tests\benchmarks\corelib\io\qdiriterator\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag) -tests\benchmarks\widgets\graphicsview\functional\GraphicsViewBenchmark\widgets\settings.h: Q_DECLARE_FLAGS(Options, Option) diff --git a/tests/qflags/qtbase-qflags_modules_analysis.json b/tests/qflags/qtbase-qflags_modules_analysis.json new file mode 100644 index 00000000..446afba6 --- /dev/null +++ b/tests/qflags/qtbase-qflags_modules_analysis.json @@ -0,0 +1,2192 @@ +{ + "flag_and_module_identified": [ + { + "qflag_class": "RegisterOptions", + "enum_class": "RegisterOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi" + }, + { + "qflag_class": "ConnectionCapabilities", + "enum_class": "ConnectionCapability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi" + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" + }, + { + "qflag_class": "OpenGLVersionFlags", + "enum_class": "OpenGLVersionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" + }, + { + "qflag_class": "BindOptions", + "enum_class": "BindOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption)", + "src\\gui\\opengl\\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" + }, + { + "qflag_class": "ShaderType", + "enum_class": "ShaderTypeBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)", + "src\\gui\\opengl\\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "WatchMode", + "enum_class": "WatchModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi" + }, + { + "qflag_class": "ConversionFlags", + "enum_class": "ConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\codecs\\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)", + "src\\corelib\\codecs\\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "CheckIndexOptions", + "enum_class": "CheckIndexOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\itemmodels\\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Filters", + "enum_class": "Filter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(Filters, Filter)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "SortFlags", + "enum_class": "SortFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Permissions", + "enum_class": "Permission", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "FileHandleFlags", + "enum_class": "FileHandleFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "SelectionFlags", + "enum_class": "SelectionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\itemmodels\\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "KeyboardModifiers", + "enum_class": "KeyboardModifier", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MouseButtons", + "enum_class": "MouseButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Orientations", + "enum_class": "Orientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Alignment", + "enum_class": "AlignmentFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "WindowFlags", + "enum_class": "WindowType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "WindowStates", + "enum_class": "WindowState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ApplicationStates", + "enum_class": "ApplicationState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ScreenOrientations", + "enum_class": "ScreenOrientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ImageConversionFlags", + "enum_class": "ImageConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "DockWidgetAreas", + "enum_class": "DockWidgetArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ToolBarAreas", + "enum_class": "ToolBarArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Edges", + "enum_class": "Edge", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "InputMethodQueries", + "enum_class": "InputMethodQuery", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "InputMethodHints", + "enum_class": "InputMethodHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "FindChildOptions", + "enum_class": "FindChildOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "DropActions", + "enum_class": "DropAction", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "ItemFlags", + "enum_class": "ItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MatchFlags", + "enum_class": "MatchFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "TextInteractionFlags", + "enum_class": "TextInteractionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "TouchPointStates", + "enum_class": "TouchPointState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "GestureFlags", + "enum_class": "GestureFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MouseEventFlags", + "enum_class": "MouseEventFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Transformations", + "enum_class": "Transformation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "ProcessEventsFlags", + "enum_class": "ProcessEventsFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "OpenMode", + "enum_class": "OpenModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "InfoFlags", + "enum_class": "InfoFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "LoadHints", + "enum_class": "LoadHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\plugin\\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "RangeAccessFlags", + "enum_class": "RangeAccessFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Sources", + "enum_class": "Source", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Types", + "enum_class": "Type", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Severities", + "enum_class": "Severity", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "TypeFlags", + "enum_class": "TypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "LocateOptions", + "enum_class": "LocateOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "PolicyFlags", + "enum_class": "PolicyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\access\\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ColorDialogOptions", + "enum_class": "ColorDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)", + "src\\widgets\\dialogs\\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "FontDialogOptions", + "enum_class": "FontDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)", + "src\\widgets\\dialogs\\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ComponentFormattingOptions", + "enum_class": "ComponentFormattingOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "FormattingOptions", + "enum_class": "UrlFormattingOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "UserInputResolutionOptions", + "enum_class": "UserInputResolutionOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "StateFlags", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\bearer\\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "UsagePolicies", + "enum_class": "UsagePolicy", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\bearer\\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "PaintEngineFeatures", + "enum_class": "PaintEngineFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "DirtyFlags", + "enum_class": "DirtyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Capabilities", + "enum_class": "CapabilityFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "Features", + "enum_class": "Feature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature)", + "src\\gui\\text\\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "RenderHints", + "enum_class": "RenderHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "PixmapFragmentHints", + "enum_class": "PixmapFragmentHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "ControlTypes", + "enum_class": "ControlType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\util\\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)", + "src\\widgets\\kernel\\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "GlyphRunFlags", + "enum_class": "GlyphRunFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "LayoutFlags", + "enum_class": "LayoutFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "MarkdownFeatures", + "enum_class": "MarkdownFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "FindFlags", + "enum_class": "FindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "ConversionMode", + "enum_class": "ConversionModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\kernel\\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "BindMode", + "enum_class": "BindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "PauseModes", + "enum_class": "PauseMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "PageBreakFlags", + "enum_class": "PageBreakFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi" + }, + { + "qflag_class": "SocketOptions", + "enum_class": "SocketOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "InterfaceFlags", + "enum_class": "InterfaceFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\kernel\\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "SslOptions", + "enum_class": "SslOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\ssl\\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi" + }, + { + "qflag_class": "Base64Options", + "enum_class": "Base64Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "NumberOptions", + "enum_class": "NumberOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "DataSizeFormats", + "enum_class": "DataSizeFormat", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "Sections", + "enum_class": "Section", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\time\\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section)", + "src\\widgets\\widgets\\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "PatternOptions", + "enum_class": "PatternOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "MatchOptions", + "enum_class": "MatchOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "NumberFlags", + "enum_class": "NumberFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\serialization\\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "BoundaryReasons", + "enum_class": "BoundaryReason", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi" + }, + { + "qflag_class": "PrintDialogOptions", + "enum_class": "PrintDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\printsupport\\dialogs\\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPrintSupport", + "module_path": "../../PyQt5-stubs/QtPrintSupport.pyi" + }, + { + "qflag_class": "ParamType", + "enum_class": "ParamTypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\sql\\kernel\\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSql", + "module_path": "../../PyQt5-stubs/QtSql.pyi" + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 3, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 3, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 3, + "module_idx": 2, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "BlurHints", + "enum_class": "BlurHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "InputDialogOptions", + "enum_class": "InputDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "WizardOptions", + "enum_class": "WizardOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "EditTriggers", + "enum_class": "EditTrigger", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\itemviews\\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "GraphicsItemFlags", + "enum_class": "GraphicsItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "Result", + "enum_class": "ResultFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\kernel\\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "SceneLayers", + "enum_class": "SceneLayer", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "CacheMode", + "enum_class": "CacheModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "OptimizationFlags", + "enum_class": "OptimizationFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "State", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "SubControls", + "enum_class": "SubControl", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "StepEnabled", + "enum_class": "StepEnabledFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "FrameFeatures", + "enum_class": "FrameFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ButtonFeatures", + "enum_class": "ButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "CornerWidgets", + "enum_class": "CornerWidget", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "TabFeatures", + "enum_class": "TabFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ToolBarFeatures", + "enum_class": "ToolBarFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ViewItemFeatures", + "enum_class": "ViewItemFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ToolButtonFeatures", + "enum_class": "ToolButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "DockWidgetFeatures", + "enum_class": "DockWidgetFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "FontFilters", + "enum_class": "FontFilter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "AreaOptions", + "enum_class": "AreaOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "SubWindowOptions", + "enum_class": "SubWindowOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "DockOptions", + "enum_class": "DockOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "AutoFormatting", + "enum_class": "AutoFormattingFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + } + ], + "flag_without_module": [] +} \ No newline at end of file diff --git a/tests/qflags/qtbase-qflags_process_result.json b/tests/qflags/qtbase-qflags_process_result.json new file mode 100644 index 00000000..59f9a269 --- /dev/null +++ b/tests/qflags/qtbase-qflags_process_result.json @@ -0,0 +1,2573 @@ +{ + "qflag_already_done": [ + { + "qflag_class": "RegisterOptions", + "enum_class": "RegisterOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)" + ], + "qflag_full_class_name": "QDBusConnection.RegisterOptions", + "enum_full_class_name": "QDBusConnection.RegisterOption", + "enum_value1": "ExportAdaptors", + "enum_value2": "ExportScriptableSlots", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ConnectionCapabilities", + "enum_class": "ConnectionCapability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)" + ], + "qflag_full_class_name": "QDBusConnection.ConnectionCapabilities", + "enum_full_class_name": "QDBusConnection.ConnectionCapability", + "enum_value1": "UnixFileDescriptorPassing", + "enum_value2": "UnixFileDescriptorPassing", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "QSurfaceFormat.FormatOptions", + "enum_full_class_name": "QSurfaceFormat.FormatOption", + "enum_value1": "StereoBuffers", + "enum_value2": "DebugContext", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "QGL.FormatOptions", + "enum_full_class_name": "QGL.FormatOption", + "enum_value1": "DoubleBuffer", + "enum_value2": "DepthBuffer", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "OpenGLVersionFlags", + "enum_class": "OpenGLVersionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)" + ], + "qflag_full_class_name": "QGLFormat.OpenGLVersionFlags", + "enum_full_class_name": "QGLFormat.OpenGLVersionFlag", + "enum_value1": "OpenGL_Version_None", + "enum_value2": "OpenGL_Version_1_1", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BindOptions", + "enum_class": "BindOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption)", + "src\\gui\\opengl\\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption)" + ], + "qflag_full_class_name": "QGLContext.BindOptions", + "enum_full_class_name": "QGLContext.BindOption", + "enum_value1": "NoBindOption", + "enum_value2": "InvertedYBindOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ShaderType", + "enum_class": "ShaderTypeBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)", + "src\\gui\\opengl\\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)" + ], + "qflag_full_class_name": "QOpenGLShader.ShaderType", + "enum_full_class_name": "QOpenGLShader.ShaderTypeBit", + "enum_value1": "Vertex", + "enum_value2": "Fragment", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WatchMode", + "enum_class": "WatchModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)" + ], + "qflag_full_class_name": "QDBusServiceWatcher.WatchMode", + "enum_full_class_name": "QDBusServiceWatcher.WatchModeFlag", + "enum_value1": "WatchForRegistration", + "enum_value2": "WatchForUnregistration", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ConversionFlags", + "enum_class": "ConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\codecs\\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)", + "src\\corelib\\codecs\\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)" + ], + "qflag_full_class_name": "QTextCodec.ConversionFlags", + "enum_full_class_name": "QTextCodec.ConversionFlag", + "enum_value1": "DefaultConversion", + "enum_value2": "ConvertInvalidToNull", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Filters", + "enum_class": "Filter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(Filters, Filter)" + ], + "qflag_full_class_name": "QDir.Filters", + "enum_full_class_name": "QDir.Filter", + "enum_value1": "Dirs", + "enum_value2": "Files", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SortFlags", + "enum_class": "SortFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag)" + ], + "qflag_full_class_name": "QDir.SortFlags", + "enum_full_class_name": "QDir.SortFlag", + "enum_value1": "Name", + "enum_value2": "Time", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "QDirIterator.IteratorFlags", + "enum_full_class_name": "QDirIterator.IteratorFlag", + "enum_value1": "NoIteratorFlags", + "enum_value2": "FollowSymlinks", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "QTreeWidgetItemIterator.IteratorFlags", + "enum_full_class_name": "QTreeWidgetItemIterator.IteratorFlag", + "enum_value1": "All", + "enum_value2": "Hidden", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Permissions", + "enum_class": "Permission", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission)" + ], + "qflag_full_class_name": "QFileDevice.Permissions", + "enum_full_class_name": "QFileDevice.Permission", + "enum_value1": "ReadOwner", + "enum_value2": "WriteOwner", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FileHandleFlags", + "enum_class": "FileHandleFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)" + ], + "qflag_full_class_name": "QFileDevice.FileHandleFlags", + "enum_full_class_name": "QFileDevice.FileHandleFlag", + "enum_value1": "AutoCloseHandle", + "enum_value2": "DontCloseHandle", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "SelectionFlags", + "enum_class": "SelectionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\itemmodels\\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" + ], + "qflag_full_class_name": "QItemSelectionModel.SelectionFlags", + "enum_full_class_name": "QItemSelectionModel.SelectionFlag", + "enum_value1": "NoUpdate", + "enum_value2": "Clear", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "KeyboardModifiers", + "enum_class": "KeyboardModifier", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)" + ], + "qflag_full_class_name": "Qt.KeyboardModifiers", + "enum_full_class_name": "Qt.KeyboardModifier", + "enum_value1": "NoModifier", + "enum_value2": "ShiftModifier", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MouseButtons", + "enum_class": "MouseButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton)" + ], + "qflag_full_class_name": "Qt.MouseButtons", + "enum_full_class_name": "Qt.MouseButton", + "enum_value1": "NoButton", + "enum_value2": "AllButtons", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Orientations", + "enum_class": "Orientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation)" + ], + "qflag_full_class_name": "Qt.Orientations", + "enum_full_class_name": "Qt.Orientation", + "enum_value1": "Horizontal", + "enum_value2": "Vertical", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Alignment", + "enum_class": "AlignmentFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag)" + ], + "qflag_full_class_name": "Qt.Alignment", + "enum_full_class_name": "Qt.AlignmentFlag", + "enum_value1": "AlignLeft", + "enum_value2": "AlignLeading", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WindowFlags", + "enum_class": "WindowType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType)" + ], + "qflag_full_class_name": "Qt.WindowFlags", + "enum_full_class_name": "Qt.WindowType", + "enum_value1": "Widget", + "enum_value2": "Window", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WindowStates", + "enum_class": "WindowState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState)" + ], + "qflag_full_class_name": "Qt.WindowStates", + "enum_full_class_name": "Qt.WindowState", + "enum_value1": "WindowNoState", + "enum_value2": "WindowMinimized", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ApplicationStates", + "enum_class": "ApplicationState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState)" + ], + "qflag_full_class_name": "Qt.ApplicationStates", + "enum_full_class_name": "Qt.ApplicationState", + "enum_value1": "ApplicationSuspended", + "enum_value2": "ApplicationHidden", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "ScreenOrientations", + "enum_class": "ScreenOrientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation)" + ], + "qflag_full_class_name": "Qt.ScreenOrientations", + "enum_full_class_name": "Qt.ScreenOrientation", + "enum_value1": "PrimaryOrientation", + "enum_value2": "PortraitOrientation", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ImageConversionFlags", + "enum_class": "ImageConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag)" + ], + "qflag_full_class_name": "Qt.ImageConversionFlags", + "enum_full_class_name": "Qt.ImageConversionFlag", + "enum_value1": "AutoColor", + "enum_value2": "ColorOnly", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DockWidgetAreas", + "enum_class": "DockWidgetArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)" + ], + "qflag_full_class_name": "Qt.DockWidgetAreas", + "enum_full_class_name": "Qt.DockWidgetArea", + "enum_value1": "LeftDockWidgetArea", + "enum_value2": "RightDockWidgetArea", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ToolBarAreas", + "enum_class": "ToolBarArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)" + ], + "qflag_full_class_name": "Qt.ToolBarAreas", + "enum_full_class_name": "Qt.ToolBarArea", + "enum_value1": "LeftToolBarArea", + "enum_value2": "RightToolBarArea", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Edges", + "enum_class": "Edge", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge)" + ], + "qflag_full_class_name": "Qt.Edges", + "enum_full_class_name": "Qt.Edge", + "enum_value1": "TopEdge", + "enum_value2": "LeftEdge", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InputMethodQueries", + "enum_class": "InputMethodQuery", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery)" + ], + "qflag_full_class_name": "Qt.InputMethodQueries", + "enum_full_class_name": "Qt.InputMethodQuery", + "enum_value1": "ImMicroFocus", + "enum_value2": "ImFont", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InputMethodHints", + "enum_class": "InputMethodHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)" + ], + "qflag_full_class_name": "Qt.InputMethodHints", + "enum_full_class_name": "Qt.InputMethodHint", + "enum_value1": "ImhNone", + "enum_value2": "ImhHiddenText", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FindChildOptions", + "enum_class": "FindChildOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)" + ], + "qflag_full_class_name": "Qt.FindChildOptions", + "enum_full_class_name": "Qt.FindChildOption", + "enum_value1": "FindDirectChildrenOnly", + "enum_value2": "FindChildrenRecursively", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "DropActions", + "enum_class": "DropAction", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction)" + ], + "qflag_full_class_name": "Qt.DropActions", + "enum_full_class_name": "Qt.DropAction", + "enum_value1": "CopyAction", + "enum_value2": "MoveAction", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ItemFlags", + "enum_class": "ItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag)" + ], + "qflag_full_class_name": "Qt.ItemFlags", + "enum_full_class_name": "Qt.ItemFlag", + "enum_value1": "NoItemFlags", + "enum_value2": "ItemIsSelectable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MatchFlags", + "enum_class": "MatchFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag)" + ], + "qflag_full_class_name": "Qt.MatchFlags", + "enum_full_class_name": "Qt.MatchFlag", + "enum_value1": "MatchExactly", + "enum_value2": "MatchFixedString", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "TextInteractionFlags", + "enum_class": "TextInteractionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag)" + ], + "qflag_full_class_name": "Qt.TextInteractionFlags", + "enum_full_class_name": "Qt.TextInteractionFlag", + "enum_value1": "NoTextInteraction", + "enum_value2": "TextSelectableByMouse", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "TouchPointStates", + "enum_class": "TouchPointState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)" + ], + "qflag_full_class_name": "Qt.TouchPointStates", + "enum_full_class_name": "Qt.TouchPointState", + "enum_value1": "TouchPointPressed", + "enum_value2": "TouchPointMoved", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "GestureFlags", + "enum_class": "GestureFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag)" + ], + "qflag_full_class_name": "Qt.GestureFlags", + "enum_full_class_name": "Qt.GestureFlag", + "enum_value1": "DontStartGestureOnChildren", + "enum_value2": "ReceivePartialGestures", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MouseEventFlags", + "enum_class": "MouseEventFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)" + ], + "qflag_full_class_name": "Qt.MouseEventFlags", + "enum_full_class_name": "Qt.MouseEventFlag", + "enum_value1": "MouseEventCreatedDoubleClick", + "enum_value2": "MouseEventCreatedDoubleClick", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Transformations", + "enum_class": "Transformation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation)" + ], + "qflag_full_class_name": "QImageIOHandler.Transformations", + "enum_full_class_name": "QImageIOHandler.Transformation", + "enum_value1": "TransformationNone", + "enum_value2": "TransformationMirror", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "QNetworkConfigurationManager.Capabilities", + "enum_full_class_name": "QNetworkConfigurationManager.Capability", + "enum_value1": "CanStartAndStopInterfaces", + "enum_value2": "DirectConnectionRouting", + "module_count": 2, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "QNetworkProxy.Capabilities", + "enum_full_class_name": "QNetworkProxy.Capability", + "enum_value1": "TunnelingCapability", + "enum_value2": "ListeningCapability", + "module_count": 2, + "module_idx": 1, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "ProcessEventsFlags", + "enum_class": "ProcessEventsFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)" + ], + "qflag_full_class_name": "QEventLoop.ProcessEventsFlags", + "enum_full_class_name": "QEventLoop.ProcessEventsFlag", + "enum_value1": "AllEvents", + "enum_value2": "ExcludeUserInputEvents", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "OpenMode", + "enum_class": "OpenModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)" + ], + "qflag_full_class_name": "QIODevice.OpenMode", + "enum_full_class_name": "QIODevice.OpenModeFlag", + "enum_value1": "NotOpen", + "enum_value2": "ReadOnly", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InfoFlags", + "enum_class": "InfoFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag)" + ], + "qflag_full_class_name": "QTouchEvent.TouchPoint.InfoFlags", + "enum_full_class_name": "QTouchEvent.TouchPoint.InfoFlag", + "enum_value1": "Pen", + "enum_value2": "Token", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "LoadHints", + "enum_class": "LoadHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\plugin\\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint)" + ], + "qflag_full_class_name": "QLibrary.LoadHints", + "enum_full_class_name": "QLibrary.LoadHint", + "enum_value1": "ResolveAllSymbolsHint", + "enum_value2": "ExportExternalSymbolsHint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "RangeAccessFlags", + "enum_class": "RangeAccessFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)" + ], + "qflag_full_class_name": "QOpenGLBuffer.RangeAccessFlags", + "enum_full_class_name": "QOpenGLBuffer.RangeAccessFlag", + "enum_value1": "RangeRead", + "enum_value2": "RangeWrite", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Sources", + "enum_class": "Source", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source)" + ], + "qflag_full_class_name": "QOpenGLDebugMessage.Sources", + "enum_full_class_name": "QOpenGLDebugMessage.Source", + "enum_value1": "InvalidSource", + "enum_value2": "APISource", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Types", + "enum_class": "Type", + "human_hint_qflag_full_class_name": "QOpenGLDebugMessage.Types", + "human_hint_enum_full_class_name": "QOpenGLDebugMessage.Type", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" + ], + "qflag_full_class_name": "QOpenGLDebugMessage.Types", + "enum_full_class_name": "QOpenGLDebugMessage.Type", + "enum_value1": "InvalidType", + "enum_value2": "ErrorType", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Severities", + "enum_class": "Severity", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity)" + ], + "qflag_full_class_name": "QOpenGLDebugMessage.Severities", + "enum_full_class_name": "QOpenGLDebugMessage.Severity", + "enum_value1": "InvalidSeverity", + "enum_value2": "HighSeverity", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "TypeFlags", + "enum_class": "TypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag)" + ], + "qflag_full_class_name": "QMetaType.TypeFlags", + "enum_full_class_name": "QMetaType.TypeFlag", + "enum_value1": "NeedsConstruction", + "enum_value2": "NeedsDestruction", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "LocateOptions", + "enum_class": "LocateOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption)" + ], + "qflag_full_class_name": "QStandardPaths.LocateOptions", + "enum_full_class_name": "QStandardPaths.LocateOption", + "enum_value1": "LocateFile", + "enum_value2": "LocateDirectory", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QCommandLineOption.Flags", + "enum_full_class_name": "QCommandLineOption.Flag", + "enum_value1": "HiddenFromHelp", + "enum_value2": "ShortOptionStyle", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QTextOption.Flags", + "enum_full_class_name": "QTextOption.Flag", + "enum_value1": "IncludeTrailingSpaces", + "enum_value2": "ShowTabsAndSpaces", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PolicyFlags", + "enum_class": "PolicyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\access\\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)" + ], + "qflag_full_class_name": "QHstsPolicy.PolicyFlags", + "enum_full_class_name": "QHstsPolicy.PolicyFlag", + "enum_value1": "IncludeSubDomains", + "enum_value2": "IncludeSubDomains", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "QDialogButtonBox.StandardButtons", + "enum_full_class_name": "QDialogButtonBox.StandardButton", + "enum_value1": "NoButton", + "enum_value2": "Ok", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "QMessageBox.StandardButtons", + "enum_full_class_name": "QMessageBox.StandardButton", + "enum_value1": "NoButton", + "enum_value2": "Ok", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ColorDialogOptions", + "enum_class": "ColorDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)", + "src\\widgets\\dialogs\\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)" + ], + "qflag_full_class_name": "QColorDialog.ColorDialogOptions", + "enum_full_class_name": "QColorDialog.ColorDialogOption", + "enum_value1": "ShowAlphaChannel", + "enum_value2": "NoButtons", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FontDialogOptions", + "enum_class": "FontDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)", + "src\\widgets\\dialogs\\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)" + ], + "qflag_full_class_name": "QFontDialog.FontDialogOptions", + "enum_full_class_name": "QFontDialog.FontDialogOption", + "enum_value1": "NoButtons", + "enum_value2": "DontUseNativeDialog", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ComponentFormattingOptions", + "enum_class": "ComponentFormattingOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)" + ], + "qflag_full_class_name": "QUrl.ComponentFormattingOptions", + "enum_full_class_name": "QUrl.ComponentFormattingOption", + "enum_value1": "PrettyDecoded", + "enum_value2": "EncodeSpaces", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "UserInputResolutionOptions", + "enum_class": "UserInputResolutionOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption)" + ], + "qflag_full_class_name": "QUrl.UserInputResolutionOptions", + "enum_full_class_name": "QUrl.UserInputResolutionOption", + "enum_value1": "DefaultResolution", + "enum_value2": "AssumeLocalFile", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "StateFlags", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\bearer\\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" + ], + "qflag_full_class_name": "QNetworkConfiguration.StateFlags", + "enum_full_class_name": "QNetworkConfiguration.StateFlag", + "enum_value1": "Undefined", + "enum_value2": "Defined", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "UsagePolicies", + "enum_class": "UsagePolicy", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\bearer\\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)" + ], + "qflag_full_class_name": "QNetworkSession.UsagePolicies", + "enum_full_class_name": "QNetworkSession.UsagePolicy", + "enum_value1": "NoPolicy", + "enum_value2": "NoBackgroundTrafficPolicy", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "QWidget.RenderFlags", + "enum_full_class_name": "QWidget.RenderFlag", + "enum_value1": "DrawWindowBackground", + "enum_value2": "DrawChildren", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "QTextItem.RenderFlags", + "enum_full_class_name": "QTextItem.RenderFlag", + "enum_value1": "RightToLeft", + "enum_value2": "Overline", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PaintEngineFeatures", + "enum_class": "PaintEngineFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)" + ], + "qflag_full_class_name": "QPaintEngine.PaintEngineFeatures", + "enum_full_class_name": "QPaintEngine.PaintEngineFeature", + "enum_value1": "PrimitiveTransform", + "enum_value2": "PatternTransform", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DirtyFlags", + "enum_class": "DirtyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" + ], + "qflag_full_class_name": "QPaintEngine.DirtyFlags", + "enum_full_class_name": "QPaintEngine.DirtyFlag", + "enum_value1": "DirtyPen", + "enum_value2": "DirtyBrush", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "Capabilities", + "enum_class": "CapabilityFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" + ], + "qflag_full_class_name": "QTouchDevice.Capabilities", + "enum_full_class_name": "QTouchDevice.CapabilityFlag", + "enum_value1": "Position", + "enum_value2": "Area", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Features", + "enum_class": "Feature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature)", + "src\\gui\\text\\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature)" + ], + "qflag_full_class_name": "QOpenGLTexture.Features", + "enum_full_class_name": "QOpenGLTexture.Feature", + "enum_value1": "ImmutableStorage", + "enum_value2": "ImmutableMultisampleStorage", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "RenderHints", + "enum_class": "RenderHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint)" + ], + "qflag_full_class_name": "QPainter.RenderHints", + "enum_full_class_name": "QPainter.RenderHint", + "enum_value1": "Antialiasing", + "enum_value2": "TextAntialiasing", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PixmapFragmentHints", + "enum_class": "PixmapFragmentHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)" + ], + "qflag_full_class_name": "QPainter.PixmapFragmentHints", + "enum_full_class_name": "QPainter.PixmapFragmentHint", + "enum_value1": "OpaqueHint", + "enum_value2": "OpaqueHint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "ControlTypes", + "enum_class": "ControlType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\util\\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)", + "src\\widgets\\kernel\\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)" + ], + "qflag_full_class_name": "QSizePolicy.ControlTypes", + "enum_full_class_name": "QSizePolicy.ControlType", + "enum_value1": "DefaultType", + "enum_value2": "ButtonBox", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "GlyphRunFlags", + "enum_class": "GlyphRunFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag)" + ], + "qflag_full_class_name": "QGlyphRun.GlyphRunFlags", + "enum_full_class_name": "QGlyphRun.GlyphRunFlag", + "enum_value1": "Overline", + "enum_value2": "Underline", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "LayoutFlags", + "enum_class": "LayoutFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)" + ], + "qflag_full_class_name": "QRawFont.LayoutFlags", + "enum_full_class_name": "QRawFont.LayoutFlag", + "enum_value1": "SeparateAdvances", + "enum_value2": "KernedAdvances", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MarkdownFeatures", + "enum_class": "MarkdownFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)" + ], + "qflag_full_class_name": "QTextDocument.MarkdownFeatures", + "enum_full_class_name": "QTextDocument.MarkdownFeature", + "enum_value1": "MarkdownNoHTML", + "enum_value2": "MarkdownDialectCommonMark", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "FindFlags", + "enum_class": "FindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag)" + ], + "qflag_full_class_name": "QTextDocument.FindFlags", + "enum_full_class_name": "QTextDocument.FindFlag", + "enum_value1": "FindBackward", + "enum_value2": "FindCaseSensitively", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ConversionMode", + "enum_class": "ConversionModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\kernel\\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)" + ], + "qflag_full_class_name": "QHostAddress.ConversionMode", + "enum_full_class_name": "QHostAddress.ConversionModeFlag", + "enum_value1": "ConvertV4MappedToIPv4", + "enum_value2": "ConvertV4CompatToIPv4", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BindMode", + "enum_class": "BindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag)" + ], + "qflag_full_class_name": "QAbstractSocket.BindMode", + "enum_full_class_name": "QAbstractSocket.BindFlag", + "enum_value1": "DefaultForPlatform", + "enum_value2": "ShareAddress", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PauseModes", + "enum_class": "PauseMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode)" + ], + "qflag_full_class_name": "QAbstractSocket.PauseModes", + "enum_full_class_name": "QAbstractSocket.PauseMode", + "enum_value1": "PauseNever", + "enum_value2": "PauseOnSslErrors", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PageBreakFlags", + "enum_class": "PageBreakFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)" + ], + "qflag_full_class_name": "QTextFormat.PageBreakFlags", + "enum_full_class_name": "QTextFormat.PageBreakFlag", + "enum_value1": "PageBreak_Auto", + "enum_value2": "PageBreak_AlwaysBefore", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SocketOptions", + "enum_class": "SocketOption", + "human_hint_qflag_full_class_name": "QLocalServer.SocketOptions", + "human_hint_enum_full_class_name": "QLocalServer.SocketOption", + "grep_line": [ + "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" + ], + "qflag_full_class_name": "QLocalServer.SocketOptions", + "enum_full_class_name": "QLocalServer.SocketOption", + "enum_value1": "UserAccessOption", + "enum_value2": "GroupAccessOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InterfaceFlags", + "enum_class": "InterfaceFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\kernel\\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)" + ], + "qflag_full_class_name": "QNetworkInterface.InterfaceFlags", + "enum_full_class_name": "QNetworkInterface.InterfaceFlag", + "enum_value1": "IsUp", + "enum_value2": "IsRunning", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SslOptions", + "enum_class": "SslOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\ssl\\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption)" + ], + "qflag_full_class_name": "QSsl.SslOptions", + "enum_full_class_name": "QSsl.SslOption", + "enum_value1": "SslOptionDisableEmptyFragments", + "enum_value2": "SslOptionDisableSessionTickets", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Base64Options", + "enum_class": "Base64Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option)" + ], + "qflag_full_class_name": "QByteArray.Base64Options", + "enum_full_class_name": "QByteArray.Base64Option", + "enum_value1": "Base64Encoding", + "enum_value2": "Base64UrlEncoding", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "NumberOptions", + "enum_class": "NumberOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption)" + ], + "qflag_full_class_name": "QLocale.NumberOptions", + "enum_full_class_name": "QLocale.NumberOption", + "enum_value1": "OmitGroupSeparator", + "enum_value2": "RejectGroupSeparator", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DataSizeFormats", + "enum_class": "DataSizeFormat", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat)" + ], + "qflag_full_class_name": "QLocale.DataSizeFormats", + "enum_full_class_name": "QLocale.DataSizeFormat", + "enum_value1": "DataSizeIecFormat", + "enum_value2": "DataSizeTraditionalFormat", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "Sections", + "enum_class": "Section", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\time\\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section)", + "src\\widgets\\widgets\\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section)" + ], + "qflag_full_class_name": "QDateTimeEdit.Sections", + "enum_full_class_name": "QDateTimeEdit.Section", + "enum_value1": "NoSection", + "enum_value2": "AmPmSection", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PatternOptions", + "enum_class": "PatternOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption)" + ], + "qflag_full_class_name": "QRegularExpression.PatternOptions", + "enum_full_class_name": "QRegularExpression.PatternOption", + "enum_value1": "NoPatternOption", + "enum_value2": "CaseInsensitiveOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MatchOptions", + "enum_class": "MatchOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption)" + ], + "qflag_full_class_name": "QRegularExpression.MatchOptions", + "enum_full_class_name": "QRegularExpression.MatchOption", + "enum_value1": "NoMatchOption", + "enum_value2": "AnchoredMatchOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "NumberFlags", + "enum_class": "NumberFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\serialization\\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag)" + ], + "qflag_full_class_name": "QTextStream.NumberFlags", + "enum_full_class_name": "QTextStream.NumberFlag", + "enum_value1": "ShowBase", + "enum_value2": "ForcePoint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BoundaryReasons", + "enum_class": "BoundaryReason", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )" + ], + "qflag_full_class_name": "QTextBoundaryFinder.BoundaryReasons", + "enum_full_class_name": "QTextBoundaryFinder.BoundaryReason", + "enum_value1": "NotAtBoundary", + "enum_value2": "SoftHyphen", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PrintDialogOptions", + "enum_class": "PrintDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\printsupport\\dialogs\\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)" + ], + "qflag_full_class_name": "QAbstractPrintDialog.PrintDialogOptions", + "enum_full_class_name": "QAbstractPrintDialog.PrintDialogOption", + "enum_value1": "None_", + "enum_value2": "PrintToFile", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPrintSupport", + "module_path": "../../PyQt5-stubs/QtPrintSupport.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ParamType", + "enum_class": "ParamTypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\sql\\kernel\\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag)" + ], + "qflag_full_class_name": "QSql.ParamType", + "enum_full_class_name": "QSql.ParamTypeFlag", + "enum_value1": "In", + "enum_value2": "Out", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSql", + "module_path": "../../PyQt5-stubs/QtSql.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "QFileDialog.Options", + "enum_full_class_name": "QFileDialog.Option", + "enum_value1": "ShowDirsOnly", + "enum_value2": "DontResolveSymlinks", + "module_count": 3, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "QFileIconProvider.Options", + "enum_full_class_name": "QFileIconProvider.Option", + "enum_value1": "DontUseCustomDirectoryIcons", + "enum_value2": "DontUseCustomDirectoryIcons", + "module_count": 3, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "QFileSystemModel.Options", + "enum_full_class_name": "QFileSystemModel.Option", + "enum_value1": "DontWatchForChanges", + "enum_value2": "DontResolveSymlinks", + "module_count": 3, + "module_idx": 2, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "QPinchGesture.ChangeFlags", + "enum_full_class_name": "QPinchGesture.ChangeFlag", + "enum_value1": "ScaleFactorChanged", + "enum_value2": "RotationAngleChanged", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "QGraphicsEffect.ChangeFlags", + "enum_full_class_name": "QGraphicsEffect.ChangeFlag", + "enum_value1": "SourceAttached", + "enum_value2": "SourceDetached", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BlurHints", + "enum_class": "BlurHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint)" + ], + "qflag_full_class_name": "QGraphicsBlurEffect.BlurHints", + "enum_full_class_name": "QGraphicsBlurEffect.BlurHint", + "enum_value1": "PerformanceHint", + "enum_value2": "QualityHint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InputDialogOptions", + "enum_class": "InputDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)" + ], + "qflag_full_class_name": "QInputDialog.InputDialogOptions", + "enum_full_class_name": "QInputDialog.InputDialogOption", + "enum_value1": "NoButtons", + "enum_value2": "UseListViewForComboBoxItems", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WizardOptions", + "enum_class": "WizardOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption)" + ], + "qflag_full_class_name": "QWizard.WizardOptions", + "enum_full_class_name": "QWizard.WizardOption", + "enum_value1": "IndependentPages", + "enum_value2": "IgnoreSubTitles", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "EditTriggers", + "enum_class": "EditTrigger", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\itemviews\\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger)" + ], + "qflag_full_class_name": "QAbstractItemView.EditTriggers", + "enum_full_class_name": "QAbstractItemView.EditTrigger", + "enum_value1": "NoEditTriggers", + "enum_value2": "CurrentChanged", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "GraphicsItemFlags", + "enum_class": "GraphicsItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)" + ], + "qflag_full_class_name": "QGraphicsItem.GraphicsItemFlags", + "enum_full_class_name": "QGraphicsItem.GraphicsItemFlag", + "enum_value1": "ItemIsMovable", + "enum_value2": "ItemIsSelectable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Result", + "enum_class": "ResultFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\kernel\\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag)" + ], + "qflag_full_class_name": "QGestureRecognizer.Result", + "enum_full_class_name": "QGestureRecognizer.ResultFlag", + "enum_value1": "Ignore", + "enum_value2": "MayBeGesture", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SceneLayers", + "enum_class": "SceneLayer", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer)" + ], + "qflag_full_class_name": "QGraphicsScene.SceneLayers", + "enum_full_class_name": "QGraphicsScene.SceneLayer", + "enum_value1": "ItemLayer", + "enum_value2": "BackgroundLayer", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "CacheMode", + "enum_class": "CacheModeFlag", + "human_hint_qflag_full_class_name": "QGraphicsView.CacheMode", + "human_hint_enum_full_class_name": "QGraphicsView.CacheModeFlag", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)" + ], + "qflag_full_class_name": "QGraphicsView.CacheMode", + "enum_full_class_name": "QGraphicsView.CacheModeFlag", + "enum_value1": "CacheNone", + "enum_value2": "CacheBackground", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "OptimizationFlags", + "enum_class": "OptimizationFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)" + ], + "qflag_full_class_name": "QGraphicsView.OptimizationFlags", + "enum_full_class_name": "QGraphicsView.OptimizationFlag", + "enum_value1": "DontClipPainter", + "enum_value2": "DontSavePainterState", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SubControls", + "enum_class": "SubControl", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl)" + ], + "qflag_full_class_name": "QStyle.SubControls", + "enum_full_class_name": "QStyle.SubControl", + "enum_value1": "SC_None", + "enum_value2": "SC_ScrollBarAddLine", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "StepEnabled", + "enum_class": "StepEnabledFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)" + ], + "qflag_full_class_name": "QAbstractSpinBox.StepEnabled", + "enum_full_class_name": "QAbstractSpinBox.StepEnabledFlag", + "enum_value1": "StepNone", + "enum_value2": "StepUpEnabled", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FrameFeatures", + "enum_class": "FrameFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)" + ], + "qflag_full_class_name": "QStyleOptionFrame.FrameFeatures", + "enum_full_class_name": "QStyleOptionFrame.FrameFeature", + "enum_value1": "None_", + "enum_value2": "Flat", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ButtonFeatures", + "enum_class": "ButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)" + ], + "qflag_full_class_name": "QStyleOptionButton.ButtonFeatures", + "enum_full_class_name": "QStyleOptionButton.ButtonFeature", + "enum_value1": "None_", + "enum_value2": "Flat", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "CornerWidgets", + "enum_class": "CornerWidget", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)" + ], + "qflag_full_class_name": "QStyleOptionTab.CornerWidgets", + "enum_full_class_name": "QStyleOptionTab.CornerWidget", + "enum_value1": "NoCornerWidgets", + "enum_value2": "LeftCornerWidget", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "TabFeatures", + "enum_class": "TabFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature)" + ], + "qflag_full_class_name": "QStyleOptionTab.TabFeatures", + "enum_full_class_name": "QStyleOptionTab.TabFeature", + "enum_value1": "None_", + "enum_value2": "HasFrame", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "ToolBarFeatures", + "enum_class": "ToolBarFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)" + ], + "qflag_full_class_name": "QStyleOptionToolBar.ToolBarFeatures", + "enum_full_class_name": "QStyleOptionToolBar.ToolBarFeature", + "enum_value1": "None_", + "enum_value2": "Movable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ViewItemFeatures", + "enum_class": "ViewItemFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)" + ], + "qflag_full_class_name": "QStyleOptionViewItem.ViewItemFeatures", + "enum_full_class_name": "QStyleOptionViewItem.ViewItemFeature", + "enum_value1": "None_", + "enum_value2": "WrapText", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ToolButtonFeatures", + "enum_class": "ToolButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)" + ], + "qflag_full_class_name": "QStyleOptionToolButton.ToolButtonFeatures", + "enum_full_class_name": "QStyleOptionToolButton.ToolButtonFeature", + "enum_value1": "None_", + "enum_value2": "Arrow", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DockWidgetFeatures", + "enum_class": "DockWidgetFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)" + ], + "qflag_full_class_name": "QDockWidget.DockWidgetFeatures", + "enum_full_class_name": "QDockWidget.DockWidgetFeature", + "enum_value1": "DockWidgetClosable", + "enum_value2": "DockWidgetMovable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FontFilters", + "enum_class": "FontFilter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter)" + ], + "qflag_full_class_name": "QFontComboBox.FontFilters", + "enum_full_class_name": "QFontComboBox.FontFilter", + "enum_value1": "AllFonts", + "enum_value2": "ScalableFonts", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "AreaOptions", + "enum_class": "AreaOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption)" + ], + "qflag_full_class_name": "QMdiArea.AreaOptions", + "enum_full_class_name": "QMdiArea.AreaOption", + "enum_value1": "DontMaximizeSubWindowOnActivation", + "enum_value2": "DontMaximizeSubWindowOnActivation", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SubWindowOptions", + "enum_class": "SubWindowOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)" + ], + "qflag_full_class_name": "QMdiSubWindow.SubWindowOptions", + "enum_full_class_name": "QMdiSubWindow.SubWindowOption", + "enum_value1": "RubberBandResize", + "enum_value2": "RubberBandMove", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DockOptions", + "enum_class": "DockOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption)" + ], + "qflag_full_class_name": "QMainWindow.DockOptions", + "enum_full_class_name": "QMainWindow.DockOption", + "enum_value1": "AnimatedDocks", + "enum_value2": "AllowNestedDocks", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "AutoFormatting", + "enum_class": "AutoFormattingFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)" + ], + "qflag_full_class_name": "QTextEdit.AutoFormatting", + "enum_full_class_name": "QTextEdit.AutoFormattingFlag", + "enum_value1": "AutoNone", + "enum_value2": "AutoBulletList", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + } + ], + "qflag_processed_done": [ + { + "qflag_class": "CheckIndexOptions", + "enum_class": "CheckIndexOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\itemmodels\\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)" + ], + "qflag_full_class_name": "QAbstractItemModel.CheckIndexOptions", + "enum_full_class_name": "QAbstractItemModel.CheckIndexOption", + "enum_value1": "NoOption", + "enum_value2": "IndexIsValid", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + } + ], + "qflag_process_error": [ + { + "qflag_class": "FormattingOptions", + "enum_class": "UrlFormattingOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)" + ], + "qflag_full_class_name": "QUrl.FormattingOptions", + "enum_full_class_name": "QUrl.UrlFormattingOption", + "enum_value1": "None_", + "enum_value2": "RemoveScheme", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "error": [ + "Enum methods are present but not QFlag methods" + ] + }, + { + "qflag_class": "State", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "QStyle.StateFlag", + "enum_value1": "State_None", + "enum_value2": "State_Enabled", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "error": [ + "Could not locate class State" + ] + } + ] +} \ No newline at end of file From 5fc7ec6053e8dbbd09e3201d37f9e679c722a402 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 17 Nov 2021 15:48:00 +0100 Subject: [PATCH 263/421] More module groups --- .../qflags/generate_qflags_stubs_and_tests.py | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 8cea63d2..670d2163 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -37,19 +37,30 @@ '''.format(prog=sys.argv[0]) -QTBASE_MODULES = { - 'QtCore': '../../PyQt5-stubs/QtCore.pyi', - 'QtWidgets': '../../PyQt5-stubs/QtWidgets.pyi', - 'QtGui': '../../PyQt5-stubs/QtGui.pyi', - 'QtNetwork': '../../PyQt5-stubs/QtNetwork.pyi', - 'QtDBus': '../../PyQt5-stubs/QtDBus.pyi', - 'QtOpenGL': '../../PyQt5-stubs/QtOpenGL.pyi', - 'QtPrintSupport': '../../PyQt5-stubs/QtPrintSupport.pyi', - 'QtSql': '../../PyQt5-stubs/QtSql.pyi', - 'QtTest': '../../PyQt5-stubs/QtTest.pyi', - 'QtXml': '../../PyQt5-stubs/QtXml.pyi', +MODULE_GROUPS = { + 'qtbase': [ + 'QtCore', + 'QtWidgets', + 'QtGui', + 'QtNetwork', + 'QtDBus', + 'QtOpenGL', + 'QtPrintSupport', + 'QtSql', + 'QtTest', + 'QtXml', + ], + 'qt3d': [ + 'Qt3DAnimation.pyi', + 'Qt3DCore.pyi', + 'Qt3DExtras.pyi', + 'Qt3DInput.pyi', + 'Qt3DLogic.pyi', + 'Qt3DRender.pyi', + ] } + def log_progress(s: str) -> None: print('>>>>>>>>>>>>>>', s) @@ -107,7 +118,7 @@ def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[s def identify_qflag_location(fname_grep_result: str, - qt_modules: Dict[str, str], + qt_modules: List[str] ) -> List[ QFlagLocationInfo ]: '''Parses the grep results to extract each qflag, and then look into all Qt modules to see where the flag is located. @@ -138,8 +149,8 @@ def identify_qflag_location(fname_grep_result: str, parsed_qflags[(qflag_class, enum_class)] = QFlagLocationInfo(qflag_class, enum_class, grep_line=(grep_line,)) # fill up modules with content - qt_modules_content = [ (mod_name, open(mod_stub_path, encoding='utf8').read()) - for (mod_name, mod_stub_path) in qt_modules.items()] + qt_modules_content = [ (mod_name, open('../../PyQt5-stubs/%s.pyi' % mod_name, encoding='utf8').read()) + for mod_name in qt_modules.items()] # associate a qflag enum/class with a mapping from module to QFlagLocationInfo module_mapping: Dict[ Tuple[str, str], Dict[str, QFlagLocationInfo]] = {} @@ -180,7 +191,7 @@ def identify_qflag_location(fname_grep_result: str, while idx < flag_info.module_count: all_qflags.append(dataclasses.replace(flag_info, module_idx=idx, module_name=mod_name, - module_path=qt_modules[mod_name])) + module_path='../../PyQt5-stubs/%s.pyi' % mod_name)) idx += 1 return all_qflags @@ -1033,7 +1044,7 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: def generate_qflags_to_process(qt_qflag_grep_result_fname): '''Run the generation process from the grep output parsing to the generation of json file listing the flags to process''' - location_qflags = identify_qflag_location(qt_qflag_grep_result_fname, QTBASE_MODULES) + location_qflags = identify_qflag_location(qt_qflag_grep_result_fname, MODULE_GROUPS['qtbase']) log_progress('%d qflags extracted from grep file' % len(location_qflags)) qflags_groups = group_qflags(location_qflags) log_progress('%d qflags ready to be processed' % len(qflags_groups['flag_and_module_identified'])) From fb4ea8aaac99a896d68fe35e35195e1275cd8836 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 17 Nov 2021 15:55:54 +0100 Subject: [PATCH 264/421] Enable Python 3.10 on Windows with a later versions of requirements --- .github/workflows/ci.yml | 6 +++--- requirements/develop.txt | 2 +- requirements/production.txt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34177b50..b4c34a36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,9 +49,9 @@ jobs: name: Windows runs-on: windows-latest python: - name: CPython 3.9 - tox: py39 - action: '3.9' + name: CPython 3.10 + tox: py310 + action: '3.10' steps: - uses: actions/checkout@v2 - name: Set up ${{ matrix.python.name }} diff --git a/requirements/develop.txt b/requirements/develop.txt index 762963b8..16656f3c 100644 --- a/requirements/develop.txt +++ b/requirements/develop.txt @@ -20,7 +20,7 @@ py==1.10.0 # via pytest pyparsing==2.4.7 # via packaging -pyqt5==5.15.4 +pyqt5==5.15.6 # via -r requirements/production.txt pyqt5-sip==12.9.0 # via diff --git a/requirements/production.txt b/requirements/production.txt index c66b0197..9ef7efdd 100644 --- a/requirements/production.txt +++ b/requirements/production.txt @@ -4,7 +4,7 @@ # # pip-compile --output-file=requirements/production.txt requirements/production.in # -pyqt5==5.15.4 +pyqt5==5.15.6 # via -r requirements/production.in pyqt5-qt5==5.15.2 # via pyqt5 From b22b4a89a58e2b27aed8eb4eaabbea9aed3043a8 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 17 Nov 2021 16:24:55 +0100 Subject: [PATCH 265/421] Group modules into where to look for qflags implementation --- .../qflags/generate_qflags_stubs_and_tests.py | 101 +++++++++++------- tests/qflags/qflags_to_process.json | 86 ++++++++++++++- 2 files changed, 148 insertions(+), 39 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 670d2163..e1691c97 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -18,25 +18,6 @@ raise ImportError('You need libcst to run the missing stubs generation\n' 'Please run the command:\n\tpython -m pip install libcst') - -USAGE = '''Usage 1: {prog} analyse_grep_results - Process the to extract all the qflag location information. Generates - two output: - - qflags_modules_analysis.json : a general file describing which qflag are suitable for processing - - qflags_to_process.json: a list of qflag ready to process with the next command. - -Usage 2: {prog} gen_qflag_stub (|all) (--auto-commit) - Using file qflag_to_process.json, process qflags and modify the PyQt modules. - The output of this processing is available in qflags_process_result.json - - If is not provided, defaults to 1. If "all" is provied, all qflags - are processed. - - If --auto-commit is specified, a git commit is performed after each successful QFlag validation - -'''.format(prog=sys.argv[0]) - - MODULE_GROUPS = { 'qtbase': [ 'QtCore', @@ -51,16 +32,40 @@ 'QtXml', ], 'qt3d': [ - 'Qt3DAnimation.pyi', - 'Qt3DCore.pyi', - 'Qt3DExtras.pyi', - 'Qt3DInput.pyi', - 'Qt3DLogic.pyi', - 'Qt3DRender.pyi', + 'Qt3DAnimation', + 'Qt3DCore', + 'Qt3DExtras', + 'Qt3DInput', + 'Qt3DLogic', + 'Qt3DRender', ] } +USAGE = '''Usage 1: {prog} analyse_grep_results --group + Process the to extract all the qflag location information. + + Generates two output: + - qflags_modules_analysis.json : a general file describing which qflag are suitable for processing + - qflags_to_process.json: a list of qflag ready to process with the next command. + + The is the name of a group of modules to see where to look for for the exact name + of the qflags. Possible modules groups are: + - {groups} + +Usage 2: {prog} gen_qflag_stub (|all) (--auto-commit) + Using file qflag_to_process.json, process qflags and modify the PyQt modules. + The output of this processing is available in qflags_process_result.json + + If is not provided, defaults to 1. If "all" is provied, all qflags + are processed. + + If --auto-commit is specified, a git commit is performed after each successful QFlag validation + +'''.format(prog=sys.argv[0], groups='\n - '.join(MODULE_GROUPS.keys())) + + + def log_progress(s: str) -> None: print('>>>>>>>>>>>>>>', s) @@ -150,18 +155,21 @@ def identify_qflag_location(fname_grep_result: str, # fill up modules with content qt_modules_content = [ (mod_name, open('../../PyQt5-stubs/%s.pyi' % mod_name, encoding='utf8').read()) - for mod_name in qt_modules.items()] + for mod_name in qt_modules] # associate a qflag enum/class with a mapping from module to QFlagLocationInfo module_mapping: Dict[ Tuple[str, str], Dict[str, QFlagLocationInfo]] = {} + flag_not_found = [] for qflag_key, flag_info in parsed_qflags.items(): decl_qflag_class = 'class %s(sip.simplewrapper' % flag_info.qflag_class decl_enum_class = 'class %s(int' % flag_info.enum_class + module_found = False for mod_name, mod_content in qt_modules_content: if decl_qflag_class in mod_content and decl_enum_class in mod_content: # we have found one module + module_found = True # print('Adding QFlags %s to module %s' % (flag_info.qflag_class, mod_name)) if qflag_key not in module_mapping: module_mapping[qflag_key] = {} @@ -182,6 +190,9 @@ def identify_qflag_location(fname_grep_result: str, # print('QFlag present more than once, adding it more than once') mod_map[mod_name].module_count += min(count_qflag_class, count_enum_class) - 1 + if not module_found: + flag_not_found.append(qflag_key) + # now, we flatten the structure by recreating one QFlagLocationInfo per module location all_qflags: List[QFlagLocationInfo] = [] @@ -194,6 +205,9 @@ def identify_qflag_location(fname_grep_result: str, module_path='../../PyQt5-stubs/%s.pyi' % mod_name)) idx += 1 + for qflag_key in flag_not_found: + all_qflags.append(parsed_qflags[qflag_key]) + return all_qflags @@ -221,6 +235,7 @@ def group_qflags(qflag_location: List[QFlagLocationInfo] ) -> Dict[str, List[QFl def extract_qflags_to_process(qflags_modules_analysis_json: str, qflags_to_process_json: str, + module_group: str, ) -> None: '''Take the json file as input describing qflags and their modules and output a json file of qflags planned to be processed. @@ -230,18 +245,22 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, with open(qflags_modules_analysis_json) as f: d = json.load(f) - result = { - '__': 'This file can be adjusted manually by a human prior to being processed by the tool', - 'qflags_to_process': [], - 'qflags_to_skip': [], - } + if os.path.exists(qflags_to_process_json): + with open(qflags_to_process_json) as f: + result = json.load(f) + else: + result = { + '__': 'This file can be adjusted manually by a human prior to being processed by the tool', + 'qflags_to_process': [], + 'qflags_to_skip': [], + } for flag_info in d['flag_without_module']: cast(List, result['qflags_to_skip']).append( { 'qflag_class': flag_info['qflag_class'], 'enum_class': flag_info['enum_class'], - 'skip_reason': 'QFlag not found', + 'skip_reason': 'QFlag not found in module group %s' % module_group, } ) @@ -1042,9 +1061,9 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: log_progress('Test file generated: %s' % test_qflag_fname) -def generate_qflags_to_process(qt_qflag_grep_result_fname): +def generate_qflags_to_process(qt_qflag_grep_result_fname: str, module_group: str) -> None: '''Run the generation process from the grep output parsing to the generation of json file listing the flags to process''' - location_qflags = identify_qflag_location(qt_qflag_grep_result_fname, MODULE_GROUPS['qtbase']) + location_qflags = identify_qflag_location(qt_qflag_grep_result_fname, MODULE_GROUPS[module_group]) log_progress('%d qflags extracted from grep file' % len(location_qflags)) qflags_groups = group_qflags(location_qflags) log_progress('%d qflags ready to be processed' % len(qflags_groups['flag_and_module_identified'])) @@ -1056,7 +1075,7 @@ def generate_qflags_to_process(qt_qflag_grep_result_fname): log_progress('QFlag analysis saved to: %s' % qflags_modules_analysis_json) qflags_to_process_json = 'qflags_to_process.json' - extract_qflags_to_process(qflags_modules_analysis_json, qflags_to_process_json) + extract_qflags_to_process(qflags_modules_analysis_json, qflags_to_process_json, module_group) log_progress('qflag file ready to process: %s' % qflags_to_process_json) @@ -1106,13 +1125,19 @@ def regen_test_files(qflag_process_results: str) -> None: log_progress('All qflags are processed.') elif sys.argv[1] == 'analyse_grep_results': - if len(sys.argv) <= 2: - print('Error, you must provide the filename of the grep results\n') + if len(sys.argv) <= 4 or sys.argv[3] != '--group': + print('Error, you must provide the filename of the grep results and the group of modules to use\n') print(USAGE) sys.exit(1) grep_fname = sys.argv[2] - generate_qflags_to_process(grep_fname) + module_group = sys.argv[4] + if not module_group in MODULE_GROUPS: + print('Unknown module group: %s' % module_group) + print('Possible choices are:\n-', '\n- '.join(MODULE_GROUPS.keys())) + sys.exit(0) + + generate_qflags_to_process(grep_fname, module_group) elif sys.argv[1] == 'regen_test_files': diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index 9c7e56b7..83237016 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -2187,7 +2187,91 @@ "module_idx": 0, "module_name": "QtWidgets", "module_path": "../../PyQt5-stubs/QtWidgets.pyi" + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h:Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + }, + { + "qflag_class": "DeliveryFlags", + "enum_class": "DeliveryFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h: Q_DECLARE_FLAGS(DeliveryFlags, DeliveryFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + }, + { + "qflag_class": "BufferTypeFlags", + "enum_class": "BufferType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qclearbuffers.h: Q_DECLARE_FLAGS(BufferTypeFlags, BufferType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + }, + { + "qflag_class": "Operations", + "enum_class": "Operation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qmemorybarrier.h: Q_DECLARE_FLAGS(Operations, Operation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" } ], - "qflags_to_skip": [] + "qflags_to_skip": [ + { + "qflag_class": "Flags", + "enum_class": "Flag", + "skip_reason": "QFlag not found" + }, + { + "qflag_class": "BackendNodeDirtySet", + "enum_class": "BackendNodeDirtyFlag", + "skip_reason": "QFlag not found" + }, + { + "qflag_class": "DirtyFlags", + "enum_class": "DirtyFlag", + "skip_reason": "QFlag not found" + } + ] } \ No newline at end of file From 5f5a1e71b7360c5e87aa36898edfbd917412aacd Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 17 Nov 2021 21:59:39 +0100 Subject: [PATCH 266/421] Stick to Python 3.9 because Python 3.10 wheels are not available for secondary PyQt modules PyQt3d, PyQtCharts, ... --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4c34a36..34177b50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,9 +49,9 @@ jobs: name: Windows runs-on: windows-latest python: - name: CPython 3.10 - tox: py310 - action: '3.10' + name: CPython 3.9 + tox: py39 + action: '3.9' steps: - uses: actions/checkout@v2 - name: Set up ${{ matrix.python.name }} From ed7bf08c70d8cea08f6e1350dc437705c388e52b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 17 Nov 2021 22:58:25 +0100 Subject: [PATCH 267/421] QFlag operations for QMemoryBarrier.Operations, QMemoryBarrier.Operation in module Qt3DRender --- PyQt5-stubs/Qt3DRender.pyi | 8 + .../test_Qt3DRender_Operations_Operation.py | 266 ++++++++++++++++++ 2 files changed, 274 insertions(+) create mode 100644 tests/qflags/test_Qt3DRender_Operations_Operation.py diff --git a/PyQt5-stubs/Qt3DRender.pyi b/PyQt5-stubs/Qt3DRender.pyi index 43b9e810..0f8fc61c 100644 --- a/PyQt5-stubs/Qt3DRender.pyi +++ b/PyQt5-stubs/Qt3DRender.pyi @@ -1483,12 +1483,20 @@ class QMemoryBarrier('QFrameGraphNode'): def __init__(self, f: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... @typing.overload def __init__(self, a0: 'QMemoryBarrier.Operations') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QMemoryBarrier.Operations': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation', int]) -> 'QMemoryBarrier.Operations': ... + def __and__(self, other: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation', int]) -> 'QMemoryBarrier.Operations': ... + def __xor__(self, other: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation', int]) -> 'QMemoryBarrier.Operations': ... + def __ror__ (self, other: 'QMemoryBarrier.Operation') -> 'QMemoryBarrier.Operations': ... + def __rand__(self, other: 'QMemoryBarrier.Operation') -> 'QMemoryBarrier.Operations': ... + def __rxor__(self, other: 'QMemoryBarrier.Operation') -> 'QMemoryBarrier.Operations': ... def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... diff --git a/tests/qflags/test_Qt3DRender_Operations_Operation.py b/tests/qflags/test_Qt3DRender_Operations_Operation.py new file mode 100644 index 00000000..c9c70a12 --- /dev/null +++ b/tests/qflags/test_Qt3DRender_Operations_Operation.py @@ -0,0 +1,266 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union, TypeVar, Type +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QMemoryBarrier.Operations" and flag class "QMemoryBarrier.Operation" +from PyQt5 import Qt3DRender + +OneFlagClass = Qt3DRender.QMemoryBarrier.Operation +MultiFlagClass = Qt3DRender.QMemoryBarrier.Operations + +oneFlagRefValue1 = Qt3DRender.QMemoryBarrier.Operation.None_ +oneFlagRefValue2 = Qt3DRender.QMemoryBarrier.Operation.VertexAttributeArray + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 161f32876ec98d23930a6db569dc248517565d31 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 17 Nov 2021 23:02:13 +0100 Subject: [PATCH 268/421] Cache CST parsed modules --- .../qflags/generate_qflags_stubs_and_tests.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index e1691c97..8e1cac31 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -418,6 +418,23 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: log_progress('.') return len(qflags_to_process) +local_cst_module_cache: Dict[str, Tuple[str, cst.Module]] = {} + +def retrieve_cst_parsed_module(mod_name: str, mod_content: str) -> cst.Module: + '''Return the cst parsed module and cache the result for each module name''' + if mod_name in local_cst_module_cache: + cached_mod_content, cached_parsed_module = local_cst_module_cache[mod_name] + if cached_mod_content == mod_content: + log_progress('Returning cached %s parse results' % mod_name) + return cached_parsed_module + else: + log_progress('Updating cache for module %s' % mod_name) + else: + log_progress('Parsing module %s and adding it to cache' % mod_name) + + parsed_module = cst.parse_module(mod_content) + local_cst_module_cache[mod_name] = (mod_content, parsed_module) + return parsed_module class QFlagGenResult(Enum): @@ -485,8 +502,7 @@ class not found, class found multiple times, ... with open(flag_info.module_path) as f: mod_content = f.read() - log_progress('Parsing module %s' % flag_info.module_name) - mod_cst = cst.parse_module(mod_content) + mod_cst = retrieve_cst_parsed_module(flag_info.module_name, mod_content) log_progress('Looking for class %s and %s in module %s, index %d' % (flag_info.qflag_class, flag_info.enum_class, flag_info.module_name, flag_info.module_idx)) From 177d1d819cab8517a3d336e17c771d0a22e9ceb0 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 17 Nov 2021 23:02:26 +0100 Subject: [PATCH 269/421] Add more module support --- tests/qflags/generate_qflags_stubs_and_tests.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 8e1cac31..ff12c24c 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -10,7 +10,9 @@ from enum import Enum from PyQt5 import (QtCore, QtWidgets, QtGui, QtNetwork, QtDBus, QtOpenGL, - QtPrintSupport, QtSql, QtTest, QtXml) + QtPrintSupport, QtSql, QtTest, QtXml, + Qt3DAnimation, Qt3DCore, Qt3DExtras, Qt3DInput, Qt3DLogic, Qt3DRender, + ) try: import libcst as cst import libcst.matchers as matchers From 383461503e6ef5608a195abe5a610c8c6fe77b1d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 09:04:43 +0100 Subject: [PATCH 270/421] QFlag operations for QClearBuffers.BufferTypeFlags, QBuffer.BufferType in module Qt3DRender --- PyQt5-stubs/Qt3DRender.pyi | 16 ++ ...t_Qt3DRender_BufferTypeFlags_BufferType.py | 272 ++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100644 tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py diff --git a/PyQt5-stubs/Qt3DRender.pyi b/PyQt5-stubs/Qt3DRender.pyi index 0f8fc61c..902253cd 100644 --- a/PyQt5-stubs/Qt3DRender.pyi +++ b/PyQt5-stubs/Qt3DRender.pyi @@ -987,12 +987,28 @@ class QClearBuffers('QFrameGraphNode'): def __init__(self, f: typing.Union['QClearBuffers.BufferTypeFlags', 'QClearBuffers.BufferType']) -> None: ... @typing.overload def __init__(self, a0: 'QClearBuffers.BufferTypeFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QClearBuffers.BufferTypeFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QClearBuffers.BufferTypeFlags', 'QClearBuffers.BufferType', int]) -> 'QClearBuffers.BufferTypeFlags': ... + def __and__(self, other: typing.Union['QClearBuffers.BufferTypeFlags', 'QClearBuffers.BufferType', int]) -> 'QClearBuffers.BufferTypeFlags': ... + def __xor__(self, other: typing.Union['QClearBuffers.BufferTypeFlags', 'QClearBuffers.BufferType', int]) -> 'QClearBuffers.BufferTypeFlags': ... + def __ror__ (self, other: 'QClearBuffers.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... + def __rand__(self, other: 'QClearBuffers.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... + def __rxor__(self, other: 'QClearBuffers.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... + def __or__ (self, other: typing.Union['QClearBuffers.BufferTypeFlags', 'QBuffer.BufferType', int]) -> 'QClearBuffers.BufferTypeFlags': ... + def __and__(self, other: typing.Union['QClearBuffers.BufferTypeFlags', 'QBuffer.BufferType', int]) -> 'QClearBuffers.BufferTypeFlags': ... + def __xor__(self, other: typing.Union['QClearBuffers.BufferTypeFlags', 'QBuffer.BufferType', int]) -> 'QClearBuffers.BufferTypeFlags': ... + def __ror__ (self, other: 'QBuffer.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... + def __rand__(self, other: 'QBuffer.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... + def __rxor__(self, other: 'QBuffer.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... diff --git a/tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py b/tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py new file mode 100644 index 00000000..267b5f8c --- /dev/null +++ b/tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QClearBuffers.BufferTypeFlags" and flag class "QBuffer.BufferType" +from PyQt5 import Qt3DRender + +OneFlagClass = Qt3DRender.QBuffer.BufferType +MultiFlagClass = Qt3DRender.QClearBuffers.BufferTypeFlags + +oneFlagRefValue1 = Qt3DRender.QBuffer.BufferType.VertexBuffer +oneFlagRefValue2 = Qt3DRender.QBuffer.BufferType.IndexBuffer + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[False] = False +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From ad91fc974d76544eebc7c16859124361531c0519 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 09:07:01 +0100 Subject: [PATCH 271/421] One additional behavior for enum/qflqgs --- .../qflags/generate_qflags_stubs_and_tests.py | 18 ++++++++++++++++-- tests/qflags/qflags_test_template.py | 19 ++++++++++++------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index ff12c24c..f42ec320 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -106,6 +106,7 @@ class QFlagLocationInfo: or_converts_to_multi: bool = True or_int_converts_to_multi: bool = False int_or_converts_to_multi: bool = True + supports_one_op_multi: bool = True def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[str, Any]]: @@ -120,6 +121,7 @@ def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[s del d["or_converts_to_multi"] del d["or_int_converts_to_multi"] del d["int_or_converts_to_multi"] + del d["supports_one_op_multi"] return d @@ -537,6 +539,15 @@ class not found, class found multiple times, ... flag_info.int_or_converts_to_multi = not eval('''type(33 | {qtmodule}.{oneFlagName}.{value1}) == int'''.format( value1=flag_info.enum_value1, qtmodule = flag_info.module_name, oneFlagName = flag_info.enum_full_class_name)) + try: + flag_info.supports_one_op_multi = True + eval('''{qtmodule}.{oneFlagName} | {qtmodule}.{multiFlagName}()''').format( + oneFlagName=flag_info.enum_value1, multiFlagName=flag_info.qflag_full_class_name, + qtmodule=flag_info.module_name + ) + except Exception: + flag_info.supports_one_op_multi = False + if visitor.enum_class_full_name == '': return (QFlagGenResult.ErrorDuringProcessing, 'Could not locate class %s' % visitor.enum_class_name, '') @@ -562,10 +573,11 @@ class not found, class found multiple times, ... log_progress('Found %s and %s' % (flag_info.qflag_full_class_name, flag_info.enum_full_class_name)) - print('OR behavior:') + print('enum behavior:') print('- or_converts_to_multi: ', flag_info.or_converts_to_multi) print('- or_int_converts_to_multi: ', flag_info.or_int_converts_to_multi) print('- int_or_converts_to_multi: ', flag_info.int_or_converts_to_multi) + print('- supports_one_op_multi: ', flag_info.supports_one_op_multi) log_progress('Updating module %s by adding new methods' % flag_info.module_name) transformer = QFlagAndEnumUpdater(visitor.enum_class_name, visitor.enum_class_full_name, @@ -1065,6 +1077,7 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: OR_CONVERTS_TO_MULTI: Literal[{or_converts_to_multi}] = {or_converts_to_multi} OR_INT_CONVERTS_TO_MULTI: Literal[{or_int_converts_to_multi}] = {or_int_converts_to_multi} INT_OR_CONVERTS_TO_MULTI: Literal[{int_or_converts_to_multi}] = {int_or_converts_to_multi} +SUPPORTS_ONE_OP_MULTI: Literal[{supports_one_op_multi}] = {supports_one_op_multi} '''.format(source=TEMPLATE_QFLAGS_TESTS, multiFlagName=flag_info.qflag_full_class_name, oneFlagName=flag_info.enum_full_class_name, @@ -1073,7 +1086,8 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: qtmodule=flag_info.module_name, or_converts_to_multi=flag_info.or_converts_to_multi, or_int_converts_to_multi=flag_info.or_int_converts_to_multi, - int_or_converts_to_multi=flag_info.int_or_converts_to_multi + int_or_converts_to_multi=flag_info.int_or_converts_to_multi, + supports_one_op_multi=flag_info.supports_one_op_multi )) f.writelines(generic_part_after) log_progress('Test file generated: %s' % test_qflag_fname) diff --git a/tests/qflags/qflags_test_template.py b/tests/qflags/qflags_test_template.py index e7af2d73..af38d2e3 100644 --- a/tests/qflags/qflags_test_template.py +++ b/tests/qflags/qflags_test_template.py @@ -1,7 +1,7 @@ # mypy: no-warn-unreachable import sys -from typing import Union, TypeVar, Type +from typing import Union if sys.version_info[:2] >= (3,8): from typing import Literal else: @@ -164,9 +164,10 @@ def test_on_multi_flag_class() -> None: assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) - assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) - assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) - assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) # MultClassFlag may be created by combining MultiFlagClass and int, right only @@ -228,14 +229,18 @@ def test_on_multi_flag_class() -> None: # #########################################################1 - # This checks the following: - # + and - operations are not supported on MultiFlagClass - # combining int with MultiFlagClass does not work + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] From 1797a9749ef084bbf9ce3d6cf3e23d8b6c18a4da Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 11:05:41 +0100 Subject: [PATCH 272/421] More qflags supported --- PyQt5-stubs/Qt3DCore.pyi | 22 ++ .../test_Qt3DCore_ChangeFlags_ChangeFlag.py | 272 ++++++++++++++++++ ...est_Qt3DCore_DeliveryFlags_DeliveryFlag.py | 272 ++++++++++++++++++ 3 files changed, 566 insertions(+) create mode 100644 tests/qflags/test_Qt3DCore_ChangeFlags_ChangeFlag.py create mode 100644 tests/qflags/test_Qt3DCore_DeliveryFlags_DeliveryFlag.py diff --git a/PyQt5-stubs/Qt3DCore.pyi b/PyQt5-stubs/Qt3DCore.pyi index 66970665..839faba9 100644 --- a/PyQt5-stubs/Qt3DCore.pyi +++ b/PyQt5-stubs/Qt3DCore.pyi @@ -40,6 +40,9 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], class ChangeFlag(int): + def __or__ (self, other: 'ChangeFlag') -> 'ChangeFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'ChangeFlags': ... # type: ignore[override, misc] + NodeCreated = ... # type: ChangeFlag NodeDeleted = ... # type: ChangeFlag PropertyUpdated = ... # type: ChangeFlag @@ -195,6 +198,9 @@ class QBackendNode(sip.simplewrapper): class QSceneChange(sip.simplewrapper): class DeliveryFlag(int): + def __or__ (self, other: 'QSceneChange.DeliveryFlag') -> 'QSceneChange.DeliveryFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSceneChange.DeliveryFlags': ... # type: ignore[override, misc] + BackendNodes = ... # type: QSceneChange.DeliveryFlag Nodes = ... # type: QSceneChange.DeliveryFlag DeliverToAll = ... # type: QSceneChange.DeliveryFlag @@ -211,12 +217,20 @@ class QSceneChange(sip.simplewrapper): def __init__(self, f: typing.Union['QSceneChange.DeliveryFlags', 'QSceneChange.DeliveryFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QSceneChange.DeliveryFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSceneChange.DeliveryFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSceneChange.DeliveryFlags', 'QSceneChange.DeliveryFlag', int]) -> 'QSceneChange.DeliveryFlags': ... + def __and__(self, other: typing.Union['QSceneChange.DeliveryFlags', 'QSceneChange.DeliveryFlag', int]) -> 'QSceneChange.DeliveryFlags': ... + def __xor__(self, other: typing.Union['QSceneChange.DeliveryFlags', 'QSceneChange.DeliveryFlag', int]) -> 'QSceneChange.DeliveryFlags': ... + def __ror__ (self, other: 'QSceneChange.DeliveryFlag') -> 'QSceneChange.DeliveryFlags': ... + def __rand__(self, other: 'QSceneChange.DeliveryFlag') -> 'QSceneChange.DeliveryFlags': ... + def __rxor__(self, other: 'QSceneChange.DeliveryFlag') -> 'QSceneChange.DeliveryFlags': ... def __init__(self, type: 'ChangeFlag', subjectId: 'QNodeId') -> None: ... @@ -426,12 +440,20 @@ class ChangeFlags(sip.simplewrapper): def __init__(self, f: typing.Union['ChangeFlags', 'ChangeFlag']) -> None: ... @typing.overload def __init__(self, a0: 'ChangeFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'ChangeFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['ChangeFlags', 'ChangeFlag', int]) -> 'ChangeFlags': ... + def __and__(self, other: typing.Union['ChangeFlags', 'ChangeFlag', int]) -> 'ChangeFlags': ... + def __xor__(self, other: typing.Union['ChangeFlags', 'ChangeFlag', int]) -> 'ChangeFlags': ... + def __ror__ (self, other: 'ChangeFlag') -> 'ChangeFlags': ... + def __rand__(self, other: 'ChangeFlag') -> 'ChangeFlags': ... + def __rxor__(self, other: 'ChangeFlag') -> 'ChangeFlags': ... class QSkeleton('QAbstractSkeleton'): diff --git a/tests/qflags/test_Qt3DCore_ChangeFlags_ChangeFlag.py b/tests/qflags/test_Qt3DCore_ChangeFlags_ChangeFlag.py new file mode 100644 index 00000000..f2552e1d --- /dev/null +++ b/tests/qflags/test_Qt3DCore_ChangeFlags_ChangeFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "ChangeFlags" and flag class "ChangeFlag" +from PyQt5 import Qt3DCore + +OneFlagClass = Qt3DCore.ChangeFlag +MultiFlagClass = Qt3DCore.ChangeFlags + +oneFlagRefValue1 = Qt3DCore.ChangeFlag.NodeCreated +oneFlagRefValue2 = Qt3DCore.ChangeFlag.NodeDeleted + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + diff --git a/tests/qflags/test_Qt3DCore_DeliveryFlags_DeliveryFlag.py b/tests/qflags/test_Qt3DCore_DeliveryFlags_DeliveryFlag.py new file mode 100644 index 00000000..833617e7 --- /dev/null +++ b/tests/qflags/test_Qt3DCore_DeliveryFlags_DeliveryFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSceneChange.DeliveryFlags" and flag class "QSceneChange.DeliveryFlag" +from PyQt5 import Qt3DCore + +OneFlagClass = Qt3DCore.QSceneChange.DeliveryFlag +MultiFlagClass = Qt3DCore.QSceneChange.DeliveryFlags + +oneFlagRefValue1 = Qt3DCore.QSceneChange.DeliveryFlag.BackendNodes +oneFlagRefValue2 = Qt3DCore.QSceneChange.DeliveryFlag.Nodes + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 36688bfb8065ef74b220f7a2bed4441f07861e1b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 11:10:06 +0100 Subject: [PATCH 273/421] Catch correct exception when evaluating behavior --- tests/qflags/generate_qflags_stubs_and_tests.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index f42ec320..7f1a3a62 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -541,11 +541,13 @@ class not found, class found multiple times, ... try: flag_info.supports_one_op_multi = True - eval('''{qtmodule}.{oneFlagName} | {qtmodule}.{multiFlagName}()''').format( - oneFlagName=flag_info.enum_value1, multiFlagName=flag_info.qflag_full_class_name, + eval('''{qtmodule}.{oneFlagName}.{enumValue} | {qtmodule}.{multiFlagName}()'''.format( + oneFlagName=flag_info.enum_full_class_name, + enumValue=flag_info.enum_value1, + multiFlagName=flag_info.qflag_full_class_name, qtmodule=flag_info.module_name - ) - except Exception: + )) + except TypeError: flag_info.supports_one_op_multi = False if visitor.enum_class_full_name == '': From ac39cfd241a39b8187eefea1e6d914528550363c Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 11:30:44 +0100 Subject: [PATCH 274/421] Remove obsolete files --- .../qtbase-qflags_modules_analysis.json | 2192 -------------- .../qflags/qtbase-qflags_process_result.json | 2573 ----------------- tests/qflags/qtbase-qflags_to_process.json | 2193 -------------- 3 files changed, 6958 deletions(-) delete mode 100644 tests/qflags/qtbase-qflags_modules_analysis.json delete mode 100644 tests/qflags/qtbase-qflags_process_result.json delete mode 100644 tests/qflags/qtbase-qflags_to_process.json diff --git a/tests/qflags/qtbase-qflags_modules_analysis.json b/tests/qflags/qtbase-qflags_modules_analysis.json deleted file mode 100644 index 446afba6..00000000 --- a/tests/qflags/qtbase-qflags_modules_analysis.json +++ /dev/null @@ -1,2192 +0,0 @@ -{ - "flag_and_module_identified": [ - { - "qflag_class": "RegisterOptions", - "enum_class": "RegisterOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi" - }, - { - "qflag_class": "ConnectionCapabilities", - "enum_class": "ConnectionCapability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi" - }, - { - "qflag_class": "FormatOptions", - "enum_class": "FormatOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", - "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "FormatOptions", - "enum_class": "FormatOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", - "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" - }, - { - "qflag_class": "OpenGLVersionFlags", - "enum_class": "OpenGLVersionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" - }, - { - "qflag_class": "BindOptions", - "enum_class": "BindOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption)", - "src\\gui\\opengl\\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" - }, - { - "qflag_class": "ShaderType", - "enum_class": "ShaderTypeBit", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)", - "src\\gui\\opengl\\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "WatchMode", - "enum_class": "WatchModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi" - }, - { - "qflag_class": "ConversionFlags", - "enum_class": "ConversionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\codecs\\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)", - "src\\corelib\\codecs\\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "CheckIndexOptions", - "enum_class": "CheckIndexOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\itemmodels\\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Filters", - "enum_class": "Filter", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(Filters, Filter)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "SortFlags", - "enum_class": "SortFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "IteratorFlags", - "enum_class": "IteratorFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "IteratorFlags", - "enum_class": "IteratorFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "Permissions", - "enum_class": "Permission", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "FileHandleFlags", - "enum_class": "FileHandleFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "SelectionFlags", - "enum_class": "SelectionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\itemmodels\\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "KeyboardModifiers", - "enum_class": "KeyboardModifier", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "MouseButtons", - "enum_class": "MouseButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Orientations", - "enum_class": "Orientation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Alignment", - "enum_class": "AlignmentFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "WindowFlags", - "enum_class": "WindowType", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "WindowStates", - "enum_class": "WindowState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "ApplicationStates", - "enum_class": "ApplicationState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "ScreenOrientations", - "enum_class": "ScreenOrientation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "ImageConversionFlags", - "enum_class": "ImageConversionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "DockWidgetAreas", - "enum_class": "DockWidgetArea", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "ToolBarAreas", - "enum_class": "ToolBarArea", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Edges", - "enum_class": "Edge", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "InputMethodQueries", - "enum_class": "InputMethodQuery", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "InputMethodHints", - "enum_class": "InputMethodHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "FindChildOptions", - "enum_class": "FindChildOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "DropActions", - "enum_class": "DropAction", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "ItemFlags", - "enum_class": "ItemFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "MatchFlags", - "enum_class": "MatchFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "TextInteractionFlags", - "enum_class": "TextInteractionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "TouchPointStates", - "enum_class": "TouchPointState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "GestureFlags", - "enum_class": "GestureFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "MouseEventFlags", - "enum_class": "MouseEventFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Transformations", - "enum_class": "Transformation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Capabilities", - "enum_class": "Capability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", - "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "Capabilities", - "enum_class": "Capability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", - "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 1, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "ProcessEventsFlags", - "enum_class": "ProcessEventsFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "OpenMode", - "enum_class": "OpenModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "InfoFlags", - "enum_class": "InfoFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "LoadHints", - "enum_class": "LoadHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\plugin\\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "RangeAccessFlags", - "enum_class": "RangeAccessFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Sources", - "enum_class": "Source", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Types", - "enum_class": "Type", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Severities", - "enum_class": "Severity", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "TypeFlags", - "enum_class": "TypeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "LocateOptions", - "enum_class": "LocateOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Flags", - "enum_class": "Flag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", - "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", - "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Flags", - "enum_class": "Flag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", - "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", - "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "PolicyFlags", - "enum_class": "PolicyFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\access\\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "StandardButtons", - "enum_class": "StandardButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "StandardButtons", - "enum_class": "StandardButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ColorDialogOptions", - "enum_class": "ColorDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)", - "src\\widgets\\dialogs\\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "FontDialogOptions", - "enum_class": "FontDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)", - "src\\widgets\\dialogs\\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ComponentFormattingOptions", - "enum_class": "ComponentFormattingOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "FormattingOptions", - "enum_class": "UrlFormattingOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "UserInputResolutionOptions", - "enum_class": "UserInputResolutionOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "StateFlags", - "enum_class": "StateFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\bearer\\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "UsagePolicies", - "enum_class": "UsagePolicy", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\bearer\\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "RenderFlags", - "enum_class": "RenderFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", - "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "RenderFlags", - "enum_class": "RenderFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", - "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "PaintEngineFeatures", - "enum_class": "PaintEngineFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "DirtyFlags", - "enum_class": "DirtyFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Capabilities", - "enum_class": "CapabilityFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Features", - "enum_class": "Feature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature)", - "src\\gui\\text\\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "RenderHints", - "enum_class": "RenderHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "PixmapFragmentHints", - "enum_class": "PixmapFragmentHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "ControlTypes", - "enum_class": "ControlType", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\util\\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)", - "src\\widgets\\kernel\\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "GlyphRunFlags", - "enum_class": "GlyphRunFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "LayoutFlags", - "enum_class": "LayoutFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "MarkdownFeatures", - "enum_class": "MarkdownFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "FindFlags", - "enum_class": "FindFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "ConversionMode", - "enum_class": "ConversionModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\kernel\\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "BindMode", - "enum_class": "BindFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "PauseModes", - "enum_class": "PauseMode", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "PageBreakFlags", - "enum_class": "PageBreakFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "SocketOptions", - "enum_class": "SocketOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "InterfaceFlags", - "enum_class": "InterfaceFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\kernel\\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "SslOptions", - "enum_class": "SslOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\ssl\\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "Base64Options", - "enum_class": "Base64Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "NumberOptions", - "enum_class": "NumberOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "DataSizeFormats", - "enum_class": "DataSizeFormat", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Sections", - "enum_class": "Section", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\time\\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section)", - "src\\widgets\\widgets\\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "PatternOptions", - "enum_class": "PatternOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "MatchOptions", - "enum_class": "MatchOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "NumberFlags", - "enum_class": "NumberFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\serialization\\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "BoundaryReasons", - "enum_class": "BoundaryReason", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "PrintDialogOptions", - "enum_class": "PrintDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\printsupport\\dialogs\\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtPrintSupport", - "module_path": "../../PyQt5-stubs/QtPrintSupport.pyi" - }, - { - "qflag_class": "ParamType", - "enum_class": "ParamTypeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\sql\\kernel\\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtSql", - "module_path": "../../PyQt5-stubs/QtSql.pyi" - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 3, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 3, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 3, - "module_idx": 2, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ChangeFlags", - "enum_class": "ChangeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", - "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ChangeFlags", - "enum_class": "ChangeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", - "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "BlurHints", - "enum_class": "BlurHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "InputDialogOptions", - "enum_class": "InputDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "WizardOptions", - "enum_class": "WizardOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "EditTriggers", - "enum_class": "EditTrigger", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\itemviews\\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "GraphicsItemFlags", - "enum_class": "GraphicsItemFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "Result", - "enum_class": "ResultFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\kernel\\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "SceneLayers", - "enum_class": "SceneLayer", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "CacheMode", - "enum_class": "CacheModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "OptimizationFlags", - "enum_class": "OptimizationFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "State", - "enum_class": "StateFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "SubControls", - "enum_class": "SubControl", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "StepEnabled", - "enum_class": "StepEnabledFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "FrameFeatures", - "enum_class": "FrameFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ButtonFeatures", - "enum_class": "ButtonFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "CornerWidgets", - "enum_class": "CornerWidget", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "TabFeatures", - "enum_class": "TabFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ToolBarFeatures", - "enum_class": "ToolBarFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ViewItemFeatures", - "enum_class": "ViewItemFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ToolButtonFeatures", - "enum_class": "ToolButtonFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "DockWidgetFeatures", - "enum_class": "DockWidgetFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "FontFilters", - "enum_class": "FontFilter", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "AreaOptions", - "enum_class": "AreaOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "SubWindowOptions", - "enum_class": "SubWindowOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "DockOptions", - "enum_class": "DockOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "AutoFormatting", - "enum_class": "AutoFormattingFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - } - ], - "flag_without_module": [] -} \ No newline at end of file diff --git a/tests/qflags/qtbase-qflags_process_result.json b/tests/qflags/qtbase-qflags_process_result.json deleted file mode 100644 index 59f9a269..00000000 --- a/tests/qflags/qtbase-qflags_process_result.json +++ /dev/null @@ -1,2573 +0,0 @@ -{ - "qflag_already_done": [ - { - "qflag_class": "RegisterOptions", - "enum_class": "RegisterOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)" - ], - "qflag_full_class_name": "QDBusConnection.RegisterOptions", - "enum_full_class_name": "QDBusConnection.RegisterOption", - "enum_value1": "ExportAdaptors", - "enum_value2": "ExportScriptableSlots", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": true, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ConnectionCapabilities", - "enum_class": "ConnectionCapability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)" - ], - "qflag_full_class_name": "QDBusConnection.ConnectionCapabilities", - "enum_full_class_name": "QDBusConnection.ConnectionCapability", - "enum_value1": "UnixFileDescriptorPassing", - "enum_value2": "UnixFileDescriptorPassing", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FormatOptions", - "enum_class": "FormatOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", - "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" - ], - "qflag_full_class_name": "QSurfaceFormat.FormatOptions", - "enum_full_class_name": "QSurfaceFormat.FormatOption", - "enum_value1": "StereoBuffers", - "enum_value2": "DebugContext", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FormatOptions", - "enum_class": "FormatOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", - "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" - ], - "qflag_full_class_name": "QGL.FormatOptions", - "enum_full_class_name": "QGL.FormatOption", - "enum_value1": "DoubleBuffer", - "enum_value2": "DepthBuffer", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "OpenGLVersionFlags", - "enum_class": "OpenGLVersionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)" - ], - "qflag_full_class_name": "QGLFormat.OpenGLVersionFlags", - "enum_full_class_name": "QGLFormat.OpenGLVersionFlag", - "enum_value1": "OpenGL_Version_None", - "enum_value2": "OpenGL_Version_1_1", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "BindOptions", - "enum_class": "BindOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption)", - "src\\gui\\opengl\\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption)" - ], - "qflag_full_class_name": "QGLContext.BindOptions", - "enum_full_class_name": "QGLContext.BindOption", - "enum_value1": "NoBindOption", - "enum_value2": "InvertedYBindOption", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ShaderType", - "enum_class": "ShaderTypeBit", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)", - "src\\gui\\opengl\\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)" - ], - "qflag_full_class_name": "QOpenGLShader.ShaderType", - "enum_full_class_name": "QOpenGLShader.ShaderTypeBit", - "enum_value1": "Vertex", - "enum_value2": "Fragment", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "WatchMode", - "enum_class": "WatchModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)" - ], - "qflag_full_class_name": "QDBusServiceWatcher.WatchMode", - "enum_full_class_name": "QDBusServiceWatcher.WatchModeFlag", - "enum_value1": "WatchForRegistration", - "enum_value2": "WatchForUnregistration", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": true, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ConversionFlags", - "enum_class": "ConversionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\codecs\\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)", - "src\\corelib\\codecs\\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)" - ], - "qflag_full_class_name": "QTextCodec.ConversionFlags", - "enum_full_class_name": "QTextCodec.ConversionFlag", - "enum_value1": "DefaultConversion", - "enum_value2": "ConvertInvalidToNull", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Filters", - "enum_class": "Filter", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(Filters, Filter)" - ], - "qflag_full_class_name": "QDir.Filters", - "enum_full_class_name": "QDir.Filter", - "enum_value1": "Dirs", - "enum_value2": "Files", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SortFlags", - "enum_class": "SortFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag)" - ], - "qflag_full_class_name": "QDir.SortFlags", - "enum_full_class_name": "QDir.SortFlag", - "enum_value1": "Name", - "enum_value2": "Time", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "IteratorFlags", - "enum_class": "IteratorFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" - ], - "qflag_full_class_name": "QDirIterator.IteratorFlags", - "enum_full_class_name": "QDirIterator.IteratorFlag", - "enum_value1": "NoIteratorFlags", - "enum_value2": "FollowSymlinks", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "IteratorFlags", - "enum_class": "IteratorFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" - ], - "qflag_full_class_name": "QTreeWidgetItemIterator.IteratorFlags", - "enum_full_class_name": "QTreeWidgetItemIterator.IteratorFlag", - "enum_value1": "All", - "enum_value2": "Hidden", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Permissions", - "enum_class": "Permission", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission)" - ], - "qflag_full_class_name": "QFileDevice.Permissions", - "enum_full_class_name": "QFileDevice.Permission", - "enum_value1": "ReadOwner", - "enum_value2": "WriteOwner", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FileHandleFlags", - "enum_class": "FileHandleFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)" - ], - "qflag_full_class_name": "QFileDevice.FileHandleFlags", - "enum_full_class_name": "QFileDevice.FileHandleFlag", - "enum_value1": "AutoCloseHandle", - "enum_value2": "DontCloseHandle", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "SelectionFlags", - "enum_class": "SelectionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\itemmodels\\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" - ], - "qflag_full_class_name": "QItemSelectionModel.SelectionFlags", - "enum_full_class_name": "QItemSelectionModel.SelectionFlag", - "enum_value1": "NoUpdate", - "enum_value2": "Clear", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "KeyboardModifiers", - "enum_class": "KeyboardModifier", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)" - ], - "qflag_full_class_name": "Qt.KeyboardModifiers", - "enum_full_class_name": "Qt.KeyboardModifier", - "enum_value1": "NoModifier", - "enum_value2": "ShiftModifier", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "MouseButtons", - "enum_class": "MouseButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton)" - ], - "qflag_full_class_name": "Qt.MouseButtons", - "enum_full_class_name": "Qt.MouseButton", - "enum_value1": "NoButton", - "enum_value2": "AllButtons", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Orientations", - "enum_class": "Orientation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation)" - ], - "qflag_full_class_name": "Qt.Orientations", - "enum_full_class_name": "Qt.Orientation", - "enum_value1": "Horizontal", - "enum_value2": "Vertical", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Alignment", - "enum_class": "AlignmentFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag)" - ], - "qflag_full_class_name": "Qt.Alignment", - "enum_full_class_name": "Qt.AlignmentFlag", - "enum_value1": "AlignLeft", - "enum_value2": "AlignLeading", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "WindowFlags", - "enum_class": "WindowType", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType)" - ], - "qflag_full_class_name": "Qt.WindowFlags", - "enum_full_class_name": "Qt.WindowType", - "enum_value1": "Widget", - "enum_value2": "Window", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "WindowStates", - "enum_class": "WindowState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState)" - ], - "qflag_full_class_name": "Qt.WindowStates", - "enum_full_class_name": "Qt.WindowState", - "enum_value1": "WindowNoState", - "enum_value2": "WindowMinimized", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ApplicationStates", - "enum_class": "ApplicationState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState)" - ], - "qflag_full_class_name": "Qt.ApplicationStates", - "enum_full_class_name": "Qt.ApplicationState", - "enum_value1": "ApplicationSuspended", - "enum_value2": "ApplicationHidden", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "ScreenOrientations", - "enum_class": "ScreenOrientation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation)" - ], - "qflag_full_class_name": "Qt.ScreenOrientations", - "enum_full_class_name": "Qt.ScreenOrientation", - "enum_value1": "PrimaryOrientation", - "enum_value2": "PortraitOrientation", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ImageConversionFlags", - "enum_class": "ImageConversionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag)" - ], - "qflag_full_class_name": "Qt.ImageConversionFlags", - "enum_full_class_name": "Qt.ImageConversionFlag", - "enum_value1": "AutoColor", - "enum_value2": "ColorOnly", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "DockWidgetAreas", - "enum_class": "DockWidgetArea", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)" - ], - "qflag_full_class_name": "Qt.DockWidgetAreas", - "enum_full_class_name": "Qt.DockWidgetArea", - "enum_value1": "LeftDockWidgetArea", - "enum_value2": "RightDockWidgetArea", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ToolBarAreas", - "enum_class": "ToolBarArea", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)" - ], - "qflag_full_class_name": "Qt.ToolBarAreas", - "enum_full_class_name": "Qt.ToolBarArea", - "enum_value1": "LeftToolBarArea", - "enum_value2": "RightToolBarArea", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Edges", - "enum_class": "Edge", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge)" - ], - "qflag_full_class_name": "Qt.Edges", - "enum_full_class_name": "Qt.Edge", - "enum_value1": "TopEdge", - "enum_value2": "LeftEdge", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "InputMethodQueries", - "enum_class": "InputMethodQuery", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery)" - ], - "qflag_full_class_name": "Qt.InputMethodQueries", - "enum_full_class_name": "Qt.InputMethodQuery", - "enum_value1": "ImMicroFocus", - "enum_value2": "ImFont", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "InputMethodHints", - "enum_class": "InputMethodHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)" - ], - "qflag_full_class_name": "Qt.InputMethodHints", - "enum_full_class_name": "Qt.InputMethodHint", - "enum_value1": "ImhNone", - "enum_value2": "ImhHiddenText", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FindChildOptions", - "enum_class": "FindChildOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)" - ], - "qflag_full_class_name": "Qt.FindChildOptions", - "enum_full_class_name": "Qt.FindChildOption", - "enum_value1": "FindDirectChildrenOnly", - "enum_value2": "FindChildrenRecursively", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "DropActions", - "enum_class": "DropAction", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction)" - ], - "qflag_full_class_name": "Qt.DropActions", - "enum_full_class_name": "Qt.DropAction", - "enum_value1": "CopyAction", - "enum_value2": "MoveAction", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ItemFlags", - "enum_class": "ItemFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag)" - ], - "qflag_full_class_name": "Qt.ItemFlags", - "enum_full_class_name": "Qt.ItemFlag", - "enum_value1": "NoItemFlags", - "enum_value2": "ItemIsSelectable", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "MatchFlags", - "enum_class": "MatchFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag)" - ], - "qflag_full_class_name": "Qt.MatchFlags", - "enum_full_class_name": "Qt.MatchFlag", - "enum_value1": "MatchExactly", - "enum_value2": "MatchFixedString", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "TextInteractionFlags", - "enum_class": "TextInteractionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag)" - ], - "qflag_full_class_name": "Qt.TextInteractionFlags", - "enum_full_class_name": "Qt.TextInteractionFlag", - "enum_value1": "NoTextInteraction", - "enum_value2": "TextSelectableByMouse", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "TouchPointStates", - "enum_class": "TouchPointState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)" - ], - "qflag_full_class_name": "Qt.TouchPointStates", - "enum_full_class_name": "Qt.TouchPointState", - "enum_value1": "TouchPointPressed", - "enum_value2": "TouchPointMoved", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "GestureFlags", - "enum_class": "GestureFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag)" - ], - "qflag_full_class_name": "Qt.GestureFlags", - "enum_full_class_name": "Qt.GestureFlag", - "enum_value1": "DontStartGestureOnChildren", - "enum_value2": "ReceivePartialGestures", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "MouseEventFlags", - "enum_class": "MouseEventFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)" - ], - "qflag_full_class_name": "Qt.MouseEventFlags", - "enum_full_class_name": "Qt.MouseEventFlag", - "enum_value1": "MouseEventCreatedDoubleClick", - "enum_value2": "MouseEventCreatedDoubleClick", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Transformations", - "enum_class": "Transformation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation)" - ], - "qflag_full_class_name": "QImageIOHandler.Transformations", - "enum_full_class_name": "QImageIOHandler.Transformation", - "enum_value1": "TransformationNone", - "enum_value2": "TransformationMirror", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "Capabilities", - "enum_class": "Capability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", - "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" - ], - "qflag_full_class_name": "QNetworkConfigurationManager.Capabilities", - "enum_full_class_name": "QNetworkConfigurationManager.Capability", - "enum_value1": "CanStartAndStopInterfaces", - "enum_value2": "DirectConnectionRouting", - "module_count": 2, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": true, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Capabilities", - "enum_class": "Capability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", - "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" - ], - "qflag_full_class_name": "QNetworkProxy.Capabilities", - "enum_full_class_name": "QNetworkProxy.Capability", - "enum_value1": "TunnelingCapability", - "enum_value2": "ListeningCapability", - "module_count": 2, - "module_idx": 1, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "ProcessEventsFlags", - "enum_class": "ProcessEventsFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)" - ], - "qflag_full_class_name": "QEventLoop.ProcessEventsFlags", - "enum_full_class_name": "QEventLoop.ProcessEventsFlag", - "enum_value1": "AllEvents", - "enum_value2": "ExcludeUserInputEvents", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "OpenMode", - "enum_class": "OpenModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)" - ], - "qflag_full_class_name": "QIODevice.OpenMode", - "enum_full_class_name": "QIODevice.OpenModeFlag", - "enum_value1": "NotOpen", - "enum_value2": "ReadOnly", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "InfoFlags", - "enum_class": "InfoFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag)" - ], - "qflag_full_class_name": "QTouchEvent.TouchPoint.InfoFlags", - "enum_full_class_name": "QTouchEvent.TouchPoint.InfoFlag", - "enum_value1": "Pen", - "enum_value2": "Token", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": true, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "LoadHints", - "enum_class": "LoadHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\plugin\\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint)" - ], - "qflag_full_class_name": "QLibrary.LoadHints", - "enum_full_class_name": "QLibrary.LoadHint", - "enum_value1": "ResolveAllSymbolsHint", - "enum_value2": "ExportExternalSymbolsHint", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "RangeAccessFlags", - "enum_class": "RangeAccessFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)" - ], - "qflag_full_class_name": "QOpenGLBuffer.RangeAccessFlags", - "enum_full_class_name": "QOpenGLBuffer.RangeAccessFlag", - "enum_value1": "RangeRead", - "enum_value2": "RangeWrite", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Sources", - "enum_class": "Source", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source)" - ], - "qflag_full_class_name": "QOpenGLDebugMessage.Sources", - "enum_full_class_name": "QOpenGLDebugMessage.Source", - "enum_value1": "InvalidSource", - "enum_value2": "APISource", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Types", - "enum_class": "Type", - "human_hint_qflag_full_class_name": "QOpenGLDebugMessage.Types", - "human_hint_enum_full_class_name": "QOpenGLDebugMessage.Type", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" - ], - "qflag_full_class_name": "QOpenGLDebugMessage.Types", - "enum_full_class_name": "QOpenGLDebugMessage.Type", - "enum_value1": "InvalidType", - "enum_value2": "ErrorType", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Severities", - "enum_class": "Severity", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity)" - ], - "qflag_full_class_name": "QOpenGLDebugMessage.Severities", - "enum_full_class_name": "QOpenGLDebugMessage.Severity", - "enum_value1": "InvalidSeverity", - "enum_value2": "HighSeverity", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "TypeFlags", - "enum_class": "TypeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag)" - ], - "qflag_full_class_name": "QMetaType.TypeFlags", - "enum_full_class_name": "QMetaType.TypeFlag", - "enum_value1": "NeedsConstruction", - "enum_value2": "NeedsDestruction", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "LocateOptions", - "enum_class": "LocateOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption)" - ], - "qflag_full_class_name": "QStandardPaths.LocateOptions", - "enum_full_class_name": "QStandardPaths.LocateOption", - "enum_value1": "LocateFile", - "enum_value2": "LocateDirectory", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Flags", - "enum_class": "Flag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", - "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", - "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" - ], - "qflag_full_class_name": "QCommandLineOption.Flags", - "enum_full_class_name": "QCommandLineOption.Flag", - "enum_value1": "HiddenFromHelp", - "enum_value2": "ShortOptionStyle", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Flags", - "enum_class": "Flag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", - "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", - "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" - ], - "qflag_full_class_name": "QTextOption.Flags", - "enum_full_class_name": "QTextOption.Flag", - "enum_value1": "IncludeTrailingSpaces", - "enum_value2": "ShowTabsAndSpaces", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PolicyFlags", - "enum_class": "PolicyFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\access\\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)" - ], - "qflag_full_class_name": "QHstsPolicy.PolicyFlags", - "enum_full_class_name": "QHstsPolicy.PolicyFlag", - "enum_value1": "IncludeSubDomains", - "enum_value2": "IncludeSubDomains", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "StandardButtons", - "enum_class": "StandardButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" - ], - "qflag_full_class_name": "QDialogButtonBox.StandardButtons", - "enum_full_class_name": "QDialogButtonBox.StandardButton", - "enum_value1": "NoButton", - "enum_value2": "Ok", - "module_count": 2, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "StandardButtons", - "enum_class": "StandardButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" - ], - "qflag_full_class_name": "QMessageBox.StandardButtons", - "enum_full_class_name": "QMessageBox.StandardButton", - "enum_value1": "NoButton", - "enum_value2": "Ok", - "module_count": 2, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ColorDialogOptions", - "enum_class": "ColorDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)", - "src\\widgets\\dialogs\\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)" - ], - "qflag_full_class_name": "QColorDialog.ColorDialogOptions", - "enum_full_class_name": "QColorDialog.ColorDialogOption", - "enum_value1": "ShowAlphaChannel", - "enum_value2": "NoButtons", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FontDialogOptions", - "enum_class": "FontDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)", - "src\\widgets\\dialogs\\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)" - ], - "qflag_full_class_name": "QFontDialog.FontDialogOptions", - "enum_full_class_name": "QFontDialog.FontDialogOption", - "enum_value1": "NoButtons", - "enum_value2": "DontUseNativeDialog", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ComponentFormattingOptions", - "enum_class": "ComponentFormattingOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)" - ], - "qflag_full_class_name": "QUrl.ComponentFormattingOptions", - "enum_full_class_name": "QUrl.ComponentFormattingOption", - "enum_value1": "PrettyDecoded", - "enum_value2": "EncodeSpaces", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "UserInputResolutionOptions", - "enum_class": "UserInputResolutionOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption)" - ], - "qflag_full_class_name": "QUrl.UserInputResolutionOptions", - "enum_full_class_name": "QUrl.UserInputResolutionOption", - "enum_value1": "DefaultResolution", - "enum_value2": "AssumeLocalFile", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "StateFlags", - "enum_class": "StateFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\bearer\\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" - ], - "qflag_full_class_name": "QNetworkConfiguration.StateFlags", - "enum_full_class_name": "QNetworkConfiguration.StateFlag", - "enum_value1": "Undefined", - "enum_value2": "Defined", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "UsagePolicies", - "enum_class": "UsagePolicy", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\bearer\\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)" - ], - "qflag_full_class_name": "QNetworkSession.UsagePolicies", - "enum_full_class_name": "QNetworkSession.UsagePolicy", - "enum_value1": "NoPolicy", - "enum_value2": "NoBackgroundTrafficPolicy", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "RenderFlags", - "enum_class": "RenderFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", - "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" - ], - "qflag_full_class_name": "QWidget.RenderFlags", - "enum_full_class_name": "QWidget.RenderFlag", - "enum_value1": "DrawWindowBackground", - "enum_value2": "DrawChildren", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "RenderFlags", - "enum_class": "RenderFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", - "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" - ], - "qflag_full_class_name": "QTextItem.RenderFlags", - "enum_full_class_name": "QTextItem.RenderFlag", - "enum_value1": "RightToLeft", - "enum_value2": "Overline", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PaintEngineFeatures", - "enum_class": "PaintEngineFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)" - ], - "qflag_full_class_name": "QPaintEngine.PaintEngineFeatures", - "enum_full_class_name": "QPaintEngine.PaintEngineFeature", - "enum_value1": "PrimitiveTransform", - "enum_value2": "PatternTransform", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "DirtyFlags", - "enum_class": "DirtyFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" - ], - "qflag_full_class_name": "QPaintEngine.DirtyFlags", - "enum_full_class_name": "QPaintEngine.DirtyFlag", - "enum_value1": "DirtyPen", - "enum_value2": "DirtyBrush", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "Capabilities", - "enum_class": "CapabilityFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" - ], - "qflag_full_class_name": "QTouchDevice.Capabilities", - "enum_full_class_name": "QTouchDevice.CapabilityFlag", - "enum_value1": "Position", - "enum_value2": "Area", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Features", - "enum_class": "Feature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature)", - "src\\gui\\text\\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature)" - ], - "qflag_full_class_name": "QOpenGLTexture.Features", - "enum_full_class_name": "QOpenGLTexture.Feature", - "enum_value1": "ImmutableStorage", - "enum_value2": "ImmutableMultisampleStorage", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "RenderHints", - "enum_class": "RenderHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint)" - ], - "qflag_full_class_name": "QPainter.RenderHints", - "enum_full_class_name": "QPainter.RenderHint", - "enum_value1": "Antialiasing", - "enum_value2": "TextAntialiasing", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PixmapFragmentHints", - "enum_class": "PixmapFragmentHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)" - ], - "qflag_full_class_name": "QPainter.PixmapFragmentHints", - "enum_full_class_name": "QPainter.PixmapFragmentHint", - "enum_value1": "OpaqueHint", - "enum_value2": "OpaqueHint", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "ControlTypes", - "enum_class": "ControlType", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\util\\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)", - "src\\widgets\\kernel\\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)" - ], - "qflag_full_class_name": "QSizePolicy.ControlTypes", - "enum_full_class_name": "QSizePolicy.ControlType", - "enum_value1": "DefaultType", - "enum_value2": "ButtonBox", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "GlyphRunFlags", - "enum_class": "GlyphRunFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag)" - ], - "qflag_full_class_name": "QGlyphRun.GlyphRunFlags", - "enum_full_class_name": "QGlyphRun.GlyphRunFlag", - "enum_value1": "Overline", - "enum_value2": "Underline", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "LayoutFlags", - "enum_class": "LayoutFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)" - ], - "qflag_full_class_name": "QRawFont.LayoutFlags", - "enum_full_class_name": "QRawFont.LayoutFlag", - "enum_value1": "SeparateAdvances", - "enum_value2": "KernedAdvances", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "MarkdownFeatures", - "enum_class": "MarkdownFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)" - ], - "qflag_full_class_name": "QTextDocument.MarkdownFeatures", - "enum_full_class_name": "QTextDocument.MarkdownFeature", - "enum_value1": "MarkdownNoHTML", - "enum_value2": "MarkdownDialectCommonMark", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "FindFlags", - "enum_class": "FindFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag)" - ], - "qflag_full_class_name": "QTextDocument.FindFlags", - "enum_full_class_name": "QTextDocument.FindFlag", - "enum_value1": "FindBackward", - "enum_value2": "FindCaseSensitively", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ConversionMode", - "enum_class": "ConversionModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\kernel\\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)" - ], - "qflag_full_class_name": "QHostAddress.ConversionMode", - "enum_full_class_name": "QHostAddress.ConversionModeFlag", - "enum_value1": "ConvertV4MappedToIPv4", - "enum_value2": "ConvertV4CompatToIPv4", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "BindMode", - "enum_class": "BindFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag)" - ], - "qflag_full_class_name": "QAbstractSocket.BindMode", - "enum_full_class_name": "QAbstractSocket.BindFlag", - "enum_value1": "DefaultForPlatform", - "enum_value2": "ShareAddress", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PauseModes", - "enum_class": "PauseMode", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode)" - ], - "qflag_full_class_name": "QAbstractSocket.PauseModes", - "enum_full_class_name": "QAbstractSocket.PauseMode", - "enum_value1": "PauseNever", - "enum_value2": "PauseOnSslErrors", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PageBreakFlags", - "enum_class": "PageBreakFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)" - ], - "qflag_full_class_name": "QTextFormat.PageBreakFlags", - "enum_full_class_name": "QTextFormat.PageBreakFlag", - "enum_value1": "PageBreak_Auto", - "enum_value2": "PageBreak_AlwaysBefore", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SocketOptions", - "enum_class": "SocketOption", - "human_hint_qflag_full_class_name": "QLocalServer.SocketOptions", - "human_hint_enum_full_class_name": "QLocalServer.SocketOption", - "grep_line": [ - "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" - ], - "qflag_full_class_name": "QLocalServer.SocketOptions", - "enum_full_class_name": "QLocalServer.SocketOption", - "enum_value1": "UserAccessOption", - "enum_value2": "GroupAccessOption", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "InterfaceFlags", - "enum_class": "InterfaceFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\kernel\\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)" - ], - "qflag_full_class_name": "QNetworkInterface.InterfaceFlags", - "enum_full_class_name": "QNetworkInterface.InterfaceFlag", - "enum_value1": "IsUp", - "enum_value2": "IsRunning", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SslOptions", - "enum_class": "SslOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\ssl\\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption)" - ], - "qflag_full_class_name": "QSsl.SslOptions", - "enum_full_class_name": "QSsl.SslOption", - "enum_value1": "SslOptionDisableEmptyFragments", - "enum_value2": "SslOptionDisableSessionTickets", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Base64Options", - "enum_class": "Base64Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option)" - ], - "qflag_full_class_name": "QByteArray.Base64Options", - "enum_full_class_name": "QByteArray.Base64Option", - "enum_value1": "Base64Encoding", - "enum_value2": "Base64UrlEncoding", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "NumberOptions", - "enum_class": "NumberOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption)" - ], - "qflag_full_class_name": "QLocale.NumberOptions", - "enum_full_class_name": "QLocale.NumberOption", - "enum_value1": "OmitGroupSeparator", - "enum_value2": "RejectGroupSeparator", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "DataSizeFormats", - "enum_class": "DataSizeFormat", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat)" - ], - "qflag_full_class_name": "QLocale.DataSizeFormats", - "enum_full_class_name": "QLocale.DataSizeFormat", - "enum_value1": "DataSizeIecFormat", - "enum_value2": "DataSizeTraditionalFormat", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "Sections", - "enum_class": "Section", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\time\\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section)", - "src\\widgets\\widgets\\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section)" - ], - "qflag_full_class_name": "QDateTimeEdit.Sections", - "enum_full_class_name": "QDateTimeEdit.Section", - "enum_value1": "NoSection", - "enum_value2": "AmPmSection", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PatternOptions", - "enum_class": "PatternOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption)" - ], - "qflag_full_class_name": "QRegularExpression.PatternOptions", - "enum_full_class_name": "QRegularExpression.PatternOption", - "enum_value1": "NoPatternOption", - "enum_value2": "CaseInsensitiveOption", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "MatchOptions", - "enum_class": "MatchOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption)" - ], - "qflag_full_class_name": "QRegularExpression.MatchOptions", - "enum_full_class_name": "QRegularExpression.MatchOption", - "enum_value1": "NoMatchOption", - "enum_value2": "AnchoredMatchOption", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "NumberFlags", - "enum_class": "NumberFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\serialization\\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag)" - ], - "qflag_full_class_name": "QTextStream.NumberFlags", - "enum_full_class_name": "QTextStream.NumberFlag", - "enum_value1": "ShowBase", - "enum_value2": "ForcePoint", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "BoundaryReasons", - "enum_class": "BoundaryReason", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )" - ], - "qflag_full_class_name": "QTextBoundaryFinder.BoundaryReasons", - "enum_full_class_name": "QTextBoundaryFinder.BoundaryReason", - "enum_value1": "NotAtBoundary", - "enum_value2": "SoftHyphen", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "PrintDialogOptions", - "enum_class": "PrintDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\printsupport\\dialogs\\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)" - ], - "qflag_full_class_name": "QAbstractPrintDialog.PrintDialogOptions", - "enum_full_class_name": "QAbstractPrintDialog.PrintDialogOption", - "enum_value1": "None_", - "enum_value2": "PrintToFile", - "module_count": 1, - "module_idx": 0, - "module_name": "QtPrintSupport", - "module_path": "../../PyQt5-stubs/QtPrintSupport.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ParamType", - "enum_class": "ParamTypeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\sql\\kernel\\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag)" - ], - "qflag_full_class_name": "QSql.ParamType", - "enum_full_class_name": "QSql.ParamTypeFlag", - "enum_value1": "In", - "enum_value2": "Out", - "module_count": 1, - "module_idx": 0, - "module_name": "QtSql", - "module_path": "../../PyQt5-stubs/QtSql.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "QFileDialog.Options", - "enum_full_class_name": "QFileDialog.Option", - "enum_value1": "ShowDirsOnly", - "enum_value2": "DontResolveSymlinks", - "module_count": 3, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "QFileIconProvider.Options", - "enum_full_class_name": "QFileIconProvider.Option", - "enum_value1": "DontUseCustomDirectoryIcons", - "enum_value2": "DontUseCustomDirectoryIcons", - "module_count": 3, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "QFileSystemModel.Options", - "enum_full_class_name": "QFileSystemModel.Option", - "enum_value1": "DontWatchForChanges", - "enum_value2": "DontResolveSymlinks", - "module_count": 3, - "module_idx": 2, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ChangeFlags", - "enum_class": "ChangeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", - "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" - ], - "qflag_full_class_name": "QPinchGesture.ChangeFlags", - "enum_full_class_name": "QPinchGesture.ChangeFlag", - "enum_value1": "ScaleFactorChanged", - "enum_value2": "RotationAngleChanged", - "module_count": 2, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "ChangeFlags", - "enum_class": "ChangeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", - "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" - ], - "qflag_full_class_name": "QGraphicsEffect.ChangeFlags", - "enum_full_class_name": "QGraphicsEffect.ChangeFlag", - "enum_value1": "SourceAttached", - "enum_value2": "SourceDetached", - "module_count": 2, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "BlurHints", - "enum_class": "BlurHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint)" - ], - "qflag_full_class_name": "QGraphicsBlurEffect.BlurHints", - "enum_full_class_name": "QGraphicsBlurEffect.BlurHint", - "enum_value1": "PerformanceHint", - "enum_value2": "QualityHint", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "InputDialogOptions", - "enum_class": "InputDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)" - ], - "qflag_full_class_name": "QInputDialog.InputDialogOptions", - "enum_full_class_name": "QInputDialog.InputDialogOption", - "enum_value1": "NoButtons", - "enum_value2": "UseListViewForComboBoxItems", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "WizardOptions", - "enum_class": "WizardOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption)" - ], - "qflag_full_class_name": "QWizard.WizardOptions", - "enum_full_class_name": "QWizard.WizardOption", - "enum_value1": "IndependentPages", - "enum_value2": "IgnoreSubTitles", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "EditTriggers", - "enum_class": "EditTrigger", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\itemviews\\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger)" - ], - "qflag_full_class_name": "QAbstractItemView.EditTriggers", - "enum_full_class_name": "QAbstractItemView.EditTrigger", - "enum_value1": "NoEditTriggers", - "enum_value2": "CurrentChanged", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "GraphicsItemFlags", - "enum_class": "GraphicsItemFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)" - ], - "qflag_full_class_name": "QGraphicsItem.GraphicsItemFlags", - "enum_full_class_name": "QGraphicsItem.GraphicsItemFlag", - "enum_value1": "ItemIsMovable", - "enum_value2": "ItemIsSelectable", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "Result", - "enum_class": "ResultFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\kernel\\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag)" - ], - "qflag_full_class_name": "QGestureRecognizer.Result", - "enum_full_class_name": "QGestureRecognizer.ResultFlag", - "enum_value1": "Ignore", - "enum_value2": "MayBeGesture", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SceneLayers", - "enum_class": "SceneLayer", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer)" - ], - "qflag_full_class_name": "QGraphicsScene.SceneLayers", - "enum_full_class_name": "QGraphicsScene.SceneLayer", - "enum_value1": "ItemLayer", - "enum_value2": "BackgroundLayer", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "CacheMode", - "enum_class": "CacheModeFlag", - "human_hint_qflag_full_class_name": "QGraphicsView.CacheMode", - "human_hint_enum_full_class_name": "QGraphicsView.CacheModeFlag", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)" - ], - "qflag_full_class_name": "QGraphicsView.CacheMode", - "enum_full_class_name": "QGraphicsView.CacheModeFlag", - "enum_value1": "CacheNone", - "enum_value2": "CacheBackground", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "OptimizationFlags", - "enum_class": "OptimizationFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)" - ], - "qflag_full_class_name": "QGraphicsView.OptimizationFlags", - "enum_full_class_name": "QGraphicsView.OptimizationFlag", - "enum_value1": "DontClipPainter", - "enum_value2": "DontSavePainterState", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SubControls", - "enum_class": "SubControl", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl)" - ], - "qflag_full_class_name": "QStyle.SubControls", - "enum_full_class_name": "QStyle.SubControl", - "enum_value1": "SC_None", - "enum_value2": "SC_ScrollBarAddLine", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "StepEnabled", - "enum_class": "StepEnabledFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)" - ], - "qflag_full_class_name": "QAbstractSpinBox.StepEnabled", - "enum_full_class_name": "QAbstractSpinBox.StepEnabledFlag", - "enum_value1": "StepNone", - "enum_value2": "StepUpEnabled", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FrameFeatures", - "enum_class": "FrameFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)" - ], - "qflag_full_class_name": "QStyleOptionFrame.FrameFeatures", - "enum_full_class_name": "QStyleOptionFrame.FrameFeature", - "enum_value1": "None_", - "enum_value2": "Flat", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ButtonFeatures", - "enum_class": "ButtonFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)" - ], - "qflag_full_class_name": "QStyleOptionButton.ButtonFeatures", - "enum_full_class_name": "QStyleOptionButton.ButtonFeature", - "enum_value1": "None_", - "enum_value2": "Flat", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "CornerWidgets", - "enum_class": "CornerWidget", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)" - ], - "qflag_full_class_name": "QStyleOptionTab.CornerWidgets", - "enum_full_class_name": "QStyleOptionTab.CornerWidget", - "enum_value1": "NoCornerWidgets", - "enum_value2": "LeftCornerWidget", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "TabFeatures", - "enum_class": "TabFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature)" - ], - "qflag_full_class_name": "QStyleOptionTab.TabFeatures", - "enum_full_class_name": "QStyleOptionTab.TabFeature", - "enum_value1": "None_", - "enum_value2": "HasFrame", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - }, - { - "qflag_class": "ToolBarFeatures", - "enum_class": "ToolBarFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)" - ], - "qflag_full_class_name": "QStyleOptionToolBar.ToolBarFeatures", - "enum_full_class_name": "QStyleOptionToolBar.ToolBarFeature", - "enum_value1": "None_", - "enum_value2": "Movable", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ViewItemFeatures", - "enum_class": "ViewItemFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)" - ], - "qflag_full_class_name": "QStyleOptionViewItem.ViewItemFeatures", - "enum_full_class_name": "QStyleOptionViewItem.ViewItemFeature", - "enum_value1": "None_", - "enum_value2": "WrapText", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "ToolButtonFeatures", - "enum_class": "ToolButtonFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)" - ], - "qflag_full_class_name": "QStyleOptionToolButton.ToolButtonFeatures", - "enum_full_class_name": "QStyleOptionToolButton.ToolButtonFeature", - "enum_value1": "None_", - "enum_value2": "Arrow", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "DockWidgetFeatures", - "enum_class": "DockWidgetFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)" - ], - "qflag_full_class_name": "QDockWidget.DockWidgetFeatures", - "enum_full_class_name": "QDockWidget.DockWidgetFeature", - "enum_value1": "DockWidgetClosable", - "enum_value2": "DockWidgetMovable", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "FontFilters", - "enum_class": "FontFilter", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter)" - ], - "qflag_full_class_name": "QFontComboBox.FontFilters", - "enum_full_class_name": "QFontComboBox.FontFilter", - "enum_value1": "AllFonts", - "enum_value2": "ScalableFonts", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "AreaOptions", - "enum_class": "AreaOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption)" - ], - "qflag_full_class_name": "QMdiArea.AreaOptions", - "enum_full_class_name": "QMdiArea.AreaOption", - "enum_value1": "DontMaximizeSubWindowOnActivation", - "enum_value2": "DontMaximizeSubWindowOnActivation", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "SubWindowOptions", - "enum_class": "SubWindowOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)" - ], - "qflag_full_class_name": "QMdiSubWindow.SubWindowOptions", - "enum_full_class_name": "QMdiSubWindow.SubWindowOption", - "enum_value1": "RubberBandResize", - "enum_value2": "RubberBandMove", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "DockOptions", - "enum_class": "DockOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption)" - ], - "qflag_full_class_name": "QMainWindow.DockOptions", - "enum_full_class_name": "QMainWindow.DockOption", - "enum_value1": "AnimatedDocks", - "enum_value2": "AllowNestedDocks", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - }, - { - "qflag_class": "AutoFormatting", - "enum_class": "AutoFormattingFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)" - ], - "qflag_full_class_name": "QTextEdit.AutoFormatting", - "enum_full_class_name": "QTextEdit.AutoFormattingFlag", - "enum_value1": "AutoNone", - "enum_value2": "AutoBulletList", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true - } - ], - "qflag_processed_done": [ - { - "qflag_class": "CheckIndexOptions", - "enum_class": "CheckIndexOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\itemmodels\\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)" - ], - "qflag_full_class_name": "QAbstractItemModel.CheckIndexOptions", - "enum_full_class_name": "QAbstractItemModel.CheckIndexOption", - "enum_value1": "NoOption", - "enum_value2": "IndexIsValid", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": false, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": false - } - ], - "qflag_process_error": [ - { - "qflag_class": "FormattingOptions", - "enum_class": "UrlFormattingOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)" - ], - "qflag_full_class_name": "QUrl.FormattingOptions", - "enum_full_class_name": "QUrl.UrlFormattingOption", - "enum_value1": "None_", - "enum_value2": "RemoveScheme", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true, - "error": [ - "Enum methods are present but not QFlag methods" - ] - }, - { - "qflag_class": "State", - "enum_class": "StateFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "QStyle.StateFlag", - "enum_value1": "State_None", - "enum_value2": "State_Enabled", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi", - "or_converts_to_multi": true, - "or_int_converts_to_multi": false, - "int_or_converts_to_multi": true, - "error": [ - "Could not locate class State" - ] - } - ] -} \ No newline at end of file diff --git a/tests/qflags/qtbase-qflags_to_process.json b/tests/qflags/qtbase-qflags_to_process.json deleted file mode 100644 index 9c7e56b7..00000000 --- a/tests/qflags/qtbase-qflags_to_process.json +++ /dev/null @@ -1,2193 +0,0 @@ -{ - "__": "This file can be adjusted manually by a human prior to being processed by the tool", - "qflags_to_process": [ - { - "qflag_class": "RegisterOptions", - "enum_class": "RegisterOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi" - }, - { - "qflag_class": "ConnectionCapabilities", - "enum_class": "ConnectionCapability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi" - }, - { - "qflag_class": "FormatOptions", - "enum_class": "FormatOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", - "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "FormatOptions", - "enum_class": "FormatOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", - "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" - }, - { - "qflag_class": "OpenGLVersionFlags", - "enum_class": "OpenGLVersionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" - }, - { - "qflag_class": "BindOptions", - "enum_class": "BindOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption)", - "src\\gui\\opengl\\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtOpenGL", - "module_path": "../../PyQt5-stubs/QtOpenGL.pyi" - }, - { - "qflag_class": "ShaderType", - "enum_class": "ShaderTypeBit", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\opengl\\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)", - "src\\gui\\opengl\\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "WatchMode", - "enum_class": "WatchModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\dbus\\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtDBus", - "module_path": "../../PyQt5-stubs/QtDBus.pyi" - }, - { - "qflag_class": "ConversionFlags", - "enum_class": "ConversionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\codecs\\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)", - "src\\corelib\\codecs\\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "CheckIndexOptions", - "enum_class": "CheckIndexOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\itemmodels\\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Filters", - "enum_class": "Filter", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(Filters, Filter)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "SortFlags", - "enum_class": "SortFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "IteratorFlags", - "enum_class": "IteratorFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "IteratorFlags", - "enum_class": "IteratorFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", - "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "Permissions", - "enum_class": "Permission", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "FileHandleFlags", - "enum_class": "FileHandleFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "SelectionFlags", - "enum_class": "SelectionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\itemmodels\\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "KeyboardModifiers", - "enum_class": "KeyboardModifier", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "MouseButtons", - "enum_class": "MouseButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Orientations", - "enum_class": "Orientation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Alignment", - "enum_class": "AlignmentFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "WindowFlags", - "enum_class": "WindowType", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "WindowStates", - "enum_class": "WindowState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "ApplicationStates", - "enum_class": "ApplicationState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "ScreenOrientations", - "enum_class": "ScreenOrientation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "ImageConversionFlags", - "enum_class": "ImageConversionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "DockWidgetAreas", - "enum_class": "DockWidgetArea", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "ToolBarAreas", - "enum_class": "ToolBarArea", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Edges", - "enum_class": "Edge", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "InputMethodQueries", - "enum_class": "InputMethodQuery", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "InputMethodHints", - "enum_class": "InputMethodHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "FindChildOptions", - "enum_class": "FindChildOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "DropActions", - "enum_class": "DropAction", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "ItemFlags", - "enum_class": "ItemFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "MatchFlags", - "enum_class": "MatchFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "TextInteractionFlags", - "enum_class": "TextInteractionFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "TouchPointStates", - "enum_class": "TouchPointState", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "GestureFlags", - "enum_class": "GestureFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "MouseEventFlags", - "enum_class": "MouseEventFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Transformations", - "enum_class": "Transformation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Capabilities", - "enum_class": "Capability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", - "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "Capabilities", - "enum_class": "Capability", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", - "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", - "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 1, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "ProcessEventsFlags", - "enum_class": "ProcessEventsFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "OpenMode", - "enum_class": "OpenModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "InfoFlags", - "enum_class": "InfoFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "LoadHints", - "enum_class": "LoadHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\plugin\\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "RangeAccessFlags", - "enum_class": "RangeAccessFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Sources", - "enum_class": "Source", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Types", - "enum_class": "Type", - "human_hint_qflag_full_class_name": "QOpenGLDebugMessage.Types", - "human_hint_enum_full_class_name": "QOpenGLDebugMessage.Type", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Severities", - "enum_class": "Severity", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "TypeFlags", - "enum_class": "TypeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "LocateOptions", - "enum_class": "LocateOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Flags", - "enum_class": "Flag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", - "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", - "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Flags", - "enum_class": "Flag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", - "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", - "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", - "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "PolicyFlags", - "enum_class": "PolicyFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\access\\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "StandardButtons", - "enum_class": "StandardButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "StandardButtons", - "enum_class": "StandardButton", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", - "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ColorDialogOptions", - "enum_class": "ColorDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)", - "src\\widgets\\dialogs\\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "FontDialogOptions", - "enum_class": "FontDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)", - "src\\widgets\\dialogs\\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ComponentFormattingOptions", - "enum_class": "ComponentFormattingOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "FormattingOptions", - "enum_class": "UrlFormattingOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "UserInputResolutionOptions", - "enum_class": "UserInputResolutionOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "StateFlags", - "enum_class": "StateFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\bearer\\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "UsagePolicies", - "enum_class": "UsagePolicy", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\bearer\\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "RenderFlags", - "enum_class": "RenderFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", - "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "RenderFlags", - "enum_class": "RenderFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", - "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "PaintEngineFeatures", - "enum_class": "PaintEngineFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "DirtyFlags", - "enum_class": "DirtyFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Capabilities", - "enum_class": "CapabilityFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\kernel\\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "Features", - "enum_class": "Feature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\opengl\\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature)", - "src\\gui\\text\\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "RenderHints", - "enum_class": "RenderHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "PixmapFragmentHints", - "enum_class": "PixmapFragmentHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "ControlTypes", - "enum_class": "ControlType", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\util\\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)", - "src\\widgets\\kernel\\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "GlyphRunFlags", - "enum_class": "GlyphRunFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "LayoutFlags", - "enum_class": "LayoutFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "MarkdownFeatures", - "enum_class": "MarkdownFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "FindFlags", - "enum_class": "FindFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "ConversionMode", - "enum_class": "ConversionModeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\kernel\\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "BindMode", - "enum_class": "BindFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "PauseModes", - "enum_class": "PauseMode", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "PageBreakFlags", - "enum_class": "PageBreakFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\gui\\text\\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtGui", - "module_path": "../../PyQt5-stubs/QtGui.pyi" - }, - { - "qflag_class": "SocketOptions", - "enum_class": "SocketOption", - "human_hint_qflag_full_class_name": "QLocalServer.SocketOptions", - "human_hint_enum_full_class_name": "QLocalServer.SocketOption", - "grep_line": [ - "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "InterfaceFlags", - "enum_class": "InterfaceFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\kernel\\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "SslOptions", - "enum_class": "SslOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\network\\ssl\\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtNetwork", - "module_path": "../../PyQt5-stubs/QtNetwork.pyi" - }, - { - "qflag_class": "Base64Options", - "enum_class": "Base64Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "NumberOptions", - "enum_class": "NumberOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "DataSizeFormats", - "enum_class": "DataSizeFormat", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "Sections", - "enum_class": "Section", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\time\\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section)", - "src\\widgets\\widgets\\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "PatternOptions", - "enum_class": "PatternOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "MatchOptions", - "enum_class": "MatchOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "NumberFlags", - "enum_class": "NumberFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\serialization\\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "BoundaryReasons", - "enum_class": "BoundaryReason", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\corelib\\text\\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtCore", - "module_path": "../../PyQt5-stubs/QtCore.pyi" - }, - { - "qflag_class": "PrintDialogOptions", - "enum_class": "PrintDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\printsupport\\dialogs\\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtPrintSupport", - "module_path": "../../PyQt5-stubs/QtPrintSupport.pyi" - }, - { - "qflag_class": "ParamType", - "enum_class": "ParamTypeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\sql\\kernel\\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtSql", - "module_path": "../../PyQt5-stubs/QtSql.pyi" - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 3, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 3, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "Options", - "enum_class": "Option", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", - "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 3, - "module_idx": 2, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ChangeFlags", - "enum_class": "ChangeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", - "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ChangeFlags", - "enum_class": "ChangeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", - "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 2, - "module_idx": 1, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "BlurHints", - "enum_class": "BlurHint", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "InputDialogOptions", - "enum_class": "InputDialogOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "WizardOptions", - "enum_class": "WizardOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\dialogs\\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "EditTriggers", - "enum_class": "EditTrigger", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\itemviews\\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "GraphicsItemFlags", - "enum_class": "GraphicsItemFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "Result", - "enum_class": "ResultFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\kernel\\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "SceneLayers", - "enum_class": "SceneLayer", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "CacheMode", - "enum_class": "CacheModeFlag", - "human_hint_qflag_full_class_name": "QGraphicsView.CacheMode", - "human_hint_enum_full_class_name": "QGraphicsView.CacheModeFlag", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "OptimizationFlags", - "enum_class": "OptimizationFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "State", - "enum_class": "StateFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "SubControls", - "enum_class": "SubControl", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "StepEnabled", - "enum_class": "StepEnabledFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "FrameFeatures", - "enum_class": "FrameFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ButtonFeatures", - "enum_class": "ButtonFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "CornerWidgets", - "enum_class": "CornerWidget", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "TabFeatures", - "enum_class": "TabFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ToolBarFeatures", - "enum_class": "ToolBarFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ViewItemFeatures", - "enum_class": "ViewItemFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "ToolButtonFeatures", - "enum_class": "ToolButtonFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "DockWidgetFeatures", - "enum_class": "DockWidgetFeature", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "FontFilters", - "enum_class": "FontFilter", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "AreaOptions", - "enum_class": "AreaOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "SubWindowOptions", - "enum_class": "SubWindowOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "DockOptions", - "enum_class": "DockOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - }, - { - "qflag_class": "AutoFormatting", - "enum_class": "AutoFormattingFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\widgets\\widgets\\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtWidgets", - "module_path": "../../PyQt5-stubs/QtWidgets.pyi" - } - ], - "qflags_to_skip": [] -} \ No newline at end of file From 0eae751e6e2cc0d5bb6f584da31aad8f045d72e8 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 11:37:59 +0100 Subject: [PATCH 275/421] All qflag processing results --- tests/qflags/qflags_modules_analysis.json | 126 + tests/qflags/qflags_process_result.json | 2671 +++++++++++++++++++++ tests/qflags/qflags_to_process.json | 4 +- 3 files changed, 2799 insertions(+), 2 deletions(-) create mode 100644 tests/qflags/qflags_modules_analysis.json create mode 100644 tests/qflags/qflags_process_result.json diff --git a/tests/qflags/qflags_modules_analysis.json b/tests/qflags/qflags_modules_analysis.json new file mode 100644 index 00000000..b4341ac8 --- /dev/null +++ b/tests/qflags/qflags_modules_analysis.json @@ -0,0 +1,126 @@ +{ + "flag_and_module_identified": [ + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h:Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + }, + { + "qflag_class": "DeliveryFlags", + "enum_class": "DeliveryFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h: Q_DECLARE_FLAGS(DeliveryFlags, DeliveryFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + }, + { + "qflag_class": "BufferTypeFlags", + "enum_class": "BufferType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qclearbuffers.h: Q_DECLARE_FLAGS(BufferTypeFlags, BufferType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + }, + { + "qflag_class": "Operations", + "enum_class": "Operation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qmemorybarrier.h: Q_DECLARE_FLAGS(Operations, Operation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + } + ], + "flag_without_module": [ + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\animation\\frontend\\qanimationcallback.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "BackendNodeDirtySet", + "enum_class": "BackendNodeDirtyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\backend\\abstractrenderer_p.h: Q_DECLARE_FLAGS(BackendNodeDirtySet, BackendNodeDirtyFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "DirtyFlags", + "enum_class": "DirtyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\texture\\texture_p.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)", + "src\\quick3d\\imports\\scene3d\\scene3dview_p.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + } + ] +} \ No newline at end of file diff --git a/tests/qflags/qflags_process_result.json b/tests/qflags/qflags_process_result.json new file mode 100644 index 00000000..87fc4e63 --- /dev/null +++ b/tests/qflags/qflags_process_result.json @@ -0,0 +1,2671 @@ +{ + "qflag_already_done": [ + { + "qflag_class": "RegisterOptions", + "enum_class": "RegisterOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)" + ], + "qflag_full_class_name": "QDBusConnection.RegisterOptions", + "enum_full_class_name": "QDBusConnection.RegisterOption", + "enum_value1": "ExportAdaptors", + "enum_value2": "ExportScriptableSlots", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ConnectionCapabilities", + "enum_class": "ConnectionCapability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusconnection.h: Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)" + ], + "qflag_full_class_name": "QDBusConnection.ConnectionCapabilities", + "enum_full_class_name": "QDBusConnection.ConnectionCapability", + "enum_value1": "UnixFileDescriptorPassing", + "enum_value2": "UnixFileDescriptorPassing", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "QSurfaceFormat.FormatOptions", + "enum_full_class_name": "QSurfaceFormat.FormatOption", + "enum_value1": "StereoBuffers", + "enum_value2": "DebugContext", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FormatOptions", + "enum_class": "FormatOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)", + "src\\gui\\kernel\\qsurfaceformat.h: Q_DECLARE_FLAGS(FormatOptions, FormatOption)" + ], + "qflag_full_class_name": "QGL.FormatOptions", + "enum_full_class_name": "QGL.FormatOption", + "enum_value1": "DoubleBuffer", + "enum_value2": "DepthBuffer", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "OpenGLVersionFlags", + "enum_class": "OpenGLVersionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(OpenGLVersionFlags, OpenGLVersionFlag)" + ], + "qflag_full_class_name": "QGLFormat.OpenGLVersionFlags", + "enum_full_class_name": "QGLFormat.OpenGLVersionFlag", + "enum_value1": "OpenGL_Version_None", + "enum_value2": "OpenGL_Version_1_1", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BindOptions", + "enum_class": "BindOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qgl.h: Q_DECLARE_FLAGS(BindOptions, BindOption)", + "src\\gui\\opengl\\qopengltextureuploader_p.h: Q_DECLARE_FLAGS(BindOptions, BindOption)" + ], + "qflag_full_class_name": "QGLContext.BindOptions", + "enum_full_class_name": "QGLContext.BindOption", + "enum_value1": "NoBindOption", + "enum_value2": "InvertedYBindOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtOpenGL", + "module_path": "../../PyQt5-stubs/QtOpenGL.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ShaderType", + "enum_class": "ShaderTypeBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\opengl\\qglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)", + "src\\gui\\opengl\\qopenglshaderprogram.h: Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)" + ], + "qflag_full_class_name": "QOpenGLShader.ShaderType", + "enum_full_class_name": "QOpenGLShader.ShaderTypeBit", + "enum_value1": "Vertex", + "enum_value2": "Fragment", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WatchMode", + "enum_class": "WatchModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\dbus\\qdbusservicewatcher.h: Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)" + ], + "qflag_full_class_name": "QDBusServiceWatcher.WatchMode", + "enum_full_class_name": "QDBusServiceWatcher.WatchModeFlag", + "enum_value1": "WatchForRegistration", + "enum_value2": "WatchForUnregistration", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDBus", + "module_path": "../../PyQt5-stubs/QtDBus.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ConversionFlags", + "enum_class": "ConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\codecs\\qtextcodec.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)", + "src\\corelib\\codecs\\qtextcodec_p.h: Q_DECLARE_FLAGS(ConversionFlags, ConversionFlag)" + ], + "qflag_full_class_name": "QTextCodec.ConversionFlags", + "enum_full_class_name": "QTextCodec.ConversionFlag", + "enum_value1": "DefaultConversion", + "enum_value2": "ConvertInvalidToNull", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "CheckIndexOptions", + "enum_class": "CheckIndexOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\itemmodels\\qabstractitemmodel.h: Q_DECLARE_FLAGS(CheckIndexOptions, CheckIndexOption)" + ], + "qflag_full_class_name": "QAbstractItemModel.CheckIndexOptions", + "enum_full_class_name": "QAbstractItemModel.CheckIndexOption", + "enum_value1": "NoOption", + "enum_value2": "IndexIsValid", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "Filters", + "enum_class": "Filter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(Filters, Filter)" + ], + "qflag_full_class_name": "QDir.Filters", + "enum_full_class_name": "QDir.Filter", + "enum_value1": "Dirs", + "enum_value2": "Files", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SortFlags", + "enum_class": "SortFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdir.h: Q_DECLARE_FLAGS(SortFlags, SortFlag)" + ], + "qflag_full_class_name": "QDir.SortFlags", + "enum_full_class_name": "QDir.SortFlag", + "enum_value1": "Name", + "enum_value2": "Time", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "QDirIterator.IteratorFlags", + "enum_full_class_name": "QDirIterator.IteratorFlag", + "enum_value1": "NoIteratorFlags", + "enum_value2": "FollowSymlinks", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "IteratorFlags", + "enum_class": "IteratorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qdiriterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "src\\widgets\\itemviews\\qtreewidgetitemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)", + "tests\\benchmarks\\corelib\\io\\qdiriterator\\qfilesystemiterator.h: Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)" + ], + "qflag_full_class_name": "QTreeWidgetItemIterator.IteratorFlags", + "enum_full_class_name": "QTreeWidgetItemIterator.IteratorFlag", + "enum_value1": "All", + "enum_value2": "Hidden", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Permissions", + "enum_class": "Permission", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(Permissions, Permission)" + ], + "qflag_full_class_name": "QFileDevice.Permissions", + "enum_full_class_name": "QFileDevice.Permission", + "enum_value1": "ReadOwner", + "enum_value2": "WriteOwner", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SelectionFlags", + "enum_class": "SelectionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\itemmodels\\qitemselectionmodel.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" + ], + "qflag_full_class_name": "QItemSelectionModel.SelectionFlags", + "enum_full_class_name": "QItemSelectionModel.SelectionFlag", + "enum_value1": "NoUpdate", + "enum_value2": "Clear", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "KeyboardModifiers", + "enum_class": "KeyboardModifier", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(KeyboardModifiers, KeyboardModifier)" + ], + "qflag_full_class_name": "Qt.KeyboardModifiers", + "enum_full_class_name": "Qt.KeyboardModifier", + "enum_value1": "NoModifier", + "enum_value2": "ShiftModifier", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MouseButtons", + "enum_class": "MouseButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseButtons, MouseButton)" + ], + "qflag_full_class_name": "Qt.MouseButtons", + "enum_full_class_name": "Qt.MouseButton", + "enum_value1": "NoButton", + "enum_value2": "AllButtons", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Orientations", + "enum_class": "Orientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Orientations, Orientation)" + ], + "qflag_full_class_name": "Qt.Orientations", + "enum_full_class_name": "Qt.Orientation", + "enum_value1": "Horizontal", + "enum_value2": "Vertical", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Alignment", + "enum_class": "AlignmentFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Alignment, AlignmentFlag)" + ], + "qflag_full_class_name": "Qt.Alignment", + "enum_full_class_name": "Qt.AlignmentFlag", + "enum_value1": "AlignLeft", + "enum_value2": "AlignLeading", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WindowFlags", + "enum_class": "WindowType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowFlags, WindowType)" + ], + "qflag_full_class_name": "Qt.WindowFlags", + "enum_full_class_name": "Qt.WindowType", + "enum_value1": "Widget", + "enum_value2": "Window", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WindowStates", + "enum_class": "WindowState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(WindowStates, WindowState)" + ], + "qflag_full_class_name": "Qt.WindowStates", + "enum_full_class_name": "Qt.WindowState", + "enum_value1": "WindowNoState", + "enum_value2": "WindowMinimized", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ScreenOrientations", + "enum_class": "ScreenOrientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ScreenOrientations, ScreenOrientation)" + ], + "qflag_full_class_name": "Qt.ScreenOrientations", + "enum_full_class_name": "Qt.ScreenOrientation", + "enum_value1": "PrimaryOrientation", + "enum_value2": "PortraitOrientation", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ImageConversionFlags", + "enum_class": "ImageConversionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ImageConversionFlags, ImageConversionFlag)" + ], + "qflag_full_class_name": "Qt.ImageConversionFlags", + "enum_full_class_name": "Qt.ImageConversionFlag", + "enum_value1": "AutoColor", + "enum_value2": "ColorOnly", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DockWidgetAreas", + "enum_class": "DockWidgetArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DockWidgetAreas, DockWidgetArea)" + ], + "qflag_full_class_name": "Qt.DockWidgetAreas", + "enum_full_class_name": "Qt.DockWidgetArea", + "enum_value1": "LeftDockWidgetArea", + "enum_value2": "RightDockWidgetArea", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ToolBarAreas", + "enum_class": "ToolBarArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)" + ], + "qflag_full_class_name": "Qt.ToolBarAreas", + "enum_full_class_name": "Qt.ToolBarArea", + "enum_value1": "LeftToolBarArea", + "enum_value2": "RightToolBarArea", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Edges", + "enum_class": "Edge", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(Edges, Edge)" + ], + "qflag_full_class_name": "Qt.Edges", + "enum_full_class_name": "Qt.Edge", + "enum_value1": "TopEdge", + "enum_value2": "LeftEdge", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InputMethodQueries", + "enum_class": "InputMethodQuery", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodQueries, InputMethodQuery)" + ], + "qflag_full_class_name": "Qt.InputMethodQueries", + "enum_full_class_name": "Qt.InputMethodQuery", + "enum_value1": "ImMicroFocus", + "enum_value2": "ImFont", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InputMethodHints", + "enum_class": "InputMethodHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(InputMethodHints, InputMethodHint)" + ], + "qflag_full_class_name": "Qt.InputMethodHints", + "enum_full_class_name": "Qt.InputMethodHint", + "enum_value1": "ImhNone", + "enum_value2": "ImhHiddenText", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DropActions", + "enum_class": "DropAction", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(DropActions, DropAction)" + ], + "qflag_full_class_name": "Qt.DropActions", + "enum_full_class_name": "Qt.DropAction", + "enum_value1": "CopyAction", + "enum_value2": "MoveAction", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ItemFlags", + "enum_class": "ItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ItemFlags, ItemFlag)" + ], + "qflag_full_class_name": "Qt.ItemFlags", + "enum_full_class_name": "Qt.ItemFlag", + "enum_value1": "NoItemFlags", + "enum_value2": "ItemIsSelectable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MatchFlags", + "enum_class": "MatchFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MatchFlags, MatchFlag)" + ], + "qflag_full_class_name": "Qt.MatchFlags", + "enum_full_class_name": "Qt.MatchFlag", + "enum_value1": "MatchExactly", + "enum_value2": "MatchFixedString", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "TextInteractionFlags", + "enum_class": "TextInteractionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TextInteractionFlags, TextInteractionFlag)" + ], + "qflag_full_class_name": "Qt.TextInteractionFlags", + "enum_full_class_name": "Qt.TextInteractionFlag", + "enum_value1": "NoTextInteraction", + "enum_value2": "TextSelectableByMouse", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "TouchPointStates", + "enum_class": "TouchPointState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)" + ], + "qflag_full_class_name": "Qt.TouchPointStates", + "enum_full_class_name": "Qt.TouchPointState", + "enum_value1": "TouchPointPressed", + "enum_value2": "TouchPointMoved", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "GestureFlags", + "enum_class": "GestureFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(GestureFlags, GestureFlag)" + ], + "qflag_full_class_name": "Qt.GestureFlags", + "enum_full_class_name": "Qt.GestureFlag", + "enum_value1": "DontStartGestureOnChildren", + "enum_value2": "ReceivePartialGestures", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MouseEventFlags", + "enum_class": "MouseEventFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(MouseEventFlags, MouseEventFlag)" + ], + "qflag_full_class_name": "Qt.MouseEventFlags", + "enum_full_class_name": "Qt.MouseEventFlag", + "enum_value1": "MouseEventCreatedDoubleClick", + "enum_value2": "MouseEventCreatedDoubleClick", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "QNetworkConfigurationManager.Capabilities", + "enum_full_class_name": "QNetworkConfigurationManager.Capability", + "enum_value1": "CanStartAndStopInterfaces", + "enum_value2": "DirectConnectionRouting", + "module_count": 2, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ProcessEventsFlags", + "enum_class": "ProcessEventsFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qeventloop.h: Q_DECLARE_FLAGS(ProcessEventsFlags, ProcessEventsFlag)" + ], + "qflag_full_class_name": "QEventLoop.ProcessEventsFlags", + "enum_full_class_name": "QEventLoop.ProcessEventsFlag", + "enum_value1": "AllEvents", + "enum_value2": "ExcludeUserInputEvents", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "OpenMode", + "enum_class": "OpenModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qiodevice.h: Q_DECLARE_FLAGS(OpenMode, OpenModeFlag)" + ], + "qflag_full_class_name": "QIODevice.OpenMode", + "enum_full_class_name": "QIODevice.OpenModeFlag", + "enum_value1": "NotOpen", + "enum_value2": "ReadOnly", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InfoFlags", + "enum_class": "InfoFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qevent.h: Q_DECLARE_FLAGS(InfoFlags, InfoFlag)" + ], + "qflag_full_class_name": "QTouchEvent.TouchPoint.InfoFlags", + "enum_full_class_name": "QTouchEvent.TouchPoint.InfoFlag", + "enum_value1": "Pen", + "enum_value2": "Token", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "LoadHints", + "enum_class": "LoadHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\plugin\\qlibrary.h: Q_DECLARE_FLAGS(LoadHints, LoadHint)" + ], + "qflag_full_class_name": "QLibrary.LoadHints", + "enum_full_class_name": "QLibrary.LoadHint", + "enum_value1": "ResolveAllSymbolsHint", + "enum_value2": "ExportExternalSymbolsHint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "RangeAccessFlags", + "enum_class": "RangeAccessFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopenglbuffer.h: Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)" + ], + "qflag_full_class_name": "QOpenGLBuffer.RangeAccessFlags", + "enum_full_class_name": "QOpenGLBuffer.RangeAccessFlag", + "enum_value1": "RangeRead", + "enum_value2": "RangeWrite", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Sources", + "enum_class": "Source", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Sources, Source)" + ], + "qflag_full_class_name": "QOpenGLDebugMessage.Sources", + "enum_full_class_name": "QOpenGLDebugMessage.Source", + "enum_value1": "InvalidSource", + "enum_value2": "APISource", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Types", + "enum_class": "Type", + "human_hint_qflag_full_class_name": "QOpenGLDebugMessage.Types", + "human_hint_enum_full_class_name": "QOpenGLDebugMessage.Type", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Types, Type)" + ], + "qflag_full_class_name": "QOpenGLDebugMessage.Types", + "enum_full_class_name": "QOpenGLDebugMessage.Type", + "enum_value1": "InvalidType", + "enum_value2": "ErrorType", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Severities", + "enum_class": "Severity", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengldebug.h: Q_DECLARE_FLAGS(Severities, Severity)" + ], + "qflag_full_class_name": "QOpenGLDebugMessage.Severities", + "enum_full_class_name": "QOpenGLDebugMessage.Severity", + "enum_value1": "InvalidSeverity", + "enum_value2": "HighSeverity", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "TypeFlags", + "enum_class": "TypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qmetatype.h: Q_DECLARE_FLAGS(TypeFlags, TypeFlag)" + ], + "qflag_full_class_name": "QMetaType.TypeFlags", + "enum_full_class_name": "QMetaType.TypeFlag", + "enum_value1": "NeedsConstruction", + "enum_value2": "NeedsDestruction", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "LocateOptions", + "enum_class": "LocateOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qstandardpaths.h: Q_DECLARE_FLAGS(LocateOptions, LocateOption)" + ], + "qflag_full_class_name": "QStandardPaths.LocateOptions", + "enum_full_class_name": "QStandardPaths.LocateOption", + "enum_value1": "LocateFile", + "enum_value2": "LocateDirectory", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QCommandLineOption.Flags", + "enum_full_class_name": "QCommandLineOption.Flag", + "enum_value1": "HiddenFromHelp", + "enum_value2": "ShortOptionStyle", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\kernel\\qppsattribute_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\painting\\qplatformbackingstore.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qrhi_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkaninstance.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\rhi\\qshader_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\vulkan\\qvulkanwindow.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\gui\\text\\qtextoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\corelib\\tools\\qcommandlineoption.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\eglconvenience\\qeglplatformcontext_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\platformsupport\\fbconvenience\\qfbscreen_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\plugins\\platforms\\direct2d\\qwindowsdirect2dpaintengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\tools\\moc\\namespaced-flags.h: Q_DECLARE_FLAGS( Flags, Flag )", + "src\\plugins\\platforms\\eglfs\\api\\qeglfswindow_p.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QTextOption.Flags", + "enum_full_class_name": "QTextOption.Flag", + "enum_value1": "IncludeTrailingSpaces", + "enum_value2": "ShowTabsAndSpaces", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PolicyFlags", + "enum_class": "PolicyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\access\\qhstspolicy.h: Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag)" + ], + "qflag_full_class_name": "QHstsPolicy.PolicyFlags", + "enum_full_class_name": "QHstsPolicy.PolicyFlag", + "enum_value1": "IncludeSubDomains", + "enum_value2": "IncludeSubDomains", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "QDialogButtonBox.StandardButtons", + "enum_full_class_name": "QDialogButtonBox.StandardButton", + "enum_value1": "NoButton", + "enum_value2": "Ok", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "StandardButtons", + "enum_class": "StandardButton", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\dialogs\\qmessagebox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)", + "src\\widgets\\widgets\\qdialogbuttonbox.h: Q_DECLARE_FLAGS(StandardButtons, StandardButton)" + ], + "qflag_full_class_name": "QMessageBox.StandardButtons", + "enum_full_class_name": "QMessageBox.StandardButton", + "enum_value1": "NoButton", + "enum_value2": "Ok", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ColorDialogOptions", + "enum_class": "ColorDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)", + "src\\widgets\\dialogs\\qcolordialog.h: Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)" + ], + "qflag_full_class_name": "QColorDialog.ColorDialogOptions", + "enum_full_class_name": "QColorDialog.ColorDialogOption", + "enum_value1": "ShowAlphaChannel", + "enum_value2": "NoButtons", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FontDialogOptions", + "enum_class": "FontDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qplatformdialoghelper.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)", + "src\\widgets\\dialogs\\qfontdialog.h: Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)" + ], + "qflag_full_class_name": "QFontDialog.FontDialogOptions", + "enum_full_class_name": "QFontDialog.FontDialogOption", + "enum_value1": "NoButtons", + "enum_value2": "DontUseNativeDialog", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ComponentFormattingOptions", + "enum_class": "ComponentFormattingOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)" + ], + "qflag_full_class_name": "QUrl.ComponentFormattingOptions", + "enum_full_class_name": "QUrl.ComponentFormattingOption", + "enum_value1": "PrettyDecoded", + "enum_value2": "EncodeSpaces", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "QWidget.RenderFlags", + "enum_full_class_name": "QWidget.RenderFlag", + "enum_value1": "DrawWindowBackground", + "enum_value2": "DrawChildren", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "RenderFlags", + "enum_class": "RenderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)", + "src\\widgets\\kernel\\qwidget.h: Q_DECLARE_FLAGS(RenderFlags, RenderFlag)" + ], + "qflag_full_class_name": "QTextItem.RenderFlags", + "enum_full_class_name": "QTextItem.RenderFlag", + "enum_value1": "RightToLeft", + "enum_value2": "Overline", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PaintEngineFeatures", + "enum_class": "PaintEngineFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(PaintEngineFeatures, PaintEngineFeature)" + ], + "qflag_full_class_name": "QPaintEngine.PaintEngineFeatures", + "enum_full_class_name": "QPaintEngine.PaintEngineFeature", + "enum_value1": "PrimitiveTransform", + "enum_value2": "PatternTransform", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Capabilities", + "enum_class": "CapabilityFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\kernel\\qtouchdevice.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" + ], + "qflag_full_class_name": "QTouchDevice.Capabilities", + "enum_full_class_name": "QTouchDevice.CapabilityFlag", + "enum_value1": "Position", + "enum_value2": "Area", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Features", + "enum_class": "Feature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\opengl\\qopengltexture.h: Q_DECLARE_FLAGS(Features, Feature)", + "src\\gui\\text\\qtextmarkdownimporter_p.h: Q_DECLARE_FLAGS(Features, Feature)" + ], + "qflag_full_class_name": "QOpenGLTexture.Features", + "enum_full_class_name": "QOpenGLTexture.Feature", + "enum_value1": "ImmutableStorage", + "enum_value2": "ImmutableMultisampleStorage", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "RenderHints", + "enum_class": "RenderHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(RenderHints, RenderHint)" + ], + "qflag_full_class_name": "QPainter.RenderHints", + "enum_full_class_name": "QPainter.RenderHint", + "enum_value1": "Antialiasing", + "enum_value2": "TextAntialiasing", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ControlTypes", + "enum_class": "ControlType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\util\\qlayoutpolicy_p.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)", + "src\\widgets\\kernel\\qsizepolicy.h: Q_DECLARE_FLAGS(ControlTypes, ControlType)" + ], + "qflag_full_class_name": "QSizePolicy.ControlTypes", + "enum_full_class_name": "QSizePolicy.ControlType", + "enum_value1": "DefaultType", + "enum_value2": "ButtonBox", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "LayoutFlags", + "enum_class": "LayoutFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qrawfont.h: Q_DECLARE_FLAGS(LayoutFlags, LayoutFlag)" + ], + "qflag_full_class_name": "QRawFont.LayoutFlags", + "enum_full_class_name": "QRawFont.LayoutFlag", + "enum_value1": "SeparateAdvances", + "enum_value2": "KernedAdvances", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FindFlags", + "enum_class": "FindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(FindFlags, FindFlag)" + ], + "qflag_full_class_name": "QTextDocument.FindFlags", + "enum_full_class_name": "QTextDocument.FindFlag", + "enum_value1": "FindBackward", + "enum_value2": "FindCaseSensitively", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ConversionMode", + "enum_class": "ConversionModeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\kernel\\qhostaddress.h: Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)" + ], + "qflag_full_class_name": "QHostAddress.ConversionMode", + "enum_full_class_name": "QHostAddress.ConversionModeFlag", + "enum_value1": "ConvertV4MappedToIPv4", + "enum_value2": "ConvertV4CompatToIPv4", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BindMode", + "enum_class": "BindFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(BindMode, BindFlag)" + ], + "qflag_full_class_name": "QAbstractSocket.BindMode", + "enum_full_class_name": "QAbstractSocket.BindFlag", + "enum_value1": "DefaultForPlatform", + "enum_value2": "ShareAddress", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PauseModes", + "enum_class": "PauseMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\socket\\qabstractsocket.h: Q_DECLARE_FLAGS(PauseModes, PauseMode)" + ], + "qflag_full_class_name": "QAbstractSocket.PauseModes", + "enum_full_class_name": "QAbstractSocket.PauseMode", + "enum_value1": "PauseNever", + "enum_value2": "PauseOnSslErrors", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PageBreakFlags", + "enum_class": "PageBreakFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextformat.h: Q_DECLARE_FLAGS(PageBreakFlags, PageBreakFlag)" + ], + "qflag_full_class_name": "QTextFormat.PageBreakFlags", + "enum_full_class_name": "QTextFormat.PageBreakFlag", + "enum_value1": "PageBreak_Auto", + "enum_value2": "PageBreak_AlwaysBefore", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SocketOptions", + "enum_class": "SocketOption", + "human_hint_qflag_full_class_name": "QLocalServer.SocketOptions", + "human_hint_enum_full_class_name": "QLocalServer.SocketOption", + "grep_line": [ + "src\\network\\socket\\qlocalserver.h: Q_DECLARE_FLAGS(SocketOptions, SocketOption)" + ], + "qflag_full_class_name": "QLocalServer.SocketOptions", + "enum_full_class_name": "QLocalServer.SocketOption", + "enum_value1": "UserAccessOption", + "enum_value2": "GroupAccessOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InterfaceFlags", + "enum_class": "InterfaceFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\kernel\\qnetworkinterface.h: Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)" + ], + "qflag_full_class_name": "QNetworkInterface.InterfaceFlags", + "enum_full_class_name": "QNetworkInterface.InterfaceFlag", + "enum_value1": "IsUp", + "enum_value2": "IsRunning", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SslOptions", + "enum_class": "SslOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\ssl\\qssl.h: Q_DECLARE_FLAGS(SslOptions, SslOption)" + ], + "qflag_full_class_name": "QSsl.SslOptions", + "enum_full_class_name": "QSsl.SslOption", + "enum_value1": "SslOptionDisableEmptyFragments", + "enum_value2": "SslOptionDisableSessionTickets", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Base64Options", + "enum_class": "Base64Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qbytearray.h: Q_DECLARE_FLAGS(Base64Options, Base64Option)" + ], + "qflag_full_class_name": "QByteArray.Base64Options", + "enum_full_class_name": "QByteArray.Base64Option", + "enum_value1": "Base64Encoding", + "enum_value2": "Base64UrlEncoding", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "NumberOptions", + "enum_class": "NumberOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(NumberOptions, NumberOption)" + ], + "qflag_full_class_name": "QLocale.NumberOptions", + "enum_full_class_name": "QLocale.NumberOption", + "enum_value1": "OmitGroupSeparator", + "enum_value2": "RejectGroupSeparator", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Sections", + "enum_class": "Section", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\time\\qdatetimeparser_p.h: Q_DECLARE_FLAGS(Sections, Section)", + "src\\widgets\\widgets\\qdatetimeedit.h: Q_DECLARE_FLAGS(Sections, Section)" + ], + "qflag_full_class_name": "QDateTimeEdit.Sections", + "enum_full_class_name": "QDateTimeEdit.Section", + "enum_value1": "NoSection", + "enum_value2": "AmPmSection", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PatternOptions", + "enum_class": "PatternOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(PatternOptions, PatternOption)" + ], + "qflag_full_class_name": "QRegularExpression.PatternOptions", + "enum_full_class_name": "QRegularExpression.PatternOption", + "enum_value1": "NoPatternOption", + "enum_value2": "CaseInsensitiveOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "MatchOptions", + "enum_class": "MatchOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qregularexpression.h: Q_DECLARE_FLAGS(MatchOptions, MatchOption)" + ], + "qflag_full_class_name": "QRegularExpression.MatchOptions", + "enum_full_class_name": "QRegularExpression.MatchOption", + "enum_value1": "NoMatchOption", + "enum_value2": "AnchoredMatchOption", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "NumberFlags", + "enum_class": "NumberFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\serialization\\qtextstream.h: Q_DECLARE_FLAGS(NumberFlags, NumberFlag)" + ], + "qflag_full_class_name": "QTextStream.NumberFlags", + "enum_full_class_name": "QTextStream.NumberFlag", + "enum_value1": "ShowBase", + "enum_value2": "ForcePoint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BoundaryReasons", + "enum_class": "BoundaryReason", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qtextboundaryfinder.h: Q_DECLARE_FLAGS( BoundaryReasons, BoundaryReason )" + ], + "qflag_full_class_name": "QTextBoundaryFinder.BoundaryReasons", + "enum_full_class_name": "QTextBoundaryFinder.BoundaryReason", + "enum_value1": "NotAtBoundary", + "enum_value2": "SoftHyphen", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "PrintDialogOptions", + "enum_class": "PrintDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\printsupport\\dialogs\\qabstractprintdialog.h: Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)" + ], + "qflag_full_class_name": "QAbstractPrintDialog.PrintDialogOptions", + "enum_full_class_name": "QAbstractPrintDialog.PrintDialogOption", + "enum_value1": "None_", + "enum_value2": "PrintToFile", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPrintSupport", + "module_path": "../../PyQt5-stubs/QtPrintSupport.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ParamType", + "enum_class": "ParamTypeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\sql\\kernel\\qtsqlglobal.h: Q_DECLARE_FLAGS(ParamType, ParamTypeFlag)" + ], + "qflag_full_class_name": "QSql.ParamType", + "enum_full_class_name": "QSql.ParamTypeFlag", + "enum_value1": "In", + "enum_value2": "Out", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSql", + "module_path": "../../PyQt5-stubs/QtSql.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "QFileDialog.Options", + "enum_full_class_name": "QFileDialog.Option", + "enum_value1": "ShowDirsOnly", + "enum_value2": "DontResolveSymlinks", + "module_count": 3, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "QFileIconProvider.Options", + "enum_full_class_name": "QFileIconProvider.Option", + "enum_value1": "DontUseCustomDirectoryIcons", + "enum_value2": "DontUseCustomDirectoryIcons", + "module_count": 3, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qfiledialog.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\dialogs\\qfilesystemmodel.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\widgets\\itemviews\\qfileiconprovider.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\cocoa\\qcocoaintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "src\\plugins\\platforms\\qnx\\qqnxintegration.h: Q_DECLARE_FLAGS(Options, Option)", + "tests\\benchmarks\\widgets\\graphicsview\\functional\\GraphicsViewBenchmark\\widgets\\settings.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "QFileSystemModel.Options", + "enum_full_class_name": "QFileSystemModel.Option", + "enum_value1": "DontWatchForChanges", + "enum_value2": "DontResolveSymlinks", + "module_count": 3, + "module_idx": 2, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "BlurHints", + "enum_class": "BlurHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(BlurHints, BlurHint)" + ], + "qflag_full_class_name": "QGraphicsBlurEffect.BlurHints", + "enum_full_class_name": "QGraphicsBlurEffect.BlurHint", + "enum_value1": "PerformanceHint", + "enum_value2": "QualityHint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "InputDialogOptions", + "enum_class": "InputDialogOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qinputdialog.h: Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)" + ], + "qflag_full_class_name": "QInputDialog.InputDialogOptions", + "enum_full_class_name": "QInputDialog.InputDialogOption", + "enum_value1": "NoButtons", + "enum_value2": "UseListViewForComboBoxItems", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "WizardOptions", + "enum_class": "WizardOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\dialogs\\qwizard.h: Q_DECLARE_FLAGS(WizardOptions, WizardOption)" + ], + "qflag_full_class_name": "QWizard.WizardOptions", + "enum_full_class_name": "QWizard.WizardOption", + "enum_value1": "IndependentPages", + "enum_value2": "IgnoreSubTitles", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "EditTriggers", + "enum_class": "EditTrigger", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\itemviews\\qabstractitemview.h: Q_DECLARE_FLAGS(EditTriggers, EditTrigger)" + ], + "qflag_full_class_name": "QAbstractItemView.EditTriggers", + "enum_full_class_name": "QAbstractItemView.EditTrigger", + "enum_value1": "NoEditTriggers", + "enum_value2": "CurrentChanged", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "GraphicsItemFlags", + "enum_class": "GraphicsItemFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsitem.h: Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)" + ], + "qflag_full_class_name": "QGraphicsItem.GraphicsItemFlags", + "enum_full_class_name": "QGraphicsItem.GraphicsItemFlag", + "enum_value1": "ItemIsMovable", + "enum_value2": "ItemIsSelectable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "Result", + "enum_class": "ResultFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\kernel\\qgesturerecognizer.h: Q_DECLARE_FLAGS(Result, ResultFlag)" + ], + "qflag_full_class_name": "QGestureRecognizer.Result", + "enum_full_class_name": "QGestureRecognizer.ResultFlag", + "enum_value1": "Ignore", + "enum_value2": "MayBeGesture", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SceneLayers", + "enum_class": "SceneLayer", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsscene.h: Q_DECLARE_FLAGS(SceneLayers, SceneLayer)" + ], + "qflag_full_class_name": "QGraphicsScene.SceneLayers", + "enum_full_class_name": "QGraphicsScene.SceneLayer", + "enum_value1": "ItemLayer", + "enum_value2": "BackgroundLayer", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "CacheMode", + "enum_class": "CacheModeFlag", + "human_hint_qflag_full_class_name": "QGraphicsView.CacheMode", + "human_hint_enum_full_class_name": "QGraphicsView.CacheModeFlag", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)" + ], + "qflag_full_class_name": "QGraphicsView.CacheMode", + "enum_full_class_name": "QGraphicsView.CacheModeFlag", + "enum_value1": "CacheNone", + "enum_value2": "CacheBackground", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "OptimizationFlags", + "enum_class": "OptimizationFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\graphicsview\\qgraphicsview.h: Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)" + ], + "qflag_full_class_name": "QGraphicsView.OptimizationFlags", + "enum_full_class_name": "QGraphicsView.OptimizationFlag", + "enum_value1": "DontClipPainter", + "enum_value2": "DontSavePainterState", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SubControls", + "enum_class": "SubControl", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(SubControls, SubControl)" + ], + "qflag_full_class_name": "QStyle.SubControls", + "enum_full_class_name": "QStyle.SubControl", + "enum_value1": "SC_None", + "enum_value2": "SC_ScrollBarAddLine", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "StepEnabled", + "enum_class": "StepEnabledFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qabstractspinbox.h: Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)" + ], + "qflag_full_class_name": "QAbstractSpinBox.StepEnabled", + "enum_full_class_name": "QAbstractSpinBox.StepEnabledFlag", + "enum_value1": "StepNone", + "enum_value2": "StepUpEnabled", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FrameFeatures", + "enum_class": "FrameFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)" + ], + "qflag_full_class_name": "QStyleOptionFrame.FrameFeatures", + "enum_full_class_name": "QStyleOptionFrame.FrameFeature", + "enum_value1": "None_", + "enum_value2": "Flat", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ButtonFeatures", + "enum_class": "ButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)" + ], + "qflag_full_class_name": "QStyleOptionButton.ButtonFeatures", + "enum_full_class_name": "QStyleOptionButton.ButtonFeature", + "enum_value1": "None_", + "enum_value2": "Flat", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "CornerWidgets", + "enum_class": "CornerWidget", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)" + ], + "qflag_full_class_name": "QStyleOptionTab.CornerWidgets", + "enum_full_class_name": "QStyleOptionTab.CornerWidget", + "enum_value1": "NoCornerWidgets", + "enum_value2": "LeftCornerWidget", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ToolBarFeatures", + "enum_class": "ToolBarFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)" + ], + "qflag_full_class_name": "QStyleOptionToolBar.ToolBarFeatures", + "enum_full_class_name": "QStyleOptionToolBar.ToolBarFeature", + "enum_value1": "None_", + "enum_value2": "Movable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ViewItemFeatures", + "enum_class": "ViewItemFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)" + ], + "qflag_full_class_name": "QStyleOptionViewItem.ViewItemFeatures", + "enum_full_class_name": "QStyleOptionViewItem.ViewItemFeature", + "enum_value1": "None_", + "enum_value2": "WrapText", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "ToolButtonFeatures", + "enum_class": "ToolButtonFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)" + ], + "qflag_full_class_name": "QStyleOptionToolButton.ToolButtonFeatures", + "enum_full_class_name": "QStyleOptionToolButton.ToolButtonFeature", + "enum_value1": "None_", + "enum_value2": "Arrow", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DockWidgetFeatures", + "enum_class": "DockWidgetFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qdockwidget.h: Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)" + ], + "qflag_full_class_name": "QDockWidget.DockWidgetFeatures", + "enum_full_class_name": "QDockWidget.DockWidgetFeature", + "enum_value1": "DockWidgetClosable", + "enum_value2": "DockWidgetMovable", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FontFilters", + "enum_class": "FontFilter", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qfontcombobox.h: Q_DECLARE_FLAGS(FontFilters, FontFilter)" + ], + "qflag_full_class_name": "QFontComboBox.FontFilters", + "enum_full_class_name": "QFontComboBox.FontFilter", + "enum_value1": "AllFonts", + "enum_value2": "ScalableFonts", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "AreaOptions", + "enum_class": "AreaOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmdiarea.h: Q_DECLARE_FLAGS(AreaOptions, AreaOption)" + ], + "qflag_full_class_name": "QMdiArea.AreaOptions", + "enum_full_class_name": "QMdiArea.AreaOption", + "enum_value1": "DontMaximizeSubWindowOnActivation", + "enum_value2": "DontMaximizeSubWindowOnActivation", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "SubWindowOptions", + "enum_class": "SubWindowOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmdisubwindow.h: Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)" + ], + "qflag_full_class_name": "QMdiSubWindow.SubWindowOptions", + "enum_full_class_name": "QMdiSubWindow.SubWindowOption", + "enum_value1": "RubberBandResize", + "enum_value2": "RubberBandMove", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "DockOptions", + "enum_class": "DockOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qmainwindow.h: Q_DECLARE_FLAGS(DockOptions, DockOption)" + ], + "qflag_full_class_name": "QMainWindow.DockOptions", + "enum_full_class_name": "QMainWindow.DockOption", + "enum_value1": "AnimatedDocks", + "enum_value2": "AllowNestedDocks", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "AutoFormatting", + "enum_class": "AutoFormattingFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\widgets\\qtextedit.h: Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)" + ], + "qflag_full_class_name": "QTextEdit.AutoFormatting", + "enum_full_class_name": "QTextEdit.AutoFormattingFlag", + "enum_value1": "AutoNone", + "enum_value2": "AutoBulletList", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true + }, + { + "qflag_class": "FileHandleFlags", + "enum_class": "FileHandleFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qfiledevice.h: Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)" + ], + "qflag_full_class_name": "QFileDevice.FileHandleFlags", + "enum_full_class_name": "QFileDevice.FileHandleFlag", + "enum_value1": "AutoCloseHandle", + "enum_value2": "DontCloseHandle", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "ApplicationStates", + "enum_class": "ApplicationState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(ApplicationStates, ApplicationState)" + ], + "qflag_full_class_name": "Qt.ApplicationStates", + "enum_full_class_name": "Qt.ApplicationState", + "enum_value1": "ApplicationSuspended", + "enum_value2": "ApplicationHidden", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "FindChildOptions", + "enum_class": "FindChildOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\global\\qnamespace.h: Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)" + ], + "qflag_full_class_name": "Qt.FindChildOptions", + "enum_full_class_name": "Qt.FindChildOption", + "enum_value1": "FindDirectChildrenOnly", + "enum_value2": "FindChildrenRecursively", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "Transformations", + "enum_class": "Transformation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Transformations, Transformation)" + ], + "qflag_full_class_name": "QImageIOHandler.Transformations", + "enum_full_class_name": "QImageIOHandler.Transformation", + "enum_value1": "TransformationNone", + "enum_value2": "TransformationMirror", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\image\\qimageiohandler.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\kernel\\qplatformcursor.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\gui\\painting\\qblittable_p.h: Q_DECLARE_FLAGS (Capabilities, Capability)", + "src\\network\\bearer\\qnetworkconfigmanager.h: Q_DECLARE_FLAGS(Capabilities, Capability)", + "src\\network\\kernel\\qnetworkproxy.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "QNetworkProxy.Capabilities", + "enum_full_class_name": "QNetworkProxy.Capability", + "enum_value1": "TunnelingCapability", + "enum_value2": "ListeningCapability", + "module_count": 2, + "module_idx": 1, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "UserInputResolutionOptions", + "enum_class": "UserInputResolutionOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(UserInputResolutionOptions, UserInputResolutionOption)" + ], + "qflag_full_class_name": "QUrl.UserInputResolutionOptions", + "enum_full_class_name": "QUrl.UserInputResolutionOption", + "enum_value1": "DefaultResolution", + "enum_value2": "AssumeLocalFile", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "StateFlags", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\bearer\\qnetworkconfiguration.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" + ], + "qflag_full_class_name": "QNetworkConfiguration.StateFlags", + "enum_full_class_name": "QNetworkConfiguration.StateFlag", + "enum_value1": "Undefined", + "enum_value2": "Defined", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "UsagePolicies", + "enum_class": "UsagePolicy", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\network\\bearer\\qnetworksession.h: Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)" + ], + "qflag_full_class_name": "QNetworkSession.UsagePolicies", + "enum_full_class_name": "QNetworkSession.UsagePolicy", + "enum_value1": "NoPolicy", + "enum_value2": "NoBackgroundTrafficPolicy", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNetwork", + "module_path": "../../PyQt5-stubs/QtNetwork.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "DirtyFlags", + "enum_class": "DirtyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpaintengine.h: Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)" + ], + "qflag_full_class_name": "QPaintEngine.DirtyFlags", + "enum_full_class_name": "QPaintEngine.DirtyFlag", + "enum_value1": "DirtyPen", + "enum_value2": "DirtyBrush", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "PixmapFragmentHints", + "enum_class": "PixmapFragmentHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\painting\\qpainter.h: Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)" + ], + "qflag_full_class_name": "QPainter.PixmapFragmentHints", + "enum_full_class_name": "QPainter.PixmapFragmentHint", + "enum_value1": "OpaqueHint", + "enum_value2": "OpaqueHint", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "GlyphRunFlags", + "enum_class": "GlyphRunFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qglyphrun.h: Q_DECLARE_FLAGS(GlyphRunFlags, GlyphRunFlag)" + ], + "qflag_full_class_name": "QGlyphRun.GlyphRunFlags", + "enum_full_class_name": "QGlyphRun.GlyphRunFlag", + "enum_value1": "Overline", + "enum_value2": "Underline", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "MarkdownFeatures", + "enum_class": "MarkdownFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\gui\\text\\qtextdocument.h: Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)" + ], + "qflag_full_class_name": "QTextDocument.MarkdownFeatures", + "enum_full_class_name": "QTextDocument.MarkdownFeature", + "enum_value1": "MarkdownNoHTML", + "enum_value2": "MarkdownDialectCommonMark", + "module_count": 1, + "module_idx": 0, + "module_name": "QtGui", + "module_path": "../../PyQt5-stubs/QtGui.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "DataSizeFormats", + "enum_class": "DataSizeFormat", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\text\\qlocale.h: Q_DECLARE_FLAGS(DataSizeFormats, DataSizeFormat)" + ], + "qflag_full_class_name": "QLocale.DataSizeFormats", + "enum_full_class_name": "QLocale.DataSizeFormat", + "enum_value1": "DataSizeIecFormat", + "enum_value2": "DataSizeTraditionalFormat", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "QPinchGesture.ChangeFlags", + "enum_full_class_name": "QPinchGesture.ChangeFlag", + "enum_value1": "ScaleFactorChanged", + "enum_value2": "RotationAngleChanged", + "module_count": 2, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\effects\\qgraphicseffect.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)", + "src\\widgets\\kernel\\qgesture.h: Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "QGraphicsEffect.ChangeFlags", + "enum_full_class_name": "QGraphicsEffect.ChangeFlag", + "enum_value1": "SourceAttached", + "enum_value2": "SourceDetached", + "module_count": 2, + "module_idx": 1, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "TabFeatures", + "enum_class": "TabFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\widgets\\styles\\qstyleoption.h: Q_DECLARE_FLAGS(TabFeatures, TabFeature)" + ], + "qflag_full_class_name": "QStyleOptionTab.TabFeatures", + "enum_full_class_name": "QStyleOptionTab.TabFeature", + "enum_value1": "None_", + "enum_value2": "HasFrame", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "State", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "QStyle.State", + "human_hint_enum_full_class_name": "QStyle.StateFlag", + "grep_line": [ + "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" + ], + "qflag_full_class_name": "QStyle.State", + "enum_full_class_name": "QStyle.StateFlag", + "enum_value1": "State_None", + "enum_value2": "State_Enabled", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWidgets", + "module_path": "../../PyQt5-stubs/QtWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + } + ], + "qflag_processed_done": [ + { + "qflag_class": "Operations", + "enum_class": "Operation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qmemorybarrier.h: Q_DECLARE_FLAGS(Operations, Operation)" + ], + "qflag_full_class_name": "QMemoryBarrier.Operations", + "enum_full_class_name": "QMemoryBarrier.Operation", + "enum_value1": "None_", + "enum_value2": "VertexAttributeArray", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h:Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "ChangeFlags", + "enum_full_class_name": "ChangeFlag", + "enum_value1": "NodeCreated", + "enum_value2": "NodeDeleted", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "DeliveryFlags", + "enum_class": "DeliveryFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h: Q_DECLARE_FLAGS(DeliveryFlags, DeliveryFlag)" + ], + "qflag_full_class_name": "QSceneChange.DeliveryFlags", + "enum_full_class_name": "QSceneChange.DeliveryFlag", + "enum_value1": "BackendNodes", + "enum_value2": "Nodes", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "BufferTypeFlags", + "enum_class": "BufferType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qclearbuffers.h: Q_DECLARE_FLAGS(BufferTypeFlags, BufferType)" + ], + "qflag_full_class_name": "QClearBuffers.BufferTypeFlags", + "enum_full_class_name": "QBuffer.BufferType", + "enum_value1": "VertexBuffer", + "enum_value2": "IndexBuffer", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": false + } + ], + "qflag_process_error": [ + { + "qflag_class": "FormattingOptions", + "enum_class": "UrlFormattingOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\corelib\\io\\qurl.h: Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)" + ], + "qflag_full_class_name": "QUrl.FormattingOptions", + "enum_full_class_name": "QUrl.UrlFormattingOption", + "enum_value1": "None_", + "enum_value2": "RemoveScheme", + "module_count": 1, + "module_idx": 0, + "module_name": "QtCore", + "module_path": "../../PyQt5-stubs/QtCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": false, + "error": [ + "Enum methods are present but not QFlag methods" + ] + } + ] +} \ No newline at end of file diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index 83237016..49cadccd 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -1919,8 +1919,8 @@ { "qflag_class": "State", "enum_class": "StateFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", + "human_hint_qflag_full_class_name": "QStyle.State", + "human_hint_enum_full_class_name": "QStyle.StateFlag", "grep_line": [ "src\\widgets\\styles\\qstyle.h: Q_DECLARE_FLAGS(State, StateFlag)" ], From 67c27b10516406fe900213514edb6000a2b1a9e4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 11:38:34 +0100 Subject: [PATCH 276/421] Make sure we have our name defined before evaluating it --- tests/qflags/generate_qflags_stubs_and_tests.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 7f1a3a62..8e6f205f 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -525,6 +525,12 @@ class not found, class found multiple times, ... flag_info.enum_value2 = visitor.enum_value2 flag_info.qflag_full_class_name = visitor.qflag_class_full_name + if visitor.enum_class_full_name == '': + return (QFlagGenResult.ErrorDuringProcessing, 'Could not locate class %s' % visitor.enum_class_name, '') + + if visitor.qflag_class_full_name == '': + return (QFlagGenResult.ErrorDuringProcessing, 'Could not locate class %s' % visitor.qflag_class_name, '') + # evaluate exact behavior of QFlag try: flag_info.or_converts_to_multi = not eval('''type({qtmodule}.{oneFlagName}.{value1} | {qtmodule}.{oneFlagName}.{value2}) == int'''.format( @@ -550,12 +556,6 @@ class not found, class found multiple times, ... except TypeError: flag_info.supports_one_op_multi = False - if visitor.enum_class_full_name == '': - return (QFlagGenResult.ErrorDuringProcessing, 'Could not locate class %s' % visitor.enum_class_name, '') - - if visitor.qflag_class_full_name == '': - return (QFlagGenResult.ErrorDuringProcessing, 'Could not locate class %s' % visitor.qflag_class_name, '') - if (visitor.enum_methods_present, visitor.qflag_method_present) == (MethodPresent.All, MethodPresent.All): return (QFlagGenResult.CodeAlreadyModified, visitor.error_msg, '') @@ -569,6 +569,9 @@ class not found, class found multiple times, ... or flag_info.or_int_converts_to_multi): # this means __or__ or __ror__ must be present, we have an error visitor.error_msg += 'QFlag methods are present but not Enum methods\n' + else: + # it's ok + return (QFlagGenResult.CodeAlreadyModified, visitor.error_msg, '') if visitor.error_msg: return (QFlagGenResult.ErrorDuringProcessing, visitor.error_msg, '') From 0720aa56da3bc18f2a1fbf6712213bbe9f122a72 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 11:57:37 +0100 Subject: [PATCH 277/421] QFlag operations for QChart.AnimationOptions, QChart.AnimationOption in module QtChart --- PyQt5-stubs/QtChart.pyi | 11 + .../qtandroidextras-qflag-grep-result.txt | 1 - ...tChart_AnimationOptions_AnimationOption.py | 272 ++++++++++++++++++ 3 files changed, 283 insertions(+), 1 deletion(-) delete mode 100644 tests/qflags/grep-results/qtandroidextras-qflag-grep-result.txt create mode 100644 tests/qflags/test_QtChart_AnimationOptions_AnimationOption.py diff --git a/PyQt5-stubs/QtChart.pyi b/PyQt5-stubs/QtChart.pyi index 5520a571..baa422cc 100644 --- a/PyQt5-stubs/QtChart.pyi +++ b/PyQt5-stubs/QtChart.pyi @@ -742,6 +742,9 @@ class QChart(QtWidgets.QGraphicsWidget): ChartTypePolar = ... # type: QChart.ChartType class AnimationOption(int): + def __or__ (self, other: typing.Union[int, 'QChart.AnimationOption']) -> 'QChart.AnimationOptions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QChart.AnimationOptions': ... # type: ignore[override, misc] + NoAnimation = ... # type: QChart.AnimationOption GridAxisAnimations = ... # type: QChart.AnimationOption SeriesAnimations = ... # type: QChart.AnimationOption @@ -779,12 +782,20 @@ class QChart(QtWidgets.QGraphicsWidget): def __init__(self, f: typing.Union['QChart.AnimationOptions', 'QChart.AnimationOption']) -> None: ... @typing.overload def __init__(self, a0: 'QChart.AnimationOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QChart.AnimationOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QChart.AnimationOptions', 'QChart.AnimationOption', int]) -> 'QChart.AnimationOptions': ... + def __and__(self, other: typing.Union['QChart.AnimationOptions', 'QChart.AnimationOption', int]) -> 'QChart.AnimationOptions': ... + def __xor__(self, other: typing.Union['QChart.AnimationOptions', 'QChart.AnimationOption', int]) -> 'QChart.AnimationOptions': ... + def __ror__ (self, other: 'QChart.AnimationOption') -> 'QChart.AnimationOptions': ... + def __rand__(self, other: 'QChart.AnimationOption') -> 'QChart.AnimationOptions': ... + def __rxor__(self, other: 'QChart.AnimationOption') -> 'QChart.AnimationOptions': ... def __init__(self, parent: typing.Optional[QtWidgets.QGraphicsItem] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... diff --git a/tests/qflags/grep-results/qtandroidextras-qflag-grep-result.txt b/tests/qflags/grep-results/qtandroidextras-qflag-grep-result.txt deleted file mode 100644 index 6c498bd7..00000000 --- a/tests/qflags/grep-results/qtandroidextras-qflag-grep-result.txt +++ /dev/null @@ -1 +0,0 @@ -src\androidextras\android\qandroidfunctions.h: Q_DECLARE_FLAGS(BindFlags, BindFlag) diff --git a/tests/qflags/test_QtChart_AnimationOptions_AnimationOption.py b/tests/qflags/test_QtChart_AnimationOptions_AnimationOption.py new file mode 100644 index 00000000..027e1d03 --- /dev/null +++ b/tests/qflags/test_QtChart_AnimationOptions_AnimationOption.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QChart.AnimationOptions" and flag class "QChart.AnimationOption" +from PyQt5 import QtChart + +OneFlagClass = QtChart.QChart.AnimationOption +MultiFlagClass = QtChart.QChart.AnimationOptions + +oneFlagRefValue1 = QtChart.QChart.AnimationOption.NoAnimation +oneFlagRefValue2 = QtChart.QChart.AnimationOption.GridAxisAnimations + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[True] = True +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a4af72533b4ba1d20817220bb3ed201a2d990f61 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 11:57:52 +0100 Subject: [PATCH 278/421] QFlag operations for QChartView.RubberBands, QChartView.RubberBand in module QtChart --- PyQt5-stubs/QtChart.pyi | 8 + .../test_QtChart_RubberBands_RubberBand.py | 272 ++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 tests/qflags/test_QtChart_RubberBands_RubberBand.py diff --git a/PyQt5-stubs/QtChart.pyi b/PyQt5-stubs/QtChart.pyi index baa422cc..34534fcf 100644 --- a/PyQt5-stubs/QtChart.pyi +++ b/PyQt5-stubs/QtChart.pyi @@ -885,12 +885,20 @@ class QChartView(QtWidgets.QGraphicsView): def __init__(self, f: typing.Union['QChartView.RubberBands', 'QChartView.RubberBand']) -> None: ... @typing.overload def __init__(self, a0: 'QChartView.RubberBands') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QChartView.RubberBands': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QChartView.RubberBands', 'QChartView.RubberBand', int]) -> 'QChartView.RubberBands': ... + def __and__(self, other: typing.Union['QChartView.RubberBands', 'QChartView.RubberBand', int]) -> 'QChartView.RubberBands': ... + def __xor__(self, other: typing.Union['QChartView.RubberBands', 'QChartView.RubberBand', int]) -> 'QChartView.RubberBands': ... + def __ror__ (self, other: 'QChartView.RubberBand') -> 'QChartView.RubberBands': ... + def __rand__(self, other: 'QChartView.RubberBand') -> 'QChartView.RubberBands': ... + def __rxor__(self, other: 'QChartView.RubberBand') -> 'QChartView.RubberBands': ... @typing.overload def __init__(self, parent: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... diff --git a/tests/qflags/test_QtChart_RubberBands_RubberBand.py b/tests/qflags/test_QtChart_RubberBands_RubberBand.py new file mode 100644 index 00000000..0a3f64bf --- /dev/null +++ b/tests/qflags/test_QtChart_RubberBands_RubberBand.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QChartView.RubberBands" and flag class "QChartView.RubberBand" +from PyQt5 import QtChart + +OneFlagClass = QtChart.QChartView.RubberBand +MultiFlagClass = QtChart.QChartView.RubberBands + +oneFlagRefValue1 = QtChart.QChartView.RubberBand.NoRubberBand +oneFlagRefValue2 = QtChart.QChartView.RubberBand.VerticalRubberBand + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 879257176b40604552c2e7d4b5720dab9f6787b6 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 11:58:09 +0100 Subject: [PATCH 279/421] QFlag operations for QPolarChart.PolarOrientations, QPolarChart.PolarOrientation in module QtChart --- PyQt5-stubs/QtChart.pyi | 8 + ...hart_PolarOrientations_PolarOrientation.py | 272 ++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 tests/qflags/test_QtChart_PolarOrientations_PolarOrientation.py diff --git a/PyQt5-stubs/QtChart.pyi b/PyQt5-stubs/QtChart.pyi index 34534fcf..08d9087b 100644 --- a/PyQt5-stubs/QtChart.pyi +++ b/PyQt5-stubs/QtChart.pyi @@ -1370,12 +1370,20 @@ class QPolarChart('QChart'): def __init__(self, f: typing.Union['QPolarChart.PolarOrientations', 'QPolarChart.PolarOrientation']) -> None: ... @typing.overload def __init__(self, a0: 'QPolarChart.PolarOrientations') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QPolarChart.PolarOrientations': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QPolarChart.PolarOrientations', 'QPolarChart.PolarOrientation', int]) -> 'QPolarChart.PolarOrientations': ... + def __and__(self, other: typing.Union['QPolarChart.PolarOrientations', 'QPolarChart.PolarOrientation', int]) -> 'QPolarChart.PolarOrientations': ... + def __xor__(self, other: typing.Union['QPolarChart.PolarOrientations', 'QPolarChart.PolarOrientation', int]) -> 'QPolarChart.PolarOrientations': ... + def __ror__ (self, other: 'QPolarChart.PolarOrientation') -> 'QPolarChart.PolarOrientations': ... + def __rand__(self, other: 'QPolarChart.PolarOrientation') -> 'QPolarChart.PolarOrientations': ... + def __rxor__(self, other: 'QPolarChart.PolarOrientation') -> 'QPolarChart.PolarOrientations': ... def __init__(self, parent: typing.Optional[QtWidgets.QGraphicsItem] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... diff --git a/tests/qflags/test_QtChart_PolarOrientations_PolarOrientation.py b/tests/qflags/test_QtChart_PolarOrientations_PolarOrientation.py new file mode 100644 index 00000000..fb3d2c6a --- /dev/null +++ b/tests/qflags/test_QtChart_PolarOrientations_PolarOrientation.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QPolarChart.PolarOrientations" and flag class "QPolarChart.PolarOrientation" +from PyQt5 import QtChart + +OneFlagClass = QtChart.QPolarChart.PolarOrientation +MultiFlagClass = QtChart.QPolarChart.PolarOrientations + +oneFlagRefValue1 = QtChart.QPolarChart.PolarOrientation.PolarOrientationRadial +oneFlagRefValue2 = QtChart.QPolarChart.PolarOrientation.PolarOrientationAngular + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 8359b9bc67289131756cee5713e1d98c20bd1dc3 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 11:58:25 +0100 Subject: [PATCH 280/421] QFlag operations for QAbstractAxis.AxisTypes, QAbstractAxis.AxisType in module QtChart --- PyQt5-stubs/QtChart.pyi | 8 + .../qflags/test_QtChart_AxisTypes_AxisType.py | 272 ++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 tests/qflags/test_QtChart_AxisTypes_AxisType.py diff --git a/PyQt5-stubs/QtChart.pyi b/PyQt5-stubs/QtChart.pyi index 08d9087b..a8634cd5 100644 --- a/PyQt5-stubs/QtChart.pyi +++ b/PyQt5-stubs/QtChart.pyi @@ -65,12 +65,20 @@ class QAbstractAxis(QtCore.QObject): def __init__(self, f: typing.Union['QAbstractAxis.AxisTypes', 'QAbstractAxis.AxisType']) -> None: ... @typing.overload def __init__(self, a0: 'QAbstractAxis.AxisTypes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QAbstractAxis.AxisTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QAbstractAxis.AxisTypes', 'QAbstractAxis.AxisType', int]) -> 'QAbstractAxis.AxisTypes': ... + def __and__(self, other: typing.Union['QAbstractAxis.AxisTypes', 'QAbstractAxis.AxisType', int]) -> 'QAbstractAxis.AxisTypes': ... + def __xor__(self, other: typing.Union['QAbstractAxis.AxisTypes', 'QAbstractAxis.AxisType', int]) -> 'QAbstractAxis.AxisTypes': ... + def __ror__ (self, other: 'QAbstractAxis.AxisType') -> 'QAbstractAxis.AxisTypes': ... + def __rand__(self, other: 'QAbstractAxis.AxisType') -> 'QAbstractAxis.AxisTypes': ... + def __rxor__(self, other: 'QAbstractAxis.AxisType') -> 'QAbstractAxis.AxisTypes': ... def labelsEditableChanged(self, editable: bool) -> None: ... def labelsEditable(self) -> bool: ... diff --git a/tests/qflags/test_QtChart_AxisTypes_AxisType.py b/tests/qflags/test_QtChart_AxisTypes_AxisType.py new file mode 100644 index 00000000..11c4c2f3 --- /dev/null +++ b/tests/qflags/test_QtChart_AxisTypes_AxisType.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QAbstractAxis.AxisTypes" and flag class "QAbstractAxis.AxisType" +from PyQt5 import QtChart + +OneFlagClass = QtChart.QAbstractAxis.AxisType +MultiFlagClass = QtChart.QAbstractAxis.AxisTypes + +oneFlagRefValue1 = QtChart.QAbstractAxis.AxisType.AxisTypeNoAxis +oneFlagRefValue2 = QtChart.QAbstractAxis.AxisType.AxisTypeValue + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 5eedc5d01218b320b8f14c373c7eae5d09599929 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 12:01:57 +0100 Subject: [PATCH 281/421] Processing QtChart result --- tests/qflags/qflags_modules_analysis.json | 119 ++++++++++++++++++++++ tests/qflags/qflags_process_result.json | 84 +++++++++++++++ 2 files changed, 203 insertions(+) diff --git a/tests/qflags/qflags_modules_analysis.json b/tests/qflags/qflags_modules_analysis.json index b4341ac8..9d568386 100644 --- a/tests/qflags/qflags_modules_analysis.json +++ b/tests/qflags/qflags_modules_analysis.json @@ -67,6 +67,125 @@ "module_idx": 0, "module_name": "Qt3DRender", "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + }, + { + "qflag_class": "AnimationOptions", + "enum_class": "AnimationOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qchart.h: Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "RubberBands", + "enum_class": "RubberBand", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qchartview.h: Q_DECLARE_FLAGS(RubberBands, RubberBand)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "PolarOrientations", + "enum_class": "PolarOrientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qpolarchart.h: Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "AxisTypes", + "enum_class": "AxisType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\axis\\qabstractaxis.h: Q_DECLARE_FLAGS(AxisTypes, AxisType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "TargetAccessModes", + "enum_class": "TargetAccessMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\nfc\\qnearfieldmanager.h: Q_DECLARE_FLAGS(TargetAccessModes, TargetAccessMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNfc", + "module_path": "../../PyQt5-stubs/QtNfc.pyi" + }, + { + "qflag_class": "ShareModes", + "enum_class": "ShareMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\nfc\\qnearfieldsharemanager.h: Q_DECLARE_FLAGS(ShareModes, ShareMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNfc", + "module_path": "../../PyQt5-stubs/QtNfc.pyi" + }, + { + "qflag_class": "AccessMethods", + "enum_class": "AccessMethod", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\nfc\\qnearfieldtarget.h: Q_DECLARE_FLAGS(AccessMethods, AccessMethod)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNfc", + "module_path": "../../PyQt5-stubs/QtNfc.pyi" } ], "flag_without_module": [ diff --git a/tests/qflags/qflags_process_result.json b/tests/qflags/qflags_process_result.json index 87fc4e63..3e5720f1 100644 --- a/tests/qflags/qflags_process_result.json +++ b/tests/qflags/qflags_process_result.json @@ -2640,6 +2640,90 @@ "or_int_converts_to_multi": false, "int_or_converts_to_multi": false, "supports_one_op_multi": false + }, + { + "qflag_class": "AnimationOptions", + "enum_class": "AnimationOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qchart.h: Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)" + ], + "qflag_full_class_name": "QChart.AnimationOptions", + "enum_full_class_name": "QChart.AnimationOption", + "enum_value1": "NoAnimation", + "enum_value2": "GridAxisAnimations", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": true, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "RubberBands", + "enum_class": "RubberBand", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qchartview.h: Q_DECLARE_FLAGS(RubberBands, RubberBand)" + ], + "qflag_full_class_name": "QChartView.RubberBands", + "enum_full_class_name": "QChartView.RubberBand", + "enum_value1": "NoRubberBand", + "enum_value2": "VerticalRubberBand", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "PolarOrientations", + "enum_class": "PolarOrientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qpolarchart.h: Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation)" + ], + "qflag_full_class_name": "QPolarChart.PolarOrientations", + "enum_full_class_name": "QPolarChart.PolarOrientation", + "enum_value1": "PolarOrientationRadial", + "enum_value2": "PolarOrientationAngular", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "AxisTypes", + "enum_class": "AxisType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\axis\\qabstractaxis.h: Q_DECLARE_FLAGS(AxisTypes, AxisType)" + ], + "qflag_full_class_name": "QAbstractAxis.AxisTypes", + "enum_full_class_name": "QAbstractAxis.AxisType", + "enum_value1": "AxisTypeNoAxis", + "enum_value2": "AxisTypeValue", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true } ], "qflag_process_error": [ From 0060e4d01bc565b4b845385505cb50049a119485 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 12:02:08 +0100 Subject: [PATCH 282/421] Full processing results --- tests/qflags/qflags_to_process.json | 398 ++++++++++++++++++++++++++++ 1 file changed, 398 insertions(+) diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index 49cadccd..bbd76419 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -2255,6 +2255,329 @@ "module_idx": 0, "module_name": "Qt3DRender", "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h:Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + }, + { + "qflag_class": "DeliveryFlags", + "enum_class": "DeliveryFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h: Q_DECLARE_FLAGS(DeliveryFlags, DeliveryFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + }, + { + "qflag_class": "BufferTypeFlags", + "enum_class": "BufferType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qclearbuffers.h: Q_DECLARE_FLAGS(BufferTypeFlags, BufferType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + }, + { + "qflag_class": "Operations", + "enum_class": "Operation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qmemorybarrier.h: Q_DECLARE_FLAGS(Operations, Operation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + }, + { + "qflag_class": "AnimationOptions", + "enum_class": "AnimationOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qchart.h: Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "RubberBands", + "enum_class": "RubberBand", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qchartview.h: Q_DECLARE_FLAGS(RubberBands, RubberBand)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "PolarOrientations", + "enum_class": "PolarOrientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qpolarchart.h: Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "AxisTypes", + "enum_class": "AxisType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\axis\\qabstractaxis.h: Q_DECLARE_FLAGS(AxisTypes, AxisType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h:Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + }, + { + "qflag_class": "DeliveryFlags", + "enum_class": "DeliveryFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h: Q_DECLARE_FLAGS(DeliveryFlags, DeliveryFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + }, + { + "qflag_class": "BufferTypeFlags", + "enum_class": "BufferType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qclearbuffers.h: Q_DECLARE_FLAGS(BufferTypeFlags, BufferType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + }, + { + "qflag_class": "Operations", + "enum_class": "Operation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qmemorybarrier.h: Q_DECLARE_FLAGS(Operations, Operation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + }, + { + "qflag_class": "AnimationOptions", + "enum_class": "AnimationOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qchart.h: Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "RubberBands", + "enum_class": "RubberBand", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qchartview.h: Q_DECLARE_FLAGS(RubberBands, RubberBand)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "PolarOrientations", + "enum_class": "PolarOrientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qpolarchart.h: Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "AxisTypes", + "enum_class": "AxisType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\axis\\qabstractaxis.h: Q_DECLARE_FLAGS(AxisTypes, AxisType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "TargetAccessModes", + "enum_class": "TargetAccessMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\nfc\\qnearfieldmanager.h: Q_DECLARE_FLAGS(TargetAccessModes, TargetAccessMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNfc", + "module_path": "../../PyQt5-stubs/QtNfc.pyi" + }, + { + "qflag_class": "ShareModes", + "enum_class": "ShareMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\nfc\\qnearfieldsharemanager.h: Q_DECLARE_FLAGS(ShareModes, ShareMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNfc", + "module_path": "../../PyQt5-stubs/QtNfc.pyi" + }, + { + "qflag_class": "AccessMethods", + "enum_class": "AccessMethod", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\nfc\\qnearfieldtarget.h: Q_DECLARE_FLAGS(AccessMethods, AccessMethod)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNfc", + "module_path": "../../PyQt5-stubs/QtNfc.pyi" } ], "qflags_to_skip": [ @@ -2272,6 +2595,81 @@ "qflag_class": "DirtyFlags", "enum_class": "DirtyFlag", "skip_reason": "QFlag not found" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "skip_reason": "QFlag not found in module group qtchart" + }, + { + "qflag_class": "BackendNodeDirtySet", + "enum_class": "BackendNodeDirtyFlag", + "skip_reason": "QFlag not found in module group qtchart" + }, + { + "qflag_class": "DirtyFlags", + "enum_class": "DirtyFlag", + "skip_reason": "QFlag not found in module group qtchart" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "BackendNodeDirtySet", + "enum_class": "BackendNodeDirtyFlag", + "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "DirtyFlags", + "enum_class": "DirtyFlag", + "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "SecurityFlags", + "enum_class": "Security", + "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "AttAccessConstraints", + "enum_class": "AttAccessConstraint", + "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "DiscoveryMethods", + "enum_class": "DiscoveryMethod", + "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "ServiceClasses", + "enum_class": "ServiceClass", + "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "Fields", + "enum_class": "Field", + "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "CoreConfigurations", + "enum_class": "CoreConfiguration", + "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "PropertyTypes", + "enum_class": "PropertyType", + "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "JobFlags", + "enum_class": "JobFlag", + "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "ServiceTypes", + "enum_class": "ServiceType", + "skip_reason": "QFlag not found in module group qtconnectivity" } ] } \ No newline at end of file From b02a6bae8dd1897c1478fb7940bd515f0034add0 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 12:02:34 +0100 Subject: [PATCH 283/421] Add qtchart and qtconnectivity group --- .../qflags/generate_qflags_stubs_and_tests.py | 55 ++++++++++++++----- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 8e6f205f..424e428a 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -12,6 +12,8 @@ from PyQt5 import (QtCore, QtWidgets, QtGui, QtNetwork, QtDBus, QtOpenGL, QtPrintSupport, QtSql, QtTest, QtXml, Qt3DAnimation, Qt3DCore, Qt3DExtras, Qt3DInput, Qt3DLogic, Qt3DRender, + QtChart, + QtBluetooth, QtNfc, ) try: import libcst as cst @@ -40,7 +42,14 @@ 'Qt3DInput', 'Qt3DLogic', 'Qt3DRender', - ] + ], + 'qtchart': [ + 'QtChart', + ], + 'qtconnectivity': [ + 'QtBluetooth', + 'QtNfc', + ], } @@ -215,7 +224,8 @@ def identify_qflag_location(fname_grep_result: str, return all_qflags -def group_qflags(qflag_location: List[QFlagLocationInfo] ) -> Dict[str, List[QFlagLocationInfo]]: +def group_qflags(qflag_location: List[QFlagLocationInfo], + qflags_group_initial: Optional[Dict[str, List[QFlagLocationInfo]]]) -> Dict[str, List[QFlagLocationInfo]]: '''Group the QFlags into the following groups (inside a dictionnary): * flag_and_module_identified: this flag is present once in one module exactly. * flag_without_module: this flag is not present in any modules at all. @@ -223,18 +233,22 @@ def group_qflags(qflag_location: List[QFlagLocationInfo] ) -> Dict[str, List[QFl The first group is suitable for automatic processing. The last group reflects the QFlags not exported to PyQt or coming from modules not present in PyQt ''' - d = { - 'flag_and_module_identified': [ - flag_info for flag_info in qflag_location - if flag_info.module_name != '' - ], - 'flag_without_module': [ - flag_info for flag_info in qflag_location - if flag_info.module_name == '' - ], - } + if not qflags_group_initial: + qflags_group_initial = { + 'flag_and_module_identified': [], + 'flag_without_module': [], + } - return d + qflags_group_initial['flag_and_module_identified'].extend([ + flag_info for flag_info in qflag_location + if flag_info.module_name != '' + ]) + qflags_group_initial['flag_without_module'].extend([ + flag_info for flag_info in qflag_location + if flag_info.module_name == '' + ]) + + return qflags_group_initial def extract_qflags_to_process(qflags_modules_analysis_json: str, @@ -1102,11 +1116,22 @@ def generate_qflags_to_process(qt_qflag_grep_result_fname: str, module_group: st '''Run the generation process from the grep output parsing to the generation of json file listing the flags to process''' location_qflags = identify_qflag_location(qt_qflag_grep_result_fname, MODULE_GROUPS[module_group]) log_progress('%d qflags extracted from grep file' % len(location_qflags)) - qflags_groups = group_qflags(location_qflags) - log_progress('%d qflags ready to be processed' % len(qflags_groups['flag_and_module_identified'])) qflags_modules_analysis_json = 'qflags_modules_analysis.json' # put our intermediate classification into a json file for human review + if os.path.exists(qflags_modules_analysis_json): + with open(qflags_modules_analysis_json) as f: + d = json.load(f) + qflag_groups_initial = { + 'flag_and_module_identified': [QFlagLocationInfo(**v) for v in d['flag_and_module_identified']], + 'flag_without_module': [QFlagLocationInfo(**v) for v in d['flag_without_module']] + } + else: + qflag_groups_initial = None + + qflags_groups = group_qflags(location_qflags, qflag_groups_initial) + log_progress('%d qflags ready to be processed' % len(qflags_groups['flag_and_module_identified'])) + with open(qflags_modules_analysis_json, 'w') as f: json.dump(qflags_groups, f, indent=4, default=json_encode_qflaglocationinfo) log_progress('QFlag analysis saved to: %s' % qflags_modules_analysis_json) From 1acfefc038019fff336e5e3a168b55258e6754a4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 12:15:55 +0100 Subject: [PATCH 284/421] QtChart processing results --- tests/qflags/qflags_to_process.json | 136 ++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index bbd76419..ba701c3c 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -2578,6 +2578,142 @@ "module_idx": 0, "module_name": "QtNfc", "module_path": "../../PyQt5-stubs/QtNfc.pyi" + }, + { + "qflag_class": "ChangeFlags", + "enum_class": "ChangeFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h:Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + }, + { + "qflag_class": "DeliveryFlags", + "enum_class": "DeliveryFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\core\\changes\\qscenechange.h: Q_DECLARE_FLAGS(DeliveryFlags, DeliveryFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DCore", + "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + }, + { + "qflag_class": "BufferTypeFlags", + "enum_class": "BufferType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qclearbuffers.h: Q_DECLARE_FLAGS(BufferTypeFlags, BufferType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + }, + { + "qflag_class": "Operations", + "enum_class": "Operation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\render\\framegraph\\qmemorybarrier.h: Q_DECLARE_FLAGS(Operations, Operation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "Qt3DRender", + "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + }, + { + "qflag_class": "AnimationOptions", + "enum_class": "AnimationOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qchart.h: Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "RubberBands", + "enum_class": "RubberBand", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qchartview.h: Q_DECLARE_FLAGS(RubberBands, RubberBand)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "PolarOrientations", + "enum_class": "PolarOrientation", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\qpolarchart.h: Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" + }, + { + "qflag_class": "AxisTypes", + "enum_class": "AxisType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\charts\\axis\\qabstractaxis.h: Q_DECLARE_FLAGS(AxisTypes, AxisType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtChart", + "module_path": "../../PyQt5-stubs/QtChart.pyi" } ], "qflags_to_skip": [ From 78850bc1a307311cad91f59e439040f51d696fa6 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 12:19:59 +0100 Subject: [PATCH 285/421] QFlag operations for QNearFieldManager.TargetAccessModes, QNearFieldManager.TargetAccessMode in module QtNfc --- PyQt5-stubs/QtNfc.pyi | 11 + ...tNfc_TargetAccessModes_TargetAccessMode.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtNfc_TargetAccessModes_TargetAccessMode.py diff --git a/PyQt5-stubs/QtNfc.pyi b/PyQt5-stubs/QtNfc.pyi index 669afa27..ea3a21f4 100644 --- a/PyQt5-stubs/QtNfc.pyi +++ b/PyQt5-stubs/QtNfc.pyi @@ -247,6 +247,9 @@ class QNearFieldManager(QtCore.QObject): TurningOff = ... # type: QNearFieldManager.AdapterState class TargetAccessMode(int): + def __or__ (self, other: 'QNearFieldManager.TargetAccessMode') -> 'QNearFieldManager.TargetAccessModes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QNearFieldManager.TargetAccessModes': ... # type: ignore[override, misc] + NoTargetAccess = ... # type: QNearFieldManager.TargetAccessMode NdefReadTargetAccess = ... # type: QNearFieldManager.TargetAccessMode NdefWriteTargetAccess = ... # type: QNearFieldManager.TargetAccessMode @@ -265,12 +268,20 @@ class QNearFieldManager(QtCore.QObject): def __init__(self, f: typing.Union['QNearFieldManager.TargetAccessModes', 'QNearFieldManager.TargetAccessMode']) -> None: ... @typing.overload def __init__(self, a0: 'QNearFieldManager.TargetAccessModes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QNearFieldManager.TargetAccessModes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QNearFieldManager.TargetAccessModes', 'QNearFieldManager.TargetAccessMode', int]) -> 'QNearFieldManager.TargetAccessModes': ... + def __and__(self, other: typing.Union['QNearFieldManager.TargetAccessModes', 'QNearFieldManager.TargetAccessMode', int]) -> 'QNearFieldManager.TargetAccessModes': ... + def __xor__(self, other: typing.Union['QNearFieldManager.TargetAccessModes', 'QNearFieldManager.TargetAccessMode', int]) -> 'QNearFieldManager.TargetAccessModes': ... + def __ror__ (self, other: 'QNearFieldManager.TargetAccessMode') -> 'QNearFieldManager.TargetAccessModes': ... + def __rand__(self, other: 'QNearFieldManager.TargetAccessMode') -> 'QNearFieldManager.TargetAccessModes': ... + def __rxor__(self, other: 'QNearFieldManager.TargetAccessMode') -> 'QNearFieldManager.TargetAccessModes': ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtNfc_TargetAccessModes_TargetAccessMode.py b/tests/qflags/test_QtNfc_TargetAccessModes_TargetAccessMode.py new file mode 100644 index 00000000..d3205f07 --- /dev/null +++ b/tests/qflags/test_QtNfc_TargetAccessModes_TargetAccessMode.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QNearFieldManager.TargetAccessModes" and flag class "QNearFieldManager.TargetAccessMode" +from PyQt5 import QtNfc + +OneFlagClass = QtNfc.QNearFieldManager.TargetAccessMode +MultiFlagClass = QtNfc.QNearFieldManager.TargetAccessModes + +oneFlagRefValue1 = QtNfc.QNearFieldManager.TargetAccessMode.NoTargetAccess +oneFlagRefValue2 = QtNfc.QNearFieldManager.TargetAccessMode.NdefReadTargetAccess + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From cf3761707802077f7bcaeb58fbf2baca3de2b421 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 12:20:11 +0100 Subject: [PATCH 286/421] QFlag operations for QNearFieldShareManager.ShareModes, QNearFieldShareManager.ShareMode in module QtNfc --- PyQt5-stubs/QtNfc.pyi | 11 + .../qflags/test_QtNfc_ShareModes_ShareMode.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtNfc_ShareModes_ShareMode.py diff --git a/PyQt5-stubs/QtNfc.pyi b/PyQt5-stubs/QtNfc.pyi index ea3a21f4..70da8be9 100644 --- a/PyQt5-stubs/QtNfc.pyi +++ b/PyQt5-stubs/QtNfc.pyi @@ -306,6 +306,9 @@ class QNearFieldManager(QtCore.QObject): class QNearFieldShareManager(QtCore.QObject): class ShareMode(int): + def __or__ (self, other: 'QNearFieldShareManager.ShareMode') -> 'QNearFieldShareManager.ShareModes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QNearFieldShareManager.ShareModes': ... # type: ignore[override, misc] + NoShare = ... # type: QNearFieldShareManager.ShareMode NdefShare = ... # type: QNearFieldShareManager.ShareMode FileShare = ... # type: QNearFieldShareManager.ShareMode @@ -343,12 +346,20 @@ class QNearFieldShareManager(QtCore.QObject): def __init__(self, f: typing.Union['QNearFieldShareManager.ShareModes', 'QNearFieldShareManager.ShareMode']) -> None: ... @typing.overload def __init__(self, a0: 'QNearFieldShareManager.ShareModes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QNearFieldShareManager.ShareModes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QNearFieldShareManager.ShareModes', 'QNearFieldShareManager.ShareMode', int]) -> 'QNearFieldShareManager.ShareModes': ... + def __and__(self, other: typing.Union['QNearFieldShareManager.ShareModes', 'QNearFieldShareManager.ShareMode', int]) -> 'QNearFieldShareManager.ShareModes': ... + def __xor__(self, other: typing.Union['QNearFieldShareManager.ShareModes', 'QNearFieldShareManager.ShareMode', int]) -> 'QNearFieldShareManager.ShareModes': ... + def __ror__ (self, other: 'QNearFieldShareManager.ShareMode') -> 'QNearFieldShareManager.ShareModes': ... + def __rand__(self, other: 'QNearFieldShareManager.ShareMode') -> 'QNearFieldShareManager.ShareModes': ... + def __rxor__(self, other: 'QNearFieldShareManager.ShareMode') -> 'QNearFieldShareManager.ShareModes': ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtNfc_ShareModes_ShareMode.py b/tests/qflags/test_QtNfc_ShareModes_ShareMode.py new file mode 100644 index 00000000..47351437 --- /dev/null +++ b/tests/qflags/test_QtNfc_ShareModes_ShareMode.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QNearFieldShareManager.ShareModes" and flag class "QNearFieldShareManager.ShareMode" +from PyQt5 import QtNfc + +OneFlagClass = QtNfc.QNearFieldShareManager.ShareMode +MultiFlagClass = QtNfc.QNearFieldShareManager.ShareModes + +oneFlagRefValue1 = QtNfc.QNearFieldShareManager.ShareMode.NoShare +oneFlagRefValue2 = QtNfc.QNearFieldShareManager.ShareMode.NdefShare + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From c6ccd34fc4749aa08ca00a38b68bb4f54b53f3d3 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 12:20:23 +0100 Subject: [PATCH 287/421] QFlag operations for QNearFieldTarget.AccessMethods, QNearFieldTarget.AccessMethod in module QtNfc --- PyQt5-stubs/QtNfc.pyi | 11 + .../test_QtNfc_AccessMethods_AccessMethod.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtNfc_AccessMethods_AccessMethod.py diff --git a/PyQt5-stubs/QtNfc.pyi b/PyQt5-stubs/QtNfc.pyi index 70da8be9..5be1e4c6 100644 --- a/PyQt5-stubs/QtNfc.pyi +++ b/PyQt5-stubs/QtNfc.pyi @@ -413,6 +413,9 @@ class QNearFieldTarget(QtCore.QObject): CommandError = ... # type: QNearFieldTarget.Error class AccessMethod(int): + def __or__ (self, other: 'QNearFieldTarget.AccessMethod') -> 'QNearFieldTarget.AccessMethods': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QNearFieldTarget.AccessMethods': ... # type: ignore[override, misc] + UnknownAccess = ... # type: QNearFieldTarget.AccessMethod NdefAccess = ... # type: QNearFieldTarget.AccessMethod TagTypeSpecificAccess = ... # type: QNearFieldTarget.AccessMethod @@ -446,12 +449,20 @@ class QNearFieldTarget(QtCore.QObject): def __init__(self, f: typing.Union['QNearFieldTarget.AccessMethods', 'QNearFieldTarget.AccessMethod']) -> None: ... @typing.overload def __init__(self, a0: 'QNearFieldTarget.AccessMethods') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QNearFieldTarget.AccessMethods': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QNearFieldTarget.AccessMethods', 'QNearFieldTarget.AccessMethod', int]) -> 'QNearFieldTarget.AccessMethods': ... + def __and__(self, other: typing.Union['QNearFieldTarget.AccessMethods', 'QNearFieldTarget.AccessMethod', int]) -> 'QNearFieldTarget.AccessMethods': ... + def __xor__(self, other: typing.Union['QNearFieldTarget.AccessMethods', 'QNearFieldTarget.AccessMethod', int]) -> 'QNearFieldTarget.AccessMethods': ... + def __ror__ (self, other: 'QNearFieldTarget.AccessMethod') -> 'QNearFieldTarget.AccessMethods': ... + def __rand__(self, other: 'QNearFieldTarget.AccessMethod') -> 'QNearFieldTarget.AccessMethods': ... + def __rxor__(self, other: 'QNearFieldTarget.AccessMethod') -> 'QNearFieldTarget.AccessMethods': ... class RequestId(sip.simplewrapper): diff --git a/tests/qflags/test_QtNfc_AccessMethods_AccessMethod.py b/tests/qflags/test_QtNfc_AccessMethods_AccessMethod.py new file mode 100644 index 00000000..b822707b --- /dev/null +++ b/tests/qflags/test_QtNfc_AccessMethods_AccessMethod.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QNearFieldTarget.AccessMethods" and flag class "QNearFieldTarget.AccessMethod" +from PyQt5 import QtNfc + +OneFlagClass = QtNfc.QNearFieldTarget.AccessMethod +MultiFlagClass = QtNfc.QNearFieldTarget.AccessMethods + +oneFlagRefValue1 = QtNfc.QNearFieldTarget.AccessMethod.UnknownAccess +oneFlagRefValue2 = QtNfc.QNearFieldTarget.AccessMethod.NdefAccess + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From cfa470b62f057bad1a0e7a06b5c5f05edc14ccc1 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 12:21:48 +0100 Subject: [PATCH 288/421] Addtional way of declaring a QFlag class --- tests/qflags/generate_qflags_stubs_and_tests.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 424e428a..e8ed1516 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -176,11 +176,13 @@ def identify_qflag_location(fname_grep_result: str, for qflag_key, flag_info in parsed_qflags.items(): decl_qflag_class = 'class %s(sip.simplewrapper' % flag_info.qflag_class + decl_qflag_class2 = 'class %s(sip.wrapper' % flag_info.qflag_class decl_enum_class = 'class %s(int' % flag_info.enum_class module_found = False for mod_name, mod_content in qt_modules_content: - if decl_qflag_class in mod_content and decl_enum_class in mod_content: + if (decl_qflag_class in mod_content or decl_qflag_class2 in mod_content) \ + and decl_enum_class in mod_content: # we have found one module module_found = True # print('Adding QFlags %s to module %s' % (flag_info.qflag_class, mod_name)) From ac13739a6095ac7d7cebd1b65548b3326555df2e Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 12:30:59 +0100 Subject: [PATCH 289/421] Remove redundant entries --- tests/qflags/qflags_to_process.json | 324 ++++------------------------ 1 file changed, 40 insertions(+), 284 deletions(-) diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index ba701c3c..03a4d7f3 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -2256,74 +2256,6 @@ "module_name": "Qt3DRender", "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" }, - { - "qflag_class": "ChangeFlags", - "enum_class": "ChangeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\core\\changes\\qscenechange.h:Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "Qt3DCore", - "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" - }, - { - "qflag_class": "DeliveryFlags", - "enum_class": "DeliveryFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\core\\changes\\qscenechange.h: Q_DECLARE_FLAGS(DeliveryFlags, DeliveryFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "Qt3DCore", - "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" - }, - { - "qflag_class": "BufferTypeFlags", - "enum_class": "BufferType", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\render\\framegraph\\qclearbuffers.h: Q_DECLARE_FLAGS(BufferTypeFlags, BufferType)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "Qt3DRender", - "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" - }, - { - "qflag_class": "Operations", - "enum_class": "Operation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\render\\framegraph\\qmemorybarrier.h: Q_DECLARE_FLAGS(Operations, Operation)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "Qt3DRender", - "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" - }, { "qflag_class": "AnimationOptions", "enum_class": "AnimationOption", @@ -2358,23 +2290,6 @@ "module_name": "QtChart", "module_path": "../../PyQt5-stubs/QtChart.pyi" }, - { - "qflag_class": "PolarOrientations", - "enum_class": "PolarOrientation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\charts\\qpolarchart.h: Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtChart", - "module_path": "../../PyQt5-stubs/QtChart.pyi" - }, { "qflag_class": "AxisTypes", "enum_class": "AxisType", @@ -2392,108 +2307,6 @@ "module_name": "QtChart", "module_path": "../../PyQt5-stubs/QtChart.pyi" }, - { - "qflag_class": "ChangeFlags", - "enum_class": "ChangeFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\core\\changes\\qscenechange.h:Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "Qt3DCore", - "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" - }, - { - "qflag_class": "DeliveryFlags", - "enum_class": "DeliveryFlag", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\core\\changes\\qscenechange.h: Q_DECLARE_FLAGS(DeliveryFlags, DeliveryFlag)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "Qt3DCore", - "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" - }, - { - "qflag_class": "BufferTypeFlags", - "enum_class": "BufferType", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\render\\framegraph\\qclearbuffers.h: Q_DECLARE_FLAGS(BufferTypeFlags, BufferType)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "Qt3DRender", - "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" - }, - { - "qflag_class": "Operations", - "enum_class": "Operation", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\render\\framegraph\\qmemorybarrier.h: Q_DECLARE_FLAGS(Operations, Operation)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "Qt3DRender", - "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" - }, - { - "qflag_class": "AnimationOptions", - "enum_class": "AnimationOption", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\charts\\qchart.h: Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtChart", - "module_path": "../../PyQt5-stubs/QtChart.pyi" - }, - { - "qflag_class": "RubberBands", - "enum_class": "RubberBand", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\charts\\qchartview.h: Q_DECLARE_FLAGS(RubberBands, RubberBand)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtChart", - "module_path": "../../PyQt5-stubs/QtChart.pyi" - }, { "qflag_class": "PolarOrientations", "enum_class": "PolarOrientation", @@ -2511,23 +2324,6 @@ "module_name": "QtChart", "module_path": "../../PyQt5-stubs/QtChart.pyi" }, - { - "qflag_class": "AxisTypes", - "enum_class": "AxisType", - "human_hint_qflag_full_class_name": "", - "human_hint_enum_full_class_name": "", - "grep_line": [ - "src\\charts\\axis\\qabstractaxis.h: Q_DECLARE_FLAGS(AxisTypes, AxisType)" - ], - "qflag_full_class_name": "", - "enum_full_class_name": "", - "enum_value1": "", - "enum_value2": "", - "module_count": 1, - "module_idx": 0, - "module_name": "QtChart", - "module_path": "../../PyQt5-stubs/QtChart.pyi" - }, { "qflag_class": "TargetAccessModes", "enum_class": "TargetAccessMode", @@ -2580,12 +2376,12 @@ "module_path": "../../PyQt5-stubs/QtNfc.pyi" }, { - "qflag_class": "ChangeFlags", - "enum_class": "ChangeFlag", + "qflag_class": "SecurityFlags", + "enum_class": "Security", "human_hint_qflag_full_class_name": "", "human_hint_enum_full_class_name": "", "grep_line": [ - "src\\core\\changes\\qscenechange.h:Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)" + "src\\bluetooth\\qbluetooth.h:Q_DECLARE_FLAGS(SecurityFlags, Security)" ], "qflag_full_class_name": "", "enum_full_class_name": "", @@ -2593,16 +2389,16 @@ "enum_value2": "", "module_count": 1, "module_idx": 0, - "module_name": "Qt3DCore", - "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" }, { - "qflag_class": "DeliveryFlags", - "enum_class": "DeliveryFlag", + "qflag_class": "AttAccessConstraints", + "enum_class": "AttAccessConstraint", "human_hint_qflag_full_class_name": "", "human_hint_enum_full_class_name": "", "grep_line": [ - "src\\core\\changes\\qscenechange.h: Q_DECLARE_FLAGS(DeliveryFlags, DeliveryFlag)" + "src\\bluetooth\\qbluetooth.h:Q_DECLARE_FLAGS(AttAccessConstraints, AttAccessConstraint)" ], "qflag_full_class_name": "", "enum_full_class_name": "", @@ -2610,16 +2406,16 @@ "enum_value2": "", "module_count": 1, "module_idx": 0, - "module_name": "Qt3DCore", - "module_path": "../../PyQt5-stubs/Qt3DCore.pyi" + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" }, { - "qflag_class": "BufferTypeFlags", - "enum_class": "BufferType", + "qflag_class": "DiscoveryMethods", + "enum_class": "DiscoveryMethod", "human_hint_qflag_full_class_name": "", "human_hint_enum_full_class_name": "", "grep_line": [ - "src\\render\\framegraph\\qclearbuffers.h: Q_DECLARE_FLAGS(BufferTypeFlags, BufferType)" + "src\\bluetooth\\qbluetoothdevicediscoveryagent.h: Q_DECLARE_FLAGS(DiscoveryMethods, DiscoveryMethod)" ], "qflag_full_class_name": "", "enum_full_class_name": "", @@ -2627,16 +2423,16 @@ "enum_value2": "", "module_count": 1, "module_idx": 0, - "module_name": "Qt3DRender", - "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" }, { - "qflag_class": "Operations", - "enum_class": "Operation", + "qflag_class": "ServiceClasses", + "enum_class": "ServiceClass", "human_hint_qflag_full_class_name": "", "human_hint_enum_full_class_name": "", "grep_line": [ - "src\\render\\framegraph\\qmemorybarrier.h: Q_DECLARE_FLAGS(Operations, Operation)" + "src\\bluetooth\\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(ServiceClasses, ServiceClass)" ], "qflag_full_class_name": "", "enum_full_class_name": "", @@ -2644,16 +2440,16 @@ "enum_value2": "", "module_count": 1, "module_idx": 0, - "module_name": "Qt3DRender", - "module_path": "../../PyQt5-stubs/Qt3DRender.pyi" + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" }, { - "qflag_class": "AnimationOptions", - "enum_class": "AnimationOption", + "qflag_class": "Fields", + "enum_class": "Field", "human_hint_qflag_full_class_name": "", "human_hint_enum_full_class_name": "", "grep_line": [ - "src\\charts\\qchart.h: Q_DECLARE_FLAGS(AnimationOptions, AnimationOption)" + "src\\bluetooth\\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(Fields, Field)" ], "qflag_full_class_name": "", "enum_full_class_name": "", @@ -2661,16 +2457,16 @@ "enum_value2": "", "module_count": 1, "module_idx": 0, - "module_name": "QtChart", - "module_path": "../../PyQt5-stubs/QtChart.pyi" + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" }, { - "qflag_class": "RubberBands", - "enum_class": "RubberBand", + "qflag_class": "CoreConfigurations", + "enum_class": "CoreConfiguration", "human_hint_qflag_full_class_name": "", "human_hint_enum_full_class_name": "", "grep_line": [ - "src\\charts\\qchartview.h: Q_DECLARE_FLAGS(RubberBands, RubberBand)" + "src\\bluetooth\\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(CoreConfigurations, CoreConfiguration)" ], "qflag_full_class_name": "", "enum_full_class_name": "", @@ -2678,16 +2474,16 @@ "enum_value2": "", "module_count": 1, "module_idx": 0, - "module_name": "QtChart", - "module_path": "../../PyQt5-stubs/QtChart.pyi" + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" }, { - "qflag_class": "PolarOrientations", - "enum_class": "PolarOrientation", + "qflag_class": "PropertyTypes", + "enum_class": "PropertyType", "human_hint_qflag_full_class_name": "", "human_hint_enum_full_class_name": "", "grep_line": [ - "src\\charts\\qpolarchart.h: Q_DECLARE_FLAGS(PolarOrientations, PolarOrientation)" + "src\\bluetooth\\qlowenergycharacteristic.h: Q_DECLARE_FLAGS(PropertyTypes, PropertyType)" ], "qflag_full_class_name": "", "enum_full_class_name": "", @@ -2695,16 +2491,16 @@ "enum_value2": "", "module_count": 1, "module_idx": 0, - "module_name": "QtChart", - "module_path": "../../PyQt5-stubs/QtChart.pyi" + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" }, { - "qflag_class": "AxisTypes", - "enum_class": "AxisType", + "qflag_class": "ServiceTypes", + "enum_class": "ServiceType", "human_hint_qflag_full_class_name": "", "human_hint_enum_full_class_name": "", "grep_line": [ - "src\\charts\\axis\\qabstractaxis.h: Q_DECLARE_FLAGS(AxisTypes, AxisType)" + "src\\bluetooth\\qlowenergyservice.h: Q_DECLARE_FLAGS(ServiceTypes, ServiceType)" ], "qflag_full_class_name": "", "enum_full_class_name": "", @@ -2712,8 +2508,8 @@ "enum_value2": "", "module_count": 1, "module_idx": 0, - "module_name": "QtChart", - "module_path": "../../PyQt5-stubs/QtChart.pyi" + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" } ], "qflags_to_skip": [ @@ -2762,50 +2558,10 @@ "enum_class": "DirtyFlag", "skip_reason": "QFlag not found in module group qtconnectivity" }, - { - "qflag_class": "SecurityFlags", - "enum_class": "Security", - "skip_reason": "QFlag not found in module group qtconnectivity" - }, - { - "qflag_class": "AttAccessConstraints", - "enum_class": "AttAccessConstraint", - "skip_reason": "QFlag not found in module group qtconnectivity" - }, - { - "qflag_class": "DiscoveryMethods", - "enum_class": "DiscoveryMethod", - "skip_reason": "QFlag not found in module group qtconnectivity" - }, - { - "qflag_class": "ServiceClasses", - "enum_class": "ServiceClass", - "skip_reason": "QFlag not found in module group qtconnectivity" - }, - { - "qflag_class": "Fields", - "enum_class": "Field", - "skip_reason": "QFlag not found in module group qtconnectivity" - }, - { - "qflag_class": "CoreConfigurations", - "enum_class": "CoreConfiguration", - "skip_reason": "QFlag not found in module group qtconnectivity" - }, - { - "qflag_class": "PropertyTypes", - "enum_class": "PropertyType", - "skip_reason": "QFlag not found in module group qtconnectivity" - }, { "qflag_class": "JobFlags", "enum_class": "JobFlag", "skip_reason": "QFlag not found in module group qtconnectivity" - }, - { - "qflag_class": "ServiceTypes", - "enum_class": "ServiceType", - "skip_reason": "QFlag not found in module group qtconnectivity" } ] } \ No newline at end of file From 015a2531e61f4c7fc9d54d7ec9c79019cc3d452c Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 13:34:18 +0100 Subject: [PATCH 290/421] Bluetooth flags to qdd --- tests/qflags/qflags_modules_analysis.json | 153 ++++++++++++++++++++++ 1 file changed, 153 insertions(+) diff --git a/tests/qflags/qflags_modules_analysis.json b/tests/qflags/qflags_modules_analysis.json index 9d568386..8dd04637 100644 --- a/tests/qflags/qflags_modules_analysis.json +++ b/tests/qflags/qflags_modules_analysis.json @@ -186,6 +186,142 @@ "module_idx": 0, "module_name": "QtNfc", "module_path": "../../PyQt5-stubs/QtNfc.pyi" + }, + { + "qflag_class": "SecurityFlags", + "enum_class": "Security", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetooth.h:Q_DECLARE_FLAGS(SecurityFlags, Security)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" + }, + { + "qflag_class": "AttAccessConstraints", + "enum_class": "AttAccessConstraint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetooth.h:Q_DECLARE_FLAGS(AttAccessConstraints, AttAccessConstraint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" + }, + { + "qflag_class": "DiscoveryMethods", + "enum_class": "DiscoveryMethod", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetoothdevicediscoveryagent.h: Q_DECLARE_FLAGS(DiscoveryMethods, DiscoveryMethod)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" + }, + { + "qflag_class": "ServiceClasses", + "enum_class": "ServiceClass", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(ServiceClasses, ServiceClass)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" + }, + { + "qflag_class": "Fields", + "enum_class": "Field", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(Fields, Field)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" + }, + { + "qflag_class": "CoreConfigurations", + "enum_class": "CoreConfiguration", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(CoreConfigurations, CoreConfiguration)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" + }, + { + "qflag_class": "PropertyTypes", + "enum_class": "PropertyType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qlowenergycharacteristic.h: Q_DECLARE_FLAGS(PropertyTypes, PropertyType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" + }, + { + "qflag_class": "ServiceTypes", + "enum_class": "ServiceType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qlowenergyservice.h: Q_DECLARE_FLAGS(ServiceTypes, ServiceType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" } ], "flag_without_module": [ @@ -240,6 +376,23 @@ "module_idx": -1, "module_name": "", "module_path": "" + }, + { + "qflag_class": "JobFlags", + "enum_class": "JobFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qlowenergycontroller_bluezdbus_p.h: Q_DECLARE_FLAGS(JobFlags, JobFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" } ] } \ No newline at end of file From c16506c36f219554cc8d62793bd2ff35c7f6f0ca Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 13:37:12 +0100 Subject: [PATCH 291/421] QFlag operations for QBluetooth.SecurityFlags, QBluetooth.Security in module QtBluetooth --- PyQt5-stubs/QtBluetooth.pyi | 11 + ...test_QtBluetooth_SecurityFlags_Security.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtBluetooth_SecurityFlags_Security.py diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index b9bb57b5..08cca69c 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -44,6 +44,9 @@ class QBluetooth(sip.simplewrapper): AttEncryptionRequired = ... # type: QBluetooth.AttAccessConstraint class Security(int): + def __or__ (self, other: 'QBluetooth.Security') -> 'QBluetooth.SecurityFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QBluetooth.SecurityFlags': ... # type: ignore[override, misc] + NoSecurity = ... # type: QBluetooth.Security Authorization = ... # type: QBluetooth.Security Authentication = ... # type: QBluetooth.Security @@ -64,12 +67,20 @@ class QBluetooth(sip.simplewrapper): def __init__(self, f: typing.Union['QBluetooth.SecurityFlags', 'QBluetooth.Security']) -> None: ... @typing.overload def __init__(self, a0: 'QBluetooth.SecurityFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QBluetooth.SecurityFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QBluetooth.SecurityFlags', 'QBluetooth.Security', int]) -> 'QBluetooth.SecurityFlags': ... + def __and__(self, other: typing.Union['QBluetooth.SecurityFlags', 'QBluetooth.Security', int]) -> 'QBluetooth.SecurityFlags': ... + def __xor__(self, other: typing.Union['QBluetooth.SecurityFlags', 'QBluetooth.Security', int]) -> 'QBluetooth.SecurityFlags': ... + def __ror__ (self, other: 'QBluetooth.Security') -> 'QBluetooth.SecurityFlags': ... + def __rand__(self, other: 'QBluetooth.Security') -> 'QBluetooth.SecurityFlags': ... + def __rxor__(self, other: 'QBluetooth.Security') -> 'QBluetooth.SecurityFlags': ... class AttAccessConstraints(sip.wrapper): diff --git a/tests/qflags/test_QtBluetooth_SecurityFlags_Security.py b/tests/qflags/test_QtBluetooth_SecurityFlags_Security.py new file mode 100644 index 00000000..d22b315b --- /dev/null +++ b/tests/qflags/test_QtBluetooth_SecurityFlags_Security.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QBluetooth.SecurityFlags" and flag class "QBluetooth.Security" +from PyQt5 import QtBluetooth + +OneFlagClass = QtBluetooth.QBluetooth.Security +MultiFlagClass = QtBluetooth.QBluetooth.SecurityFlags + +oneFlagRefValue1 = QtBluetooth.QBluetooth.Security.NoSecurity +oneFlagRefValue2 = QtBluetooth.QBluetooth.Security.Authorization + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From dc0186453b657d41876b2a443cad7f92e12717ca Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 13:37:28 +0100 Subject: [PATCH 292/421] QFlag operations for QBluetooth.AttAccessConstraints, QBluetooth.AttAccessConstraint in module QtBluetooth --- PyQt5-stubs/QtBluetooth.pyi | 11 + ...ttAccessConstraints_AttAccessConstraint.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtBluetooth_AttAccessConstraints_AttAccessConstraint.py diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index 08cca69c..544c30ab 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -35,6 +35,9 @@ PYQT_SLOT = typing.Union[typing.Callable[..., None], QtCore.pyqtBoundSignal] class QBluetooth(sip.simplewrapper): class AttAccessConstraint(int): + def __or__ (self, other: 'QBluetooth.AttAccessConstraint') -> 'QBluetooth.AttAccessConstraints': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QBluetooth.AttAccessConstraints': ... # type: ignore[override, misc] + AttAuthorizationRequired = ... # type: QBluetooth.AttAccessConstraint AttAuthenticationRequired = ... # type: QBluetooth.AttAccessConstraint AttEncryptionRequired = ... # type: QBluetooth.AttAccessConstraint @@ -90,12 +93,20 @@ class QBluetooth(sip.simplewrapper): def __init__(self, f: typing.Union['QBluetooth.AttAccessConstraints', 'QBluetooth.AttAccessConstraint']) -> None: ... @typing.overload def __init__(self, a0: 'QBluetooth.AttAccessConstraints') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QBluetooth.AttAccessConstraints': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QBluetooth.AttAccessConstraints', 'QBluetooth.AttAccessConstraint', int]) -> 'QBluetooth.AttAccessConstraints': ... + def __and__(self, other: typing.Union['QBluetooth.AttAccessConstraints', 'QBluetooth.AttAccessConstraint', int]) -> 'QBluetooth.AttAccessConstraints': ... + def __xor__(self, other: typing.Union['QBluetooth.AttAccessConstraints', 'QBluetooth.AttAccessConstraint', int]) -> 'QBluetooth.AttAccessConstraints': ... + def __ror__ (self, other: 'QBluetooth.AttAccessConstraint') -> 'QBluetooth.AttAccessConstraints': ... + def __rand__(self, other: 'QBluetooth.AttAccessConstraint') -> 'QBluetooth.AttAccessConstraints': ... + def __rxor__(self, other: 'QBluetooth.AttAccessConstraint') -> 'QBluetooth.AttAccessConstraints': ... class QBluetoothAddress(sip.wrapper): diff --git a/tests/qflags/test_QtBluetooth_AttAccessConstraints_AttAccessConstraint.py b/tests/qflags/test_QtBluetooth_AttAccessConstraints_AttAccessConstraint.py new file mode 100644 index 00000000..30f09868 --- /dev/null +++ b/tests/qflags/test_QtBluetooth_AttAccessConstraints_AttAccessConstraint.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QBluetooth.AttAccessConstraints" and flag class "QBluetooth.AttAccessConstraint" +from PyQt5 import QtBluetooth + +OneFlagClass = QtBluetooth.QBluetooth.AttAccessConstraint +MultiFlagClass = QtBluetooth.QBluetooth.AttAccessConstraints + +oneFlagRefValue1 = QtBluetooth.QBluetooth.AttAccessConstraint.AttAuthorizationRequired +oneFlagRefValue2 = QtBluetooth.QBluetooth.AttAccessConstraint.AttAuthenticationRequired + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 54bb96fad619529ee552fb62c107514cfb7a1fb7 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 13:37:49 +0100 Subject: [PATCH 293/421] QFlag operations for QBluetoothDeviceInfo.ServiceClasses, QBluetoothDeviceInfo.ServiceClass in module QtBluetooth --- PyQt5-stubs/QtBluetooth.pyi | 11 + ...QtBluetooth_ServiceClasses_ServiceClass.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtBluetooth_ServiceClasses_ServiceClass.py diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index 544c30ab..8dae2b2f 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -239,6 +239,9 @@ class QBluetoothDeviceInfo(sip.wrapper): DataUnavailable = ... # type: QBluetoothDeviceInfo.DataCompleteness class ServiceClass(int): + def __or__ (self, other: 'QBluetoothDeviceInfo.ServiceClass') -> 'QBluetoothDeviceInfo.ServiceClasses': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QBluetoothDeviceInfo.ServiceClasses': ... # type: ignore[override, misc] + NoService = ... # type: QBluetoothDeviceInfo.ServiceClass PositioningService = ... # type: QBluetoothDeviceInfo.ServiceClass NetworkingService = ... # type: QBluetoothDeviceInfo.ServiceClass @@ -474,12 +477,20 @@ class QBluetoothDeviceInfo(sip.wrapper): def __init__(self, f: typing.Union['QBluetoothDeviceInfo.ServiceClasses', 'QBluetoothDeviceInfo.ServiceClass']) -> None: ... @typing.overload def __init__(self, a0: 'QBluetoothDeviceInfo.ServiceClasses') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QBluetoothDeviceInfo.ServiceClasses': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QBluetoothDeviceInfo.ServiceClasses', 'QBluetoothDeviceInfo.ServiceClass', int]) -> 'QBluetoothDeviceInfo.ServiceClasses': ... + def __and__(self, other: typing.Union['QBluetoothDeviceInfo.ServiceClasses', 'QBluetoothDeviceInfo.ServiceClass', int]) -> 'QBluetoothDeviceInfo.ServiceClasses': ... + def __xor__(self, other: typing.Union['QBluetoothDeviceInfo.ServiceClasses', 'QBluetoothDeviceInfo.ServiceClass', int]) -> 'QBluetoothDeviceInfo.ServiceClasses': ... + def __ror__ (self, other: 'QBluetoothDeviceInfo.ServiceClass') -> 'QBluetoothDeviceInfo.ServiceClasses': ... + def __rand__(self, other: 'QBluetoothDeviceInfo.ServiceClass') -> 'QBluetoothDeviceInfo.ServiceClasses': ... + def __rxor__(self, other: 'QBluetoothDeviceInfo.ServiceClass') -> 'QBluetoothDeviceInfo.ServiceClasses': ... class CoreConfigurations(sip.wrapper): diff --git a/tests/qflags/test_QtBluetooth_ServiceClasses_ServiceClass.py b/tests/qflags/test_QtBluetooth_ServiceClasses_ServiceClass.py new file mode 100644 index 00000000..a0029ef8 --- /dev/null +++ b/tests/qflags/test_QtBluetooth_ServiceClasses_ServiceClass.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QBluetoothDeviceInfo.ServiceClasses" and flag class "QBluetoothDeviceInfo.ServiceClass" +from PyQt5 import QtBluetooth + +OneFlagClass = QtBluetooth.QBluetoothDeviceInfo.ServiceClass +MultiFlagClass = QtBluetooth.QBluetoothDeviceInfo.ServiceClasses + +oneFlagRefValue1 = QtBluetooth.QBluetoothDeviceInfo.ServiceClass.NoService +oneFlagRefValue2 = QtBluetooth.QBluetoothDeviceInfo.ServiceClass.PositioningService + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 64589916ae9b8d8f698efd9f8056f28e2f4c91d5 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 13:38:08 +0100 Subject: [PATCH 294/421] QFlag operations for QBluetoothDeviceInfo.Fields, QBluetoothDeviceInfo.Field in module QtBluetooth --- PyQt5-stubs/QtBluetooth.pyi | 8 + tests/qflags/test_QtBluetooth_Fields_Field.py | 272 ++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 tests/qflags/test_QtBluetooth_Fields_Field.py diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index 8dae2b2f..81856e89 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -515,12 +515,20 @@ class QBluetoothDeviceInfo(sip.wrapper): def __init__(self, f: typing.Union['QBluetoothDeviceInfo.Fields', 'QBluetoothDeviceInfo.Field']) -> None: ... @typing.overload def __init__(self, a0: 'QBluetoothDeviceInfo.Fields') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QBluetoothDeviceInfo.Fields': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QBluetoothDeviceInfo.Fields', 'QBluetoothDeviceInfo.Field', int]) -> 'QBluetoothDeviceInfo.Fields': ... + def __and__(self, other: typing.Union['QBluetoothDeviceInfo.Fields', 'QBluetoothDeviceInfo.Field', int]) -> 'QBluetoothDeviceInfo.Fields': ... + def __xor__(self, other: typing.Union['QBluetoothDeviceInfo.Fields', 'QBluetoothDeviceInfo.Field', int]) -> 'QBluetoothDeviceInfo.Fields': ... + def __ror__ (self, other: 'QBluetoothDeviceInfo.Field') -> 'QBluetoothDeviceInfo.Fields': ... + def __rand__(self, other: 'QBluetoothDeviceInfo.Field') -> 'QBluetoothDeviceInfo.Fields': ... + def __rxor__(self, other: 'QBluetoothDeviceInfo.Field') -> 'QBluetoothDeviceInfo.Fields': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtBluetooth_Fields_Field.py b/tests/qflags/test_QtBluetooth_Fields_Field.py new file mode 100644 index 00000000..b2df8359 --- /dev/null +++ b/tests/qflags/test_QtBluetooth_Fields_Field.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QBluetoothDeviceInfo.Fields" and flag class "QBluetoothDeviceInfo.Field" +from PyQt5 import QtBluetooth + +OneFlagClass = QtBluetooth.QBluetoothDeviceInfo.Field +MultiFlagClass = QtBluetooth.QBluetoothDeviceInfo.Fields + +oneFlagRefValue1 = QtBluetooth.QBluetoothDeviceInfo.Field.None_ +oneFlagRefValue2 = QtBluetooth.QBluetoothDeviceInfo.Field.RSSI + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From fa2e3b6d5d82e7a727dfbc8d4927c1043a4e2b2b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 13:38:34 +0100 Subject: [PATCH 295/421] QFlag operations for QBluetoothDeviceInfo.CoreConfigurations, QBluetoothDeviceInfo.CoreConfiguration in module QtBluetooth --- PyQt5-stubs/QtBluetooth.pyi | 11 + ...th_CoreConfigurations_CoreConfiguration.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtBluetooth_CoreConfigurations_CoreConfiguration.py diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index 81856e89..d5ce1412 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -219,6 +219,9 @@ class QBluetoothDeviceInfo(sip.wrapper): All = ... # type: QBluetoothDeviceInfo.Field class CoreConfiguration(int): + def __or__ (self, other: 'QBluetoothDeviceInfo.CoreConfiguration') -> 'QBluetoothDeviceInfo.CoreConfigurations': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QBluetoothDeviceInfo.CoreConfigurations': ... # type: ignore[override, misc] + UnknownCoreConfiguration = ... # type: QBluetoothDeviceInfo.CoreConfiguration LowEnergyCoreConfiguration = ... # type: QBluetoothDeviceInfo.CoreConfiguration BaseRateCoreConfiguration = ... # type: QBluetoothDeviceInfo.CoreConfiguration @@ -500,12 +503,20 @@ class QBluetoothDeviceInfo(sip.wrapper): def __init__(self, f: typing.Union['QBluetoothDeviceInfo.CoreConfigurations', 'QBluetoothDeviceInfo.CoreConfiguration']) -> None: ... @typing.overload def __init__(self, a0: 'QBluetoothDeviceInfo.CoreConfigurations') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QBluetoothDeviceInfo.CoreConfigurations': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QBluetoothDeviceInfo.CoreConfigurations', 'QBluetoothDeviceInfo.CoreConfiguration', int]) -> 'QBluetoothDeviceInfo.CoreConfigurations': ... + def __and__(self, other: typing.Union['QBluetoothDeviceInfo.CoreConfigurations', 'QBluetoothDeviceInfo.CoreConfiguration', int]) -> 'QBluetoothDeviceInfo.CoreConfigurations': ... + def __xor__(self, other: typing.Union['QBluetoothDeviceInfo.CoreConfigurations', 'QBluetoothDeviceInfo.CoreConfiguration', int]) -> 'QBluetoothDeviceInfo.CoreConfigurations': ... + def __ror__ (self, other: 'QBluetoothDeviceInfo.CoreConfiguration') -> 'QBluetoothDeviceInfo.CoreConfigurations': ... + def __rand__(self, other: 'QBluetoothDeviceInfo.CoreConfiguration') -> 'QBluetoothDeviceInfo.CoreConfigurations': ... + def __rxor__(self, other: 'QBluetoothDeviceInfo.CoreConfiguration') -> 'QBluetoothDeviceInfo.CoreConfigurations': ... class Fields(sip.wrapper): diff --git a/tests/qflags/test_QtBluetooth_CoreConfigurations_CoreConfiguration.py b/tests/qflags/test_QtBluetooth_CoreConfigurations_CoreConfiguration.py new file mode 100644 index 00000000..37cda47a --- /dev/null +++ b/tests/qflags/test_QtBluetooth_CoreConfigurations_CoreConfiguration.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QBluetoothDeviceInfo.CoreConfigurations" and flag class "QBluetoothDeviceInfo.CoreConfiguration" +from PyQt5 import QtBluetooth + +OneFlagClass = QtBluetooth.QBluetoothDeviceInfo.CoreConfiguration +MultiFlagClass = QtBluetooth.QBluetoothDeviceInfo.CoreConfigurations + +oneFlagRefValue1 = QtBluetooth.QBluetoothDeviceInfo.CoreConfiguration.UnknownCoreConfiguration +oneFlagRefValue2 = QtBluetooth.QBluetoothDeviceInfo.CoreConfiguration.LowEnergyCoreConfiguration + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From daa8c4da92652655711ecf89695029d4bb044874 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 13:38:55 +0100 Subject: [PATCH 296/421] QFlag operations for QLowEnergyCharacteristic.PropertyTypes, QLowEnergyCharacteristic.PropertyType in module QtBluetooth --- PyQt5-stubs/QtBluetooth.pyi | 11 + ..._QtBluetooth_PropertyTypes_PropertyType.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtBluetooth_PropertyTypes_PropertyType.py diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index d5ce1412..afc3ea35 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -1642,6 +1642,9 @@ class QLowEnergyAdvertisingParameters(sip.wrapper): class QLowEnergyCharacteristic(sip.wrapper): class PropertyType(int): + def __or__ (self, other: 'QLowEnergyCharacteristic.PropertyType') -> 'QLowEnergyCharacteristic.PropertyTypes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QLowEnergyCharacteristic.PropertyTypes': ... # type: ignore[override, misc] + Unknown = ... # type: QLowEnergyCharacteristic.PropertyType Broadcasting = ... # type: QLowEnergyCharacteristic.PropertyType Read = ... # type: QLowEnergyCharacteristic.PropertyType @@ -1670,12 +1673,20 @@ class QLowEnergyCharacteristic(sip.wrapper): def __init__(self, f: typing.Union['QLowEnergyCharacteristic.PropertyTypes', 'QLowEnergyCharacteristic.PropertyType']) -> None: ... @typing.overload def __init__(self, a0: 'QLowEnergyCharacteristic.PropertyTypes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QLowEnergyCharacteristic.PropertyTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QLowEnergyCharacteristic.PropertyTypes', 'QLowEnergyCharacteristic.PropertyType', int]) -> 'QLowEnergyCharacteristic.PropertyTypes': ... + def __and__(self, other: typing.Union['QLowEnergyCharacteristic.PropertyTypes', 'QLowEnergyCharacteristic.PropertyType', int]) -> 'QLowEnergyCharacteristic.PropertyTypes': ... + def __xor__(self, other: typing.Union['QLowEnergyCharacteristic.PropertyTypes', 'QLowEnergyCharacteristic.PropertyType', int]) -> 'QLowEnergyCharacteristic.PropertyTypes': ... + def __ror__ (self, other: 'QLowEnergyCharacteristic.PropertyType') -> 'QLowEnergyCharacteristic.PropertyTypes': ... + def __rand__(self, other: 'QLowEnergyCharacteristic.PropertyType') -> 'QLowEnergyCharacteristic.PropertyTypes': ... + def __rxor__(self, other: 'QLowEnergyCharacteristic.PropertyType') -> 'QLowEnergyCharacteristic.PropertyTypes': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtBluetooth_PropertyTypes_PropertyType.py b/tests/qflags/test_QtBluetooth_PropertyTypes_PropertyType.py new file mode 100644 index 00000000..08e34deb --- /dev/null +++ b/tests/qflags/test_QtBluetooth_PropertyTypes_PropertyType.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QLowEnergyCharacteristic.PropertyTypes" and flag class "QLowEnergyCharacteristic.PropertyType" +from PyQt5 import QtBluetooth + +OneFlagClass = QtBluetooth.QLowEnergyCharacteristic.PropertyType +MultiFlagClass = QtBluetooth.QLowEnergyCharacteristic.PropertyTypes + +oneFlagRefValue1 = QtBluetooth.QLowEnergyCharacteristic.PropertyType.Unknown +oneFlagRefValue2 = QtBluetooth.QLowEnergyCharacteristic.PropertyType.Broadcasting + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 46aa02f574e9618ec92fd8d02bc1070faced344f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 13:39:21 +0100 Subject: [PATCH 297/421] QFlag operations for QLowEnergyService.ServiceTypes, QLowEnergyService.ServiceType in module QtBluetooth --- PyQt5-stubs/QtBluetooth.pyi | 11 + ...st_QtBluetooth_ServiceTypes_ServiceType.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtBluetooth_ServiceTypes_ServiceType.py diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index afc3ea35..c793ac0f 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -1926,6 +1926,9 @@ class QLowEnergyService(QtCore.QObject): UnknownError = ... # type: QLowEnergyService.ServiceError class ServiceType(int): + def __or__ (self, other: 'QLowEnergyService.ServiceType') -> 'QLowEnergyService.ServiceTypes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QLowEnergyService.ServiceTypes': ... # type: ignore[override, misc] + PrimaryService = ... # type: QLowEnergyService.ServiceType IncludedService = ... # type: QLowEnergyService.ServiceType @@ -1940,12 +1943,20 @@ class QLowEnergyService(QtCore.QObject): def __init__(self, f: typing.Union['QLowEnergyService.ServiceTypes', 'QLowEnergyService.ServiceType']) -> None: ... @typing.overload def __init__(self, a0: 'QLowEnergyService.ServiceTypes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QLowEnergyService.ServiceTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QLowEnergyService.ServiceTypes', 'QLowEnergyService.ServiceType', int]) -> 'QLowEnergyService.ServiceTypes': ... + def __and__(self, other: typing.Union['QLowEnergyService.ServiceTypes', 'QLowEnergyService.ServiceType', int]) -> 'QLowEnergyService.ServiceTypes': ... + def __xor__(self, other: typing.Union['QLowEnergyService.ServiceTypes', 'QLowEnergyService.ServiceType', int]) -> 'QLowEnergyService.ServiceTypes': ... + def __ror__ (self, other: 'QLowEnergyService.ServiceType') -> 'QLowEnergyService.ServiceTypes': ... + def __rand__(self, other: 'QLowEnergyService.ServiceType') -> 'QLowEnergyService.ServiceTypes': ... + def __rxor__(self, other: 'QLowEnergyService.ServiceType') -> 'QLowEnergyService.ServiceTypes': ... def descriptorRead(self, info: QLowEnergyDescriptor, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... def characteristicRead(self, info: QLowEnergyCharacteristic, value: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... diff --git a/tests/qflags/test_QtBluetooth_ServiceTypes_ServiceType.py b/tests/qflags/test_QtBluetooth_ServiceTypes_ServiceType.py new file mode 100644 index 00000000..8bf18411 --- /dev/null +++ b/tests/qflags/test_QtBluetooth_ServiceTypes_ServiceType.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QLowEnergyService.ServiceTypes" and flag class "QLowEnergyService.ServiceType" +from PyQt5 import QtBluetooth + +OneFlagClass = QtBluetooth.QLowEnergyService.ServiceType +MultiFlagClass = QtBluetooth.QLowEnergyService.ServiceTypes + +oneFlagRefValue1 = QtBluetooth.QLowEnergyService.ServiceType.PrimaryService +oneFlagRefValue2 = QtBluetooth.QLowEnergyService.ServiceType.IncludedService + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 583d87789a92624b07c264a8bc946a4b0f9ee658 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 13:42:44 +0100 Subject: [PATCH 298/421] QFlag may inherit from sip.wrapper as well --- tests/qflags/generate_qflags_stubs_and_tests.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index e8ed1516..80f78a8a 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -788,14 +788,21 @@ def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier' def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: ''' if (len(qflag_node.bases) == 0 - or not matchers.matches(qflag_node.bases[0], + or not (matchers.matches(qflag_node.bases[0], + matchers.Arg(value=matchers.Attribute(value=matchers.Name('sip'), + attr=matchers.Name('simplewrapper') + ) + ) + ) + or matchers.matches(qflag_node.bases[0], matchers.Arg(value=matchers.Attribute(value=matchers.Name('sip'), - attr=matchers.Name('simplewrapper') + attr=matchers.Name('wrapper') ) ) ) + ) ): - # 'Class does not inherit from sip.simplewrapper' + # 'Class does not inherit from sip.simplewrapper' or sip.wrapper return False has_method = [ From 7764ec5f7dfe4f71fd74c1c635a3d093968e0246 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 13:42:53 +0100 Subject: [PATCH 299/421] Processing results --- tests/qflags/qflags_process_result.json | 238 ++++++++++++++++++++++++ 1 file changed, 238 insertions(+) diff --git a/tests/qflags/qflags_process_result.json b/tests/qflags/qflags_process_result.json index 3e5720f1..6bf46058 100644 --- a/tests/qflags/qflags_process_result.json +++ b/tests/qflags/qflags_process_result.json @@ -2724,6 +2724,216 @@ "or_int_converts_to_multi": false, "int_or_converts_to_multi": false, "supports_one_op_multi": true + }, + { + "qflag_class": "TargetAccessModes", + "enum_class": "TargetAccessMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\nfc\\qnearfieldmanager.h: Q_DECLARE_FLAGS(TargetAccessModes, TargetAccessMode)" + ], + "qflag_full_class_name": "QNearFieldManager.TargetAccessModes", + "enum_full_class_name": "QNearFieldManager.TargetAccessMode", + "enum_value1": "NoTargetAccess", + "enum_value2": "NdefReadTargetAccess", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNfc", + "module_path": "../../PyQt5-stubs/QtNfc.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "ShareModes", + "enum_class": "ShareMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\nfc\\qnearfieldsharemanager.h: Q_DECLARE_FLAGS(ShareModes, ShareMode)" + ], + "qflag_full_class_name": "QNearFieldShareManager.ShareModes", + "enum_full_class_name": "QNearFieldShareManager.ShareMode", + "enum_value1": "NoShare", + "enum_value2": "NdefShare", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNfc", + "module_path": "../../PyQt5-stubs/QtNfc.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "AccessMethods", + "enum_class": "AccessMethod", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\nfc\\qnearfieldtarget.h: Q_DECLARE_FLAGS(AccessMethods, AccessMethod)" + ], + "qflag_full_class_name": "QNearFieldTarget.AccessMethods", + "enum_full_class_name": "QNearFieldTarget.AccessMethod", + "enum_value1": "UnknownAccess", + "enum_value2": "NdefAccess", + "module_count": 1, + "module_idx": 0, + "module_name": "QtNfc", + "module_path": "../../PyQt5-stubs/QtNfc.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "SecurityFlags", + "enum_class": "Security", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetooth.h:Q_DECLARE_FLAGS(SecurityFlags, Security)" + ], + "qflag_full_class_name": "QBluetooth.SecurityFlags", + "enum_full_class_name": "QBluetooth.Security", + "enum_value1": "NoSecurity", + "enum_value2": "Authorization", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "AttAccessConstraints", + "enum_class": "AttAccessConstraint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetooth.h:Q_DECLARE_FLAGS(AttAccessConstraints, AttAccessConstraint)" + ], + "qflag_full_class_name": "QBluetooth.AttAccessConstraints", + "enum_full_class_name": "QBluetooth.AttAccessConstraint", + "enum_value1": "AttAuthorizationRequired", + "enum_value2": "AttAuthenticationRequired", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "ServiceClasses", + "enum_class": "ServiceClass", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(ServiceClasses, ServiceClass)" + ], + "qflag_full_class_name": "QBluetoothDeviceInfo.ServiceClasses", + "enum_full_class_name": "QBluetoothDeviceInfo.ServiceClass", + "enum_value1": "NoService", + "enum_value2": "PositioningService", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "Fields", + "enum_class": "Field", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(Fields, Field)" + ], + "qflag_full_class_name": "QBluetoothDeviceInfo.Fields", + "enum_full_class_name": "QBluetoothDeviceInfo.Field", + "enum_value1": "None_", + "enum_value2": "RSSI", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "CoreConfigurations", + "enum_class": "CoreConfiguration", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetoothdeviceinfo.h: Q_DECLARE_FLAGS(CoreConfigurations, CoreConfiguration)" + ], + "qflag_full_class_name": "QBluetoothDeviceInfo.CoreConfigurations", + "enum_full_class_name": "QBluetoothDeviceInfo.CoreConfiguration", + "enum_value1": "UnknownCoreConfiguration", + "enum_value2": "LowEnergyCoreConfiguration", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "PropertyTypes", + "enum_class": "PropertyType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qlowenergycharacteristic.h: Q_DECLARE_FLAGS(PropertyTypes, PropertyType)" + ], + "qflag_full_class_name": "QLowEnergyCharacteristic.PropertyTypes", + "enum_full_class_name": "QLowEnergyCharacteristic.PropertyType", + "enum_value1": "Unknown", + "enum_value2": "Broadcasting", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "ServiceTypes", + "enum_class": "ServiceType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qlowenergyservice.h: Q_DECLARE_FLAGS(ServiceTypes, ServiceType)" + ], + "qflag_full_class_name": "QLowEnergyService.ServiceTypes", + "enum_full_class_name": "QLowEnergyService.ServiceType", + "enum_value1": "PrimaryService", + "enum_value2": "IncludedService", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true } ], "qflag_process_error": [ @@ -2750,6 +2960,34 @@ "error": [ "Enum methods are present but not QFlag methods" ] + }, + { + "qflag_class": "DiscoveryMethods", + "enum_class": "DiscoveryMethod", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\bluetooth\\qbluetoothdevicediscoveryagent.h: Q_DECLARE_FLAGS(DiscoveryMethods, DiscoveryMethod)" + ], + "qflag_full_class_name": "QBluetoothDeviceDiscoveryAgent.DiscoveryMethods", + "enum_full_class_name": "QBluetoothDeviceDiscoveryAgent.DiscoveryMethod", + "enum_value1": "NoMethod", + "enum_value2": "ClassicMethod", + "module_count": 1, + "module_idx": 0, + "module_name": "QtBluetooth", + "module_path": "../../PyQt5-stubs/QtBluetooth.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true, + "error": [ + "Traceback (most recent call last):", + " File \"generate_qflags_stubs_and_tests.py\", line 552, in generate_missing_stubs", + " flag_info.or_converts_to_multi = not eval('''type({qtmodule}.{oneFlagName}.{value1} | {qtmodule}.{oneFlagName}.{value2}) == int'''.format(", + " File \"\", line 1, in ", + "AttributeError: sip.enumtype object 'DiscoveryMethod' has no member 'NoMethod'" + ] } ] } \ No newline at end of file From a291ef84f1919a063f12be3185d76fa4995be3ff Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:19:22 +0100 Subject: [PATCH 300/421] Add visualization module --- .../qflags/generate_qflags_stubs_and_tests.py | 54 +++++++++++++++---- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 80f78a8a..bf8cafa9 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -14,6 +14,7 @@ Qt3DAnimation, Qt3DCore, Qt3DExtras, Qt3DInput, Qt3DLogic, Qt3DRender, QtChart, QtBluetooth, QtNfc, + QtDataVisualization, ) try: import libcst as cst @@ -50,6 +51,9 @@ 'QtBluetooth', 'QtNfc', ], + 'qtdatavisualization': [ + 'QtDataVisualization', + ], } @@ -110,6 +114,10 @@ class QFlagLocationInfo: module_name: str = '' module_path: str = '' + def key(self) -> Tuple[str, str, str]: + '''Mostly unique description of the QFlagInfo''' + return (self.module_name, self.qflag_class, self.enum_class) + # specific behavior of some QFlag classes varies slightly # this helps to define the exact behavior or_converts_to_multi: bool = True @@ -241,14 +249,22 @@ def group_qflags(qflag_location: List[QFlagLocationInfo], 'flag_without_module': [], } - qflags_group_initial['flag_and_module_identified'].extend([ - flag_info for flag_info in qflag_location - if flag_info.module_name != '' - ]) - qflags_group_initial['flag_without_module'].extend([ - flag_info for flag_info in qflag_location - if flag_info.module_name == '' - ]) + qflag_already_present = [ + (loc.module_name, loc.qflag_class, loc.enum_class) + for loc in qflags_group_initial['flag_and_module_identified'] + ] + + for flag_info in qflag_location: + qflag_key = flag_info.key() + + if flag_info.module_name != '': + if qflag_key in qflag_already_present: + print('QFlag already analysed: ', qflag_key) + continue + + qflags_group_initial['flag_and_module_identified'].append(flag_info) + else: + qflags_group_initial['flag_without_module'].append(flag_info) return qflags_group_initial @@ -275,7 +291,13 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, 'qflags_to_skip': [], } + skip_already_present = set( (d['qflag_class'], d['enum_class']) + for d in result['qflags_to_skip'] + ) for flag_info in d['flag_without_module']: + key = (flag_info['qflag_class'], flag_info['enum_class']) + if key in skip_already_present: + continue cast(List, result['qflags_to_skip']).append( { 'qflag_class': flag_info['qflag_class'], @@ -284,8 +306,15 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, } ) - for flag_info in d['flag_and_module_identified']: - cast(List, result['qflags_to_process']).append( flag_info ) + already_present = set((flag_info_d['module_name'], flag_info_d['qflag_class'], flag_info_d['enum_class']) + for flag_info_d in result['qflags_to_process']) + + for flag_info_d in d['flag_and_module_identified']: + key = (flag_info_d['module_name'], flag_info_d['qflag_class'], flag_info_d['enum_class']) + if key in already_present: + print('QFlag to process already present: ', key ) + continue + cast(List, result['qflags_to_process']).append( flag_info_d ) with open(qflags_to_process_json, 'w') as f: json.dump(result, f, indent=4) @@ -1138,8 +1167,11 @@ def generate_qflags_to_process(qt_qflag_grep_result_fname: str, module_group: st else: qflag_groups_initial = None + + initial_len = len(qflag_groups_initial['flag_and_module_identified']) qflags_groups = group_qflags(location_qflags, qflag_groups_initial) - log_progress('%d qflags ready to be processed' % len(qflags_groups['flag_and_module_identified'])) + new_len = len(qflag_groups_initial['flag_and_module_identified']) + log_progress('%d qflags ready to be processed' % (new_len - initial_len)) with open(qflags_modules_analysis_json, 'w') as f: json.dump(qflags_groups, f, indent=4, default=json_encode_qflaglocationinfo) From bd64a607da1d9db775351bce47f41d0927276b50 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:20:18 +0100 Subject: [PATCH 301/421] QFlag operations for QAbstract3DGraph.SelectionFlags, QAbstract3DGraph.SelectionFlag in module QtDataVisualization --- PyQt5-stubs/QtDataVisualization.pyi | 11 + ...ualization_SelectionFlags_SelectionFlag.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtDataVisualization_SelectionFlags_SelectionFlag.py diff --git a/PyQt5-stubs/QtDataVisualization.pyi b/PyQt5-stubs/QtDataVisualization.pyi index b4c86933..4eb74d1d 100644 --- a/PyQt5-stubs/QtDataVisualization.pyi +++ b/PyQt5-stubs/QtDataVisualization.pyi @@ -81,6 +81,9 @@ class QAbstract3DGraph(QtGui.QWindow): ShadowQualitySoftHigh = ... # type: QAbstract3DGraph.ShadowQuality class SelectionFlag(int): + def __or__ (self, other: 'QAbstract3DGraph.SelectionFlag') -> 'QAbstract3DGraph.SelectionFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QAbstract3DGraph.SelectionFlags': ... # type: ignore[override, misc] + SelectionNone = ... # type: QAbstract3DGraph.SelectionFlag SelectionItem = ... # type: QAbstract3DGraph.SelectionFlag SelectionRow = ... # type: QAbstract3DGraph.SelectionFlag @@ -111,12 +114,20 @@ class QAbstract3DGraph(QtGui.QWindow): def __init__(self, f: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QAbstract3DGraph.SelectionFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QAbstract3DGraph.SelectionFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag', int]) -> 'QAbstract3DGraph.SelectionFlags': ... + def __and__(self, other: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag', int]) -> 'QAbstract3DGraph.SelectionFlags': ... + def __xor__(self, other: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag', int]) -> 'QAbstract3DGraph.SelectionFlags': ... + def __ror__ (self, other: 'QAbstract3DGraph.SelectionFlag') -> 'QAbstract3DGraph.SelectionFlags': ... + def __rand__(self, other: 'QAbstract3DGraph.SelectionFlag') -> 'QAbstract3DGraph.SelectionFlags': ... + def __rxor__(self, other: 'QAbstract3DGraph.SelectionFlag') -> 'QAbstract3DGraph.SelectionFlags': ... class OptimizationHints(sip.simplewrapper): diff --git a/tests/qflags/test_QtDataVisualization_SelectionFlags_SelectionFlag.py b/tests/qflags/test_QtDataVisualization_SelectionFlags_SelectionFlag.py new file mode 100644 index 00000000..780647e1 --- /dev/null +++ b/tests/qflags/test_QtDataVisualization_SelectionFlags_SelectionFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QAbstract3DGraph.SelectionFlags" and flag class "QAbstract3DGraph.SelectionFlag" +from PyQt5 import QtDataVisualization + +OneFlagClass = QtDataVisualization.QAbstract3DGraph.SelectionFlag +MultiFlagClass = QtDataVisualization.QAbstract3DGraph.SelectionFlags + +oneFlagRefValue1 = QtDataVisualization.QAbstract3DGraph.SelectionFlag.SelectionNone +oneFlagRefValue2 = QtDataVisualization.QAbstract3DGraph.SelectionFlag.SelectionItem + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From a920426016fa34d66866fd33957cf8eefbc4000d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:20:34 +0100 Subject: [PATCH 302/421] QFlag operations for QAbstract3DGraph.OptimizationHints, QAbstract3DGraph.OptimizationHint in module QtDataVisualization --- PyQt5-stubs/QtDataVisualization.pyi | 11 + ...tion_OptimizationHints_OptimizationHint.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtDataVisualization_OptimizationHints_OptimizationHint.py diff --git a/PyQt5-stubs/QtDataVisualization.pyi b/PyQt5-stubs/QtDataVisualization.pyi index 4eb74d1d..6a614dd8 100644 --- a/PyQt5-stubs/QtDataVisualization.pyi +++ b/PyQt5-stubs/QtDataVisualization.pyi @@ -42,6 +42,9 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], class QAbstract3DGraph(QtGui.QWindow): class OptimizationHint(int): + def __or__ (self, other: 'QAbstract3DGraph.OptimizationHint') -> 'QAbstract3DGraph.OptimizationHints': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QAbstract3DGraph.OptimizationHints': ... # type: ignore[override, misc] + OptimizationDefault = ... # type: QAbstract3DGraph.OptimizationHint OptimizationStatic = ... # type: QAbstract3DGraph.OptimizationHint @@ -137,12 +140,20 @@ class QAbstract3DGraph(QtGui.QWindow): def __init__(self, f: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... @typing.overload def __init__(self, a0: 'QAbstract3DGraph.OptimizationHints') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QAbstract3DGraph.OptimizationHints': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint', int]) -> 'QAbstract3DGraph.OptimizationHints': ... + def __and__(self, other: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint', int]) -> 'QAbstract3DGraph.OptimizationHints': ... + def __xor__(self, other: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint', int]) -> 'QAbstract3DGraph.OptimizationHints': ... + def __ror__ (self, other: 'QAbstract3DGraph.OptimizationHint') -> 'QAbstract3DGraph.OptimizationHints': ... + def __rand__(self, other: 'QAbstract3DGraph.OptimizationHint') -> 'QAbstract3DGraph.OptimizationHints': ... + def __rxor__(self, other: 'QAbstract3DGraph.OptimizationHint') -> 'QAbstract3DGraph.OptimizationHints': ... def hasContext(self) -> bool: ... def marginChanged(self, margin: float) -> None: ... diff --git a/tests/qflags/test_QtDataVisualization_OptimizationHints_OptimizationHint.py b/tests/qflags/test_QtDataVisualization_OptimizationHints_OptimizationHint.py new file mode 100644 index 00000000..bf20974f --- /dev/null +++ b/tests/qflags/test_QtDataVisualization_OptimizationHints_OptimizationHint.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QAbstract3DGraph.OptimizationHints" and flag class "QAbstract3DGraph.OptimizationHint" +from PyQt5 import QtDataVisualization + +OneFlagClass = QtDataVisualization.QAbstract3DGraph.OptimizationHint +MultiFlagClass = QtDataVisualization.QAbstract3DGraph.OptimizationHints + +oneFlagRefValue1 = QtDataVisualization.QAbstract3DGraph.OptimizationHint.OptimizationDefault +oneFlagRefValue2 = QtDataVisualization.QAbstract3DGraph.OptimizationHint.OptimizationStatic + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From ec31cda16c0b65667bb0738c8995cb04cb4f25b5 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:20:50 +0100 Subject: [PATCH 303/421] QFlag operations for QSurface3DSeries.DrawFlags, QSurface3DSeries.DrawFlag in module QtDataVisualization --- PyQt5-stubs/QtDataVisualization.pyi | 8 + ..._QtDataVisualization_DrawFlags_DrawFlag.py | 272 ++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 tests/qflags/test_QtDataVisualization_DrawFlags_DrawFlag.py diff --git a/PyQt5-stubs/QtDataVisualization.pyi b/PyQt5-stubs/QtDataVisualization.pyi index 6a614dd8..fda2a308 100644 --- a/PyQt5-stubs/QtDataVisualization.pyi +++ b/PyQt5-stubs/QtDataVisualization.pyi @@ -1455,12 +1455,20 @@ class QSurface3DSeries('QAbstract3DSeries'): def __init__(self, f: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QSurface3DSeries.DrawFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSurface3DSeries.DrawFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag', int]) -> 'QSurface3DSeries.DrawFlags': ... + def __and__(self, other: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag', int]) -> 'QSurface3DSeries.DrawFlags': ... + def __xor__(self, other: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag', int]) -> 'QSurface3DSeries.DrawFlags': ... + def __ror__ (self, other: 'QSurface3DSeries.DrawFlag') -> 'QSurface3DSeries.DrawFlags': ... + def __rand__(self, other: 'QSurface3DSeries.DrawFlag') -> 'QSurface3DSeries.DrawFlags': ... + def __rxor__(self, other: 'QSurface3DSeries.DrawFlag') -> 'QSurface3DSeries.DrawFlags': ... @typing.overload def __init__(self, dataProxy: 'QSurfaceDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtDataVisualization_DrawFlags_DrawFlag.py b/tests/qflags/test_QtDataVisualization_DrawFlags_DrawFlag.py new file mode 100644 index 00000000..addcc08d --- /dev/null +++ b/tests/qflags/test_QtDataVisualization_DrawFlags_DrawFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSurface3DSeries.DrawFlags" and flag class "QSurface3DSeries.DrawFlag" +from PyQt5 import QtDataVisualization + +OneFlagClass = QtDataVisualization.QSurface3DSeries.DrawFlag +MultiFlagClass = QtDataVisualization.QSurface3DSeries.DrawFlags + +oneFlagRefValue1 = QtDataVisualization.QSurface3DSeries.DrawFlag.DrawWireframe +oneFlagRefValue2 = QtDataVisualization.QSurface3DSeries.DrawFlag.DrawSurface + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From c0406fa882ecb577a93b4ab28377249b53788063 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:21:28 +0100 Subject: [PATCH 304/421] Add visualization module results --- tests/qflags/qflags_modules_analysis.json | 70 +++++++++++++++++++++++ tests/qflags/qflags_process_result.json | 65 +++++++++++++++++++++ tests/qflags/qflags_to_process.json | 58 +++++++++++++++++++ 3 files changed, 193 insertions(+) diff --git a/tests/qflags/qflags_modules_analysis.json b/tests/qflags/qflags_modules_analysis.json index 8dd04637..5a6617bc 100644 --- a/tests/qflags/qflags_modules_analysis.json +++ b/tests/qflags/qflags_modules_analysis.json @@ -322,6 +322,59 @@ "module_idx": 0, "module_name": "QtBluetooth", "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" + }, + { + "qflag_class": "SelectionFlags", + "enum_class": "SelectionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\datavisualizationqml2\\abstractdeclarative_p.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)", + "src\\datavisualization\\engine\\qabstract3dgraph.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDataVisualization", + "module_path": "../../PyQt5-stubs/QtDataVisualization.pyi" + }, + { + "qflag_class": "OptimizationHints", + "enum_class": "OptimizationHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\datavisualizationqml2\\abstractdeclarative_p.h: Q_DECLARE_FLAGS(OptimizationHints, OptimizationHint)", + "src\\datavisualization\\engine\\qabstract3dgraph.h: Q_DECLARE_FLAGS(OptimizationHints, OptimizationHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDataVisualization", + "module_path": "../../PyQt5-stubs/QtDataVisualization.pyi" + }, + { + "qflag_class": "DrawFlags", + "enum_class": "DrawFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\datavisualization\\data\\qsurface3dseries.h: Q_DECLARE_FLAGS(DrawFlags, DrawFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDataVisualization", + "module_path": "../../PyQt5-stubs/QtDataVisualization.pyi" } ], "flag_without_module": [ @@ -393,6 +446,23 @@ "module_idx": -1, "module_name": "", "module_path": "" + }, + { + "qflag_class": "DataDimensions", + "enum_class": "DataDimension", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\datavisualization\\utils\\surfaceobject_p.h: Q_DECLARE_FLAGS(DataDimensions, DataDimension)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" } ] } \ No newline at end of file diff --git a/tests/qflags/qflags_process_result.json b/tests/qflags/qflags_process_result.json index 6bf46058..5220aa4b 100644 --- a/tests/qflags/qflags_process_result.json +++ b/tests/qflags/qflags_process_result.json @@ -2934,6 +2934,71 @@ "or_int_converts_to_multi": false, "int_or_converts_to_multi": true, "supports_one_op_multi": true + }, + { + "qflag_class": "SelectionFlags", + "enum_class": "SelectionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\datavisualizationqml2\\abstractdeclarative_p.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)", + "src\\datavisualization\\engine\\qabstract3dgraph.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" + ], + "qflag_full_class_name": "QAbstract3DGraph.SelectionFlags", + "enum_full_class_name": "QAbstract3DGraph.SelectionFlag", + "enum_value1": "SelectionNone", + "enum_value2": "SelectionItem", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDataVisualization", + "module_path": "../../PyQt5-stubs/QtDataVisualization.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "OptimizationHints", + "enum_class": "OptimizationHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\datavisualizationqml2\\abstractdeclarative_p.h: Q_DECLARE_FLAGS(OptimizationHints, OptimizationHint)", + "src\\datavisualization\\engine\\qabstract3dgraph.h: Q_DECLARE_FLAGS(OptimizationHints, OptimizationHint)" + ], + "qflag_full_class_name": "QAbstract3DGraph.OptimizationHints", + "enum_full_class_name": "QAbstract3DGraph.OptimizationHint", + "enum_value1": "OptimizationDefault", + "enum_value2": "OptimizationStatic", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDataVisualization", + "module_path": "../../PyQt5-stubs/QtDataVisualization.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "DrawFlags", + "enum_class": "DrawFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\datavisualization\\data\\qsurface3dseries.h: Q_DECLARE_FLAGS(DrawFlags, DrawFlag)" + ], + "qflag_full_class_name": "QSurface3DSeries.DrawFlags", + "enum_full_class_name": "QSurface3DSeries.DrawFlag", + "enum_value1": "DrawWireframe", + "enum_value2": "DrawSurface", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDataVisualization", + "module_path": "../../PyQt5-stubs/QtDataVisualization.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true } ], "qflag_process_error": [ diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index 03a4d7f3..3e9e3eaf 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -2510,6 +2510,59 @@ "module_idx": 0, "module_name": "QtBluetooth", "module_path": "../../PyQt5-stubs/QtBluetooth.pyi" + }, + { + "qflag_class": "SelectionFlags", + "enum_class": "SelectionFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\datavisualizationqml2\\abstractdeclarative_p.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)", + "src\\datavisualization\\engine\\qabstract3dgraph.h: Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDataVisualization", + "module_path": "../../PyQt5-stubs/QtDataVisualization.pyi" + }, + { + "qflag_class": "OptimizationHints", + "enum_class": "OptimizationHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\datavisualizationqml2\\abstractdeclarative_p.h: Q_DECLARE_FLAGS(OptimizationHints, OptimizationHint)", + "src\\datavisualization\\engine\\qabstract3dgraph.h: Q_DECLARE_FLAGS(OptimizationHints, OptimizationHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDataVisualization", + "module_path": "../../PyQt5-stubs/QtDataVisualization.pyi" + }, + { + "qflag_class": "DrawFlags", + "enum_class": "DrawFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\datavisualization\\data\\qsurface3dseries.h: Q_DECLARE_FLAGS(DrawFlags, DrawFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDataVisualization", + "module_path": "../../PyQt5-stubs/QtDataVisualization.pyi" } ], "qflags_to_skip": [ @@ -2562,6 +2615,11 @@ "qflag_class": "JobFlags", "enum_class": "JobFlag", "skip_reason": "QFlag not found in module group qtconnectivity" + }, + { + "qflag_class": "DataDimensions", + "enum_class": "DataDimension", + "skip_reason": "QFlag not found in module group qtdatavisualization" } ] } \ No newline at end of file From e39a2b5a3a0ebd45386064d126378c7d3a2dd876 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:30:05 +0100 Subject: [PATCH 305/421] Add qtquick group --- .../qflags/generate_qflags_stubs_and_tests.py | 5 + .../qtcanvas3d-qflag-grep-result.txt | 0 tests/qflags/qflags_modules_analysis.json | 828 ++++++++++++++++++ tests/qflags/qflags_to_process.json | 514 +++++++++++ 4 files changed, 1347 insertions(+) delete mode 100644 tests/qflags/grep-results/qtcanvas3d-qflag-grep-result.txt diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index bf8cafa9..153c9be3 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -15,6 +15,7 @@ QtChart, QtBluetooth, QtNfc, QtDataVisualization, + QtQuick, QtQml ) try: import libcst as cst @@ -54,6 +55,10 @@ 'qtdatavisualization': [ 'QtDataVisualization', ], + 'qtquick': [ + 'QtQuick', + 'QtQml', + ], } diff --git a/tests/qflags/grep-results/qtcanvas3d-qflag-grep-result.txt b/tests/qflags/grep-results/qtcanvas3d-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/qflags/qflags_modules_analysis.json b/tests/qflags/qflags_modules_analysis.json index 5a6617bc..eb62ff2e 100644 --- a/tests/qflags/qflags_modules_analysis.json +++ b/tests/qflags/qflags_modules_analysis.json @@ -375,6 +375,390 @@ "module_idx": 0, "module_name": "QtDataVisualization", "module_path": "../../PyQt5-stubs/QtDataVisualization.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 4, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 4, + "module_idx": 1, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 4, + "module_idx": 2, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 4, + "module_idx": 3, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQml", + "module_path": "../../PyQt5-stubs/QtQml.pyi" + }, + { + "qflag_class": "Extensions", + "enum_class": "Extension", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\qml\\jsapi\\qjsengine.h: Q_DECLARE_FLAGS(Extensions, Extension)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQml", + "module_path": "../../PyQt5-stubs/QtQml.pyi" + }, + { + "qflag_class": "PerformanceHints", + "enum_class": "PerformanceHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickpainteditem.h: Q_DECLARE_FLAGS(PerformanceHints, PerformanceHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "CreateTextureOptions", + "enum_class": "CreateTextureOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickwindow.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)", + "src\\quick\\scenegraph\\util\\qsgengine.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "CreateTextureOptions", + "enum_class": "CreateTextureOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickwindow.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)", + "src\\quick\\scenegraph\\util\\qsgengine.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "ClearMode", + "enum_class": "ClearModeBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgabstractrenderer.h: Q_DECLARE_FLAGS(ClearMode, ClearModeBit)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "MatrixTransformFlags", + "enum_class": "MatrixTransformFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgabstractrenderer.h: Q_DECLARE_FLAGS(MatrixTransformFlags, MatrixTransformFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "ColorMask", + "enum_class": "ColorMaskComponent", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "DirtyStates", + "enum_class": "DirtyState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgmaterialshader.h: Q_DECLARE_FLAGS(DirtyStates, DirtyState)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "DirtyState", + "enum_class": "DirtyStateBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(DirtyState, DirtyStateBit)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "ShaderCompilationTypes", + "enum_class": "ShaderCompilationType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendererinterface.h: Q_DECLARE_FLAGS(ShaderCompilationTypes, ShaderCompilationType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "ShaderSourceTypes", + "enum_class": "ShaderSourceType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendererinterface.h: Q_DECLARE_FLAGS(ShaderSourceTypes, ShaderSourceType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "StateFlags", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendernode.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "RenderingFlags", + "enum_class": "RenderingFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendernode.h: Q_DECLARE_FLAGS(RenderingFlags, RenderingFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "TextureCoordinatesTransformMode", + "enum_class": "TextureCoordinatesTransformFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\util\\qsgimagenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)", + "src\\quick\\scenegraph\\util\\qsgsimpletexturenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "TextureCoordinatesTransformMode", + "enum_class": "TextureCoordinatesTransformFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\util\\qsgimagenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)", + "src\\quick\\scenegraph\\util\\qsgsimpletexturenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" } ], "flag_without_module": [ @@ -463,6 +847,450 @@ "module_idx": -1, "module_name": "", "module_path": "" + }, + { + "qflag_class": "ReleaseFlags", + "enum_class": "ReleaseFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\qmlmodels\\qqmlobjectmodel_p.h: Q_DECLARE_FLAGS(ReleaseFlags, ReleaseFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "ChangeTypes", + "enum_class": "ChangeType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\qml\\animations\\qabstractanimationjob_p.h: Q_DECLARE_FLAGS(ChangeTypes, ChangeType)", + "src\\quick\\items\\qquickitem_p.h: Q_DECLARE_FLAGS(ChangeTypes, ChangeType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "PropertyFlags", + "enum_class": "PropertyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\qml\\jsruntime\\qv4global_p.h:Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "WriteFlags", + "enum_class": "WriteFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\qml\\qml\\qqmlpropertydata_p.h: Q_DECLARE_FLAGS(WriteFlags, WriteFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "BindingFlags", + "enum_class": "BindingFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\qml\\qml\\qqmlproperty_p.h: Q_DECLARE_FLAGS(BindingFlags, BindingFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "Anchors", + "enum_class": "Anchor", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickanchors_p.h: Q_DECLARE_FLAGS(Anchors, Anchor)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "GrabPermissions", + "enum_class": "GrabPermission", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\handlers\\qquickpointerhandler_p.h: Q_DECLARE_FLAGS(GrabPermissions, GrabPermission)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "States", + "enum_class": "State", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickevents_p_p.h: Q_DECLARE_FLAGS(States, State)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "DeviceTypes", + "enum_class": "DeviceType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickevents_p_p.h: Q_DECLARE_FLAGS(DeviceTypes, DeviceType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "PointerTypes", + "enum_class": "PointerType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickevents_p_p.h: Q_DECLARE_FLAGS(PointerTypes, PointerType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "Capabilities", + "enum_class": "CapabilityFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickevents_p_p.h: Q_DECLARE_FLAGS(Capabilities, CapabilityFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "BoundsBehavior", + "enum_class": "BoundsBehaviorFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickflickable_p.h: Q_DECLARE_FLAGS(BoundsBehavior, BoundsBehaviorFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "DirtyShaderFlags", + "enum_class": "DirtyShaderFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\qsgadaptationlayer_p.h: Q_DECLARE_FLAGS(DirtyShaderFlags, DirtyShaderFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "LoadPixmapOptions", + "enum_class": "LoadPixmapOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickimagebase_p.h: Q_DECLARE_FLAGS(LoadPixmapOptions, LoadPixmapOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\util\\qquickpixmapcache_p.h: Q_DECLARE_FLAGS(Options, Option)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "RebuildOptions", + "enum_class": "RebuildOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquicktableview_p_p.h: Q_DECLARE_FLAGS(RebuildOptions, RebuildOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "Decorations", + "enum_class": "Decoration", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquicktextnodeengine_p.h: Q_DECLARE_FLAGS(Decorations, Decoration)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "FocusOptions", + "enum_class": "FocusOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickwindow_p.h: Q_DECLARE_FLAGS(FocusOptions, FocusOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "MyFlags", + "enum_class": "MyFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "tests\\auto\\qml\\qqmlecmascript\\testtypes.h: Q_DECLARE_FLAGS(MyFlags, MyFlag)", + "tests\\auto\\qml\\qqmllanguage\\testtypes.h: Q_DECLARE_FLAGS(MyFlags, MyFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "ClearFlags", + "enum_class": "ClearFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\plugins\\scenegraph\\d3d12\\qsgd3d12engine_p.h: Q_DECLARE_FLAGS(ClearFlags, ClearFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "TextureCreateFlags", + "enum_class": "TextureCreateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\plugins\\scenegraph\\d3d12\\qsgd3d12engine_p.h: Q_DECLARE_FLAGS(TextureCreateFlags, TextureCreateFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "TextureUploadFlags", + "enum_class": "TextureUploadFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\plugins\\scenegraph\\d3d12\\qsgd3d12engine_p.h: Q_DECLARE_FLAGS(TextureUploadFlags, TextureUploadFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "UpdateResults", + "enum_class": "UpdateResult", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\plugins\\scenegraph\\d3d12\\qsgd3d12material_p.h: Q_DECLARE_FLAGS(UpdateResults, UpdateResult)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "ClipType", + "enum_class": "ClipTypeBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgbatchrenderer_p.h: Q_DECLARE_FLAGS(ClipType, ClipTypeBit)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "Attachments", + "enum_class": "Attachment", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\util\\qsgdepthstencilbuffer_p.h: Q_DECLARE_FLAGS(Attachments, Attachment)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "DrawingHints", + "enum_class": "DrawingHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\adaptations\\software\\qsgsoftwareinternalimagenode_p.h: Q_DECLARE_FLAGS(DrawingHints, DrawingHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" } ] } \ No newline at end of file diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index 3e9e3eaf..cd1eeb1a 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -2563,6 +2563,390 @@ "module_idx": 0, "module_name": "QtDataVisualization", "module_path": "../../PyQt5-stubs/QtDataVisualization.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 4, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 4, + "module_idx": 1, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 4, + "module_idx": 2, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 4, + "module_idx": 3, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQml", + "module_path": "../../PyQt5-stubs/QtQml.pyi" + }, + { + "qflag_class": "Extensions", + "enum_class": "Extension", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\qml\\jsapi\\qjsengine.h: Q_DECLARE_FLAGS(Extensions, Extension)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQml", + "module_path": "../../PyQt5-stubs/QtQml.pyi" + }, + { + "qflag_class": "PerformanceHints", + "enum_class": "PerformanceHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickpainteditem.h: Q_DECLARE_FLAGS(PerformanceHints, PerformanceHint)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "CreateTextureOptions", + "enum_class": "CreateTextureOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickwindow.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)", + "src\\quick\\scenegraph\\util\\qsgengine.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "CreateTextureOptions", + "enum_class": "CreateTextureOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickwindow.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)", + "src\\quick\\scenegraph\\util\\qsgengine.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "ClearMode", + "enum_class": "ClearModeBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgabstractrenderer.h: Q_DECLARE_FLAGS(ClearMode, ClearModeBit)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "MatrixTransformFlags", + "enum_class": "MatrixTransformFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgabstractrenderer.h: Q_DECLARE_FLAGS(MatrixTransformFlags, MatrixTransformFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "ColorMask", + "enum_class": "ColorMaskComponent", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "DirtyStates", + "enum_class": "DirtyState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgmaterialshader.h: Q_DECLARE_FLAGS(DirtyStates, DirtyState)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "DirtyState", + "enum_class": "DirtyStateBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(DirtyState, DirtyStateBit)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "ShaderCompilationTypes", + "enum_class": "ShaderCompilationType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendererinterface.h: Q_DECLARE_FLAGS(ShaderCompilationTypes, ShaderCompilationType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "ShaderSourceTypes", + "enum_class": "ShaderSourceType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendererinterface.h: Q_DECLARE_FLAGS(ShaderSourceTypes, ShaderSourceType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "StateFlags", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendernode.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "RenderingFlags", + "enum_class": "RenderingFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendernode.h: Q_DECLARE_FLAGS(RenderingFlags, RenderingFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "TextureCoordinatesTransformMode", + "enum_class": "TextureCoordinatesTransformFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\util\\qsgimagenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)", + "src\\quick\\scenegraph\\util\\qsgsimpletexturenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "TextureCoordinatesTransformMode", + "enum_class": "TextureCoordinatesTransformFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\util\\qsgimagenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)", + "src\\quick\\scenegraph\\util\\qsgsimpletexturenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 2, + "module_idx": 1, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi" } ], "qflags_to_skip": [ @@ -2620,6 +3004,136 @@ "qflag_class": "DataDimensions", "enum_class": "DataDimension", "skip_reason": "QFlag not found in module group qtdatavisualization" + }, + { + "qflag_class": "ReleaseFlags", + "enum_class": "ReleaseFlag", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "ChangeTypes", + "enum_class": "ChangeType", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "PropertyFlags", + "enum_class": "PropertyFlag", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "WriteFlags", + "enum_class": "WriteFlag", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "BindingFlags", + "enum_class": "BindingFlag", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "Anchors", + "enum_class": "Anchor", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "GrabPermissions", + "enum_class": "GrabPermission", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "States", + "enum_class": "State", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "DeviceTypes", + "enum_class": "DeviceType", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "PointerTypes", + "enum_class": "PointerType", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "Capabilities", + "enum_class": "CapabilityFlag", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "BoundsBehavior", + "enum_class": "BoundsBehaviorFlag", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "DirtyShaderFlags", + "enum_class": "DirtyShaderFlag", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "LoadPixmapOptions", + "enum_class": "LoadPixmapOption", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "Options", + "enum_class": "Option", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "RebuildOptions", + "enum_class": "RebuildOption", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "Decorations", + "enum_class": "Decoration", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "FocusOptions", + "enum_class": "FocusOption", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "MyFlags", + "enum_class": "MyFlag", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "ClearFlags", + "enum_class": "ClearFlag", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "TextureCreateFlags", + "enum_class": "TextureCreateFlag", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "TextureUploadFlags", + "enum_class": "TextureUploadFlag", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "UpdateResults", + "enum_class": "UpdateResult", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "ClipType", + "enum_class": "ClipTypeBit", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "Attachments", + "enum_class": "Attachment", + "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "DrawingHints", + "enum_class": "DrawingHint", + "skip_reason": "QFlag not found in module group qtquick" } ] } \ No newline at end of file From d683f438c40d380fcde947557206c088d1339e4f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:30:36 +0100 Subject: [PATCH 306/421] QFlag operations for QQuickItem.Flags, QQuickItem.Flag in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 + tests/qflags/test_QtQuick_Flags_Flag.py | 272 ++++++++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQuick_Flags_Flag.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 0f9ea248..3107101f 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -89,6 +89,9 @@ class QQuickItem(QtCore.QObject, QtQml.QQmlParserStatus): ItemEnabledHasChanged = ... # type: QQuickItem.ItemChange class Flag(int): + def __or__ (self, other: 'QQuickItem.Flag') -> 'QQuickItem.Flags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QQuickItem.Flags': ... # type: ignore[override, misc] + ItemClipsChildrenToShape = ... # type: QQuickItem.Flag ItemAcceptsInputMethod = ... # type: QQuickItem.Flag ItemIsFocusScope = ... # type: QQuickItem.Flag @@ -109,12 +112,20 @@ class QQuickItem(QtCore.QObject, QtQml.QQmlParserStatus): def __init__(self, f: typing.Union['QQuickItem.Flags', 'QQuickItem.Flag']) -> None: ... @typing.overload def __init__(self, a0: 'QQuickItem.Flags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QQuickItem.Flags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QQuickItem.Flags', 'QQuickItem.Flag', int]) -> 'QQuickItem.Flags': ... + def __and__(self, other: typing.Union['QQuickItem.Flags', 'QQuickItem.Flag', int]) -> 'QQuickItem.Flags': ... + def __xor__(self, other: typing.Union['QQuickItem.Flags', 'QQuickItem.Flag', int]) -> 'QQuickItem.Flags': ... + def __ror__ (self, other: 'QQuickItem.Flag') -> 'QQuickItem.Flags': ... + def __rand__(self, other: 'QQuickItem.Flag') -> 'QQuickItem.Flags': ... + def __rxor__(self, other: 'QQuickItem.Flag') -> 'QQuickItem.Flags': ... class ItemChangeData(sip.simplewrapper): diff --git a/tests/qflags/test_QtQuick_Flags_Flag.py b/tests/qflags/test_QtQuick_Flags_Flag.py new file mode 100644 index 00000000..fa5141f8 --- /dev/null +++ b/tests/qflags/test_QtQuick_Flags_Flag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QQuickItem.Flags" and flag class "QQuickItem.Flag" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QQuickItem.Flag +MultiFlagClass = QtQuick.QQuickItem.Flags + +oneFlagRefValue1 = QtQuick.QQuickItem.Flag.ItemClipsChildrenToShape +oneFlagRefValue2 = QtQuick.QQuickItem.Flag.ItemAcceptsInputMethod + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 94d829dc3103c9d66c0b271d330786788176568b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:30:53 +0100 Subject: [PATCH 307/421] QFlag operations for QSGMaterial.Flags, QSGMaterial.Flag in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 +++++++++++ tests/qflags/test_QtQuick_Flags_Flag.py | 10 +++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 3107101f..e7e5843a 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -792,6 +792,9 @@ class QSGEngine(QtCore.QObject): class QSGMaterial(sip.wrapper): class Flag(int): + def __or__ (self, other: 'QSGMaterial.Flag') -> 'QSGMaterial.Flags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGMaterial.Flags': ... # type: ignore[override, misc] + Blending = ... # type: QSGMaterial.Flag RequiresDeterminant = ... # type: QSGMaterial.Flag RequiresFullMatrixExceptTranslate = ... # type: QSGMaterial.Flag @@ -816,12 +819,20 @@ class QSGMaterial(sip.wrapper): def __init__(self, f: typing.Union['QSGMaterial.Flags', 'QSGMaterial.Flag']) -> None: ... @typing.overload def __init__(self, a0: 'QSGMaterial.Flags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGMaterial.Flags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGMaterial.Flags', 'QSGMaterial.Flag', int]) -> 'QSGMaterial.Flags': ... + def __and__(self, other: typing.Union['QSGMaterial.Flags', 'QSGMaterial.Flag', int]) -> 'QSGMaterial.Flags': ... + def __xor__(self, other: typing.Union['QSGMaterial.Flags', 'QSGMaterial.Flag', int]) -> 'QSGMaterial.Flags': ... + def __ror__ (self, other: 'QSGMaterial.Flag') -> 'QSGMaterial.Flags': ... + def __rand__(self, other: 'QSGMaterial.Flag') -> 'QSGMaterial.Flags': ... + def __rxor__(self, other: 'QSGMaterial.Flag') -> 'QSGMaterial.Flags': ... def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtQuick_Flags_Flag.py b/tests/qflags/test_QtQuick_Flags_Flag.py index fa5141f8..cf9425f3 100644 --- a/tests/qflags/test_QtQuick_Flags_Flag.py +++ b/tests/qflags/test_QtQuick_Flags_Flag.py @@ -9,14 +9,14 @@ import pytest ### Specific part -# file generated from qflags_test_template.py for QFlags class "QQuickItem.Flags" and flag class "QQuickItem.Flag" +# file generated from qflags_test_template.py for QFlags class "QSGMaterial.Flags" and flag class "QSGMaterial.Flag" from PyQt5 import QtQuick -OneFlagClass = QtQuick.QQuickItem.Flag -MultiFlagClass = QtQuick.QQuickItem.Flags +OneFlagClass = QtQuick.QSGMaterial.Flag +MultiFlagClass = QtQuick.QSGMaterial.Flags -oneFlagRefValue1 = QtQuick.QQuickItem.Flag.ItemClipsChildrenToShape -oneFlagRefValue2 = QtQuick.QQuickItem.Flag.ItemAcceptsInputMethod +oneFlagRefValue1 = QtQuick.QSGMaterial.Flag.Blending +oneFlagRefValue2 = QtQuick.QSGMaterial.Flag.RequiresDeterminant OR_CONVERTS_TO_MULTI: Literal[True] = True OR_INT_CONVERTS_TO_MULTI: Literal[False] = False From fb3321b631941c054d17590ee49ec3dbc9ef2b1f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:31:09 +0100 Subject: [PATCH 308/421] QFlag operations for QSGNode.Flags, QSGNode.Flag in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 +++++++++++ tests/qflags/test_QtQuick_Flags_Flag.py | 10 +++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index e7e5843a..3f2a4028 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1064,6 +1064,9 @@ class QSGNode(sip.wrapper): DirtyOpacity = ... # type: QSGNode.DirtyStateBit class Flag(int): + def __or__ (self, other: 'QSGNode.Flag') -> 'QSGNode.Flags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGNode.Flags': ... # type: ignore[override, misc] + OwnedByParent = ... # type: QSGNode.Flag UsePreprocess = ... # type: QSGNode.Flag OwnsGeometry = ... # type: QSGNode.Flag @@ -1097,12 +1100,20 @@ class QSGNode(sip.wrapper): def __init__(self, f: typing.Union['QSGNode.Flags', 'QSGNode.Flag']) -> None: ... @typing.overload def __init__(self, a0: 'QSGNode.Flags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGNode.Flags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGNode.Flags', 'QSGNode.Flag', int]) -> 'QSGNode.Flags': ... + def __and__(self, other: typing.Union['QSGNode.Flags', 'QSGNode.Flag', int]) -> 'QSGNode.Flags': ... + def __xor__(self, other: typing.Union['QSGNode.Flags', 'QSGNode.Flag', int]) -> 'QSGNode.Flags': ... + def __ror__ (self, other: 'QSGNode.Flag') -> 'QSGNode.Flags': ... + def __rand__(self, other: 'QSGNode.Flag') -> 'QSGNode.Flags': ... + def __rxor__(self, other: 'QSGNode.Flag') -> 'QSGNode.Flags': ... class DirtyState(sip.simplewrapper): diff --git a/tests/qflags/test_QtQuick_Flags_Flag.py b/tests/qflags/test_QtQuick_Flags_Flag.py index cf9425f3..5b10a9ca 100644 --- a/tests/qflags/test_QtQuick_Flags_Flag.py +++ b/tests/qflags/test_QtQuick_Flags_Flag.py @@ -9,14 +9,14 @@ import pytest ### Specific part -# file generated from qflags_test_template.py for QFlags class "QSGMaterial.Flags" and flag class "QSGMaterial.Flag" +# file generated from qflags_test_template.py for QFlags class "QSGNode.Flags" and flag class "QSGNode.Flag" from PyQt5 import QtQuick -OneFlagClass = QtQuick.QSGMaterial.Flag -MultiFlagClass = QtQuick.QSGMaterial.Flags +OneFlagClass = QtQuick.QSGNode.Flag +MultiFlagClass = QtQuick.QSGNode.Flags -oneFlagRefValue1 = QtQuick.QSGMaterial.Flag.Blending -oneFlagRefValue2 = QtQuick.QSGMaterial.Flag.RequiresDeterminant +oneFlagRefValue1 = QtQuick.QSGNode.Flag.OwnedByParent +oneFlagRefValue2 = QtQuick.QSGNode.Flag.UsePreprocess OR_CONVERTS_TO_MULTI: Literal[True] = True OR_INT_CONVERTS_TO_MULTI: Literal[False] = False From feeaba9a6fa007ca291e9779611a40c25f91ae79 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:31:26 +0100 Subject: [PATCH 309/421] QFlag operations for QSGMaterialRhiShader.Flags, QSGMaterialRhiShader.Flag in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 +++++++++++ tests/qflags/test_QtQuick_Flags_Flag.py | 10 +++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 3f2a4028..2c5f3926 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1296,6 +1296,9 @@ class QSGMaterialType(sip.simplewrapper): class QSGMaterialRhiShader(QSGMaterialShader): class Flag(int): + def __or__ (self, other: 'QSGMaterialRhiShader.Flag') -> 'QSGMaterialRhiShader.Flags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGMaterialRhiShader.Flags': ... # type: ignore[override, misc] + UpdatesGraphicsPipelineState = ... # type: QSGMaterialRhiShader.Flag UpdatesGraphicsPipelineState = ... # type: QSGMaterialRhiShader.Flag @@ -1411,12 +1414,20 @@ class QSGMaterialRhiShader(QSGMaterialShader): def __init__(self, f: typing.Union['QSGMaterialRhiShader.Flags', 'QSGMaterialRhiShader.Flag']) -> None: ... @typing.overload def __init__(self, a0: 'QSGMaterialRhiShader.Flags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGMaterialRhiShader.Flags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGMaterialRhiShader.Flags', 'QSGMaterialRhiShader.Flag', int]) -> 'QSGMaterialRhiShader.Flags': ... + def __and__(self, other: typing.Union['QSGMaterialRhiShader.Flags', 'QSGMaterialRhiShader.Flag', int]) -> 'QSGMaterialRhiShader.Flags': ... + def __xor__(self, other: typing.Union['QSGMaterialRhiShader.Flags', 'QSGMaterialRhiShader.Flag', int]) -> 'QSGMaterialRhiShader.Flags': ... + def __ror__ (self, other: 'QSGMaterialRhiShader.Flag') -> 'QSGMaterialRhiShader.Flags': ... + def __rand__(self, other: 'QSGMaterialRhiShader.Flag') -> 'QSGMaterialRhiShader.Flags': ... + def __rxor__(self, other: 'QSGMaterialRhiShader.Flag') -> 'QSGMaterialRhiShader.Flags': ... def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtQuick_Flags_Flag.py b/tests/qflags/test_QtQuick_Flags_Flag.py index 5b10a9ca..11d2ebf2 100644 --- a/tests/qflags/test_QtQuick_Flags_Flag.py +++ b/tests/qflags/test_QtQuick_Flags_Flag.py @@ -9,14 +9,14 @@ import pytest ### Specific part -# file generated from qflags_test_template.py for QFlags class "QSGNode.Flags" and flag class "QSGNode.Flag" +# file generated from qflags_test_template.py for QFlags class "QSGMaterialRhiShader.Flags" and flag class "QSGMaterialRhiShader.Flag" from PyQt5 import QtQuick -OneFlagClass = QtQuick.QSGNode.Flag -MultiFlagClass = QtQuick.QSGNode.Flags +OneFlagClass = QtQuick.QSGMaterialRhiShader.Flag +MultiFlagClass = QtQuick.QSGMaterialRhiShader.Flags -oneFlagRefValue1 = QtQuick.QSGNode.Flag.OwnedByParent -oneFlagRefValue2 = QtQuick.QSGNode.Flag.UsePreprocess +oneFlagRefValue1 = QtQuick.QSGMaterialRhiShader.Flag.UpdatesGraphicsPipelineState +oneFlagRefValue2 = QtQuick.QSGMaterialRhiShader.Flag.UpdatesGraphicsPipelineState OR_CONVERTS_TO_MULTI: Literal[True] = True OR_INT_CONVERTS_TO_MULTI: Literal[False] = False From 8170b18ed466576676e88e0b4e99d4da38dbd963 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:31:40 +0100 Subject: [PATCH 310/421] QFlag operations for QQmlImageProviderBase.Flags, QQmlImageProviderBase.Flag in module QtQml --- PyQt5-stubs/QtQml.pyi | 11 ++ tests/qflags/test_QtQml_Flags_Flag.py | 272 ++++++++++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQml_Flags_Flag.py diff --git a/PyQt5-stubs/QtQml.pyi b/PyQt5-stubs/QtQml.pyi index 78e530bd..49f01182 100644 --- a/PyQt5-stubs/QtQml.pyi +++ b/PyQt5-stubs/QtQml.pyi @@ -361,6 +361,9 @@ class QQmlContext(QtCore.QObject): class QQmlImageProviderBase(sip.wrapper): class Flag(int): + def __or__ (self, other: 'QQmlImageProviderBase.Flag') -> 'QQmlImageProviderBase.Flags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QQmlImageProviderBase.Flags': ... # type: ignore[override, misc] + ForceAsynchronousImageLoading = ... # type: QQmlImageProviderBase.Flag ForceAsynchronousImageLoading = ... # type: QQmlImageProviderBase.Flag @@ -384,12 +387,20 @@ class QQmlImageProviderBase(sip.wrapper): def __init__(self, f: typing.Union['QQmlImageProviderBase.Flags', 'QQmlImageProviderBase.Flag']) -> None: ... @typing.overload def __init__(self, a0: 'QQmlImageProviderBase.Flags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QQmlImageProviderBase.Flags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QQmlImageProviderBase.Flags', 'QQmlImageProviderBase.Flag', int]) -> 'QQmlImageProviderBase.Flags': ... + def __and__(self, other: typing.Union['QQmlImageProviderBase.Flags', 'QQmlImageProviderBase.Flag', int]) -> 'QQmlImageProviderBase.Flags': ... + def __xor__(self, other: typing.Union['QQmlImageProviderBase.Flags', 'QQmlImageProviderBase.Flag', int]) -> 'QQmlImageProviderBase.Flags': ... + def __ror__ (self, other: 'QQmlImageProviderBase.Flag') -> 'QQmlImageProviderBase.Flags': ... + def __rand__(self, other: 'QQmlImageProviderBase.Flag') -> 'QQmlImageProviderBase.Flags': ... + def __rxor__(self, other: 'QQmlImageProviderBase.Flag') -> 'QQmlImageProviderBase.Flags': ... def __init__(self, a0: 'QQmlImageProviderBase') -> None: ... diff --git a/tests/qflags/test_QtQml_Flags_Flag.py b/tests/qflags/test_QtQml_Flags_Flag.py new file mode 100644 index 00000000..c766de9c --- /dev/null +++ b/tests/qflags/test_QtQml_Flags_Flag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QQmlImageProviderBase.Flags" and flag class "QQmlImageProviderBase.Flag" +from PyQt5 import QtQml + +OneFlagClass = QtQml.QQmlImageProviderBase.Flag +MultiFlagClass = QtQml.QQmlImageProviderBase.Flags + +oneFlagRefValue1 = QtQml.QQmlImageProviderBase.Flag.ForceAsynchronousImageLoading +oneFlagRefValue2 = QtQml.QQmlImageProviderBase.Flag.ForceAsynchronousImageLoading + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From e2d751a85b2fb991d8aebea353a93a2c88e42e16 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:31:54 +0100 Subject: [PATCH 311/421] QFlag operations for QJSEngine.Extensions, QJSEngine.Extension in module QtQml --- PyQt5-stubs/QtQml.pyi | 11 + .../qflags/test_QtQml_Extensions_Extension.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQml_Extensions_Extension.py diff --git a/PyQt5-stubs/QtQml.pyi b/PyQt5-stubs/QtQml.pyi index 49f01182..54d550df 100644 --- a/PyQt5-stubs/QtQml.pyi +++ b/PyQt5-stubs/QtQml.pyi @@ -36,6 +36,9 @@ PYQT_SLOT = typing.Union[typing.Callable[..., None], QtCore.pyqtBoundSignal] class QJSEngine(QtCore.QObject): class Extension(int): + def __or__ (self, other: 'QJSEngine.Extension') -> 'QJSEngine.Extensions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QJSEngine.Extensions': ... # type: ignore[override, misc] + TranslationExtension = ... # type: QJSEngine.Extension ConsoleExtension = ... # type: QJSEngine.Extension GarbageCollectionExtension = ... # type: QJSEngine.Extension @@ -54,12 +57,20 @@ class QJSEngine(QtCore.QObject): def __init__(self, f: typing.Union['QJSEngine.Extensions', 'QJSEngine.Extension']) -> None: ... @typing.overload def __init__(self, a0: 'QJSEngine.Extensions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QJSEngine.Extensions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QJSEngine.Extensions', 'QJSEngine.Extension', int]) -> 'QJSEngine.Extensions': ... + def __and__(self, other: typing.Union['QJSEngine.Extensions', 'QJSEngine.Extension', int]) -> 'QJSEngine.Extensions': ... + def __xor__(self, other: typing.Union['QJSEngine.Extensions', 'QJSEngine.Extension', int]) -> 'QJSEngine.Extensions': ... + def __ror__ (self, other: 'QJSEngine.Extension') -> 'QJSEngine.Extensions': ... + def __rand__(self, other: 'QJSEngine.Extension') -> 'QJSEngine.Extensions': ... + def __rxor__(self, other: 'QJSEngine.Extension') -> 'QJSEngine.Extensions': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtQml_Extensions_Extension.py b/tests/qflags/test_QtQml_Extensions_Extension.py new file mode 100644 index 00000000..7815319a --- /dev/null +++ b/tests/qflags/test_QtQml_Extensions_Extension.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QJSEngine.Extensions" and flag class "QJSEngine.Extension" +from PyQt5 import QtQml + +OneFlagClass = QtQml.QJSEngine.Extension +MultiFlagClass = QtQml.QJSEngine.Extensions + +oneFlagRefValue1 = QtQml.QJSEngine.Extension.TranslationExtension +oneFlagRefValue2 = QtQml.QJSEngine.Extension.ConsoleExtension + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 8ff4ab014b70e2dbac4e0913abd3a85b4768f0a6 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:32:10 +0100 Subject: [PATCH 312/421] QFlag operations for QQuickPaintedItem.PerformanceHints, QQuickPaintedItem.PerformanceHint in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 + ...tQuick_PerformanceHints_PerformanceHint.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQuick_PerformanceHints_PerformanceHint.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 2c5f3926..db56473d 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -385,6 +385,9 @@ class QQuickItemGrabResult(QtCore.QObject): class QQuickPaintedItem(QQuickItem): class PerformanceHint(int): + def __or__ (self, other: 'QQuickPaintedItem.PerformanceHint') -> 'QQuickPaintedItem.PerformanceHints': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QQuickPaintedItem.PerformanceHints': ... # type: ignore[override, misc] + FastFBOResizing = ... # type: QQuickPaintedItem.PerformanceHint FastFBOResizing = ... # type: QQuickPaintedItem.PerformanceHint @@ -406,12 +409,20 @@ class QQuickPaintedItem(QQuickItem): def __init__(self, f: typing.Union['QQuickPaintedItem.PerformanceHints', 'QQuickPaintedItem.PerformanceHint']) -> None: ... @typing.overload def __init__(self, a0: 'QQuickPaintedItem.PerformanceHints') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QQuickPaintedItem.PerformanceHints': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QQuickPaintedItem.PerformanceHints', 'QQuickPaintedItem.PerformanceHint', int]) -> 'QQuickPaintedItem.PerformanceHints': ... + def __and__(self, other: typing.Union['QQuickPaintedItem.PerformanceHints', 'QQuickPaintedItem.PerformanceHint', int]) -> 'QQuickPaintedItem.PerformanceHints': ... + def __xor__(self, other: typing.Union['QQuickPaintedItem.PerformanceHints', 'QQuickPaintedItem.PerformanceHint', int]) -> 'QQuickPaintedItem.PerformanceHints': ... + def __ror__ (self, other: 'QQuickPaintedItem.PerformanceHint') -> 'QQuickPaintedItem.PerformanceHints': ... + def __rand__(self, other: 'QQuickPaintedItem.PerformanceHint') -> 'QQuickPaintedItem.PerformanceHints': ... + def __rxor__(self, other: 'QQuickPaintedItem.PerformanceHint') -> 'QQuickPaintedItem.PerformanceHints': ... def __init__(self, parent: typing.Optional[QQuickItem] = ...) -> None: ... diff --git a/tests/qflags/test_QtQuick_PerformanceHints_PerformanceHint.py b/tests/qflags/test_QtQuick_PerformanceHints_PerformanceHint.py new file mode 100644 index 00000000..6a81ab3d --- /dev/null +++ b/tests/qflags/test_QtQuick_PerformanceHints_PerformanceHint.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QQuickPaintedItem.PerformanceHints" and flag class "QQuickPaintedItem.PerformanceHint" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QQuickPaintedItem.PerformanceHint +MultiFlagClass = QtQuick.QQuickPaintedItem.PerformanceHints + +oneFlagRefValue1 = QtQuick.QQuickPaintedItem.PerformanceHint.FastFBOResizing +oneFlagRefValue2 = QtQuick.QQuickPaintedItem.PerformanceHint.FastFBOResizing + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From df1a6b8c4286fa5cd05e35a913f63b7e3f39c893 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:32:26 +0100 Subject: [PATCH 313/421] QFlag operations for QQuickWindow.CreateTextureOptions, QQuickWindow.CreateTextureOption in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 8 + ...reateTextureOptions_CreateTextureOption.py | 272 ++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index db56473d..21dff62b 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -541,12 +541,20 @@ class QQuickWindow(QtGui.QWindow): def __init__(self, f: typing.Union['QQuickWindow.CreateTextureOptions', 'QQuickWindow.CreateTextureOption']) -> None: ... @typing.overload def __init__(self, a0: 'QQuickWindow.CreateTextureOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QQuickWindow.CreateTextureOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QQuickWindow.CreateTextureOptions', 'QQuickWindow.CreateTextureOption', int]) -> 'QQuickWindow.CreateTextureOptions': ... + def __and__(self, other: typing.Union['QQuickWindow.CreateTextureOptions', 'QQuickWindow.CreateTextureOption', int]) -> 'QQuickWindow.CreateTextureOptions': ... + def __xor__(self, other: typing.Union['QQuickWindow.CreateTextureOptions', 'QQuickWindow.CreateTextureOption', int]) -> 'QQuickWindow.CreateTextureOptions': ... + def __ror__ (self, other: 'QQuickWindow.CreateTextureOption') -> 'QQuickWindow.CreateTextureOptions': ... + def __rand__(self, other: 'QQuickWindow.CreateTextureOption') -> 'QQuickWindow.CreateTextureOptions': ... + def __rxor__(self, other: 'QQuickWindow.CreateTextureOption') -> 'QQuickWindow.CreateTextureOptions': ... def __init__(self, parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... diff --git a/tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py b/tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py new file mode 100644 index 00000000..aa196265 --- /dev/null +++ b/tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QQuickWindow.CreateTextureOptions" and flag class "QQuickWindow.CreateTextureOption" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QQuickWindow.CreateTextureOption +MultiFlagClass = QtQuick.QQuickWindow.CreateTextureOptions + +oneFlagRefValue1 = QtQuick.QQuickWindow.CreateTextureOption.TextureHasAlphaChannel +oneFlagRefValue2 = QtQuick.QQuickWindow.CreateTextureOption.TextureHasMipmaps + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 69d92766b9cf94c9ce46db3f12613785d75d0237 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:32:43 +0100 Subject: [PATCH 314/421] QFlag operations for QSGEngine.CreateTextureOptions, QSGEngine.CreateTextureOption in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 8 ++++++++ ...QtQuick_CreateTextureOptions_CreateTextureOption.py | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 21dff62b..7e6fdf59 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -789,12 +789,20 @@ class QSGEngine(QtCore.QObject): def __init__(self, f: typing.Union['QSGEngine.CreateTextureOptions', 'QSGEngine.CreateTextureOption']) -> None: ... @typing.overload def __init__(self, a0: 'QSGEngine.CreateTextureOptions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGEngine.CreateTextureOptions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGEngine.CreateTextureOptions', 'QSGEngine.CreateTextureOption', int]) -> 'QSGEngine.CreateTextureOptions': ... + def __and__(self, other: typing.Union['QSGEngine.CreateTextureOptions', 'QSGEngine.CreateTextureOption', int]) -> 'QSGEngine.CreateTextureOptions': ... + def __xor__(self, other: typing.Union['QSGEngine.CreateTextureOptions', 'QSGEngine.CreateTextureOption', int]) -> 'QSGEngine.CreateTextureOptions': ... + def __ror__ (self, other: 'QSGEngine.CreateTextureOption') -> 'QSGEngine.CreateTextureOptions': ... + def __rand__(self, other: 'QSGEngine.CreateTextureOption') -> 'QSGEngine.CreateTextureOptions': ... + def __rxor__(self, other: 'QSGEngine.CreateTextureOption') -> 'QSGEngine.CreateTextureOptions': ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py b/tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py index aa196265..e3311ce4 100644 --- a/tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py +++ b/tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py @@ -9,14 +9,14 @@ import pytest ### Specific part -# file generated from qflags_test_template.py for QFlags class "QQuickWindow.CreateTextureOptions" and flag class "QQuickWindow.CreateTextureOption" +# file generated from qflags_test_template.py for QFlags class "QSGEngine.CreateTextureOptions" and flag class "QSGEngine.CreateTextureOption" from PyQt5 import QtQuick -OneFlagClass = QtQuick.QQuickWindow.CreateTextureOption -MultiFlagClass = QtQuick.QQuickWindow.CreateTextureOptions +OneFlagClass = QtQuick.QSGEngine.CreateTextureOption +MultiFlagClass = QtQuick.QSGEngine.CreateTextureOptions -oneFlagRefValue1 = QtQuick.QQuickWindow.CreateTextureOption.TextureHasAlphaChannel -oneFlagRefValue2 = QtQuick.QQuickWindow.CreateTextureOption.TextureHasMipmaps +oneFlagRefValue1 = QtQuick.QSGEngine.CreateTextureOption.TextureHasAlphaChannel +oneFlagRefValue2 = QtQuick.QSGEngine.CreateTextureOption.TextureOwnsGLTexture OR_CONVERTS_TO_MULTI: Literal[False] = False OR_INT_CONVERTS_TO_MULTI: Literal[False] = False From be70a6b14e949713ad14daee13ee393f8682350d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:32:59 +0100 Subject: [PATCH 315/421] QFlag operations for QSGAbstractRenderer.ClearMode, QSGAbstractRenderer.ClearModeBit in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 + .../test_QtQuick_ClearMode_ClearModeBit.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQuick_ClearMode_ClearModeBit.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 7e6fdf59..dbeadab3 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -706,6 +706,9 @@ class QSGAbstractRenderer(QtCore.QObject): MatrixTransformFlipY = ... # type: QSGAbstractRenderer.MatrixTransformFlag class ClearModeBit(int): + def __or__ (self, other: 'QSGAbstractRenderer.ClearModeBit') -> 'QSGAbstractRenderer.ClearMode': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGAbstractRenderer.ClearMode': ... # type: ignore[override, misc] + ClearColorBuffer = ... # type: QSGAbstractRenderer.ClearModeBit ClearDepthBuffer = ... # type: QSGAbstractRenderer.ClearModeBit ClearStencilBuffer = ... # type: QSGAbstractRenderer.ClearModeBit @@ -722,12 +725,20 @@ class QSGAbstractRenderer(QtCore.QObject): def __init__(self, f: typing.Union['QSGAbstractRenderer.ClearMode', 'QSGAbstractRenderer.ClearModeBit']) -> None: ... @typing.overload def __init__(self, a0: 'QSGAbstractRenderer.ClearMode') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGAbstractRenderer.ClearMode': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGAbstractRenderer.ClearMode', 'QSGAbstractRenderer.ClearModeBit', int]) -> 'QSGAbstractRenderer.ClearMode': ... + def __and__(self, other: typing.Union['QSGAbstractRenderer.ClearMode', 'QSGAbstractRenderer.ClearModeBit', int]) -> 'QSGAbstractRenderer.ClearMode': ... + def __xor__(self, other: typing.Union['QSGAbstractRenderer.ClearMode', 'QSGAbstractRenderer.ClearModeBit', int]) -> 'QSGAbstractRenderer.ClearMode': ... + def __ror__ (self, other: 'QSGAbstractRenderer.ClearModeBit') -> 'QSGAbstractRenderer.ClearMode': ... + def __rand__(self, other: 'QSGAbstractRenderer.ClearModeBit') -> 'QSGAbstractRenderer.ClearMode': ... + def __rxor__(self, other: 'QSGAbstractRenderer.ClearModeBit') -> 'QSGAbstractRenderer.ClearMode': ... class MatrixTransformFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtQuick_ClearMode_ClearModeBit.py b/tests/qflags/test_QtQuick_ClearMode_ClearModeBit.py new file mode 100644 index 00000000..3c9fe22f --- /dev/null +++ b/tests/qflags/test_QtQuick_ClearMode_ClearModeBit.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSGAbstractRenderer.ClearMode" and flag class "QSGAbstractRenderer.ClearModeBit" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QSGAbstractRenderer.ClearModeBit +MultiFlagClass = QtQuick.QSGAbstractRenderer.ClearMode + +oneFlagRefValue1 = QtQuick.QSGAbstractRenderer.ClearModeBit.ClearColorBuffer +oneFlagRefValue2 = QtQuick.QSGAbstractRenderer.ClearModeBit.ClearDepthBuffer + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 1fe95e918aa48c00390697911ef564786d1e8f27 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:33:19 +0100 Subject: [PATCH 316/421] QFlag operations for QSGAbstractRenderer.MatrixTransformFlags, QSGAbstractRenderer.MatrixTransformFlag in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 8 + ...atrixTransformFlags_MatrixTransformFlag.py | 272 ++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 tests/qflags/test_QtQuick_MatrixTransformFlags_MatrixTransformFlag.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index dbeadab3..9efcf8e2 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -748,12 +748,20 @@ class QSGAbstractRenderer(QtCore.QObject): def __init__(self, f: typing.Union['QSGAbstractRenderer.MatrixTransformFlags', 'QSGAbstractRenderer.MatrixTransformFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QSGAbstractRenderer.MatrixTransformFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGAbstractRenderer.MatrixTransformFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGAbstractRenderer.MatrixTransformFlags', 'QSGAbstractRenderer.MatrixTransformFlag', int]) -> 'QSGAbstractRenderer.MatrixTransformFlags': ... + def __and__(self, other: typing.Union['QSGAbstractRenderer.MatrixTransformFlags', 'QSGAbstractRenderer.MatrixTransformFlag', int]) -> 'QSGAbstractRenderer.MatrixTransformFlags': ... + def __xor__(self, other: typing.Union['QSGAbstractRenderer.MatrixTransformFlags', 'QSGAbstractRenderer.MatrixTransformFlag', int]) -> 'QSGAbstractRenderer.MatrixTransformFlags': ... + def __ror__ (self, other: 'QSGAbstractRenderer.MatrixTransformFlag') -> 'QSGAbstractRenderer.MatrixTransformFlags': ... + def __rand__(self, other: 'QSGAbstractRenderer.MatrixTransformFlag') -> 'QSGAbstractRenderer.MatrixTransformFlags': ... + def __rxor__(self, other: 'QSGAbstractRenderer.MatrixTransformFlag') -> 'QSGAbstractRenderer.MatrixTransformFlags': ... def sceneGraphChanged(self) -> None: ... def renderScene(self, fboId: int = ...) -> None: ... diff --git a/tests/qflags/test_QtQuick_MatrixTransformFlags_MatrixTransformFlag.py b/tests/qflags/test_QtQuick_MatrixTransformFlags_MatrixTransformFlag.py new file mode 100644 index 00000000..0662ab5f --- /dev/null +++ b/tests/qflags/test_QtQuick_MatrixTransformFlags_MatrixTransformFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSGAbstractRenderer.MatrixTransformFlags" and flag class "QSGAbstractRenderer.MatrixTransformFlag" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QSGAbstractRenderer.MatrixTransformFlag +MultiFlagClass = QtQuick.QSGAbstractRenderer.MatrixTransformFlags + +oneFlagRefValue1 = QtQuick.QSGAbstractRenderer.MatrixTransformFlag.MatrixTransformFlipY +oneFlagRefValue2 = QtQuick.QSGAbstractRenderer.MatrixTransformFlag.MatrixTransformFlipY + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 741e4875c20ad1232e37078b074b1d43b5326367 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:33:36 +0100 Subject: [PATCH 317/421] QFlag operations for QSGMaterialRhiShader.GraphicsPipelineState.ColorMask, QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 + ...st_QtQuick_ColorMask_ColorMaskComponent.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQuick_ColorMask_ColorMaskComponent.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 9efcf8e2..696af2f6 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1381,6 +1381,9 @@ class QSGMaterialRhiShader(QSGMaterialShader): CullBack = ... # type: QSGMaterialRhiShader.GraphicsPipelineState.CullMode class ColorMaskComponent(int): + def __or__ (self, other: 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent') -> 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMask': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMask': ... # type: ignore[override, misc] + R = ... # type: QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent G = ... # type: QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent B = ... # type: QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent @@ -1440,12 +1443,20 @@ class QSGMaterialRhiShader(QSGMaterialShader): def __init__(self, f: typing.Union['QSGMaterialRhiShader.GraphicsPipelineState.ColorMask', 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent']) -> None: ... @typing.overload def __init__(self, a0: 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMask') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMask': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGMaterialRhiShader.GraphicsPipelineState.ColorMask', 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent', int]) -> 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMask': ... + def __and__(self, other: typing.Union['QSGMaterialRhiShader.GraphicsPipelineState.ColorMask', 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent', int]) -> 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMask': ... + def __xor__(self, other: typing.Union['QSGMaterialRhiShader.GraphicsPipelineState.ColorMask', 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent', int]) -> 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMask': ... + def __ror__ (self, other: 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent') -> 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMask': ... + def __rand__(self, other: 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent') -> 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMask': ... + def __rxor__(self, other: 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent') -> 'QSGMaterialRhiShader.GraphicsPipelineState.ColorMask': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtQuick_ColorMask_ColorMaskComponent.py b/tests/qflags/test_QtQuick_ColorMask_ColorMaskComponent.py new file mode 100644 index 00000000..9ebf4acc --- /dev/null +++ b/tests/qflags/test_QtQuick_ColorMask_ColorMaskComponent.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSGMaterialRhiShader.GraphicsPipelineState.ColorMask" and flag class "QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent +MultiFlagClass = QtQuick.QSGMaterialRhiShader.GraphicsPipelineState.ColorMask + +oneFlagRefValue1 = QtQuick.QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent.R +oneFlagRefValue2 = QtQuick.QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent.G + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 3512e9bb4000daca9cb20d7b403f62f21c5059fa Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:33:57 +0100 Subject: [PATCH 318/421] QFlag operations for QSGNode.DirtyState, QSGNode.DirtyStateBit in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 + .../test_QtQuick_DirtyState_DirtyStateBit.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQuick_DirtyState_DirtyStateBit.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 696af2f6..ef958cc5 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1095,6 +1095,9 @@ class QSGGeometry(sip.wrapper): class QSGNode(sip.wrapper): class DirtyStateBit(int): + def __or__ (self, other: 'QSGNode.DirtyStateBit') -> 'QSGNode.DirtyState': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGNode.DirtyState': ... # type: ignore[override, misc] + DirtyMatrix = ... # type: QSGNode.DirtyStateBit DirtyNodeAdded = ... # type: QSGNode.DirtyStateBit DirtyNodeRemoved = ... # type: QSGNode.DirtyStateBit @@ -1169,12 +1172,20 @@ class QSGNode(sip.wrapper): def __init__(self, f: typing.Union['QSGNode.DirtyState', 'QSGNode.DirtyStateBit']) -> None: ... @typing.overload def __init__(self, a0: 'QSGNode.DirtyState') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGNode.DirtyState': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGNode.DirtyState', 'QSGNode.DirtyStateBit', int]) -> 'QSGNode.DirtyState': ... + def __and__(self, other: typing.Union['QSGNode.DirtyState', 'QSGNode.DirtyStateBit', int]) -> 'QSGNode.DirtyState': ... + def __xor__(self, other: typing.Union['QSGNode.DirtyState', 'QSGNode.DirtyStateBit', int]) -> 'QSGNode.DirtyState': ... + def __ror__ (self, other: 'QSGNode.DirtyStateBit') -> 'QSGNode.DirtyState': ... + def __rand__(self, other: 'QSGNode.DirtyStateBit') -> 'QSGNode.DirtyState': ... + def __rxor__(self, other: 'QSGNode.DirtyStateBit') -> 'QSGNode.DirtyState': ... def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtQuick_DirtyState_DirtyStateBit.py b/tests/qflags/test_QtQuick_DirtyState_DirtyStateBit.py new file mode 100644 index 00000000..74e12ad0 --- /dev/null +++ b/tests/qflags/test_QtQuick_DirtyState_DirtyStateBit.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSGNode.DirtyState" and flag class "QSGNode.DirtyStateBit" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QSGNode.DirtyStateBit +MultiFlagClass = QtQuick.QSGNode.DirtyState + +oneFlagRefValue1 = QtQuick.QSGNode.DirtyStateBit.DirtyMatrix +oneFlagRefValue2 = QtQuick.QSGNode.DirtyStateBit.DirtyNodeAdded + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 384dcdf6fe6dd62c27a7c19238ada7e3a4a8d4d0 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:34:27 +0100 Subject: [PATCH 319/421] QFlag operations for QSGRendererInterface.ShaderCompilationTypes, QSGRendererInterface.ShaderCompilationType in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 + ...rCompilationTypes_ShaderCompilationType.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQuick_ShaderCompilationTypes_ShaderCompilationType.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index ef958cc5..dee334bf 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1555,6 +1555,9 @@ class QSGRendererInterface(sip.simplewrapper): ShaderByteCode = ... # type: QSGRendererInterface.ShaderSourceType class ShaderCompilationType(int): + def __or__ (self, other: 'QSGRendererInterface.ShaderCompilationType') -> 'QSGRendererInterface.ShaderCompilationTypes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGRendererInterface.ShaderCompilationTypes': ... # type: ignore[override, misc] + RuntimeCompilation = ... # type: QSGRendererInterface.ShaderCompilationType OfflineCompilation = ... # type: QSGRendererInterface.ShaderCompilationType @@ -1628,12 +1631,20 @@ class QSGRendererInterface(sip.simplewrapper): def __init__(self, f: typing.Union['QSGRendererInterface.ShaderCompilationTypes', 'QSGRendererInterface.ShaderCompilationType']) -> None: ... @typing.overload def __init__(self, a0: 'QSGRendererInterface.ShaderCompilationTypes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGRendererInterface.ShaderCompilationTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGRendererInterface.ShaderCompilationTypes', 'QSGRendererInterface.ShaderCompilationType', int]) -> 'QSGRendererInterface.ShaderCompilationTypes': ... + def __and__(self, other: typing.Union['QSGRendererInterface.ShaderCompilationTypes', 'QSGRendererInterface.ShaderCompilationType', int]) -> 'QSGRendererInterface.ShaderCompilationTypes': ... + def __xor__(self, other: typing.Union['QSGRendererInterface.ShaderCompilationTypes', 'QSGRendererInterface.ShaderCompilationType', int]) -> 'QSGRendererInterface.ShaderCompilationTypes': ... + def __ror__ (self, other: 'QSGRendererInterface.ShaderCompilationType') -> 'QSGRendererInterface.ShaderCompilationTypes': ... + def __rand__(self, other: 'QSGRendererInterface.ShaderCompilationType') -> 'QSGRendererInterface.ShaderCompilationTypes': ... + def __rxor__(self, other: 'QSGRendererInterface.ShaderCompilationType') -> 'QSGRendererInterface.ShaderCompilationTypes': ... class ShaderSourceTypes(sip.simplewrapper): diff --git a/tests/qflags/test_QtQuick_ShaderCompilationTypes_ShaderCompilationType.py b/tests/qflags/test_QtQuick_ShaderCompilationTypes_ShaderCompilationType.py new file mode 100644 index 00000000..73a2e1d6 --- /dev/null +++ b/tests/qflags/test_QtQuick_ShaderCompilationTypes_ShaderCompilationType.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSGRendererInterface.ShaderCompilationTypes" and flag class "QSGRendererInterface.ShaderCompilationType" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QSGRendererInterface.ShaderCompilationType +MultiFlagClass = QtQuick.QSGRendererInterface.ShaderCompilationTypes + +oneFlagRefValue1 = QtQuick.QSGRendererInterface.ShaderCompilationType.RuntimeCompilation +oneFlagRefValue2 = QtQuick.QSGRendererInterface.ShaderCompilationType.OfflineCompilation + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From abb8481dc19b528001e016080490b57fceec6505 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:34:52 +0100 Subject: [PATCH 320/421] QFlag operations for QSGRendererInterface.ShaderSourceTypes, QSGRendererInterface.ShaderSourceType in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 + ...uick_ShaderSourceTypes_ShaderSourceType.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQuick_ShaderSourceTypes_ShaderSourceType.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index dee334bf..fcce486c 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1546,6 +1546,9 @@ class QSGRectangleNode(QSGGeometryNode): class QSGRendererInterface(sip.simplewrapper): class ShaderSourceType(int): + def __or__ (self, other: 'QSGRendererInterface.ShaderSourceType') -> 'QSGRendererInterface.ShaderSourceTypes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGRendererInterface.ShaderSourceTypes': ... # type: ignore[override, misc] + ShaderSourceString = ... # type: QSGRendererInterface.ShaderSourceType ShaderSourceFile = ... # type: QSGRendererInterface.ShaderSourceType ShaderByteCode = ... # type: QSGRendererInterface.ShaderSourceType @@ -1654,12 +1657,20 @@ class QSGRendererInterface(sip.simplewrapper): def __init__(self, f: typing.Union['QSGRendererInterface.ShaderSourceTypes', 'QSGRendererInterface.ShaderSourceType']) -> None: ... @typing.overload def __init__(self, a0: 'QSGRendererInterface.ShaderSourceTypes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGRendererInterface.ShaderSourceTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGRendererInterface.ShaderSourceTypes', 'QSGRendererInterface.ShaderSourceType', int]) -> 'QSGRendererInterface.ShaderSourceTypes': ... + def __and__(self, other: typing.Union['QSGRendererInterface.ShaderSourceTypes', 'QSGRendererInterface.ShaderSourceType', int]) -> 'QSGRendererInterface.ShaderSourceTypes': ... + def __xor__(self, other: typing.Union['QSGRendererInterface.ShaderSourceTypes', 'QSGRendererInterface.ShaderSourceType', int]) -> 'QSGRendererInterface.ShaderSourceTypes': ... + def __ror__ (self, other: 'QSGRendererInterface.ShaderSourceType') -> 'QSGRendererInterface.ShaderSourceTypes': ... + def __rand__(self, other: 'QSGRendererInterface.ShaderSourceType') -> 'QSGRendererInterface.ShaderSourceTypes': ... + def __rxor__(self, other: 'QSGRendererInterface.ShaderSourceType') -> 'QSGRendererInterface.ShaderSourceTypes': ... @staticmethod def isApiRhiBased(api: 'QSGRendererInterface.GraphicsApi') -> bool: ... diff --git a/tests/qflags/test_QtQuick_ShaderSourceTypes_ShaderSourceType.py b/tests/qflags/test_QtQuick_ShaderSourceTypes_ShaderSourceType.py new file mode 100644 index 00000000..e0cf2e41 --- /dev/null +++ b/tests/qflags/test_QtQuick_ShaderSourceTypes_ShaderSourceType.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSGRendererInterface.ShaderSourceTypes" and flag class "QSGRendererInterface.ShaderSourceType" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QSGRendererInterface.ShaderSourceType +MultiFlagClass = QtQuick.QSGRendererInterface.ShaderSourceTypes + +oneFlagRefValue1 = QtQuick.QSGRendererInterface.ShaderSourceType.ShaderSourceString +oneFlagRefValue2 = QtQuick.QSGRendererInterface.ShaderSourceType.ShaderSourceFile + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 32d9a603aa06b930e63102ba696a99d126406b16 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:35:11 +0100 Subject: [PATCH 321/421] QFlag operations for QSGRenderNode.StateFlags, QSGRenderNode.StateFlag in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 + .../test_QtQuick_StateFlags_StateFlag.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQuick_StateFlags_StateFlag.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index fcce486c..edb13829 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1696,6 +1696,9 @@ class QSGRenderNode(QSGNode): OpaqueRendering = ... # type: QSGRenderNode.RenderingFlag class StateFlag(int): + def __or__ (self, other: 'QSGRenderNode.StateFlag') -> 'QSGRenderNode.StateFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGRenderNode.StateFlags': ... # type: ignore[override, misc] + DepthState = ... # type: QSGRenderNode.StateFlag StencilState = ... # type: QSGRenderNode.StateFlag ScissorState = ... # type: QSGRenderNode.StateFlag @@ -1722,12 +1725,20 @@ class QSGRenderNode(QSGNode): def __init__(self, f: typing.Union['QSGRenderNode.StateFlags', 'QSGRenderNode.StateFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QSGRenderNode.StateFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGRenderNode.StateFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGRenderNode.StateFlags', 'QSGRenderNode.StateFlag', int]) -> 'QSGRenderNode.StateFlags': ... + def __and__(self, other: typing.Union['QSGRenderNode.StateFlags', 'QSGRenderNode.StateFlag', int]) -> 'QSGRenderNode.StateFlags': ... + def __xor__(self, other: typing.Union['QSGRenderNode.StateFlags', 'QSGRenderNode.StateFlag', int]) -> 'QSGRenderNode.StateFlags': ... + def __ror__ (self, other: 'QSGRenderNode.StateFlag') -> 'QSGRenderNode.StateFlags': ... + def __rand__(self, other: 'QSGRenderNode.StateFlag') -> 'QSGRenderNode.StateFlags': ... + def __rxor__(self, other: 'QSGRenderNode.StateFlag') -> 'QSGRenderNode.StateFlags': ... class RenderingFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtQuick_StateFlags_StateFlag.py b/tests/qflags/test_QtQuick_StateFlags_StateFlag.py new file mode 100644 index 00000000..cbcb4f19 --- /dev/null +++ b/tests/qflags/test_QtQuick_StateFlags_StateFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSGRenderNode.StateFlags" and flag class "QSGRenderNode.StateFlag" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QSGRenderNode.StateFlag +MultiFlagClass = QtQuick.QSGRenderNode.StateFlags + +oneFlagRefValue1 = QtQuick.QSGRenderNode.StateFlag.DepthState +oneFlagRefValue2 = QtQuick.QSGRenderNode.StateFlag.StencilState + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From c3ecf72b2b9c4ecebb4404bd7aa8e2546bcf1052 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:35:27 +0100 Subject: [PATCH 322/421] QFlag operations for QSGRenderNode.RenderingFlags, QSGRenderNode.RenderingFlag in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 + ...st_QtQuick_RenderingFlags_RenderingFlag.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQuick_RenderingFlags_RenderingFlag.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index edb13829..de9b1f84 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1687,6 +1687,9 @@ class QSGRendererInterface(sip.simplewrapper): class QSGRenderNode(QSGNode): class RenderingFlag(int): + def __or__ (self, other: 'QSGRenderNode.RenderingFlag') -> 'QSGRenderNode.RenderingFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGRenderNode.RenderingFlags': ... # type: ignore[override, misc] + BoundedRectRendering = ... # type: QSGRenderNode.RenderingFlag DepthAwareRendering = ... # type: QSGRenderNode.RenderingFlag OpaqueRendering = ... # type: QSGRenderNode.RenderingFlag @@ -1748,12 +1751,20 @@ class QSGRenderNode(QSGNode): def __init__(self, f: typing.Union['QSGRenderNode.RenderingFlags', 'QSGRenderNode.RenderingFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QSGRenderNode.RenderingFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGRenderNode.RenderingFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGRenderNode.RenderingFlags', 'QSGRenderNode.RenderingFlag', int]) -> 'QSGRenderNode.RenderingFlags': ... + def __and__(self, other: typing.Union['QSGRenderNode.RenderingFlags', 'QSGRenderNode.RenderingFlag', int]) -> 'QSGRenderNode.RenderingFlags': ... + def __xor__(self, other: typing.Union['QSGRenderNode.RenderingFlags', 'QSGRenderNode.RenderingFlag', int]) -> 'QSGRenderNode.RenderingFlags': ... + def __ror__ (self, other: 'QSGRenderNode.RenderingFlag') -> 'QSGRenderNode.RenderingFlags': ... + def __rand__(self, other: 'QSGRenderNode.RenderingFlag') -> 'QSGRenderNode.RenderingFlags': ... + def __rxor__(self, other: 'QSGRenderNode.RenderingFlag') -> 'QSGRenderNode.RenderingFlags': ... class RenderState(sip.simplewrapper): diff --git a/tests/qflags/test_QtQuick_RenderingFlags_RenderingFlag.py b/tests/qflags/test_QtQuick_RenderingFlags_RenderingFlag.py new file mode 100644 index 00000000..5373ebe4 --- /dev/null +++ b/tests/qflags/test_QtQuick_RenderingFlags_RenderingFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSGRenderNode.RenderingFlags" and flag class "QSGRenderNode.RenderingFlag" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QSGRenderNode.RenderingFlag +MultiFlagClass = QtQuick.QSGRenderNode.RenderingFlags + +oneFlagRefValue1 = QtQuick.QSGRenderNode.RenderingFlag.BoundedRectRendering +oneFlagRefValue2 = QtQuick.QSGRenderNode.RenderingFlag.DepthAwareRendering + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From ec338d2949c89d17ac9e07575913a2924f3ca42f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:35:45 +0100 Subject: [PATCH 323/421] QFlag operations for QSGImageNode.TextureCoordinatesTransformMode, QSGImageNode.TextureCoordinatesTransformFlag in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 + ...ormMode_TextureCoordinatesTransformFlag.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index de9b1f84..94f0314d 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1231,6 +1231,9 @@ class QSGGeometryNode(QSGBasicGeometryNode): class QSGImageNode(QSGGeometryNode): class TextureCoordinatesTransformFlag(int): + def __or__ (self, other: 'QSGImageNode.TextureCoordinatesTransformFlag') -> 'QSGImageNode.TextureCoordinatesTransformMode': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGImageNode.TextureCoordinatesTransformMode': ... # type: ignore[override, misc] + NoTransform = ... # type: QSGImageNode.TextureCoordinatesTransformFlag MirrorHorizontally = ... # type: QSGImageNode.TextureCoordinatesTransformFlag MirrorVertically = ... # type: QSGImageNode.TextureCoordinatesTransformFlag @@ -1247,12 +1250,20 @@ class QSGImageNode(QSGGeometryNode): def __init__(self, f: typing.Union['QSGImageNode.TextureCoordinatesTransformMode', 'QSGImageNode.TextureCoordinatesTransformFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QSGImageNode.TextureCoordinatesTransformMode') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGImageNode.TextureCoordinatesTransformMode': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGImageNode.TextureCoordinatesTransformMode', 'QSGImageNode.TextureCoordinatesTransformFlag', int]) -> 'QSGImageNode.TextureCoordinatesTransformMode': ... + def __and__(self, other: typing.Union['QSGImageNode.TextureCoordinatesTransformMode', 'QSGImageNode.TextureCoordinatesTransformFlag', int]) -> 'QSGImageNode.TextureCoordinatesTransformMode': ... + def __xor__(self, other: typing.Union['QSGImageNode.TextureCoordinatesTransformMode', 'QSGImageNode.TextureCoordinatesTransformFlag', int]) -> 'QSGImageNode.TextureCoordinatesTransformMode': ... + def __ror__ (self, other: 'QSGImageNode.TextureCoordinatesTransformFlag') -> 'QSGImageNode.TextureCoordinatesTransformMode': ... + def __rand__(self, other: 'QSGImageNode.TextureCoordinatesTransformFlag') -> 'QSGImageNode.TextureCoordinatesTransformMode': ... + def __rxor__(self, other: 'QSGImageNode.TextureCoordinatesTransformFlag') -> 'QSGImageNode.TextureCoordinatesTransformMode': ... @staticmethod def rebuildGeometry(g: QSGGeometry, texture: 'QSGTexture', rect: QtCore.QRectF, sourceRect: QtCore.QRectF, texCoordMode: typing.Union['QSGImageNode.TextureCoordinatesTransformMode', 'QSGImageNode.TextureCoordinatesTransformFlag']) -> None: ... diff --git a/tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py b/tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py new file mode 100644 index 00000000..109d7c6e --- /dev/null +++ b/tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSGImageNode.TextureCoordinatesTransformMode" and flag class "QSGImageNode.TextureCoordinatesTransformFlag" +from PyQt5 import QtQuick + +OneFlagClass = QtQuick.QSGImageNode.TextureCoordinatesTransformFlag +MultiFlagClass = QtQuick.QSGImageNode.TextureCoordinatesTransformMode + +oneFlagRefValue1 = QtQuick.QSGImageNode.TextureCoordinatesTransformFlag.NoTransform +oneFlagRefValue2 = QtQuick.QSGImageNode.TextureCoordinatesTransformFlag.MirrorHorizontally + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 7698df34b8141b8e838238f2d949c2c723eeb4eb Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 14:36:03 +0100 Subject: [PATCH 324/421] QFlag operations for QSGSimpleTextureNode.TextureCoordinatesTransformMode, QSGSimpleTextureNode.TextureCoordinatesTransformFlag in module QtQuick --- PyQt5-stubs/QtQuick.pyi | 11 +++++++++++ ...esTransformMode_TextureCoordinatesTransformFlag.py | 10 +++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 94f0314d..bbbd5484 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1818,6 +1818,9 @@ class QSGSimpleRectNode(QSGGeometryNode): class QSGSimpleTextureNode(QSGGeometryNode): class TextureCoordinatesTransformFlag(int): + def __or__ (self, other: 'QSGSimpleTextureNode.TextureCoordinatesTransformFlag') -> 'QSGSimpleTextureNode.TextureCoordinatesTransformMode': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSGSimpleTextureNode.TextureCoordinatesTransformMode': ... # type: ignore[override, misc] + NoTransform = ... # type: QSGSimpleTextureNode.TextureCoordinatesTransformFlag MirrorHorizontally = ... # type: QSGSimpleTextureNode.TextureCoordinatesTransformFlag MirrorVertically = ... # type: QSGSimpleTextureNode.TextureCoordinatesTransformFlag @@ -1834,12 +1837,20 @@ class QSGSimpleTextureNode(QSGGeometryNode): def __init__(self, f: typing.Union['QSGSimpleTextureNode.TextureCoordinatesTransformMode', 'QSGSimpleTextureNode.TextureCoordinatesTransformFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QSGSimpleTextureNode.TextureCoordinatesTransformMode') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSGSimpleTextureNode.TextureCoordinatesTransformMode': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSGSimpleTextureNode.TextureCoordinatesTransformMode', 'QSGSimpleTextureNode.TextureCoordinatesTransformFlag', int]) -> 'QSGSimpleTextureNode.TextureCoordinatesTransformMode': ... + def __and__(self, other: typing.Union['QSGSimpleTextureNode.TextureCoordinatesTransformMode', 'QSGSimpleTextureNode.TextureCoordinatesTransformFlag', int]) -> 'QSGSimpleTextureNode.TextureCoordinatesTransformMode': ... + def __xor__(self, other: typing.Union['QSGSimpleTextureNode.TextureCoordinatesTransformMode', 'QSGSimpleTextureNode.TextureCoordinatesTransformFlag', int]) -> 'QSGSimpleTextureNode.TextureCoordinatesTransformMode': ... + def __ror__ (self, other: 'QSGSimpleTextureNode.TextureCoordinatesTransformFlag') -> 'QSGSimpleTextureNode.TextureCoordinatesTransformMode': ... + def __rand__(self, other: 'QSGSimpleTextureNode.TextureCoordinatesTransformFlag') -> 'QSGSimpleTextureNode.TextureCoordinatesTransformMode': ... + def __rxor__(self, other: 'QSGSimpleTextureNode.TextureCoordinatesTransformFlag') -> 'QSGSimpleTextureNode.TextureCoordinatesTransformMode': ... def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py b/tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py index 109d7c6e..5ead690b 100644 --- a/tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py +++ b/tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py @@ -9,14 +9,14 @@ import pytest ### Specific part -# file generated from qflags_test_template.py for QFlags class "QSGImageNode.TextureCoordinatesTransformMode" and flag class "QSGImageNode.TextureCoordinatesTransformFlag" +# file generated from qflags_test_template.py for QFlags class "QSGSimpleTextureNode.TextureCoordinatesTransformMode" and flag class "QSGSimpleTextureNode.TextureCoordinatesTransformFlag" from PyQt5 import QtQuick -OneFlagClass = QtQuick.QSGImageNode.TextureCoordinatesTransformFlag -MultiFlagClass = QtQuick.QSGImageNode.TextureCoordinatesTransformMode +OneFlagClass = QtQuick.QSGSimpleTextureNode.TextureCoordinatesTransformFlag +MultiFlagClass = QtQuick.QSGSimpleTextureNode.TextureCoordinatesTransformMode -oneFlagRefValue1 = QtQuick.QSGImageNode.TextureCoordinatesTransformFlag.NoTransform -oneFlagRefValue2 = QtQuick.QSGImageNode.TextureCoordinatesTransformFlag.MirrorHorizontally +oneFlagRefValue1 = QtQuick.QSGSimpleTextureNode.TextureCoordinatesTransformFlag.NoTransform +oneFlagRefValue2 = QtQuick.QSGSimpleTextureNode.TextureCoordinatesTransformFlag.MirrorHorizontally OR_CONVERTS_TO_MULTI: Literal[True] = True OR_INT_CONVERTS_TO_MULTI: Literal[False] = False From 4d3d85fbd83c41a2bacdae29be0d4ae253975204 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 17:58:43 +0100 Subject: [PATCH 325/421] Add QML processing results --- tests/qflags/qflags_process_result.json | 467 ++++++++++++++++++++++++ 1 file changed, 467 insertions(+) diff --git a/tests/qflags/qflags_process_result.json b/tests/qflags/qflags_process_result.json index 5220aa4b..5a5121ac 100644 --- a/tests/qflags/qflags_process_result.json +++ b/tests/qflags/qflags_process_result.json @@ -2999,6 +2999,449 @@ "or_int_converts_to_multi": false, "int_or_converts_to_multi": false, "supports_one_op_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QQuickItem.Flags", + "enum_full_class_name": "QQuickItem.Flag", + "enum_value1": "ItemClipsChildrenToShape", + "enum_value2": "ItemAcceptsInputMethod", + "module_count": 4, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QSGMaterial.Flags", + "enum_full_class_name": "QSGMaterial.Flag", + "enum_value1": "Blending", + "enum_value2": "RequiresDeterminant", + "module_count": 4, + "module_idx": 1, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QSGNode.Flags", + "enum_full_class_name": "QSGNode.Flag", + "enum_value1": "OwnedByParent", + "enum_value2": "UsePreprocess", + "module_count": 4, + "module_idx": 2, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QSGMaterialRhiShader.Flags", + "enum_full_class_name": "QSGMaterialRhiShader.Flag", + "enum_value1": "UpdatesGraphicsPipelineState", + "enum_value2": "UpdatesGraphicsPipelineState", + "module_count": 4, + "module_idx": 3, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quickshapes\\qquickshape_p_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlcustomparser_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\qml\\qml\\qqmlengine.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\qsgcontextplugin_p.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\items\\qquickitem.h: Q_DECLARE_FLAGS(Flags, Flag)", + "tests\\auto\\qml\\qmltyperegistrar\\tst_qmltyperegistrar.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterial.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(Flags, Flag)", + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QQmlImageProviderBase.Flags", + "enum_full_class_name": "QQmlImageProviderBase.Flag", + "enum_value1": "ForceAsynchronousImageLoading", + "enum_value2": "ForceAsynchronousImageLoading", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQml", + "module_path": "../../PyQt5-stubs/QtQml.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "Extensions", + "enum_class": "Extension", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\qml\\jsapi\\qjsengine.h: Q_DECLARE_FLAGS(Extensions, Extension)" + ], + "qflag_full_class_name": "QJSEngine.Extensions", + "enum_full_class_name": "QJSEngine.Extension", + "enum_value1": "TranslationExtension", + "enum_value2": "ConsoleExtension", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQml", + "module_path": "../../PyQt5-stubs/QtQml.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "PerformanceHints", + "enum_class": "PerformanceHint", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickpainteditem.h: Q_DECLARE_FLAGS(PerformanceHints, PerformanceHint)" + ], + "qflag_full_class_name": "QQuickPaintedItem.PerformanceHints", + "enum_full_class_name": "QQuickPaintedItem.PerformanceHint", + "enum_value1": "FastFBOResizing", + "enum_value2": "FastFBOResizing", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "CreateTextureOptions", + "enum_class": "CreateTextureOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickwindow.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)", + "src\\quick\\scenegraph\\util\\qsgengine.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)" + ], + "qflag_full_class_name": "QQuickWindow.CreateTextureOptions", + "enum_full_class_name": "QQuickWindow.CreateTextureOption", + "enum_value1": "TextureHasAlphaChannel", + "enum_value2": "TextureHasMipmaps", + "module_count": 2, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "CreateTextureOptions", + "enum_class": "CreateTextureOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\items\\qquickwindow.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)", + "src\\quick\\scenegraph\\util\\qsgengine.h: Q_DECLARE_FLAGS(CreateTextureOptions, CreateTextureOption)" + ], + "qflag_full_class_name": "QSGEngine.CreateTextureOptions", + "enum_full_class_name": "QSGEngine.CreateTextureOption", + "enum_value1": "TextureHasAlphaChannel", + "enum_value2": "TextureOwnsGLTexture", + "module_count": 2, + "module_idx": 1, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "ClearMode", + "enum_class": "ClearModeBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgabstractrenderer.h: Q_DECLARE_FLAGS(ClearMode, ClearModeBit)" + ], + "qflag_full_class_name": "QSGAbstractRenderer.ClearMode", + "enum_full_class_name": "QSGAbstractRenderer.ClearModeBit", + "enum_value1": "ClearColorBuffer", + "enum_value2": "ClearDepthBuffer", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "MatrixTransformFlags", + "enum_class": "MatrixTransformFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgabstractrenderer.h: Q_DECLARE_FLAGS(MatrixTransformFlags, MatrixTransformFlag)" + ], + "qflag_full_class_name": "QSGAbstractRenderer.MatrixTransformFlags", + "enum_full_class_name": "QSGAbstractRenderer.MatrixTransformFlag", + "enum_value1": "MatrixTransformFlipY", + "enum_value2": "MatrixTransformFlipY", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "ColorMask", + "enum_class": "ColorMaskComponent", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgmaterialrhishader.h: Q_DECLARE_FLAGS(ColorMask, ColorMaskComponent)" + ], + "qflag_full_class_name": "QSGMaterialRhiShader.GraphicsPipelineState.ColorMask", + "enum_full_class_name": "QSGMaterialRhiShader.GraphicsPipelineState.ColorMaskComponent", + "enum_value1": "R", + "enum_value2": "G", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "DirtyState", + "enum_class": "DirtyStateBit", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgnode.h: Q_DECLARE_FLAGS(DirtyState, DirtyStateBit)" + ], + "qflag_full_class_name": "QSGNode.DirtyState", + "enum_full_class_name": "QSGNode.DirtyStateBit", + "enum_value1": "DirtyMatrix", + "enum_value2": "DirtyNodeAdded", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "ShaderCompilationTypes", + "enum_class": "ShaderCompilationType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendererinterface.h: Q_DECLARE_FLAGS(ShaderCompilationTypes, ShaderCompilationType)" + ], + "qflag_full_class_name": "QSGRendererInterface.ShaderCompilationTypes", + "enum_full_class_name": "QSGRendererInterface.ShaderCompilationType", + "enum_value1": "RuntimeCompilation", + "enum_value2": "OfflineCompilation", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "ShaderSourceTypes", + "enum_class": "ShaderSourceType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendererinterface.h: Q_DECLARE_FLAGS(ShaderSourceTypes, ShaderSourceType)" + ], + "qflag_full_class_name": "QSGRendererInterface.ShaderSourceTypes", + "enum_full_class_name": "QSGRendererInterface.ShaderSourceType", + "enum_value1": "ShaderSourceString", + "enum_value2": "ShaderSourceFile", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "StateFlags", + "enum_class": "StateFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendernode.h: Q_DECLARE_FLAGS(StateFlags, StateFlag)" + ], + "qflag_full_class_name": "QSGRenderNode.StateFlags", + "enum_full_class_name": "QSGRenderNode.StateFlag", + "enum_value1": "DepthState", + "enum_value2": "StencilState", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "RenderingFlags", + "enum_class": "RenderingFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgrendernode.h: Q_DECLARE_FLAGS(RenderingFlags, RenderingFlag)" + ], + "qflag_full_class_name": "QSGRenderNode.RenderingFlags", + "enum_full_class_name": "QSGRenderNode.RenderingFlag", + "enum_value1": "BoundedRectRendering", + "enum_value2": "DepthAwareRendering", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "TextureCoordinatesTransformMode", + "enum_class": "TextureCoordinatesTransformFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\util\\qsgimagenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)", + "src\\quick\\scenegraph\\util\\qsgsimpletexturenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)" + ], + "qflag_full_class_name": "QSGImageNode.TextureCoordinatesTransformMode", + "enum_full_class_name": "QSGImageNode.TextureCoordinatesTransformFlag", + "enum_value1": "NoTransform", + "enum_value2": "MirrorHorizontally", + "module_count": 2, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "TextureCoordinatesTransformMode", + "enum_class": "TextureCoordinatesTransformFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\util\\qsgimagenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)", + "src\\quick\\scenegraph\\util\\qsgsimpletexturenode.h: Q_DECLARE_FLAGS(TextureCoordinatesTransformMode, TextureCoordinatesTransformFlag)" + ], + "qflag_full_class_name": "QSGSimpleTextureNode.TextureCoordinatesTransformMode", + "enum_full_class_name": "QSGSimpleTextureNode.TextureCoordinatesTransformFlag", + "enum_value1": "NoTransform", + "enum_value2": "MirrorHorizontally", + "module_count": 2, + "module_idx": 1, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true } ], "qflag_process_error": [ @@ -3053,6 +3496,30 @@ " File \"\", line 1, in ", "AttributeError: sip.enumtype object 'DiscoveryMethod' has no member 'NoMethod'" ] + }, + { + "qflag_class": "DirtyStates", + "enum_class": "DirtyState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\quick\\scenegraph\\coreapi\\qsgmaterialshader.h: Q_DECLARE_FLAGS(DirtyStates, DirtyState)" + ], + "qflag_full_class_name": "QSGMaterialShader.RenderState.DirtyStates", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtQuick", + "module_path": "../../PyQt5-stubs/QtQuick.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true, + "error": [ + "Could not locate class DirtyState" + ] } ] } \ No newline at end of file From d1bf116268bf7a43774acde8dbfcf4e21fa4d1a9 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:05:08 +0100 Subject: [PATCH 326/421] Remove non relevant grep results --- tests/qflags/grep-results/qtdoc-qflag-grep-result.txt | 0 tests/qflags/grep-results/qtdocgallery-qflag-grep-result.txt | 0 tests/qflags/grep-results/qtfeedback-qflag-grep-result.txt | 0 tests/qflags/grep-results/qtgamepad-qflag-grep-result.txt | 2 -- .../grep-results/qtgraphicaleffects-qflag-grep-result.txt | 0 tests/qflags/grep-results/qtimageformats-qflag-grep-result.txt | 0 6 files changed, 2 deletions(-) delete mode 100644 tests/qflags/grep-results/qtdoc-qflag-grep-result.txt delete mode 100644 tests/qflags/grep-results/qtdocgallery-qflag-grep-result.txt delete mode 100644 tests/qflags/grep-results/qtfeedback-qflag-grep-result.txt delete mode 100644 tests/qflags/grep-results/qtgamepad-qflag-grep-result.txt delete mode 100644 tests/qflags/grep-results/qtgraphicaleffects-qflag-grep-result.txt delete mode 100644 tests/qflags/grep-results/qtimageformats-qflag-grep-result.txt diff --git a/tests/qflags/grep-results/qtdoc-qflag-grep-result.txt b/tests/qflags/grep-results/qtdoc-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/qflags/grep-results/qtdocgallery-qflag-grep-result.txt b/tests/qflags/grep-results/qtdocgallery-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/qflags/grep-results/qtfeedback-qflag-grep-result.txt b/tests/qflags/grep-results/qtfeedback-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/qflags/grep-results/qtgamepad-qflag-grep-result.txt b/tests/qflags/grep-results/qtgamepad-qflag-grep-result.txt deleted file mode 100644 index 6efa7f77..00000000 --- a/tests/qflags/grep-results/qtgamepad-qflag-grep-result.txt +++ /dev/null @@ -1,2 +0,0 @@ -src\gamepad\qgamepadmanager.h: Q_DECLARE_FLAGS(GamepadButtons, GamepadButton) -src\gamepad\qgamepadmanager.h: Q_DECLARE_FLAGS(GamepadAxes, GamepadAxis) diff --git a/tests/qflags/grep-results/qtgraphicaleffects-qflag-grep-result.txt b/tests/qflags/grep-results/qtgraphicaleffects-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/qflags/grep-results/qtimageformats-qflag-grep-result.txt b/tests/qflags/grep-results/qtimageformats-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 From 516cd87eb214f5a3e476f5721ff82231ee10c0a4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:05:58 +0100 Subject: [PATCH 327/421] Add QtLocation qflags to process --- .../qflags/generate_qflags_stubs_and_tests.py | 7 +- tests/qflags/qflags_modules_analysis.json | 403 ++++++++++++++++++ tests/qflags/qflags_to_process.json | 295 +++++++++++++ 3 files changed, 704 insertions(+), 1 deletion(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 153c9be3..9b6f69f4 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -15,7 +15,8 @@ QtChart, QtBluetooth, QtNfc, QtDataVisualization, - QtQuick, QtQml + QtQuick, QtQml, + QtPositioning, QtLocation, ) try: import libcst as cst @@ -59,6 +60,10 @@ 'QtQuick', 'QtQml', ], + 'qtlocation': [ + 'QtPositioning', + 'QtLocation', + ], } diff --git a/tests/qflags/qflags_modules_analysis.json b/tests/qflags/qflags_modules_analysis.json index eb62ff2e..762310fc 100644 --- a/tests/qflags/qflags_modules_analysis.json +++ b/tests/qflags/qflags_modules_analysis.json @@ -759,6 +759,256 @@ "module_idx": 1, "module_name": "QtQuick", "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "VisibilityScope", + "enum_class": "Visibility", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\qlocation.h:Q_DECLARE_FLAGS(VisibilityScope, Visibility)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "PositioningMethods", + "enum_class": "PositioningMethod", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\positioningquick\\qdeclarativepositionsource_p.h: Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod)", + "src\\positioning\\qgeopositioninfosource.h: Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPositioning", + "module_path": "../../PyQt5-stubs/QtPositioning.pyi" + }, + { + "qflag_class": "AreaMonitorFeatures", + "enum_class": "AreaMonitorFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\positioning\\qgeoareamonitorsource.h: Q_DECLARE_FLAGS(AreaMonitorFeatures, AreaMonitorFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPositioning", + "module_path": "../../PyQt5-stubs/QtPositioning.pyi" + }, + { + "qflag_class": "TravelModes", + "enum_class": "TravelMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(TravelModes, TravelMode)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(TravelModes, TravelMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "FeatureTypes", + "enum_class": "FeatureType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(FeatureTypes, FeatureType)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(FeatureTypes, FeatureType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "FeatureWeights", + "enum_class": "FeatureWeight", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(FeatureWeights, FeatureWeight)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(FeatureWeights, FeatureWeight)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "RouteOptimizations", + "enum_class": "RouteOptimization", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(RouteOptimizations, RouteOptimization)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(RouteOptimizations, RouteOptimization)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "SegmentDetails", + "enum_class": "SegmentDetail", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(SegmentDetails, SegmentDetail)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(SegmentDetails, SegmentDetail)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "ManeuverDetails", + "enum_class": "ManeuverDetail", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(ManeuverDetails, ManeuverDetail)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(ManeuverDetails, ManeuverDetail)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "RoutingFeatures", + "enum_class": "RoutingFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "GeocodingFeatures", + "enum_class": "GeocodingFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "MappingFeatures", + "enum_class": "MappingFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(MappingFeatures, MappingFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(MappingFeatures, MappingFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "PlacesFeatures", + "enum_class": "PlacesFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "NavigationFeatures", + "enum_class": "NavigationFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(NavigationFeatures, NavigationFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(NavigationFeatures, NavigationFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" } ], "flag_without_module": [ @@ -1291,6 +1541,159 @@ "module_idx": -1, "module_name": "", "module_path": "" + }, + { + "qflag_class": "CacheAreas", + "enum_class": "CacheArea", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\maps\\qabstractgeotilecache_p.h: Q_DECLARE_FLAGS(CacheAreas, CacheArea)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "ItemTypes", + "enum_class": "ItemType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\maps\\qgeomap_p.h: Q_DECLARE_FLAGS(ItemTypes, ItemType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\maps\\qgeomap_p.h: Q_DECLARE_FLAGS(Capabilities, Capability)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "Features", + "enum_class": "Feature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qgeomapobject_p.h: Q_DECLARE_FLAGS(Features, Feature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "AcceptedGestures", + "enum_class": "GeoMapGesture", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qquickgeomapgesturearea_p.h: Q_DECLARE_FLAGS(AcceptedGestures, GeoMapGesture)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "SyncStates", + "enum_class": "SyncState", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\plugins\\geoservices\\mapboxgl\\qgeomapmapboxgl_p.h: Q_DECLARE_FLAGS(SyncStates, SyncState);" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "ResourceFlags", + "enum_class": "ResourceFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\plugins\\position\\geoclue\\qgeocluemaster.h: Q_DECLARE_FLAGS(ResourceFlags, ResourceFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "PositionFields", + "enum_class": "PositionField", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\plugins\\position\\geoclue\\qgeopositioninfosource_geocluemaster.h: Q_DECLARE_FLAGS(PositionFields, PositionField)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "VelocityFields", + "enum_class": "VelocityField", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\plugins\\position\\geoclue\\qgeopositioninfosource_geocluemaster.h: Q_DECLARE_FLAGS(VelocityFields, VelocityField)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" } ] } \ No newline at end of file diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index cd1eeb1a..15c6efaf 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -2947,6 +2947,256 @@ "module_idx": 1, "module_name": "QtQuick", "module_path": "../../PyQt5-stubs/QtQuick.pyi" + }, + { + "qflag_class": "VisibilityScope", + "enum_class": "Visibility", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\qlocation.h:Q_DECLARE_FLAGS(VisibilityScope, Visibility)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "PositioningMethods", + "enum_class": "PositioningMethod", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\positioningquick\\qdeclarativepositionsource_p.h: Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod)", + "src\\positioning\\qgeopositioninfosource.h: Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPositioning", + "module_path": "../../PyQt5-stubs/QtPositioning.pyi" + }, + { + "qflag_class": "AreaMonitorFeatures", + "enum_class": "AreaMonitorFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\positioning\\qgeoareamonitorsource.h: Q_DECLARE_FLAGS(AreaMonitorFeatures, AreaMonitorFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPositioning", + "module_path": "../../PyQt5-stubs/QtPositioning.pyi" + }, + { + "qflag_class": "TravelModes", + "enum_class": "TravelMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(TravelModes, TravelMode)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(TravelModes, TravelMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "FeatureTypes", + "enum_class": "FeatureType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(FeatureTypes, FeatureType)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(FeatureTypes, FeatureType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "FeatureWeights", + "enum_class": "FeatureWeight", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(FeatureWeights, FeatureWeight)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(FeatureWeights, FeatureWeight)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "RouteOptimizations", + "enum_class": "RouteOptimization", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(RouteOptimizations, RouteOptimization)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(RouteOptimizations, RouteOptimization)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "SegmentDetails", + "enum_class": "SegmentDetail", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(SegmentDetails, SegmentDetail)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(SegmentDetails, SegmentDetail)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "ManeuverDetails", + "enum_class": "ManeuverDetail", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(ManeuverDetails, ManeuverDetail)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(ManeuverDetails, ManeuverDetail)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "RoutingFeatures", + "enum_class": "RoutingFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "GeocodingFeatures", + "enum_class": "GeocodingFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "MappingFeatures", + "enum_class": "MappingFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(MappingFeatures, MappingFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(MappingFeatures, MappingFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "PlacesFeatures", + "enum_class": "PlacesFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "NavigationFeatures", + "enum_class": "NavigationFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(NavigationFeatures, NavigationFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(NavigationFeatures, NavigationFeature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi" } ], "qflags_to_skip": [ @@ -3134,6 +3384,51 @@ "qflag_class": "DrawingHints", "enum_class": "DrawingHint", "skip_reason": "QFlag not found in module group qtquick" + }, + { + "qflag_class": "CacheAreas", + "enum_class": "CacheArea", + "skip_reason": "QFlag not found in module group qtlocation" + }, + { + "qflag_class": "ItemTypes", + "enum_class": "ItemType", + "skip_reason": "QFlag not found in module group qtlocation" + }, + { + "qflag_class": "Capabilities", + "enum_class": "Capability", + "skip_reason": "QFlag not found in module group qtlocation" + }, + { + "qflag_class": "Features", + "enum_class": "Feature", + "skip_reason": "QFlag not found in module group qtlocation" + }, + { + "qflag_class": "AcceptedGestures", + "enum_class": "GeoMapGesture", + "skip_reason": "QFlag not found in module group qtlocation" + }, + { + "qflag_class": "SyncStates", + "enum_class": "SyncState", + "skip_reason": "QFlag not found in module group qtlocation" + }, + { + "qflag_class": "ResourceFlags", + "enum_class": "ResourceFlag", + "skip_reason": "QFlag not found in module group qtlocation" + }, + { + "qflag_class": "PositionFields", + "enum_class": "PositionField", + "skip_reason": "QFlag not found in module group qtlocation" + }, + { + "qflag_class": "VelocityFields", + "enum_class": "VelocityField", + "skip_reason": "QFlag not found in module group qtlocation" } ] } \ No newline at end of file From d64c69e91765028f091c0e55b3418ed4f9133f2d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:06:35 +0100 Subject: [PATCH 328/421] QFlag operations for QLocation.VisibilityScope, QLocation.Visibility in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + ...t_QtLocation_VisibilityScope_Visibility.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_VisibilityScope_Visibility.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index 3926f660..bcd8b448 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -725,6 +725,9 @@ class QGeoServiceProvider(QtCore.QObject): class QLocation(sip.simplewrapper): class Visibility(int): + def __or__ (self, other: 'QLocation.Visibility') -> 'QLocation.VisibilityScope': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QLocation.VisibilityScope': ... # type: ignore[override, misc] + UnspecifiedVisibility = ... # type: QLocation.Visibility DeviceVisibility = ... # type: QLocation.Visibility PrivateVisibility = ... # type: QLocation.Visibility @@ -743,12 +746,20 @@ class QLocation(sip.simplewrapper): def __init__(self, f: typing.Union['QLocation.VisibilityScope', 'QLocation.Visibility']) -> None: ... @typing.overload def __init__(self, a0: 'QLocation.VisibilityScope') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QLocation.VisibilityScope': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QLocation.VisibilityScope', 'QLocation.Visibility', int]) -> 'QLocation.VisibilityScope': ... + def __and__(self, other: typing.Union['QLocation.VisibilityScope', 'QLocation.Visibility', int]) -> 'QLocation.VisibilityScope': ... + def __xor__(self, other: typing.Union['QLocation.VisibilityScope', 'QLocation.Visibility', int]) -> 'QLocation.VisibilityScope': ... + def __ror__ (self, other: 'QLocation.Visibility') -> 'QLocation.VisibilityScope': ... + def __rand__(self, other: 'QLocation.Visibility') -> 'QLocation.VisibilityScope': ... + def __rxor__(self, other: 'QLocation.Visibility') -> 'QLocation.VisibilityScope': ... class QPlace(sip.simplewrapper): diff --git a/tests/qflags/test_QtLocation_VisibilityScope_Visibility.py b/tests/qflags/test_QtLocation_VisibilityScope_Visibility.py new file mode 100644 index 00000000..c881626a --- /dev/null +++ b/tests/qflags/test_QtLocation_VisibilityScope_Visibility.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QLocation.VisibilityScope" and flag class "QLocation.Visibility" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QLocation.Visibility +MultiFlagClass = QtLocation.QLocation.VisibilityScope + +oneFlagRefValue1 = QtLocation.QLocation.Visibility.UnspecifiedVisibility +oneFlagRefValue2 = QtLocation.QLocation.Visibility.DeviceVisibility + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From d6a8db2c6459a50cd5d93da73a724fe0e610e82e Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:06:51 +0100 Subject: [PATCH 329/421] QFlag operations for QGeoPositionInfoSource.PositioningMethods, QGeoPositionInfoSource.PositioningMethod in module QtPositioning --- PyQt5-stubs/QtPositioning.pyi | 11 + ...ng_PositioningMethods_PositioningMethod.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtPositioning_PositioningMethods_PositioningMethod.py diff --git a/PyQt5-stubs/QtPositioning.pyi b/PyQt5-stubs/QtPositioning.pyi index de57e255..2dd7cacb 100644 --- a/PyQt5-stubs/QtPositioning.pyi +++ b/PyQt5-stubs/QtPositioning.pyi @@ -374,6 +374,9 @@ class QGeoPositionInfo(sip.wrapper): class QGeoPositionInfoSource(QtCore.QObject): class PositioningMethod(int): + def __or__ (self, other: 'QGeoPositionInfoSource.PositioningMethod') -> 'QGeoPositionInfoSource.PositioningMethods': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoPositionInfoSource.PositioningMethods': ... # type: ignore[override, misc] + NoPositioningMethods = ... # type: QGeoPositionInfoSource.PositioningMethod SatellitePositioningMethods = ... # type: QGeoPositionInfoSource.PositioningMethod NonSatellitePositioningMethods = ... # type: QGeoPositionInfoSource.PositioningMethod @@ -403,12 +406,20 @@ class QGeoPositionInfoSource(QtCore.QObject): def __init__(self, f: typing.Union['QGeoPositionInfoSource.PositioningMethods', 'QGeoPositionInfoSource.PositioningMethod']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoPositionInfoSource.PositioningMethods') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoPositionInfoSource.PositioningMethods': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoPositionInfoSource.PositioningMethods', 'QGeoPositionInfoSource.PositioningMethod', int]) -> 'QGeoPositionInfoSource.PositioningMethods': ... + def __and__(self, other: typing.Union['QGeoPositionInfoSource.PositioningMethods', 'QGeoPositionInfoSource.PositioningMethod', int]) -> 'QGeoPositionInfoSource.PositioningMethods': ... + def __xor__(self, other: typing.Union['QGeoPositionInfoSource.PositioningMethods', 'QGeoPositionInfoSource.PositioningMethod', int]) -> 'QGeoPositionInfoSource.PositioningMethods': ... + def __ror__ (self, other: 'QGeoPositionInfoSource.PositioningMethod') -> 'QGeoPositionInfoSource.PositioningMethods': ... + def __rand__(self, other: 'QGeoPositionInfoSource.PositioningMethod') -> 'QGeoPositionInfoSource.PositioningMethods': ... + def __rxor__(self, other: 'QGeoPositionInfoSource.PositioningMethod') -> 'QGeoPositionInfoSource.PositioningMethods': ... def __init__(self, parent: QtCore.QObject) -> None: ... diff --git a/tests/qflags/test_QtPositioning_PositioningMethods_PositioningMethod.py b/tests/qflags/test_QtPositioning_PositioningMethods_PositioningMethod.py new file mode 100644 index 00000000..a7c9486f --- /dev/null +++ b/tests/qflags/test_QtPositioning_PositioningMethods_PositioningMethod.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoPositionInfoSource.PositioningMethods" and flag class "QGeoPositionInfoSource.PositioningMethod" +from PyQt5 import QtPositioning + +OneFlagClass = QtPositioning.QGeoPositionInfoSource.PositioningMethod +MultiFlagClass = QtPositioning.QGeoPositionInfoSource.PositioningMethods + +oneFlagRefValue1 = QtPositioning.QGeoPositionInfoSource.PositioningMethod.NoPositioningMethods +oneFlagRefValue2 = QtPositioning.QGeoPositionInfoSource.PositioningMethod.SatellitePositioningMethods + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 436cb1f81d7c05e32c48b16602a4186e630194e8 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:07:07 +0100 Subject: [PATCH 330/421] QFlag operations for QGeoAreaMonitorSource.AreaMonitorFeatures, QGeoAreaMonitorSource.AreaMonitorFeature in module QtPositioning --- PyQt5-stubs/QtPositioning.pyi | 8 + ..._AreaMonitorFeatures_AreaMonitorFeature.py | 272 ++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 tests/qflags/test_QtPositioning_AreaMonitorFeatures_AreaMonitorFeature.py diff --git a/PyQt5-stubs/QtPositioning.pyi b/PyQt5-stubs/QtPositioning.pyi index 2dd7cacb..8e786ee8 100644 --- a/PyQt5-stubs/QtPositioning.pyi +++ b/PyQt5-stubs/QtPositioning.pyi @@ -111,12 +111,20 @@ class QGeoAreaMonitorSource(QtCore.QObject): def __init__(self, f: typing.Union['QGeoAreaMonitorSource.AreaMonitorFeatures', 'QGeoAreaMonitorSource.AreaMonitorFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoAreaMonitorSource.AreaMonitorFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoAreaMonitorSource.AreaMonitorFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoAreaMonitorSource.AreaMonitorFeatures', 'QGeoAreaMonitorSource.AreaMonitorFeature', int]) -> 'QGeoAreaMonitorSource.AreaMonitorFeatures': ... + def __and__(self, other: typing.Union['QGeoAreaMonitorSource.AreaMonitorFeatures', 'QGeoAreaMonitorSource.AreaMonitorFeature', int]) -> 'QGeoAreaMonitorSource.AreaMonitorFeatures': ... + def __xor__(self, other: typing.Union['QGeoAreaMonitorSource.AreaMonitorFeatures', 'QGeoAreaMonitorSource.AreaMonitorFeature', int]) -> 'QGeoAreaMonitorSource.AreaMonitorFeatures': ... + def __ror__ (self, other: 'QGeoAreaMonitorSource.AreaMonitorFeature') -> 'QGeoAreaMonitorSource.AreaMonitorFeatures': ... + def __rand__(self, other: 'QGeoAreaMonitorSource.AreaMonitorFeature') -> 'QGeoAreaMonitorSource.AreaMonitorFeatures': ... + def __rxor__(self, other: 'QGeoAreaMonitorSource.AreaMonitorFeature') -> 'QGeoAreaMonitorSource.AreaMonitorFeatures': ... def __init__(self, parent: QtCore.QObject) -> None: ... diff --git a/tests/qflags/test_QtPositioning_AreaMonitorFeatures_AreaMonitorFeature.py b/tests/qflags/test_QtPositioning_AreaMonitorFeatures_AreaMonitorFeature.py new file mode 100644 index 00000000..066c4240 --- /dev/null +++ b/tests/qflags/test_QtPositioning_AreaMonitorFeatures_AreaMonitorFeature.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoAreaMonitorSource.AreaMonitorFeatures" and flag class "QGeoAreaMonitorSource.AreaMonitorFeature" +from PyQt5 import QtPositioning + +OneFlagClass = QtPositioning.QGeoAreaMonitorSource.AreaMonitorFeature +MultiFlagClass = QtPositioning.QGeoAreaMonitorSource.AreaMonitorFeatures + +oneFlagRefValue1 = QtPositioning.QGeoAreaMonitorSource.AreaMonitorFeature.PersistentAreaMonitorFeature +oneFlagRefValue2 = QtPositioning.QGeoAreaMonitorSource.AreaMonitorFeature.AnyAreaMonitorFeature + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 29ab157d1d3d0b38c295e7369bd525a3f253da09 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:07:25 +0100 Subject: [PATCH 331/421] QFlag operations for QGeoRouteRequest.TravelModes, QGeoRouteRequest.TravelMode in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + .../test_QtLocation_TravelModes_TravelMode.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_TravelModes_TravelMode.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index bcd8b448..b3b5490b 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -307,6 +307,9 @@ class QGeoRouteRequest(sip.simplewrapper): TrafficFeature = ... # type: QGeoRouteRequest.FeatureType class TravelMode(int): + def __or__ (self, other: 'QGeoRouteRequest.TravelMode') -> 'QGeoRouteRequest.TravelModes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoRouteRequest.TravelModes': ... # type: ignore[override, misc] + CarTravel = ... # type: QGeoRouteRequest.TravelMode PedestrianTravel = ... # type: QGeoRouteRequest.TravelMode BicycleTravel = ... # type: QGeoRouteRequest.TravelMode @@ -327,12 +330,20 @@ class QGeoRouteRequest(sip.simplewrapper): def __init__(self, f: typing.Union['QGeoRouteRequest.TravelModes', 'QGeoRouteRequest.TravelMode']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoRouteRequest.TravelModes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoRouteRequest.TravelModes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoRouteRequest.TravelModes', 'QGeoRouteRequest.TravelMode', int]) -> 'QGeoRouteRequest.TravelModes': ... + def __and__(self, other: typing.Union['QGeoRouteRequest.TravelModes', 'QGeoRouteRequest.TravelMode', int]) -> 'QGeoRouteRequest.TravelModes': ... + def __xor__(self, other: typing.Union['QGeoRouteRequest.TravelModes', 'QGeoRouteRequest.TravelMode', int]) -> 'QGeoRouteRequest.TravelModes': ... + def __ror__ (self, other: 'QGeoRouteRequest.TravelMode') -> 'QGeoRouteRequest.TravelModes': ... + def __rand__(self, other: 'QGeoRouteRequest.TravelMode') -> 'QGeoRouteRequest.TravelModes': ... + def __rxor__(self, other: 'QGeoRouteRequest.TravelMode') -> 'QGeoRouteRequest.TravelModes': ... class FeatureTypes(sip.simplewrapper): diff --git a/tests/qflags/test_QtLocation_TravelModes_TravelMode.py b/tests/qflags/test_QtLocation_TravelModes_TravelMode.py new file mode 100644 index 00000000..472101f9 --- /dev/null +++ b/tests/qflags/test_QtLocation_TravelModes_TravelMode.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoRouteRequest.TravelModes" and flag class "QGeoRouteRequest.TravelMode" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QGeoRouteRequest.TravelMode +MultiFlagClass = QtLocation.QGeoRouteRequest.TravelModes + +oneFlagRefValue1 = QtLocation.QGeoRouteRequest.TravelMode.CarTravel +oneFlagRefValue2 = QtLocation.QGeoRouteRequest.TravelMode.PedestrianTravel + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 250ad55b29edc38c4658068b17d5c6ec3de41090 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:07:44 +0100 Subject: [PATCH 332/421] QFlag operations for QGeoRouteRequest.FeatureTypes, QGeoRouteRequest.FeatureType in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + ...est_QtLocation_FeatureTypes_FeatureType.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_FeatureTypes_FeatureType.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index b3b5490b..f8672172 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -284,6 +284,9 @@ class QGeoRouteRequest(sip.simplewrapper): DisallowFeatureWeight = ... # type: QGeoRouteRequest.FeatureWeight class FeatureType(int): + def __or__ (self, other: 'QGeoRouteRequest.FeatureType') -> 'QGeoRouteRequest.FeatureTypes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoRouteRequest.FeatureTypes': ... # type: ignore[override, misc] + NoFeature = ... # type: QGeoRouteRequest.FeatureType TollFeature = ... # type: QGeoRouteRequest.FeatureType HighwayFeature = ... # type: QGeoRouteRequest.FeatureType @@ -353,12 +356,20 @@ class QGeoRouteRequest(sip.simplewrapper): def __init__(self, f: typing.Union['QGeoRouteRequest.FeatureTypes', 'QGeoRouteRequest.FeatureType']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoRouteRequest.FeatureTypes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoRouteRequest.FeatureTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoRouteRequest.FeatureTypes', 'QGeoRouteRequest.FeatureType', int]) -> 'QGeoRouteRequest.FeatureTypes': ... + def __and__(self, other: typing.Union['QGeoRouteRequest.FeatureTypes', 'QGeoRouteRequest.FeatureType', int]) -> 'QGeoRouteRequest.FeatureTypes': ... + def __xor__(self, other: typing.Union['QGeoRouteRequest.FeatureTypes', 'QGeoRouteRequest.FeatureType', int]) -> 'QGeoRouteRequest.FeatureTypes': ... + def __ror__ (self, other: 'QGeoRouteRequest.FeatureType') -> 'QGeoRouteRequest.FeatureTypes': ... + def __rand__(self, other: 'QGeoRouteRequest.FeatureType') -> 'QGeoRouteRequest.FeatureTypes': ... + def __rxor__(self, other: 'QGeoRouteRequest.FeatureType') -> 'QGeoRouteRequest.FeatureTypes': ... class FeatureWeights(sip.simplewrapper): diff --git a/tests/qflags/test_QtLocation_FeatureTypes_FeatureType.py b/tests/qflags/test_QtLocation_FeatureTypes_FeatureType.py new file mode 100644 index 00000000..39a84147 --- /dev/null +++ b/tests/qflags/test_QtLocation_FeatureTypes_FeatureType.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoRouteRequest.FeatureTypes" and flag class "QGeoRouteRequest.FeatureType" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QGeoRouteRequest.FeatureType +MultiFlagClass = QtLocation.QGeoRouteRequest.FeatureTypes + +oneFlagRefValue1 = QtLocation.QGeoRouteRequest.FeatureType.NoFeature +oneFlagRefValue2 = QtLocation.QGeoRouteRequest.FeatureType.TollFeature + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 81ac940c40863d734ae2d422eea02ffc01406741 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:08:02 +0100 Subject: [PATCH 333/421] QFlag operations for QGeoRouteRequest.FeatureWeights, QGeoRouteRequest.FeatureWeight in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + ...QtLocation_FeatureWeights_FeatureWeight.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_FeatureWeights_FeatureWeight.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index f8672172..e2795189 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -271,6 +271,9 @@ class QGeoRouteRequest(sip.simplewrapper): MostScenicRoute = ... # type: QGeoRouteRequest.RouteOptimization class FeatureWeight(int): + def __or__ (self, other: 'QGeoRouteRequest.FeatureWeight') -> 'QGeoRouteRequest.FeatureWeights': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoRouteRequest.FeatureWeights': ... # type: ignore[override, misc] + NeutralFeatureWeight = ... # type: QGeoRouteRequest.FeatureWeight PreferFeatureWeight = ... # type: QGeoRouteRequest.FeatureWeight RequireFeatureWeight = ... # type: QGeoRouteRequest.FeatureWeight @@ -379,12 +382,20 @@ class QGeoRouteRequest(sip.simplewrapper): def __init__(self, f: typing.Union['QGeoRouteRequest.FeatureWeights', 'QGeoRouteRequest.FeatureWeight']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoRouteRequest.FeatureWeights') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoRouteRequest.FeatureWeights': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoRouteRequest.FeatureWeights', 'QGeoRouteRequest.FeatureWeight', int]) -> 'QGeoRouteRequest.FeatureWeights': ... + def __and__(self, other: typing.Union['QGeoRouteRequest.FeatureWeights', 'QGeoRouteRequest.FeatureWeight', int]) -> 'QGeoRouteRequest.FeatureWeights': ... + def __xor__(self, other: typing.Union['QGeoRouteRequest.FeatureWeights', 'QGeoRouteRequest.FeatureWeight', int]) -> 'QGeoRouteRequest.FeatureWeights': ... + def __ror__ (self, other: 'QGeoRouteRequest.FeatureWeight') -> 'QGeoRouteRequest.FeatureWeights': ... + def __rand__(self, other: 'QGeoRouteRequest.FeatureWeight') -> 'QGeoRouteRequest.FeatureWeights': ... + def __rxor__(self, other: 'QGeoRouteRequest.FeatureWeight') -> 'QGeoRouteRequest.FeatureWeights': ... class RouteOptimizations(sip.simplewrapper): diff --git a/tests/qflags/test_QtLocation_FeatureWeights_FeatureWeight.py b/tests/qflags/test_QtLocation_FeatureWeights_FeatureWeight.py new file mode 100644 index 00000000..aba2845a --- /dev/null +++ b/tests/qflags/test_QtLocation_FeatureWeights_FeatureWeight.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoRouteRequest.FeatureWeights" and flag class "QGeoRouteRequest.FeatureWeight" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QGeoRouteRequest.FeatureWeight +MultiFlagClass = QtLocation.QGeoRouteRequest.FeatureWeights + +oneFlagRefValue1 = QtLocation.QGeoRouteRequest.FeatureWeight.NeutralFeatureWeight +oneFlagRefValue2 = QtLocation.QGeoRouteRequest.FeatureWeight.PreferFeatureWeight + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From bb4b78b7c0dc2dc16b41966562ef96b010b31719 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:08:21 +0100 Subject: [PATCH 334/421] QFlag operations for QGeoRouteRequest.RouteOptimizations, QGeoRouteRequest.RouteOptimization in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + ...on_RouteOptimizations_RouteOptimization.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_RouteOptimizations_RouteOptimization.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index e2795189..78fa03f5 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -260,6 +260,9 @@ class QGeoRouteRequest(sip.simplewrapper): BasicSegmentData = ... # type: QGeoRouteRequest.SegmentDetail class RouteOptimization(int): + def __or__ (self, other: 'QGeoRouteRequest.RouteOptimization') -> 'QGeoRouteRequest.RouteOptimizations': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoRouteRequest.RouteOptimizations': ... # type: ignore[override, misc] + ShortestRoute = ... # type: QGeoRouteRequest.RouteOptimization FastestRoute = ... # type: QGeoRouteRequest.RouteOptimization MostEconomicRoute = ... # type: QGeoRouteRequest.RouteOptimization @@ -405,12 +408,20 @@ class QGeoRouteRequest(sip.simplewrapper): def __init__(self, f: typing.Union['QGeoRouteRequest.RouteOptimizations', 'QGeoRouteRequest.RouteOptimization']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoRouteRequest.RouteOptimizations') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoRouteRequest.RouteOptimizations': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoRouteRequest.RouteOptimizations', 'QGeoRouteRequest.RouteOptimization', int]) -> 'QGeoRouteRequest.RouteOptimizations': ... + def __and__(self, other: typing.Union['QGeoRouteRequest.RouteOptimizations', 'QGeoRouteRequest.RouteOptimization', int]) -> 'QGeoRouteRequest.RouteOptimizations': ... + def __xor__(self, other: typing.Union['QGeoRouteRequest.RouteOptimizations', 'QGeoRouteRequest.RouteOptimization', int]) -> 'QGeoRouteRequest.RouteOptimizations': ... + def __ror__ (self, other: 'QGeoRouteRequest.RouteOptimization') -> 'QGeoRouteRequest.RouteOptimizations': ... + def __rand__(self, other: 'QGeoRouteRequest.RouteOptimization') -> 'QGeoRouteRequest.RouteOptimizations': ... + def __rxor__(self, other: 'QGeoRouteRequest.RouteOptimization') -> 'QGeoRouteRequest.RouteOptimizations': ... class SegmentDetails(sip.simplewrapper): diff --git a/tests/qflags/test_QtLocation_RouteOptimizations_RouteOptimization.py b/tests/qflags/test_QtLocation_RouteOptimizations_RouteOptimization.py new file mode 100644 index 00000000..3587be58 --- /dev/null +++ b/tests/qflags/test_QtLocation_RouteOptimizations_RouteOptimization.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoRouteRequest.RouteOptimizations" and flag class "QGeoRouteRequest.RouteOptimization" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QGeoRouteRequest.RouteOptimization +MultiFlagClass = QtLocation.QGeoRouteRequest.RouteOptimizations + +oneFlagRefValue1 = QtLocation.QGeoRouteRequest.RouteOptimization.ShortestRoute +oneFlagRefValue2 = QtLocation.QGeoRouteRequest.RouteOptimization.FastestRoute + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 50d1f97ff0c1561d91b671fc1d46062c449547c5 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:08:38 +0100 Subject: [PATCH 335/421] QFlag operations for QGeoRouteRequest.SegmentDetails, QGeoRouteRequest.SegmentDetail in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + ...QtLocation_SegmentDetails_SegmentDetail.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_SegmentDetails_SegmentDetail.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index 78fa03f5..a97fb5c8 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -253,6 +253,9 @@ class QGeoRouteRequest(sip.simplewrapper): BasicManeuvers = ... # type: QGeoRouteRequest.ManeuverDetail class SegmentDetail(int): + def __or__ (self, other: 'QGeoRouteRequest.SegmentDetail') -> 'QGeoRouteRequest.SegmentDetails': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoRouteRequest.SegmentDetails': ... # type: ignore[override, misc] + NoSegmentData = ... # type: QGeoRouteRequest.SegmentDetail BasicSegmentData = ... # type: QGeoRouteRequest.SegmentDetail @@ -431,12 +434,20 @@ class QGeoRouteRequest(sip.simplewrapper): def __init__(self, f: typing.Union['QGeoRouteRequest.SegmentDetails', 'QGeoRouteRequest.SegmentDetail']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoRouteRequest.SegmentDetails') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoRouteRequest.SegmentDetails': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoRouteRequest.SegmentDetails', 'QGeoRouteRequest.SegmentDetail', int]) -> 'QGeoRouteRequest.SegmentDetails': ... + def __and__(self, other: typing.Union['QGeoRouteRequest.SegmentDetails', 'QGeoRouteRequest.SegmentDetail', int]) -> 'QGeoRouteRequest.SegmentDetails': ... + def __xor__(self, other: typing.Union['QGeoRouteRequest.SegmentDetails', 'QGeoRouteRequest.SegmentDetail', int]) -> 'QGeoRouteRequest.SegmentDetails': ... + def __ror__ (self, other: 'QGeoRouteRequest.SegmentDetail') -> 'QGeoRouteRequest.SegmentDetails': ... + def __rand__(self, other: 'QGeoRouteRequest.SegmentDetail') -> 'QGeoRouteRequest.SegmentDetails': ... + def __rxor__(self, other: 'QGeoRouteRequest.SegmentDetail') -> 'QGeoRouteRequest.SegmentDetails': ... class ManeuverDetails(sip.simplewrapper): diff --git a/tests/qflags/test_QtLocation_SegmentDetails_SegmentDetail.py b/tests/qflags/test_QtLocation_SegmentDetails_SegmentDetail.py new file mode 100644 index 00000000..693260e5 --- /dev/null +++ b/tests/qflags/test_QtLocation_SegmentDetails_SegmentDetail.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoRouteRequest.SegmentDetails" and flag class "QGeoRouteRequest.SegmentDetail" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QGeoRouteRequest.SegmentDetail +MultiFlagClass = QtLocation.QGeoRouteRequest.SegmentDetails + +oneFlagRefValue1 = QtLocation.QGeoRouteRequest.SegmentDetail.NoSegmentData +oneFlagRefValue2 = QtLocation.QGeoRouteRequest.SegmentDetail.BasicSegmentData + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 141b2067ecab1202235bb825e39ccabd85c93f8b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:08:57 +0100 Subject: [PATCH 336/421] QFlag operations for QGeoRouteRequest.ManeuverDetails, QGeoRouteRequest.ManeuverDetail in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + ...Location_ManeuverDetails_ManeuverDetail.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_ManeuverDetails_ManeuverDetail.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index a97fb5c8..5a158646 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -246,6 +246,9 @@ class QGeoRouteReply(QtCore.QObject): class QGeoRouteRequest(sip.simplewrapper): class ManeuverDetail(int): + def __or__ (self, other: 'QGeoRouteRequest.ManeuverDetail') -> 'QGeoRouteRequest.ManeuverDetails': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoRouteRequest.ManeuverDetails': ... # type: ignore[override, misc] + NoManeuvers = ... # type: QGeoRouteRequest.ManeuverDetail BasicManeuvers = ... # type: QGeoRouteRequest.ManeuverDetail @@ -457,12 +460,20 @@ class QGeoRouteRequest(sip.simplewrapper): def __init__(self, f: typing.Union['QGeoRouteRequest.ManeuverDetails', 'QGeoRouteRequest.ManeuverDetail']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoRouteRequest.ManeuverDetails') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoRouteRequest.ManeuverDetails': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoRouteRequest.ManeuverDetails', 'QGeoRouteRequest.ManeuverDetail', int]) -> 'QGeoRouteRequest.ManeuverDetails': ... + def __and__(self, other: typing.Union['QGeoRouteRequest.ManeuverDetails', 'QGeoRouteRequest.ManeuverDetail', int]) -> 'QGeoRouteRequest.ManeuverDetails': ... + def __xor__(self, other: typing.Union['QGeoRouteRequest.ManeuverDetails', 'QGeoRouteRequest.ManeuverDetail', int]) -> 'QGeoRouteRequest.ManeuverDetails': ... + def __ror__ (self, other: 'QGeoRouteRequest.ManeuverDetail') -> 'QGeoRouteRequest.ManeuverDetails': ... + def __rand__(self, other: 'QGeoRouteRequest.ManeuverDetail') -> 'QGeoRouteRequest.ManeuverDetails': ... + def __rxor__(self, other: 'QGeoRouteRequest.ManeuverDetail') -> 'QGeoRouteRequest.ManeuverDetails': ... @typing.overload def __init__(self, waypoints: typing.Iterable[QtPositioning.QGeoCoordinate] = ...) -> None: ... diff --git a/tests/qflags/test_QtLocation_ManeuverDetails_ManeuverDetail.py b/tests/qflags/test_QtLocation_ManeuverDetails_ManeuverDetail.py new file mode 100644 index 00000000..8c48f8a2 --- /dev/null +++ b/tests/qflags/test_QtLocation_ManeuverDetails_ManeuverDetail.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoRouteRequest.ManeuverDetails" and flag class "QGeoRouteRequest.ManeuverDetail" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QGeoRouteRequest.ManeuverDetail +MultiFlagClass = QtLocation.QGeoRouteRequest.ManeuverDetails + +oneFlagRefValue1 = QtLocation.QGeoRouteRequest.ManeuverDetail.NoManeuvers +oneFlagRefValue2 = QtLocation.QGeoRouteRequest.ManeuverDetail.BasicManeuvers + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From c9d370ebb914b40183e4a007c70a26c11bddc808 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:09:21 +0100 Subject: [PATCH 337/421] QFlag operations for QGeoServiceProvider.RoutingFeatures, QGeoServiceProvider.RoutingFeature in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + ...Location_RoutingFeatures_RoutingFeature.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_RoutingFeatures_RoutingFeature.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index 5a158646..61ff47ad 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -650,6 +650,9 @@ class QGeoServiceProvider(QtCore.QObject): AnyGeocodingFeatures = ... # type: QGeoServiceProvider.GeocodingFeature class RoutingFeature(int): + def __or__ (self, other: 'QGeoServiceProvider.RoutingFeature') -> 'QGeoServiceProvider.RoutingFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoServiceProvider.RoutingFeatures': ... # type: ignore[override, misc] + NoRoutingFeatures = ... # type: QGeoServiceProvider.RoutingFeature OnlineRoutingFeature = ... # type: QGeoServiceProvider.RoutingFeature OfflineRoutingFeature = ... # type: QGeoServiceProvider.RoutingFeature @@ -691,12 +694,20 @@ class QGeoServiceProvider(QtCore.QObject): def __init__(self, f: typing.Union['QGeoServiceProvider.RoutingFeatures', 'QGeoServiceProvider.RoutingFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoServiceProvider.RoutingFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoServiceProvider.RoutingFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoServiceProvider.RoutingFeatures', 'QGeoServiceProvider.RoutingFeature', int]) -> 'QGeoServiceProvider.RoutingFeatures': ... + def __and__(self, other: typing.Union['QGeoServiceProvider.RoutingFeatures', 'QGeoServiceProvider.RoutingFeature', int]) -> 'QGeoServiceProvider.RoutingFeatures': ... + def __xor__(self, other: typing.Union['QGeoServiceProvider.RoutingFeatures', 'QGeoServiceProvider.RoutingFeature', int]) -> 'QGeoServiceProvider.RoutingFeatures': ... + def __ror__ (self, other: 'QGeoServiceProvider.RoutingFeature') -> 'QGeoServiceProvider.RoutingFeatures': ... + def __rand__(self, other: 'QGeoServiceProvider.RoutingFeature') -> 'QGeoServiceProvider.RoutingFeatures': ... + def __rxor__(self, other: 'QGeoServiceProvider.RoutingFeature') -> 'QGeoServiceProvider.RoutingFeatures': ... class GeocodingFeatures(sip.simplewrapper): diff --git a/tests/qflags/test_QtLocation_RoutingFeatures_RoutingFeature.py b/tests/qflags/test_QtLocation_RoutingFeatures_RoutingFeature.py new file mode 100644 index 00000000..2a730201 --- /dev/null +++ b/tests/qflags/test_QtLocation_RoutingFeatures_RoutingFeature.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoServiceProvider.RoutingFeatures" and flag class "QGeoServiceProvider.RoutingFeature" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QGeoServiceProvider.RoutingFeature +MultiFlagClass = QtLocation.QGeoServiceProvider.RoutingFeatures + +oneFlagRefValue1 = QtLocation.QGeoServiceProvider.RoutingFeature.NoRoutingFeatures +oneFlagRefValue2 = QtLocation.QGeoServiceProvider.RoutingFeature.OnlineRoutingFeature + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 17de6e89ae7dad3eb2e5cb38e9cbdcc366f20340 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:09:40 +0100 Subject: [PATCH 338/421] QFlag operations for QGeoServiceProvider.GeocodingFeatures, QGeoServiceProvider.GeocodingFeature in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + ...tion_GeocodingFeatures_GeocodingFeature.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_GeocodingFeatures_GeocodingFeature.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index 61ff47ad..e140ce33 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -635,6 +635,9 @@ class QGeoServiceProvider(QtCore.QObject): AnyMappingFeatures = ... # type: QGeoServiceProvider.MappingFeature class GeocodingFeature(int): + def __or__ (self, other: 'QGeoServiceProvider.GeocodingFeature') -> 'QGeoServiceProvider.GeocodingFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoServiceProvider.GeocodingFeatures': ... # type: ignore[override, misc] + NoGeocodingFeatures = ... # type: QGeoServiceProvider.GeocodingFeature OnlineGeocodingFeature = ... # type: QGeoServiceProvider.GeocodingFeature OfflineGeocodingFeature = ... # type: QGeoServiceProvider.GeocodingFeature @@ -717,12 +720,20 @@ class QGeoServiceProvider(QtCore.QObject): def __init__(self, f: typing.Union['QGeoServiceProvider.GeocodingFeatures', 'QGeoServiceProvider.GeocodingFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoServiceProvider.GeocodingFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoServiceProvider.GeocodingFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoServiceProvider.GeocodingFeatures', 'QGeoServiceProvider.GeocodingFeature', int]) -> 'QGeoServiceProvider.GeocodingFeatures': ... + def __and__(self, other: typing.Union['QGeoServiceProvider.GeocodingFeatures', 'QGeoServiceProvider.GeocodingFeature', int]) -> 'QGeoServiceProvider.GeocodingFeatures': ... + def __xor__(self, other: typing.Union['QGeoServiceProvider.GeocodingFeatures', 'QGeoServiceProvider.GeocodingFeature', int]) -> 'QGeoServiceProvider.GeocodingFeatures': ... + def __ror__ (self, other: 'QGeoServiceProvider.GeocodingFeature') -> 'QGeoServiceProvider.GeocodingFeatures': ... + def __rand__(self, other: 'QGeoServiceProvider.GeocodingFeature') -> 'QGeoServiceProvider.GeocodingFeatures': ... + def __rxor__(self, other: 'QGeoServiceProvider.GeocodingFeature') -> 'QGeoServiceProvider.GeocodingFeatures': ... class MappingFeatures(sip.simplewrapper): diff --git a/tests/qflags/test_QtLocation_GeocodingFeatures_GeocodingFeature.py b/tests/qflags/test_QtLocation_GeocodingFeatures_GeocodingFeature.py new file mode 100644 index 00000000..1080e987 --- /dev/null +++ b/tests/qflags/test_QtLocation_GeocodingFeatures_GeocodingFeature.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoServiceProvider.GeocodingFeatures" and flag class "QGeoServiceProvider.GeocodingFeature" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QGeoServiceProvider.GeocodingFeature +MultiFlagClass = QtLocation.QGeoServiceProvider.GeocodingFeatures + +oneFlagRefValue1 = QtLocation.QGeoServiceProvider.GeocodingFeature.NoGeocodingFeatures +oneFlagRefValue2 = QtLocation.QGeoServiceProvider.GeocodingFeature.OnlineGeocodingFeature + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 06cdbeeb14c7744fdc527266827e6fb9501a1887 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:09:58 +0100 Subject: [PATCH 339/421] QFlag operations for QGeoServiceProvider.MappingFeatures, QGeoServiceProvider.MappingFeature in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + ...Location_MappingFeatures_MappingFeature.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_MappingFeatures_MappingFeature.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index e140ce33..3a8c4fc3 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -622,6 +622,9 @@ class QGeoServiceProvider(QtCore.QObject): AnyPlacesFeatures = ... # type: QGeoServiceProvider.PlacesFeature class MappingFeature(int): + def __or__ (self, other: 'QGeoServiceProvider.MappingFeature') -> 'QGeoServiceProvider.MappingFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoServiceProvider.MappingFeatures': ... # type: ignore[override, misc] + NoMappingFeatures = ... # type: QGeoServiceProvider.MappingFeature OnlineMappingFeature = ... # type: QGeoServiceProvider.MappingFeature OfflineMappingFeature = ... # type: QGeoServiceProvider.MappingFeature @@ -743,12 +746,20 @@ class QGeoServiceProvider(QtCore.QObject): def __init__(self, f: typing.Union['QGeoServiceProvider.MappingFeatures', 'QGeoServiceProvider.MappingFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoServiceProvider.MappingFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoServiceProvider.MappingFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoServiceProvider.MappingFeatures', 'QGeoServiceProvider.MappingFeature', int]) -> 'QGeoServiceProvider.MappingFeatures': ... + def __and__(self, other: typing.Union['QGeoServiceProvider.MappingFeatures', 'QGeoServiceProvider.MappingFeature', int]) -> 'QGeoServiceProvider.MappingFeatures': ... + def __xor__(self, other: typing.Union['QGeoServiceProvider.MappingFeatures', 'QGeoServiceProvider.MappingFeature', int]) -> 'QGeoServiceProvider.MappingFeatures': ... + def __ror__ (self, other: 'QGeoServiceProvider.MappingFeature') -> 'QGeoServiceProvider.MappingFeatures': ... + def __rand__(self, other: 'QGeoServiceProvider.MappingFeature') -> 'QGeoServiceProvider.MappingFeatures': ... + def __rxor__(self, other: 'QGeoServiceProvider.MappingFeature') -> 'QGeoServiceProvider.MappingFeatures': ... class PlacesFeatures(sip.simplewrapper): diff --git a/tests/qflags/test_QtLocation_MappingFeatures_MappingFeature.py b/tests/qflags/test_QtLocation_MappingFeatures_MappingFeature.py new file mode 100644 index 00000000..add03fb7 --- /dev/null +++ b/tests/qflags/test_QtLocation_MappingFeatures_MappingFeature.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoServiceProvider.MappingFeatures" and flag class "QGeoServiceProvider.MappingFeature" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QGeoServiceProvider.MappingFeature +MultiFlagClass = QtLocation.QGeoServiceProvider.MappingFeatures + +oneFlagRefValue1 = QtLocation.QGeoServiceProvider.MappingFeature.NoMappingFeatures +oneFlagRefValue2 = QtLocation.QGeoServiceProvider.MappingFeature.OnlineMappingFeature + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 523aff752082518da76a5f6611ebfc68885e8b37 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:10:16 +0100 Subject: [PATCH 340/421] QFlag operations for QGeoServiceProvider.PlacesFeatures, QGeoServiceProvider.PlacesFeature in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + ...QtLocation_PlacesFeatures_PlacesFeature.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_PlacesFeatures_PlacesFeature.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index 3a8c4fc3..c5bdc1b1 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -593,6 +593,9 @@ class QGeoServiceProvider(QtCore.QObject): AnyNavigationFeatures = ... # type: QGeoServiceProvider.NavigationFeature class PlacesFeature(int): + def __or__ (self, other: 'QGeoServiceProvider.PlacesFeature') -> 'QGeoServiceProvider.PlacesFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoServiceProvider.PlacesFeatures': ... # type: ignore[override, misc] + NoPlacesFeatures = ... # type: QGeoServiceProvider.PlacesFeature OnlinePlacesFeature = ... # type: QGeoServiceProvider.PlacesFeature OfflinePlacesFeature = ... # type: QGeoServiceProvider.PlacesFeature @@ -769,12 +772,20 @@ class QGeoServiceProvider(QtCore.QObject): def __init__(self, f: typing.Union['QGeoServiceProvider.PlacesFeatures', 'QGeoServiceProvider.PlacesFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoServiceProvider.PlacesFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoServiceProvider.PlacesFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoServiceProvider.PlacesFeatures', 'QGeoServiceProvider.PlacesFeature', int]) -> 'QGeoServiceProvider.PlacesFeatures': ... + def __and__(self, other: typing.Union['QGeoServiceProvider.PlacesFeatures', 'QGeoServiceProvider.PlacesFeature', int]) -> 'QGeoServiceProvider.PlacesFeatures': ... + def __xor__(self, other: typing.Union['QGeoServiceProvider.PlacesFeatures', 'QGeoServiceProvider.PlacesFeature', int]) -> 'QGeoServiceProvider.PlacesFeatures': ... + def __ror__ (self, other: 'QGeoServiceProvider.PlacesFeature') -> 'QGeoServiceProvider.PlacesFeatures': ... + def __rand__(self, other: 'QGeoServiceProvider.PlacesFeature') -> 'QGeoServiceProvider.PlacesFeatures': ... + def __rxor__(self, other: 'QGeoServiceProvider.PlacesFeature') -> 'QGeoServiceProvider.PlacesFeatures': ... class NavigationFeatures(sip.simplewrapper): diff --git a/tests/qflags/test_QtLocation_PlacesFeatures_PlacesFeature.py b/tests/qflags/test_QtLocation_PlacesFeatures_PlacesFeature.py new file mode 100644 index 00000000..38cc9181 --- /dev/null +++ b/tests/qflags/test_QtLocation_PlacesFeatures_PlacesFeature.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoServiceProvider.PlacesFeatures" and flag class "QGeoServiceProvider.PlacesFeature" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QGeoServiceProvider.PlacesFeature +MultiFlagClass = QtLocation.QGeoServiceProvider.PlacesFeatures + +oneFlagRefValue1 = QtLocation.QGeoServiceProvider.PlacesFeature.NoPlacesFeatures +oneFlagRefValue2 = QtLocation.QGeoServiceProvider.PlacesFeature.OnlinePlacesFeature + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From d8655ebb96560ec1ef45dfa913a0d3d7c6c38fca Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:10:35 +0100 Subject: [PATCH 341/421] QFlag operations for QGeoServiceProvider.NavigationFeatures, QGeoServiceProvider.NavigationFeature in module QtLocation --- PyQt5-stubs/QtLocation.pyi | 11 + ...on_NavigationFeatures_NavigationFeature.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtLocation_NavigationFeatures_NavigationFeature.py diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index c5bdc1b1..dd44aceb 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -582,6 +582,9 @@ class QNavigationManager(sip.simplewrapper): ... class QGeoServiceProvider(QtCore.QObject): class NavigationFeature(int): + def __or__ (self, other: 'QGeoServiceProvider.NavigationFeature') -> 'QGeoServiceProvider.NavigationFeatures': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QGeoServiceProvider.NavigationFeatures': ... # type: ignore[override, misc] + NoNavigationFeatures = ... # type: QGeoServiceProvider.NavigationFeature OnlineNavigationFeature = ... # type: QGeoServiceProvider.NavigationFeature OfflineNavigationFeature = ... # type: QGeoServiceProvider.NavigationFeature @@ -795,12 +798,20 @@ class QGeoServiceProvider(QtCore.QObject): def __init__(self, f: typing.Union['QGeoServiceProvider.NavigationFeatures', 'QGeoServiceProvider.NavigationFeature']) -> None: ... @typing.overload def __init__(self, a0: 'QGeoServiceProvider.NavigationFeatures') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QGeoServiceProvider.NavigationFeatures': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QGeoServiceProvider.NavigationFeatures', 'QGeoServiceProvider.NavigationFeature', int]) -> 'QGeoServiceProvider.NavigationFeatures': ... + def __and__(self, other: typing.Union['QGeoServiceProvider.NavigationFeatures', 'QGeoServiceProvider.NavigationFeature', int]) -> 'QGeoServiceProvider.NavigationFeatures': ... + def __xor__(self, other: typing.Union['QGeoServiceProvider.NavigationFeatures', 'QGeoServiceProvider.NavigationFeature', int]) -> 'QGeoServiceProvider.NavigationFeatures': ... + def __ror__ (self, other: 'QGeoServiceProvider.NavigationFeature') -> 'QGeoServiceProvider.NavigationFeatures': ... + def __rand__(self, other: 'QGeoServiceProvider.NavigationFeature') -> 'QGeoServiceProvider.NavigationFeatures': ... + def __rxor__(self, other: 'QGeoServiceProvider.NavigationFeature') -> 'QGeoServiceProvider.NavigationFeatures': ... def __init__(self, providerName: str, parameters: typing.Dict[str, typing.Any] = ..., allowExperimental: bool = ...) -> None: ... diff --git a/tests/qflags/test_QtLocation_NavigationFeatures_NavigationFeature.py b/tests/qflags/test_QtLocation_NavigationFeatures_NavigationFeature.py new file mode 100644 index 00000000..e31cddbc --- /dev/null +++ b/tests/qflags/test_QtLocation_NavigationFeatures_NavigationFeature.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QGeoServiceProvider.NavigationFeatures" and flag class "QGeoServiceProvider.NavigationFeature" +from PyQt5 import QtLocation + +OneFlagClass = QtLocation.QGeoServiceProvider.NavigationFeature +MultiFlagClass = QtLocation.QGeoServiceProvider.NavigationFeatures + +oneFlagRefValue1 = QtLocation.QGeoServiceProvider.NavigationFeature.NoNavigationFeatures +oneFlagRefValue2 = QtLocation.QGeoServiceProvider.NavigationFeature.OnlineNavigationFeature + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 84b66c6aee919a33395833cb541fd9eecae4d5a9 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:13:20 +0100 Subject: [PATCH 342/421] Remove non relevant grep results --- tests/qflags/grep-results/qtlottie-qflag-grep-result.txt | 0 tests/qflags/grep-results/qtmacextras-qflag-grep-result.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/qflags/grep-results/qtlottie-qflag-grep-result.txt delete mode 100644 tests/qflags/grep-results/qtmacextras-qflag-grep-result.txt diff --git a/tests/qflags/grep-results/qtlottie-qflag-grep-result.txt b/tests/qflags/grep-results/qtlottie-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/qflags/grep-results/qtmacextras-qflag-grep-result.txt b/tests/qflags/grep-results/qtmacextras-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 From bf355ec14cca2cf9bb750a4ae0d7140fb3b1bf09 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:13:42 +0100 Subject: [PATCH 343/421] Qt location processing results --- tests/qflags/qflags_process_result.json | 306 ++++++++++++++++++++++++ tests/qflags/qflags_to_process.json | 15 ++ 2 files changed, 321 insertions(+) diff --git a/tests/qflags/qflags_process_result.json b/tests/qflags/qflags_process_result.json index 5a5121ac..24967afa 100644 --- a/tests/qflags/qflags_process_result.json +++ b/tests/qflags/qflags_process_result.json @@ -3442,6 +3442,312 @@ "or_int_converts_to_multi": false, "int_or_converts_to_multi": true, "supports_one_op_multi": true + }, + { + "qflag_class": "VisibilityScope", + "enum_class": "Visibility", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\qlocation.h:Q_DECLARE_FLAGS(VisibilityScope, Visibility)" + ], + "qflag_full_class_name": "QLocation.VisibilityScope", + "enum_full_class_name": "QLocation.Visibility", + "enum_value1": "UnspecifiedVisibility", + "enum_value2": "DeviceVisibility", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "PositioningMethods", + "enum_class": "PositioningMethod", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\positioningquick\\qdeclarativepositionsource_p.h: Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod)", + "src\\positioning\\qgeopositioninfosource.h: Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod)" + ], + "qflag_full_class_name": "QGeoPositionInfoSource.PositioningMethods", + "enum_full_class_name": "QGeoPositionInfoSource.PositioningMethod", + "enum_value1": "NoPositioningMethods", + "enum_value2": "SatellitePositioningMethods", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPositioning", + "module_path": "../../PyQt5-stubs/QtPositioning.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "AreaMonitorFeatures", + "enum_class": "AreaMonitorFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\positioning\\qgeoareamonitorsource.h: Q_DECLARE_FLAGS(AreaMonitorFeatures, AreaMonitorFeature)" + ], + "qflag_full_class_name": "QGeoAreaMonitorSource.AreaMonitorFeatures", + "enum_full_class_name": "QGeoAreaMonitorSource.AreaMonitorFeature", + "enum_value1": "PersistentAreaMonitorFeature", + "enum_value2": "AnyAreaMonitorFeature", + "module_count": 1, + "module_idx": 0, + "module_name": "QtPositioning", + "module_path": "../../PyQt5-stubs/QtPositioning.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "TravelModes", + "enum_class": "TravelMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(TravelModes, TravelMode)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(TravelModes, TravelMode)" + ], + "qflag_full_class_name": "QGeoRouteRequest.TravelModes", + "enum_full_class_name": "QGeoRouteRequest.TravelMode", + "enum_value1": "CarTravel", + "enum_value2": "PedestrianTravel", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "FeatureTypes", + "enum_class": "FeatureType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(FeatureTypes, FeatureType)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(FeatureTypes, FeatureType)" + ], + "qflag_full_class_name": "QGeoRouteRequest.FeatureTypes", + "enum_full_class_name": "QGeoRouteRequest.FeatureType", + "enum_value1": "NoFeature", + "enum_value2": "TollFeature", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "FeatureWeights", + "enum_class": "FeatureWeight", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(FeatureWeights, FeatureWeight)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(FeatureWeights, FeatureWeight)" + ], + "qflag_full_class_name": "QGeoRouteRequest.FeatureWeights", + "enum_full_class_name": "QGeoRouteRequest.FeatureWeight", + "enum_value1": "NeutralFeatureWeight", + "enum_value2": "PreferFeatureWeight", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "RouteOptimizations", + "enum_class": "RouteOptimization", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(RouteOptimizations, RouteOptimization)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(RouteOptimizations, RouteOptimization)" + ], + "qflag_full_class_name": "QGeoRouteRequest.RouteOptimizations", + "enum_full_class_name": "QGeoRouteRequest.RouteOptimization", + "enum_value1": "ShortestRoute", + "enum_value2": "FastestRoute", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "SegmentDetails", + "enum_class": "SegmentDetail", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(SegmentDetails, SegmentDetail)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(SegmentDetails, SegmentDetail)" + ], + "qflag_full_class_name": "QGeoRouteRequest.SegmentDetails", + "enum_full_class_name": "QGeoRouteRequest.SegmentDetail", + "enum_value1": "NoSegmentData", + "enum_value2": "BasicSegmentData", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "ManeuverDetails", + "enum_class": "ManeuverDetail", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoroutemodel_p.h: Q_DECLARE_FLAGS(ManeuverDetails, ManeuverDetail)", + "src\\location\\maps\\qgeorouterequest.h: Q_DECLARE_FLAGS(ManeuverDetails, ManeuverDetail)" + ], + "qflag_full_class_name": "QGeoRouteRequest.ManeuverDetails", + "enum_full_class_name": "QGeoRouteRequest.ManeuverDetail", + "enum_value1": "NoManeuvers", + "enum_value2": "BasicManeuvers", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "RoutingFeatures", + "enum_class": "RoutingFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(RoutingFeatures, RoutingFeature)" + ], + "qflag_full_class_name": "QGeoServiceProvider.RoutingFeatures", + "enum_full_class_name": "QGeoServiceProvider.RoutingFeature", + "enum_value1": "NoRoutingFeatures", + "enum_value2": "OnlineRoutingFeature", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "GeocodingFeatures", + "enum_class": "GeocodingFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(GeocodingFeatures, GeocodingFeature)" + ], + "qflag_full_class_name": "QGeoServiceProvider.GeocodingFeatures", + "enum_full_class_name": "QGeoServiceProvider.GeocodingFeature", + "enum_value1": "NoGeocodingFeatures", + "enum_value2": "OnlineGeocodingFeature", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "MappingFeatures", + "enum_class": "MappingFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(MappingFeatures, MappingFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(MappingFeatures, MappingFeature)" + ], + "qflag_full_class_name": "QGeoServiceProvider.MappingFeatures", + "enum_full_class_name": "QGeoServiceProvider.MappingFeature", + "enum_value1": "NoMappingFeatures", + "enum_value2": "OnlineMappingFeature", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "PlacesFeatures", + "enum_class": "PlacesFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(PlacesFeatures, PlacesFeature)" + ], + "qflag_full_class_name": "QGeoServiceProvider.PlacesFeatures", + "enum_full_class_name": "QGeoServiceProvider.PlacesFeature", + "enum_value1": "NoPlacesFeatures", + "enum_value2": "OnlinePlacesFeature", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "NavigationFeatures", + "enum_class": "NavigationFeature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\location\\declarativemaps\\qdeclarativegeoserviceprovider_p.h: Q_DECLARE_FLAGS(NavigationFeatures, NavigationFeature)", + "src\\location\\maps\\qgeoserviceprovider.h: Q_DECLARE_FLAGS(NavigationFeatures, NavigationFeature)" + ], + "qflag_full_class_name": "QGeoServiceProvider.NavigationFeatures", + "enum_full_class_name": "QGeoServiceProvider.NavigationFeature", + "enum_value1": "NoNavigationFeatures", + "enum_value2": "OnlineNavigationFeature", + "module_count": 1, + "module_idx": 0, + "module_name": "QtLocation", + "module_path": "../../PyQt5-stubs/QtLocation.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true } ], "qflag_process_error": [ diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index 15c6efaf..cd257fbc 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -3429,6 +3429,21 @@ "qflag_class": "VelocityFields", "enum_class": "VelocityField", "skip_reason": "QFlag not found in module group qtlocation" + }, + { + "qflag_class": "ShaderTypes", + "enum_class": "ShaderType", + "skip_reason": "QFlag not found in module group qtmultimedia" + }, + { + "qflag_class": "FrameFlags", + "enum_class": "FrameFlag", + "skip_reason": "QFlag not found in module group qtmultimedia" + }, + { + "qflag_class": "EmptyStreamOptions", + "enum_class": "EmptyStreamOption", + "skip_reason": "QFlag not found in module group qtmultimedia" } ] } \ No newline at end of file From e3e5a3e41b36473b5887a85d9612ad67c73c8327 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:16:20 +0100 Subject: [PATCH 344/421] Add QtMultimedia to process --- .../qflags/generate_qflags_stubs_and_tests.py | 4 + tests/qflags/qflags_modules_analysis.json | 187 ++++++++++++++++++ tests/qflags/qflags_to_process.json | 119 +++++++++++ 3 files changed, 310 insertions(+) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 9b6f69f4..a38ad81d 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -17,6 +17,7 @@ QtDataVisualization, QtQuick, QtQml, QtPositioning, QtLocation, + QtMultimedia, ) try: import libcst as cst @@ -64,6 +65,9 @@ 'QtPositioning', 'QtLocation', ], + 'qtmultimedia': [ + 'QtMultimedia', + ], } diff --git a/tests/qflags/qflags_modules_analysis.json b/tests/qflags/qflags_modules_analysis.json index 762310fc..01f3a096 100644 --- a/tests/qflags/qflags_modules_analysis.json +++ b/tests/qflags/qflags_modules_analysis.json @@ -1009,6 +1009,125 @@ "module_idx": 0, "module_name": "QtLocation", "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "CaptureModes", + "enum_class": "CaptureMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcamera.h: Q_DECLARE_FLAGS(CaptureModes, CaptureMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "LockTypes", + "enum_class": "LockType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcamera.h: Q_DECLARE_FLAGS(LockTypes, LockType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "FlashModes", + "enum_class": "FlashMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcameraexposure.h: Q_DECLARE_FLAGS(FlashModes, FlashMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "FocusModes", + "enum_class": "FocusMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcamerafocus.h: Q_DECLARE_FLAGS(FocusModes, FocusMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "CaptureDestinations", + "enum_class": "CaptureDestination", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcameraimagecapture.h: Q_DECLARE_FLAGS(CaptureDestinations, CaptureDestination)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\playback\\qmediaplayer.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "RunFlags", + "enum_class": "RunFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\video\\qabstractvideofilter.h: Q_DECLARE_FLAGS(RunFlags, RunFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" } ], "flag_without_module": [ @@ -1694,6 +1813,74 @@ "module_idx": -1, "module_name": "", "module_path": "" + }, + { + "qflag_class": "ShaderTypes", + "enum_class": "ShaderType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimediawidgets\\qpaintervideosurface_p.h: Q_DECLARE_FLAGS(ShaderTypes, ShaderType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "FrameFlags", + "enum_class": "FrameFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\qtmultimediaquicktools\\qsgvideonode_p.h: Q_DECLARE_FLAGS(FrameFlags, FrameFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "Features", + "enum_class": "Feature", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\qmediaserviceproviderplugin.h: Q_DECLARE_FLAGS(Features, Feature)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" + }, + { + "qflag_class": "EmptyStreamOptions", + "enum_class": "EmptyStreamOption", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\audio\\qsoundeffect_pulse_p.h: Q_DECLARE_FLAGS(EmptyStreamOptions, EmptyStreamOption)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 0, + "module_idx": -1, + "module_name": "", + "module_path": "" } ] } \ No newline at end of file diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index cd257fbc..da97a2cb 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -3197,6 +3197,125 @@ "module_idx": 0, "module_name": "QtLocation", "module_path": "../../PyQt5-stubs/QtLocation.pyi" + }, + { + "qflag_class": "CaptureModes", + "enum_class": "CaptureMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcamera.h: Q_DECLARE_FLAGS(CaptureModes, CaptureMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "LockTypes", + "enum_class": "LockType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcamera.h: Q_DECLARE_FLAGS(LockTypes, LockType)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "FlashModes", + "enum_class": "FlashMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcameraexposure.h: Q_DECLARE_FLAGS(FlashModes, FlashMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "FocusModes", + "enum_class": "FocusMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcamerafocus.h: Q_DECLARE_FLAGS(FocusModes, FocusMode)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "CaptureDestinations", + "enum_class": "CaptureDestination", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcameraimagecapture.h: Q_DECLARE_FLAGS(CaptureDestinations, CaptureDestination)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\playback\\qmediaplayer.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "RunFlags", + "enum_class": "RunFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\video\\qabstractvideofilter.h: Q_DECLARE_FLAGS(RunFlags, RunFlag)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" } ], "qflags_to_skip": [ From 269571a093fb2ec2492ea0c8cf93c6444063851f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:16:50 +0100 Subject: [PATCH 345/421] QFlag operations for QCamera.CaptureModes, QCamera.CaptureMode in module QtMultimedia --- PyQt5-stubs/QtMultimedia.pyi | 8 + ...t_QtMultimedia_CaptureModes_CaptureMode.py | 272 ++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 tests/qflags/test_QtMultimedia_CaptureModes_CaptureMode.py diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index e574b8cd..f4103a1d 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -800,12 +800,20 @@ class QCamera(QMediaObject): def __init__(self, f: typing.Union['QCamera.CaptureModes', 'QCamera.CaptureMode']) -> None: ... @typing.overload def __init__(self, a0: 'QCamera.CaptureModes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QCamera.CaptureModes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QCamera.CaptureModes', 'QCamera.CaptureMode', int]) -> 'QCamera.CaptureModes': ... + def __and__(self, other: typing.Union['QCamera.CaptureModes', 'QCamera.CaptureMode', int]) -> 'QCamera.CaptureModes': ... + def __xor__(self, other: typing.Union['QCamera.CaptureModes', 'QCamera.CaptureMode', int]) -> 'QCamera.CaptureModes': ... + def __ror__ (self, other: 'QCamera.CaptureMode') -> 'QCamera.CaptureModes': ... + def __rand__(self, other: 'QCamera.CaptureMode') -> 'QCamera.CaptureModes': ... + def __rxor__(self, other: 'QCamera.CaptureMode') -> 'QCamera.CaptureModes': ... class LockTypes(sip.simplewrapper): diff --git a/tests/qflags/test_QtMultimedia_CaptureModes_CaptureMode.py b/tests/qflags/test_QtMultimedia_CaptureModes_CaptureMode.py new file mode 100644 index 00000000..6aa911a5 --- /dev/null +++ b/tests/qflags/test_QtMultimedia_CaptureModes_CaptureMode.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QCamera.CaptureModes" and flag class "QCamera.CaptureMode" +from PyQt5 import QtMultimedia + +OneFlagClass = QtMultimedia.QCamera.CaptureMode +MultiFlagClass = QtMultimedia.QCamera.CaptureModes + +oneFlagRefValue1 = QtMultimedia.QCamera.CaptureMode.CaptureViewfinder +oneFlagRefValue2 = QtMultimedia.QCamera.CaptureMode.CaptureStillImage + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From d1903f51e7b0d928bb17f032d7c306412d8df92f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:17:13 +0100 Subject: [PATCH 346/421] QFlag operations for QCamera.LockTypes, QCamera.LockType in module QtMultimedia --- PyQt5-stubs/QtMultimedia.pyi | 11 + .../test_QtMultimedia_LockTypes_LockType.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtMultimedia_LockTypes_LockType.py diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index f4103a1d..b3487228 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -708,6 +708,9 @@ class QCamera(QMediaObject): FrontFace = ... # type: QCamera.Position class LockType(int): + def __or__ (self, other: 'QCamera.LockType') -> 'QCamera.LockTypes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QCamera.LockTypes': ... # type: ignore[override, misc] + NoLock = ... # type: QCamera.LockType LockExposure = ... # type: QCamera.LockType LockWhiteBalance = ... # type: QCamera.LockType @@ -823,12 +826,20 @@ class QCamera(QMediaObject): def __init__(self, f: typing.Union['QCamera.LockTypes', 'QCamera.LockType']) -> None: ... @typing.overload def __init__(self, a0: 'QCamera.LockTypes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QCamera.LockTypes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QCamera.LockTypes', 'QCamera.LockType', int]) -> 'QCamera.LockTypes': ... + def __and__(self, other: typing.Union['QCamera.LockTypes', 'QCamera.LockType', int]) -> 'QCamera.LockTypes': ... + def __xor__(self, other: typing.Union['QCamera.LockTypes', 'QCamera.LockType', int]) -> 'QCamera.LockTypes': ... + def __ror__ (self, other: 'QCamera.LockType') -> 'QCamera.LockTypes': ... + def __rand__(self, other: 'QCamera.LockType') -> 'QCamera.LockTypes': ... + def __rxor__(self, other: 'QCamera.LockType') -> 'QCamera.LockTypes': ... class FrameRateRange(sip.simplewrapper): diff --git a/tests/qflags/test_QtMultimedia_LockTypes_LockType.py b/tests/qflags/test_QtMultimedia_LockTypes_LockType.py new file mode 100644 index 00000000..b98b1a4a --- /dev/null +++ b/tests/qflags/test_QtMultimedia_LockTypes_LockType.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QCamera.LockTypes" and flag class "QCamera.LockType" +from PyQt5 import QtMultimedia + +OneFlagClass = QtMultimedia.QCamera.LockType +MultiFlagClass = QtMultimedia.QCamera.LockTypes + +oneFlagRefValue1 = QtMultimedia.QCamera.LockType.NoLock +oneFlagRefValue2 = QtMultimedia.QCamera.LockType.LockExposure + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 40cee3e1552c23fb667022914c12303d66232b66 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 18:17:33 +0100 Subject: [PATCH 347/421] QFlag operations for QCameraExposure.FlashModes, QCameraExposure.FlashMode in module QtMultimedia --- PyQt5-stubs/QtMultimedia.pyi | 11 + .../test_QtMultimedia_FlashModes_FlashMode.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtMultimedia_FlashModes_FlashMode.py diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index b3487228..ae7d864e 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -1031,6 +1031,9 @@ class QCameraExposure(QtCore.QObject): ExposureModeVendor = ... # type: QCameraExposure.ExposureMode class FlashMode(int): + def __or__ (self, other: 'QCameraExposure.FlashMode') -> 'QCameraExposure.FlashModes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QCameraExposure.FlashModes': ... # type: ignore[override, misc] + FlashAuto = ... # type: QCameraExposure.FlashMode FlashOff = ... # type: QCameraExposure.FlashMode FlashOn = ... # type: QCameraExposure.FlashMode @@ -1061,12 +1064,20 @@ class QCameraExposure(QtCore.QObject): def __init__(self, f: typing.Union['QCameraExposure.FlashModes', 'QCameraExposure.FlashMode']) -> None: ... @typing.overload def __init__(self, a0: 'QCameraExposure.FlashModes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QCameraExposure.FlashModes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QCameraExposure.FlashModes', 'QCameraExposure.FlashMode', int]) -> 'QCameraExposure.FlashModes': ... + def __and__(self, other: typing.Union['QCameraExposure.FlashModes', 'QCameraExposure.FlashMode', int]) -> 'QCameraExposure.FlashModes': ... + def __xor__(self, other: typing.Union['QCameraExposure.FlashModes', 'QCameraExposure.FlashMode', int]) -> 'QCameraExposure.FlashModes': ... + def __ror__ (self, other: 'QCameraExposure.FlashMode') -> 'QCameraExposure.FlashModes': ... + def __rand__(self, other: 'QCameraExposure.FlashMode') -> 'QCameraExposure.FlashModes': ... + def __rxor__(self, other: 'QCameraExposure.FlashMode') -> 'QCameraExposure.FlashModes': ... def exposureCompensationChanged(self, a0: float) -> None: ... def isoSensitivityChanged(self, a0: int) -> None: ... diff --git a/tests/qflags/test_QtMultimedia_FlashModes_FlashMode.py b/tests/qflags/test_QtMultimedia_FlashModes_FlashMode.py new file mode 100644 index 00000000..ddb745bd --- /dev/null +++ b/tests/qflags/test_QtMultimedia_FlashModes_FlashMode.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QCameraExposure.FlashModes" and flag class "QCameraExposure.FlashMode" +from PyQt5 import QtMultimedia + +OneFlagClass = QtMultimedia.QCameraExposure.FlashMode +MultiFlagClass = QtMultimedia.QCameraExposure.FlashModes + +oneFlagRefValue1 = QtMultimedia.QCameraExposure.FlashMode.FlashAuto +oneFlagRefValue2 = QtMultimedia.QCameraExposure.FlashMode.FlashOff + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 93e34b5fa3a9511cfdf25aaea335fc74bd31fb2c Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:16:43 +0100 Subject: [PATCH 348/421] QFlag operations for QCameraFocus.FocusModes, QCameraFocus.FocusMode in module QtMultimedia --- PyQt5-stubs/QtMultimedia.pyi | 11 + .../test_QtMultimedia_FocusModes_FocusMode.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtMultimedia_FocusModes_FocusMode.py diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index ae7d864e..5406a8e1 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -1238,6 +1238,9 @@ class QCameraFocus(QtCore.QObject): FocusPointCustom = ... # type: QCameraFocus.FocusPointMode class FocusMode(int): + def __or__ (self, other: 'QCameraFocus.FocusMode') -> 'QCameraFocus.FocusModes': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QCameraFocus.FocusModes': ... # type: ignore[override, misc] + ManualFocus = ... # type: QCameraFocus.FocusMode HyperfocalFocus = ... # type: QCameraFocus.FocusMode InfinityFocus = ... # type: QCameraFocus.FocusMode @@ -1260,12 +1263,20 @@ class QCameraFocus(QtCore.QObject): def __init__(self, f: typing.Union['QCameraFocus.FocusModes', 'QCameraFocus.FocusMode']) -> None: ... @typing.overload def __init__(self, a0: 'QCameraFocus.FocusModes') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QCameraFocus.FocusModes': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QCameraFocus.FocusModes', 'QCameraFocus.FocusMode', int]) -> 'QCameraFocus.FocusModes': ... + def __and__(self, other: typing.Union['QCameraFocus.FocusModes', 'QCameraFocus.FocusMode', int]) -> 'QCameraFocus.FocusModes': ... + def __xor__(self, other: typing.Union['QCameraFocus.FocusModes', 'QCameraFocus.FocusMode', int]) -> 'QCameraFocus.FocusModes': ... + def __ror__ (self, other: 'QCameraFocus.FocusMode') -> 'QCameraFocus.FocusModes': ... + def __rand__(self, other: 'QCameraFocus.FocusMode') -> 'QCameraFocus.FocusModes': ... + def __rxor__(self, other: 'QCameraFocus.FocusMode') -> 'QCameraFocus.FocusModes': ... def maximumDigitalZoomChanged(self, a0: float) -> None: ... def maximumOpticalZoomChanged(self, a0: float) -> None: ... diff --git a/tests/qflags/test_QtMultimedia_FocusModes_FocusMode.py b/tests/qflags/test_QtMultimedia_FocusModes_FocusMode.py new file mode 100644 index 00000000..2eda0dfb --- /dev/null +++ b/tests/qflags/test_QtMultimedia_FocusModes_FocusMode.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QCameraFocus.FocusModes" and flag class "QCameraFocus.FocusMode" +from PyQt5 import QtMultimedia + +OneFlagClass = QtMultimedia.QCameraFocus.FocusMode +MultiFlagClass = QtMultimedia.QCameraFocus.FocusModes + +oneFlagRefValue1 = QtMultimedia.QCameraFocus.FocusMode.ManualFocus +oneFlagRefValue2 = QtMultimedia.QCameraFocus.FocusMode.HyperfocalFocus + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 55338b20882a01faf0048c8c04ce4566a9c41d87 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:17:12 +0100 Subject: [PATCH 349/421] QFlag operations for QCameraImageCapture.CaptureDestinations, QCameraImageCapture.CaptureDestination in module QtMultimedia --- PyQt5-stubs/QtMultimedia.pyi | 11 + ..._CaptureDestinations_CaptureDestination.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtMultimedia_CaptureDestinations_CaptureDestination.py diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index 5406a8e1..52a73037 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -1322,6 +1322,9 @@ class QCameraFocusControl(QMediaControl): class QCameraImageCapture(QtCore.QObject, QMediaBindableInterface): class CaptureDestination(int): + def __or__ (self, other: 'QCameraImageCapture.CaptureDestination') -> 'QCameraImageCapture.CaptureDestinations': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QCameraImageCapture.CaptureDestinations': ... # type: ignore[override, misc] + CaptureToFile = ... # type: QCameraImageCapture.CaptureDestination CaptureToBuffer = ... # type: QCameraImageCapture.CaptureDestination @@ -1356,12 +1359,20 @@ class QCameraImageCapture(QtCore.QObject, QMediaBindableInterface): def __init__(self, f: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination']) -> None: ... @typing.overload def __init__(self, a0: 'QCameraImageCapture.CaptureDestinations') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QCameraImageCapture.CaptureDestinations': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination', int]) -> 'QCameraImageCapture.CaptureDestinations': ... + def __and__(self, other: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination', int]) -> 'QCameraImageCapture.CaptureDestinations': ... + def __xor__(self, other: typing.Union['QCameraImageCapture.CaptureDestinations', 'QCameraImageCapture.CaptureDestination', int]) -> 'QCameraImageCapture.CaptureDestinations': ... + def __ror__ (self, other: 'QCameraImageCapture.CaptureDestination') -> 'QCameraImageCapture.CaptureDestinations': ... + def __rand__(self, other: 'QCameraImageCapture.CaptureDestination') -> 'QCameraImageCapture.CaptureDestinations': ... + def __rxor__(self, other: 'QCameraImageCapture.CaptureDestination') -> 'QCameraImageCapture.CaptureDestinations': ... def __init__(self, mediaObject: QMediaObject, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtMultimedia_CaptureDestinations_CaptureDestination.py b/tests/qflags/test_QtMultimedia_CaptureDestinations_CaptureDestination.py new file mode 100644 index 00000000..773f9357 --- /dev/null +++ b/tests/qflags/test_QtMultimedia_CaptureDestinations_CaptureDestination.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QCameraImageCapture.CaptureDestinations" and flag class "QCameraImageCapture.CaptureDestination" +from PyQt5 import QtMultimedia + +OneFlagClass = QtMultimedia.QCameraImageCapture.CaptureDestination +MultiFlagClass = QtMultimedia.QCameraImageCapture.CaptureDestinations + +oneFlagRefValue1 = QtMultimedia.QCameraImageCapture.CaptureDestination.CaptureToFile +oneFlagRefValue2 = QtMultimedia.QCameraImageCapture.CaptureDestination.CaptureToBuffer + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 220f0198764f8f09e4caf3a1350199a404df11d2 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:17:33 +0100 Subject: [PATCH 350/421] QFlag operations for QMediaPlayer.Flags, QMediaPlayer.Flag in module QtMultimedia --- PyQt5-stubs/QtMultimedia.pyi | 8 + tests/qflags/test_QtMultimedia_Flags_Flag.py | 272 +++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 tests/qflags/test_QtMultimedia_Flags_Flag.py diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index 52a73037..453950e3 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -1988,12 +1988,20 @@ class QMediaPlayer(QMediaObject): def __init__(self, f: typing.Union['QMediaPlayer.Flags', 'QMediaPlayer.Flag']) -> None: ... @typing.overload def __init__(self, a0: 'QMediaPlayer.Flags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QMediaPlayer.Flags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QMediaPlayer.Flags', 'QMediaPlayer.Flag', int]) -> 'QMediaPlayer.Flags': ... + def __and__(self, other: typing.Union['QMediaPlayer.Flags', 'QMediaPlayer.Flag', int]) -> 'QMediaPlayer.Flags': ... + def __xor__(self, other: typing.Union['QMediaPlayer.Flags', 'QMediaPlayer.Flag', int]) -> 'QMediaPlayer.Flags': ... + def __ror__ (self, other: 'QMediaPlayer.Flag') -> 'QMediaPlayer.Flags': ... + def __rand__(self, other: 'QMediaPlayer.Flag') -> 'QMediaPlayer.Flags': ... + def __rxor__(self, other: 'QMediaPlayer.Flag') -> 'QMediaPlayer.Flags': ... def __init__(self, parent: typing.Optional[QtCore.QObject] = ..., flags: typing.Union['QMediaPlayer.Flags', 'QMediaPlayer.Flag'] = ...) -> None: ... diff --git a/tests/qflags/test_QtMultimedia_Flags_Flag.py b/tests/qflags/test_QtMultimedia_Flags_Flag.py new file mode 100644 index 00000000..e83b75d0 --- /dev/null +++ b/tests/qflags/test_QtMultimedia_Flags_Flag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QMediaPlayer.Flags" and flag class "QMediaPlayer.Flag" +from PyQt5 import QtMultimedia + +OneFlagClass = QtMultimedia.QMediaPlayer.Flag +MultiFlagClass = QtMultimedia.QMediaPlayer.Flags + +oneFlagRefValue1 = QtMultimedia.QMediaPlayer.Flag.LowLatency +oneFlagRefValue2 = QtMultimedia.QMediaPlayer.Flag.StreamPlayback + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 52a219b3046ffb5447cda3c4ac5d0a2ec35e36bc Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:17:58 +0100 Subject: [PATCH 351/421] QFlag operations for QVideoFilterRunnable.RunFlags, QVideoFilterRunnable.RunFlag in module QtMultimedia --- PyQt5-stubs/QtMultimedia.pyi | 11 + .../test_QtMultimedia_RunFlags_RunFlag.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtMultimedia_RunFlags_RunFlag.py diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index 453950e3..9fbc16cd 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -84,6 +84,9 @@ class QAbstractVideoBuffer(sip.simplewrapper): class QVideoFilterRunnable(sip.simplewrapper): class RunFlag(int): + def __or__ (self, other: 'QVideoFilterRunnable.RunFlag') -> 'QVideoFilterRunnable.RunFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QVideoFilterRunnable.RunFlags': ... # type: ignore[override, misc] + LastInChain = ... # type: QVideoFilterRunnable.RunFlag LastInChain = ... # type: QVideoFilterRunnable.RunFlag @@ -96,12 +99,20 @@ class QVideoFilterRunnable(sip.simplewrapper): def __init__(self, f: typing.Union['QVideoFilterRunnable.RunFlags', 'QVideoFilterRunnable.RunFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QVideoFilterRunnable.RunFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QVideoFilterRunnable.RunFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QVideoFilterRunnable.RunFlags', 'QVideoFilterRunnable.RunFlag', int]) -> 'QVideoFilterRunnable.RunFlags': ... + def __and__(self, other: typing.Union['QVideoFilterRunnable.RunFlags', 'QVideoFilterRunnable.RunFlag', int]) -> 'QVideoFilterRunnable.RunFlags': ... + def __xor__(self, other: typing.Union['QVideoFilterRunnable.RunFlags', 'QVideoFilterRunnable.RunFlag', int]) -> 'QVideoFilterRunnable.RunFlags': ... + def __ror__ (self, other: 'QVideoFilterRunnable.RunFlag') -> 'QVideoFilterRunnable.RunFlags': ... + def __rand__(self, other: 'QVideoFilterRunnable.RunFlag') -> 'QVideoFilterRunnable.RunFlags': ... + def __rxor__(self, other: 'QVideoFilterRunnable.RunFlag') -> 'QVideoFilterRunnable.RunFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtMultimedia_RunFlags_RunFlag.py b/tests/qflags/test_QtMultimedia_RunFlags_RunFlag.py new file mode 100644 index 00000000..02ea1caa --- /dev/null +++ b/tests/qflags/test_QtMultimedia_RunFlags_RunFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QVideoFilterRunnable.RunFlags" and flag class "QVideoFilterRunnable.RunFlag" +from PyQt5 import QtMultimedia + +OneFlagClass = QtMultimedia.QVideoFilterRunnable.RunFlag +MultiFlagClass = QtMultimedia.QVideoFilterRunnable.RunFlags + +oneFlagRefValue1 = QtMultimedia.QVideoFilterRunnable.RunFlag.LastInChain +oneFlagRefValue2 = QtMultimedia.QVideoFilterRunnable.RunFlag.LastInChain + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 2369981477977f2a290cc22d67b94d1794371358 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:18:42 +0100 Subject: [PATCH 352/421] Results of processing QtMultimedia --- tests/qflags/qflags_process_result.json | 147 ++++++++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/tests/qflags/qflags_process_result.json b/tests/qflags/qflags_process_result.json index 24967afa..402e5daa 100644 --- a/tests/qflags/qflags_process_result.json +++ b/tests/qflags/qflags_process_result.json @@ -3748,6 +3748,153 @@ "or_int_converts_to_multi": false, "int_or_converts_to_multi": true, "supports_one_op_multi": true + }, + { + "qflag_class": "CaptureModes", + "enum_class": "CaptureMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcamera.h: Q_DECLARE_FLAGS(CaptureModes, CaptureMode)" + ], + "qflag_full_class_name": "QCamera.CaptureModes", + "enum_full_class_name": "QCamera.CaptureMode", + "enum_value1": "CaptureViewfinder", + "enum_value2": "CaptureStillImage", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "LockTypes", + "enum_class": "LockType", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcamera.h: Q_DECLARE_FLAGS(LockTypes, LockType)" + ], + "qflag_full_class_name": "QCamera.LockTypes", + "enum_full_class_name": "QCamera.LockType", + "enum_value1": "NoLock", + "enum_value2": "LockExposure", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "FlashModes", + "enum_class": "FlashMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcameraexposure.h: Q_DECLARE_FLAGS(FlashModes, FlashMode)" + ], + "qflag_full_class_name": "QCameraExposure.FlashModes", + "enum_full_class_name": "QCameraExposure.FlashMode", + "enum_value1": "FlashAuto", + "enum_value2": "FlashOff", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "FocusModes", + "enum_class": "FocusMode", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcamerafocus.h: Q_DECLARE_FLAGS(FocusModes, FocusMode)" + ], + "qflag_full_class_name": "QCameraFocus.FocusModes", + "enum_full_class_name": "QCameraFocus.FocusMode", + "enum_value1": "ManualFocus", + "enum_value2": "HyperfocalFocus", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "CaptureDestinations", + "enum_class": "CaptureDestination", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\camera\\qcameraimagecapture.h: Q_DECLARE_FLAGS(CaptureDestinations, CaptureDestination)" + ], + "qflag_full_class_name": "QCameraImageCapture.CaptureDestinations", + "enum_full_class_name": "QCameraImageCapture.CaptureDestination", + "enum_value1": "CaptureToFile", + "enum_value2": "CaptureToBuffer", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\playback\\qmediaplayer.h: Q_DECLARE_FLAGS(Flags, Flag)" + ], + "qflag_full_class_name": "QMediaPlayer.Flags", + "enum_full_class_name": "QMediaPlayer.Flag", + "enum_value1": "LowLatency", + "enum_value2": "StreamPlayback", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true + }, + { + "qflag_class": "RunFlags", + "enum_class": "RunFlag", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\multimedia\\video\\qabstractvideofilter.h: Q_DECLARE_FLAGS(RunFlags, RunFlag)" + ], + "qflag_full_class_name": "QVideoFilterRunnable.RunFlags", + "enum_full_class_name": "QVideoFilterRunnable.RunFlag", + "enum_value1": "LastInChain", + "enum_value2": "LastInChain", + "module_count": 1, + "module_idx": 0, + "module_name": "QtMultimedia", + "module_path": "../../PyQt5-stubs/QtMultimedia.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true } ], "qflag_process_error": [ From ccb1b6b68128623cbcb3c4ac57b574275e0c037d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:27:58 +0100 Subject: [PATCH 353/421] Remove non relevant grep results --- tests/qflags/grep-results/qtpim-qflag-grep-result.txt | 0 tests/qflags/grep-results/qtqa-qflag-grep-result.txt | 0 tests/qflags/grep-results/qtrepotools-qflag-grep-result.txt | 0 tests/qflags/grep-results/qtscript-qflag-grep-result.txt | 4 ---- tests/qflags/grep-results/qtscxml-qflag-grep-result.txt | 0 5 files changed, 4 deletions(-) delete mode 100644 tests/qflags/grep-results/qtpim-qflag-grep-result.txt delete mode 100644 tests/qflags/grep-results/qtqa-qflag-grep-result.txt delete mode 100644 tests/qflags/grep-results/qtrepotools-qflag-grep-result.txt delete mode 100644 tests/qflags/grep-results/qtscript-qflag-grep-result.txt delete mode 100644 tests/qflags/grep-results/qtscxml-qflag-grep-result.txt diff --git a/tests/qflags/grep-results/qtpim-qflag-grep-result.txt b/tests/qflags/grep-results/qtpim-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/qflags/grep-results/qtqa-qflag-grep-result.txt b/tests/qflags/grep-results/qtqa-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/qflags/grep-results/qtrepotools-qflag-grep-result.txt b/tests/qflags/grep-results/qtrepotools-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/qflags/grep-results/qtscript-qflag-grep-result.txt b/tests/qflags/grep-results/qtscript-qflag-grep-result.txt deleted file mode 100644 index 8a8ebf1f..00000000 --- a/tests/qflags/grep-results/qtscript-qflag-grep-result.txt +++ /dev/null @@ -1,4 +0,0 @@ -src\script\api\qscriptclass.h: Q_DECLARE_FLAGS(QueryFlags, QueryFlag) -src\script\api\qscriptengine.h: Q_DECLARE_FLAGS(QObjectWrapOptions, QObjectWrapOption) -src\script\api\qscriptvalue.h: Q_DECLARE_FLAGS(ResolveFlags, ResolveFlag) -src\script\api\qscriptvalue.h: Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag) diff --git a/tests/qflags/grep-results/qtscxml-qflag-grep-result.txt b/tests/qflags/grep-results/qtscxml-qflag-grep-result.txt deleted file mode 100644 index e69de29b..00000000 From e91966abe7c9f8be3c5fc8bc425b9cc273b7e044 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:28:27 +0100 Subject: [PATCH 354/421] Prepare for QFlags of QtSerialPort --- .../qflags/generate_qflags_stubs_and_tests.py | 4 +++ tests/qflags/qflags_modules_analysis.json | 34 +++++++++++++++++++ tests/qflags/qflags_to_process.json | 34 +++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index a38ad81d..5666def8 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -18,6 +18,7 @@ QtQuick, QtQml, QtPositioning, QtLocation, QtMultimedia, + QtSerialPort, ) try: import libcst as cst @@ -68,6 +69,9 @@ 'qtmultimedia': [ 'QtMultimedia', ], + 'qtserialport': [ + 'QtSerialPort', + ], } diff --git a/tests/qflags/qflags_modules_analysis.json b/tests/qflags/qflags_modules_analysis.json index 01f3a096..c26c636f 100644 --- a/tests/qflags/qflags_modules_analysis.json +++ b/tests/qflags/qflags_modules_analysis.json @@ -1128,6 +1128,40 @@ "module_idx": 0, "module_name": "QtMultimedia", "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "Directions", + "enum_class": "Direction", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\serialport\\qserialport.h: Q_DECLARE_FLAGS(Directions, Direction)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSerialPort", + "module_path": "../../PyQt5-stubs/QtSerialPort.pyi" + }, + { + "qflag_class": "PinoutSignals", + "enum_class": "PinoutSignal", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\serialport\\qserialport.h: Q_DECLARE_FLAGS(PinoutSignals, PinoutSignal)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSerialPort", + "module_path": "../../PyQt5-stubs/QtSerialPort.pyi" } ], "flag_without_module": [ diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index da97a2cb..8440618e 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -3316,6 +3316,40 @@ "module_idx": 0, "module_name": "QtMultimedia", "module_path": "../../PyQt5-stubs/QtMultimedia.pyi" + }, + { + "qflag_class": "Directions", + "enum_class": "Direction", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\serialport\\qserialport.h: Q_DECLARE_FLAGS(Directions, Direction)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSerialPort", + "module_path": "../../PyQt5-stubs/QtSerialPort.pyi" + }, + { + "qflag_class": "PinoutSignals", + "enum_class": "PinoutSignal", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\serialport\\qserialport.h: Q_DECLARE_FLAGS(PinoutSignals, PinoutSignal)" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSerialPort", + "module_path": "../../PyQt5-stubs/QtSerialPort.pyi" } ], "qflags_to_skip": [ From c7cdff199b2401d651e1016195f4e4b08c4921a9 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:28:51 +0100 Subject: [PATCH 355/421] QFlag operations for QSerialPort.Directions, QSerialPort.Direction in module QtSerialPort --- PyQt5-stubs/QtSerialPort.pyi | 11 + .../test_QtSerialPort_Directions_Direction.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtSerialPort_Directions_Direction.py diff --git a/PyQt5-stubs/QtSerialPort.pyi b/PyQt5-stubs/QtSerialPort.pyi index 607e7f50..23b805bf 100644 --- a/PyQt5-stubs/QtSerialPort.pyi +++ b/PyQt5-stubs/QtSerialPort.pyi @@ -175,6 +175,9 @@ class QSerialPort(QtCore.QIODevice): UnknownBaud = ... # type: QSerialPort.BaudRate class Direction(int): + def __or__ (self, other: 'QSerialPort.Direction') -> 'QSerialPort.Directions': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSerialPort.Directions': ... # type: ignore[override, misc] + Input = ... # type: QSerialPort.Direction Output = ... # type: QSerialPort.Direction AllDirections = ... # type: QSerialPort.Direction @@ -191,12 +194,20 @@ class QSerialPort(QtCore.QIODevice): def __init__(self, f: typing.Union['QSerialPort.Directions', 'QSerialPort.Direction']) -> None: ... @typing.overload def __init__(self, a0: 'QSerialPort.Directions') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSerialPort.Directions': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSerialPort.Directions', 'QSerialPort.Direction', int]) -> 'QSerialPort.Directions': ... + def __and__(self, other: typing.Union['QSerialPort.Directions', 'QSerialPort.Direction', int]) -> 'QSerialPort.Directions': ... + def __xor__(self, other: typing.Union['QSerialPort.Directions', 'QSerialPort.Direction', int]) -> 'QSerialPort.Directions': ... + def __ror__ (self, other: 'QSerialPort.Direction') -> 'QSerialPort.Directions': ... + def __rand__(self, other: 'QSerialPort.Direction') -> 'QSerialPort.Directions': ... + def __rxor__(self, other: 'QSerialPort.Direction') -> 'QSerialPort.Directions': ... class PinoutSignals(sip.simplewrapper): diff --git a/tests/qflags/test_QtSerialPort_Directions_Direction.py b/tests/qflags/test_QtSerialPort_Directions_Direction.py new file mode 100644 index 00000000..cb09c81d --- /dev/null +++ b/tests/qflags/test_QtSerialPort_Directions_Direction.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSerialPort.Directions" and flag class "QSerialPort.Direction" +from PyQt5 import QtSerialPort + +OneFlagClass = QtSerialPort.QSerialPort.Direction +MultiFlagClass = QtSerialPort.QSerialPort.Directions + +oneFlagRefValue1 = QtSerialPort.QSerialPort.Direction.Input +oneFlagRefValue2 = QtSerialPort.QSerialPort.Direction.Output + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 860361b53ce6c98ed940cfa9be39d21e5fd931f1 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:29:05 +0100 Subject: [PATCH 356/421] QFlag operations for QSerialPort.PinoutSignals, QSerialPort.PinoutSignal in module QtSerialPort --- PyQt5-stubs/QtSerialPort.pyi | 11 + ...QtSerialPort_PinoutSignals_PinoutSignal.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtSerialPort_PinoutSignals_PinoutSignal.py diff --git a/PyQt5-stubs/QtSerialPort.pyi b/PyQt5-stubs/QtSerialPort.pyi index 23b805bf..58127409 100644 --- a/PyQt5-stubs/QtSerialPort.pyi +++ b/PyQt5-stubs/QtSerialPort.pyi @@ -79,6 +79,9 @@ class QSerialPort(QtCore.QIODevice): UnknownPolicy = ... # type: QSerialPort.DataErrorPolicy class PinoutSignal(int): + def __or__ (self, other: 'QSerialPort.PinoutSignal') -> 'QSerialPort.PinoutSignals': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QSerialPort.PinoutSignals': ... # type: ignore[override, misc] + NoSignal = ... # type: QSerialPort.PinoutSignal TransmittedDataSignal = ... # type: QSerialPort.PinoutSignal ReceivedDataSignal = ... # type: QSerialPort.PinoutSignal @@ -217,12 +220,20 @@ class QSerialPort(QtCore.QIODevice): def __init__(self, f: typing.Union['QSerialPort.PinoutSignals', 'QSerialPort.PinoutSignal']) -> None: ... @typing.overload def __init__(self, a0: 'QSerialPort.PinoutSignals') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QSerialPort.PinoutSignals': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QSerialPort.PinoutSignals', 'QSerialPort.PinoutSignal', int]) -> 'QSerialPort.PinoutSignals': ... + def __and__(self, other: typing.Union['QSerialPort.PinoutSignals', 'QSerialPort.PinoutSignal', int]) -> 'QSerialPort.PinoutSignals': ... + def __xor__(self, other: typing.Union['QSerialPort.PinoutSignals', 'QSerialPort.PinoutSignal', int]) -> 'QSerialPort.PinoutSignals': ... + def __ror__ (self, other: 'QSerialPort.PinoutSignal') -> 'QSerialPort.PinoutSignals': ... + def __rand__(self, other: 'QSerialPort.PinoutSignal') -> 'QSerialPort.PinoutSignals': ... + def __rxor__(self, other: 'QSerialPort.PinoutSignal') -> 'QSerialPort.PinoutSignals': ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtSerialPort_PinoutSignals_PinoutSignal.py b/tests/qflags/test_QtSerialPort_PinoutSignals_PinoutSignal.py new file mode 100644 index 00000000..24a8fbaf --- /dev/null +++ b/tests/qflags/test_QtSerialPort_PinoutSignals_PinoutSignal.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QSerialPort.PinoutSignals" and flag class "QSerialPort.PinoutSignal" +from PyQt5 import QtSerialPort + +OneFlagClass = QtSerialPort.QSerialPort.PinoutSignal +MultiFlagClass = QtSerialPort.QSerialPort.PinoutSignals + +oneFlagRefValue1 = QtSerialPort.QSerialPort.PinoutSignal.NoSignal +oneFlagRefValue2 = QtSerialPort.QSerialPort.PinoutSignal.TransmittedDataSignal + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 45b4e8545dc2f60c540a92ba0fcdbf78d43d0bd9 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:31:37 +0100 Subject: [PATCH 357/421] Results of processing QtSerialPort --- tests/qflags/qflags_process_result.json | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/qflags/qflags_process_result.json b/tests/qflags/qflags_process_result.json index 402e5daa..e12b81da 100644 --- a/tests/qflags/qflags_process_result.json +++ b/tests/qflags/qflags_process_result.json @@ -3895,6 +3895,48 @@ "or_int_converts_to_multi": false, "int_or_converts_to_multi": true, "supports_one_op_multi": true + }, + { + "qflag_class": "Directions", + "enum_class": "Direction", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\serialport\\qserialport.h: Q_DECLARE_FLAGS(Directions, Direction)" + ], + "qflag_full_class_name": "QSerialPort.Directions", + "enum_full_class_name": "QSerialPort.Direction", + "enum_value1": "Input", + "enum_value2": "Output", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSerialPort", + "module_path": "../../PyQt5-stubs/QtSerialPort.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "PinoutSignals", + "enum_class": "PinoutSignal", + "human_hint_qflag_full_class_name": "", + "human_hint_enum_full_class_name": "", + "grep_line": [ + "src\\serialport\\qserialport.h: Q_DECLARE_FLAGS(PinoutSignals, PinoutSignal)" + ], + "qflag_full_class_name": "QSerialPort.PinoutSignals", + "enum_full_class_name": "QSerialPort.PinoutSignal", + "enum_value1": "NoSignal", + "enum_value2": "TransmittedDataSignal", + "module_count": 1, + "module_idx": 0, + "module_name": "QtSerialPort", + "module_path": "../../PyQt5-stubs/QtSerialPort.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true } ], "qflag_process_error": [ From a3d328a0095b7b0a0e49287b3f83feb9bf660fdd Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:51:30 +0100 Subject: [PATCH 358/421] Remove duplicated methods --- PyQt5-stubs/Qt3DRender.pyi | 6 ------ 1 file changed, 6 deletions(-) diff --git a/PyQt5-stubs/Qt3DRender.pyi b/PyQt5-stubs/Qt3DRender.pyi index 902253cd..a5ab75a5 100644 --- a/PyQt5-stubs/Qt3DRender.pyi +++ b/PyQt5-stubs/Qt3DRender.pyi @@ -1003,12 +1003,6 @@ class QClearBuffers('QFrameGraphNode'): def __ror__ (self, other: 'QClearBuffers.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... def __rand__(self, other: 'QClearBuffers.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... def __rxor__(self, other: 'QClearBuffers.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... - def __or__ (self, other: typing.Union['QClearBuffers.BufferTypeFlags', 'QBuffer.BufferType', int]) -> 'QClearBuffers.BufferTypeFlags': ... - def __and__(self, other: typing.Union['QClearBuffers.BufferTypeFlags', 'QBuffer.BufferType', int]) -> 'QClearBuffers.BufferTypeFlags': ... - def __xor__(self, other: typing.Union['QClearBuffers.BufferTypeFlags', 'QBuffer.BufferType', int]) -> 'QClearBuffers.BufferTypeFlags': ... - def __ror__ (self, other: 'QBuffer.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... - def __rand__(self, other: 'QBuffer.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... - def __rxor__(self, other: 'QBuffer.BufferType') -> 'QClearBuffers.BufferTypeFlags': ... def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... From da37a6049f71a98a7031cc32ff248a7c3de1e2d0 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 21:51:47 +0100 Subject: [PATCH 359/421] More flags, manually extracted from .pyi --- tests/qflags/qflags_to_process.json | 119 ++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index 8440618e..94cfcec7 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -3350,6 +3350,125 @@ "module_idx": 0, "module_name": "QtSerialPort", "module_path": "../../PyQt5-stubs/QtSerialPort.pyi" + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "QWebEngineUrlScheme.Flags", + "human_hint_enum_full_class_name": "QWebEngineUrlScheme.Flag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebEngineCore", + "module_path": "../../PyQt5-stubs/QtWebEngineCore.pyi" + }, + { + "qflag_class": "MediaFlags", + "enum_class": "MediaFlag", + "human_hint_qflag_full_class_name": "QWebEngineContextMenuData.MediaFlags", + "human_hint_enum_full_class_name": "QWebEngineContextMenuData.MediaFlag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebEngineWidgets", + "module_path": "../../PyQt5-stubs/QtWebEngineWidgets.pyi" + }, + { + "qflag_class": "EditFlags", + "enum_class": "EditFlag", + "human_hint_qflag_full_class_name": "QWebEngineContextMenuData.EditFlags", + "human_hint_enum_full_class_name": "QWebEngineContextMenuData.EditFlag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebEngineWidgets", + "module_path": "../../PyQt5-stubs/QtWebEngineWidgets.pyi" + }, + { + "qflag_class": "FindFlags", + "enum_class": "FindFlag", + "human_hint_qflag_full_class_name": "QWebEnginePage.FindFlags", + "human_hint_enum_full_class_name": "QWebEnginePage.FindFlag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebEngineWidgets", + "module_path": "../../PyQt5-stubs/QtWebEngineWidgets.pyi" + }, + { + "qflag_class": "RenderLayers", + "enum_class": "RenderLayer", + "human_hint_qflag_full_class_name": "QWebFrame.RenderLayers", + "human_hint_enum_full_class_name": "QWebFrame.RenderLayer", + "grep_line": [ + "" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebKitWiddgets", + "module_path": "../../PyQt5-stubs/QtWebKitWidgets.pyi" + }, + { + "qflag_class": "FindFlags", + "enum_class": "FindFlag", + "human_hint_qflag_full_class_name": "QWebPage.FindFlags", + "human_hint_enum_full_class_name": "QWebPage.FindFlag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebKitWiddgets", + "module_path": "../../PyQt5-stubs/QtWebKitWidgets.pyi" + }, + { + "qflag_class": "Feature", + "enum_class": "FeatureFlag", + "human_hint_qflag_full_class_name": "QDesignerFormWindowInterface.Feature", + "human_hint_enum_full_class_name": "QDesignerFormWindowInterface.FeatureFlag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "", + "enum_full_class_name": "", + "enum_value1": "", + "enum_value2": "", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebKitWiddgets", + "module_path": "../../PyQt5-stubs/QtWebKitWidgets.pyi" } ], "qflags_to_skip": [ From a42c1d9dd8bbe7cfd45d5200374ee3d0033ed273 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 22:03:13 +0100 Subject: [PATCH 360/421] QFlag operations for QWebEngineUrlScheme.Flags, QWebEngineUrlScheme.Flag in module QtWebEngineCore --- PyQt5-stubs/QtWebEngineCore.pyi | 11 + .../qflags/test_QtWebEngineCore_Flags_Flag.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtWebEngineCore_Flags_Flag.py diff --git a/PyQt5-stubs/QtWebEngineCore.pyi b/PyQt5-stubs/QtWebEngineCore.pyi index 9ded0abd..6b2add9a 100644 --- a/PyQt5-stubs/QtWebEngineCore.pyi +++ b/PyQt5-stubs/QtWebEngineCore.pyi @@ -265,6 +265,9 @@ class QWebEngineUrlRequestJob(QtCore.QObject): class QWebEngineUrlScheme(sip.simplewrapper): class Flag(int): + def __or__ (self, other: 'QWebEngineUrlScheme.Flag') -> 'QWebEngineUrlScheme.Flags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QWebEngineUrlScheme.Flags': ... # type: ignore[override, misc] + SecureScheme = ... # type: QWebEngineUrlScheme.Flag LocalScheme = ... # type: QWebEngineUrlScheme.Flag LocalAccessAllowed = ... # type: QWebEngineUrlScheme.Flag @@ -307,12 +310,20 @@ class QWebEngineUrlScheme(sip.simplewrapper): def __init__(self, f: typing.Union['QWebEngineUrlScheme.Flags', 'QWebEngineUrlScheme.Flag']) -> None: ... @typing.overload def __init__(self, a0: 'QWebEngineUrlScheme.Flags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QWebEngineUrlScheme.Flags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QWebEngineUrlScheme.Flags', 'QWebEngineUrlScheme.Flag', int]) -> 'QWebEngineUrlScheme.Flags': ... + def __and__(self, other: typing.Union['QWebEngineUrlScheme.Flags', 'QWebEngineUrlScheme.Flag', int]) -> 'QWebEngineUrlScheme.Flags': ... + def __xor__(self, other: typing.Union['QWebEngineUrlScheme.Flags', 'QWebEngineUrlScheme.Flag', int]) -> 'QWebEngineUrlScheme.Flags': ... + def __ror__ (self, other: 'QWebEngineUrlScheme.Flag') -> 'QWebEngineUrlScheme.Flags': ... + def __rand__(self, other: 'QWebEngineUrlScheme.Flag') -> 'QWebEngineUrlScheme.Flags': ... + def __rxor__(self, other: 'QWebEngineUrlScheme.Flag') -> 'QWebEngineUrlScheme.Flags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtWebEngineCore_Flags_Flag.py b/tests/qflags/test_QtWebEngineCore_Flags_Flag.py new file mode 100644 index 00000000..7219f3b2 --- /dev/null +++ b/tests/qflags/test_QtWebEngineCore_Flags_Flag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QWebEngineUrlScheme.Flags" and flag class "QWebEngineUrlScheme.Flag" +from PyQt5 import QtWebEngineCore + +OneFlagClass = QtWebEngineCore.QWebEngineUrlScheme.Flag +MultiFlagClass = QtWebEngineCore.QWebEngineUrlScheme.Flags + +oneFlagRefValue1 = QtWebEngineCore.QWebEngineUrlScheme.Flag.SecureScheme +oneFlagRefValue2 = QtWebEngineCore.QWebEngineUrlScheme.Flag.LocalScheme + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From c26af8a2a8ab79cccba59ac034b88436c59a17e4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 22:03:30 +0100 Subject: [PATCH 361/421] QFlag operations for QWebEngineContextMenuData.MediaFlags, QWebEngineContextMenuData.MediaFlag in module QtWebEngineWidgets --- PyQt5-stubs/QtWebEngineWidgets.pyi | 11 + ...QtWebEngineWidgets_MediaFlags_MediaFlag.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtWebEngineWidgets_MediaFlags_MediaFlag.py diff --git a/PyQt5-stubs/QtWebEngineWidgets.pyi b/PyQt5-stubs/QtWebEngineWidgets.pyi index fe699fc7..29e4a78c 100644 --- a/PyQt5-stubs/QtWebEngineWidgets.pyi +++ b/PyQt5-stubs/QtWebEngineWidgets.pyi @@ -129,6 +129,9 @@ class QWebEngineContextMenuData(sip.simplewrapper): CanEditRichly = ... # type: QWebEngineContextMenuData.EditFlag class MediaFlag(int): + def __or__ (self, other: 'QWebEngineContextMenuData.MediaFlag') -> 'QWebEngineContextMenuData.MediaFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QWebEngineContextMenuData.MediaFlags': ... # type: ignore[override, misc] + MediaInError = ... # type: QWebEngineContextMenuData.MediaFlag MediaPaused = ... # type: QWebEngineContextMenuData.MediaFlag MediaMuted = ... # type: QWebEngineContextMenuData.MediaFlag @@ -176,12 +179,20 @@ class QWebEngineContextMenuData(sip.simplewrapper): def __init__(self, f: typing.Union['QWebEngineContextMenuData.MediaFlags', 'QWebEngineContextMenuData.MediaFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QWebEngineContextMenuData.MediaFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QWebEngineContextMenuData.MediaFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QWebEngineContextMenuData.MediaFlags', 'QWebEngineContextMenuData.MediaFlag', int]) -> 'QWebEngineContextMenuData.MediaFlags': ... + def __and__(self, other: typing.Union['QWebEngineContextMenuData.MediaFlags', 'QWebEngineContextMenuData.MediaFlag', int]) -> 'QWebEngineContextMenuData.MediaFlags': ... + def __xor__(self, other: typing.Union['QWebEngineContextMenuData.MediaFlags', 'QWebEngineContextMenuData.MediaFlag', int]) -> 'QWebEngineContextMenuData.MediaFlags': ... + def __ror__ (self, other: 'QWebEngineContextMenuData.MediaFlag') -> 'QWebEngineContextMenuData.MediaFlags': ... + def __rand__(self, other: 'QWebEngineContextMenuData.MediaFlag') -> 'QWebEngineContextMenuData.MediaFlags': ... + def __rxor__(self, other: 'QWebEngineContextMenuData.MediaFlag') -> 'QWebEngineContextMenuData.MediaFlags': ... class EditFlags(sip.simplewrapper): diff --git a/tests/qflags/test_QtWebEngineWidgets_MediaFlags_MediaFlag.py b/tests/qflags/test_QtWebEngineWidgets_MediaFlags_MediaFlag.py new file mode 100644 index 00000000..1e37eb14 --- /dev/null +++ b/tests/qflags/test_QtWebEngineWidgets_MediaFlags_MediaFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QWebEngineContextMenuData.MediaFlags" and flag class "QWebEngineContextMenuData.MediaFlag" +from PyQt5 import QtWebEngineWidgets + +OneFlagClass = QtWebEngineWidgets.QWebEngineContextMenuData.MediaFlag +MultiFlagClass = QtWebEngineWidgets.QWebEngineContextMenuData.MediaFlags + +oneFlagRefValue1 = QtWebEngineWidgets.QWebEngineContextMenuData.MediaFlag.MediaInError +oneFlagRefValue2 = QtWebEngineWidgets.QWebEngineContextMenuData.MediaFlag.MediaPaused + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From b2adbd21f2f7bc1a89354095ce44e52432fae1ed Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 22:03:44 +0100 Subject: [PATCH 362/421] QFlag operations for QWebEngineContextMenuData.EditFlags, QWebEngineContextMenuData.EditFlag in module QtWebEngineWidgets --- PyQt5-stubs/QtWebEngineWidgets.pyi | 11 + ...t_QtWebEngineWidgets_EditFlags_EditFlag.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtWebEngineWidgets_EditFlags_EditFlag.py diff --git a/PyQt5-stubs/QtWebEngineWidgets.pyi b/PyQt5-stubs/QtWebEngineWidgets.pyi index 29e4a78c..2f77b8b4 100644 --- a/PyQt5-stubs/QtWebEngineWidgets.pyi +++ b/PyQt5-stubs/QtWebEngineWidgets.pyi @@ -108,6 +108,9 @@ class QWebEngineClientCertificateSelection(sip.simplewrapper): class QWebEngineContextMenuData(sip.simplewrapper): class EditFlag(int): + def __or__ (self, other: 'QWebEngineContextMenuData.EditFlag') -> 'QWebEngineContextMenuData.EditFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QWebEngineContextMenuData.EditFlags': ... # type: ignore[override, misc] + CanUndo = ... # type: QWebEngineContextMenuData.EditFlag CanRedo = ... # type: QWebEngineContextMenuData.EditFlag CanCut = ... # type: QWebEngineContextMenuData.EditFlag @@ -202,12 +205,20 @@ class QWebEngineContextMenuData(sip.simplewrapper): def __init__(self, f: typing.Union['QWebEngineContextMenuData.EditFlags', 'QWebEngineContextMenuData.EditFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QWebEngineContextMenuData.EditFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QWebEngineContextMenuData.EditFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QWebEngineContextMenuData.EditFlags', 'QWebEngineContextMenuData.EditFlag', int]) -> 'QWebEngineContextMenuData.EditFlags': ... + def __and__(self, other: typing.Union['QWebEngineContextMenuData.EditFlags', 'QWebEngineContextMenuData.EditFlag', int]) -> 'QWebEngineContextMenuData.EditFlags': ... + def __xor__(self, other: typing.Union['QWebEngineContextMenuData.EditFlags', 'QWebEngineContextMenuData.EditFlag', int]) -> 'QWebEngineContextMenuData.EditFlags': ... + def __ror__ (self, other: 'QWebEngineContextMenuData.EditFlag') -> 'QWebEngineContextMenuData.EditFlags': ... + def __rand__(self, other: 'QWebEngineContextMenuData.EditFlag') -> 'QWebEngineContextMenuData.EditFlags': ... + def __rxor__(self, other: 'QWebEngineContextMenuData.EditFlag') -> 'QWebEngineContextMenuData.EditFlags': ... @typing.overload def __init__(self) -> None: ... diff --git a/tests/qflags/test_QtWebEngineWidgets_EditFlags_EditFlag.py b/tests/qflags/test_QtWebEngineWidgets_EditFlags_EditFlag.py new file mode 100644 index 00000000..40454479 --- /dev/null +++ b/tests/qflags/test_QtWebEngineWidgets_EditFlags_EditFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QWebEngineContextMenuData.EditFlags" and flag class "QWebEngineContextMenuData.EditFlag" +from PyQt5 import QtWebEngineWidgets + +OneFlagClass = QtWebEngineWidgets.QWebEngineContextMenuData.EditFlag +MultiFlagClass = QtWebEngineWidgets.QWebEngineContextMenuData.EditFlags + +oneFlagRefValue1 = QtWebEngineWidgets.QWebEngineContextMenuData.EditFlag.CanUndo +oneFlagRefValue2 = QtWebEngineWidgets.QWebEngineContextMenuData.EditFlag.CanRedo + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 76f2ea19e76490a23ffed5f1d45cb52b3e9c825e Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 22:04:03 +0100 Subject: [PATCH 363/421] QFlag operations for QWebEnginePage.FindFlags, QWebEnginePage.FindFlag in module QtWebEngineWidgets --- PyQt5-stubs/QtWebEngineWidgets.pyi | 11 + ...t_QtWebEngineWidgets_FindFlags_FindFlag.py | 272 ++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 tests/qflags/test_QtWebEngineWidgets_FindFlags_FindFlag.py diff --git a/PyQt5-stubs/QtWebEngineWidgets.pyi b/PyQt5-stubs/QtWebEngineWidgets.pyi index 2f77b8b4..e0a94946 100644 --- a/PyQt5-stubs/QtWebEngineWidgets.pyi +++ b/PyQt5-stubs/QtWebEngineWidgets.pyi @@ -495,6 +495,9 @@ class QWebEnginePage(QtCore.QObject): WebBrowserBackgroundTab = ... # type: QWebEnginePage.WebWindowType class FindFlag(int): + def __or__ (self, other: 'QWebEnginePage.FindFlag') -> 'QWebEnginePage.FindFlags': ... # type: ignore[override] + def __ror__ (self, other: int) -> 'QWebEnginePage.FindFlags': ... # type: ignore[override, misc] + FindBackward = ... # type: QWebEnginePage.FindFlag FindCaseSensitively = ... # type: QWebEnginePage.FindFlag @@ -604,12 +607,20 @@ class QWebEnginePage(QtCore.QObject): def __init__(self, f: typing.Union['QWebEnginePage.FindFlags', 'QWebEnginePage.FindFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QWebEnginePage.FindFlags') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QWebEnginePage.FindFlags': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QWebEnginePage.FindFlags', 'QWebEnginePage.FindFlag', int]) -> 'QWebEnginePage.FindFlags': ... + def __and__(self, other: typing.Union['QWebEnginePage.FindFlags', 'QWebEnginePage.FindFlag', int]) -> 'QWebEnginePage.FindFlags': ... + def __xor__(self, other: typing.Union['QWebEnginePage.FindFlags', 'QWebEnginePage.FindFlag', int]) -> 'QWebEnginePage.FindFlags': ... + def __ror__ (self, other: 'QWebEnginePage.FindFlag') -> 'QWebEnginePage.FindFlags': ... + def __rand__(self, other: 'QWebEnginePage.FindFlag') -> 'QWebEnginePage.FindFlags': ... + def __rxor__(self, other: 'QWebEnginePage.FindFlag') -> 'QWebEnginePage.FindFlags': ... @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/tests/qflags/test_QtWebEngineWidgets_FindFlags_FindFlag.py b/tests/qflags/test_QtWebEngineWidgets_FindFlags_FindFlag.py new file mode 100644 index 00000000..0ff413cd --- /dev/null +++ b/tests/qflags/test_QtWebEngineWidgets_FindFlags_FindFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QWebEnginePage.FindFlags" and flag class "QWebEnginePage.FindFlag" +from PyQt5 import QtWebEngineWidgets + +OneFlagClass = QtWebEngineWidgets.QWebEnginePage.FindFlag +MultiFlagClass = QtWebEngineWidgets.QWebEnginePage.FindFlags + +oneFlagRefValue1 = QtWebEngineWidgets.QWebEnginePage.FindFlag.FindBackward +oneFlagRefValue2 = QtWebEngineWidgets.QWebEnginePage.FindFlag.FindCaseSensitively + +OR_CONVERTS_TO_MULTI: Literal[True] = True +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[True] = True +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From b1e7f2d124fb414763fb33dabe7e5cc53e81b282 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 22:06:40 +0100 Subject: [PATCH 364/421] QFlag operations for QDesignerFormWindowInterface.Feature, QDesignerFormWindowInterface.FeatureFlag in module QtDesigner --- PyQt5-stubs/QtDesigner.pyi | 8 + .../test_QtDesigner_Feature_FeatureFlag.py | 272 ++++++++++++++++++ 2 files changed, 280 insertions(+) create mode 100644 tests/qflags/test_QtDesigner_Feature_FeatureFlag.py diff --git a/PyQt5-stubs/QtDesigner.pyi b/PyQt5-stubs/QtDesigner.pyi index 8bd1874d..05f9670d 100644 --- a/PyQt5-stubs/QtDesigner.pyi +++ b/PyQt5-stubs/QtDesigner.pyi @@ -99,12 +99,20 @@ class QDesignerFormWindowInterface(QtWidgets.QWidget): def __init__(self, f: typing.Union['QDesignerFormWindowInterface.Feature', 'QDesignerFormWindowInterface.FeatureFlag']) -> None: ... @typing.overload def __init__(self, a0: 'QDesignerFormWindowInterface.Feature') -> None: ... + @typing.overload + def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... def __invert__(self) -> 'QDesignerFormWindowInterface.Feature': ... def __index__(self) -> int: ... def __int__(self) -> int: ... + def __or__ (self, other: typing.Union['QDesignerFormWindowInterface.Feature', 'QDesignerFormWindowInterface.FeatureFlag', int]) -> 'QDesignerFormWindowInterface.Feature': ... + def __and__(self, other: typing.Union['QDesignerFormWindowInterface.Feature', 'QDesignerFormWindowInterface.FeatureFlag', int]) -> 'QDesignerFormWindowInterface.Feature': ... + def __xor__(self, other: typing.Union['QDesignerFormWindowInterface.Feature', 'QDesignerFormWindowInterface.FeatureFlag', int]) -> 'QDesignerFormWindowInterface.Feature': ... + def __ror__ (self, other: 'QDesignerFormWindowInterface.FeatureFlag') -> 'QDesignerFormWindowInterface.Feature': ... + def __rand__(self, other: 'QDesignerFormWindowInterface.FeatureFlag') -> 'QDesignerFormWindowInterface.Feature': ... + def __rxor__(self, other: 'QDesignerFormWindowInterface.FeatureFlag') -> 'QDesignerFormWindowInterface.Feature': ... def __init__(self, parent: typing.Optional[QtWidgets.QWidget] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... diff --git a/tests/qflags/test_QtDesigner_Feature_FeatureFlag.py b/tests/qflags/test_QtDesigner_Feature_FeatureFlag.py new file mode 100644 index 00000000..6f8a70b0 --- /dev/null +++ b/tests/qflags/test_QtDesigner_Feature_FeatureFlag.py @@ -0,0 +1,272 @@ +# mypy: no-warn-unreachable + +import sys +from typing import Union +if sys.version_info[:2] >= (3,8): + from typing import Literal +else: + from typing_extensions import Literal +import pytest + +### Specific part +# file generated from qflags_test_template.py for QFlags class "QDesignerFormWindowInterface.Feature" and flag class "QDesignerFormWindowInterface.FeatureFlag" +from PyQt5 import QtDesigner + +OneFlagClass = QtDesigner.QDesignerFormWindowInterface.FeatureFlag +MultiFlagClass = QtDesigner.QDesignerFormWindowInterface.Feature + +oneFlagRefValue1 = QtDesigner.QDesignerFormWindowInterface.FeatureFlag.EditFeature +oneFlagRefValue2 = QtDesigner.QDesignerFormWindowInterface.FeatureFlag.GridFeature + +OR_CONVERTS_TO_MULTI: Literal[False] = False +OR_INT_CONVERTS_TO_MULTI: Literal[False] = False +INT_OR_CONVERTS_TO_MULTI: Literal[False] = False +SUPPORTS_ONE_OP_MULTI: Literal[True] = True +### End of specific part + +def assert_type_of_value_int(value: int) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert isinstance(value, int) + +def assert_type_of_value_oneFlag(value: OneFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == OneFlagClass + +def assert_type_of_value_multiFlag(value: MultiFlagClass) -> None: + '''Raise an exception if the value is not of type expected_type''' + assert type(value) == MultiFlagClass + + + +def test_on_one_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + oneFlagValue2 = oneFlagRefValue2 + oneFlagValueTest = oneFlagValue1 # type: OneFlagClass + intValue = 0 # type: int + oneOrMultiFlagValueTest = oneFlagValue1 # type: Union[OneFlagClass, MultiFlagClass] + oneFlagOrIntValue = oneFlagValue1 # type: Union[int, OneFlagClass] + + # upcast from OneFlagClass to int + intValue = oneFlagValue1 + + # conversion also accepted + intValue = int(oneFlagValue1) + + # this is not supported type-safely for a good reason + oneFlagValueTest = 1 # type: ignore + + # correct way to do it + oneFlagValueTest = OneFlagClass(1) + oneFlagValueTest = OneFlagClass(oneFlagValue1) + + # The rules of OneFlagClass conversion defined in PyQt5 are: + # 1. | ~= with OneFlagClass return a MultiFlagClass (which is not compatible to int) + # Note that this breaks Liskov principle + # 2. everything else returns int: & ^ &= ^= + # 3. operations with int return int. + + if OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | oneFlagValue2) + else: + assert_type_of_value_int(oneFlagValue1 | oneFlagValue2) + + assert_type_of_value_int(~oneFlagValue1) + assert_type_of_value_int(oneFlagValue1 & oneFlagValue2) + assert_type_of_value_int(oneFlagValue1 ^ oneFlagValue2) + + # right operand + if OR_INT_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(oneFlagValue1 | 1) + else: + assert_type_of_value_int(oneFlagValue1 | 1) + assert_type_of_value_int(oneFlagValue1 & 1) + assert_type_of_value_int(oneFlagValue1 ^ 1) + assert_type_of_value_int(oneFlagValue1 + 1) + assert_type_of_value_int(oneFlagValue1 - 1) + + # left operand + if INT_OR_CONVERTS_TO_MULTI: + assert_type_of_value_multiFlag(1 | oneFlagValue1) + else: + assert_type_of_value_int(1 | oneFlagValue1) + assert_type_of_value_int(1 & oneFlagValue1) + assert_type_of_value_int(1 ^ oneFlagValue1) + assert_type_of_value_int(1 + oneFlagValue1) + assert_type_of_value_int(1 - oneFlagValue1) + + if OR_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= oneFlagValue2 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) # nice violation of Liskov principle here + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + if OR_INT_CONVERTS_TO_MULTI: + oneOrMultiFlagValueTest = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneOrMultiFlagValueTest) + oneOrMultiFlagValueTest |= 1 + assert_type_of_value_multiFlag(oneOrMultiFlagValueTest) + else: + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue |= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue &= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= 1 + assert_type_of_value_int(oneFlagOrIntValue) + + oneFlagOrIntValue = oneFlagValue1 # reset type and value + assert_type_of_value_oneFlag(oneFlagOrIntValue) + oneFlagOrIntValue ^= oneFlagValue2 + assert_type_of_value_int(oneFlagOrIntValue) + + + +def test_on_multi_flag_class() -> None: + oneFlagValue1 = oneFlagRefValue1 + multiFlagValue1 = MultiFlagClass() + multiFlagValue2 = MultiFlagClass() + multiFlagValueTest = multiFlagValue1 # type: MultiFlagClass + intValue = 0 + + assert_type_of_value_oneFlag(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue1) + assert_type_of_value_multiFlag(multiFlagValue2) + assert_type_of_value_multiFlag(multiFlagValueTest) + assert_type_of_value_int(intValue) + + + # MultiFlagClass may be created by combining MultiFlagClass together + assert_type_of_value_multiFlag( ~multiFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 | multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 & multiFlagValue2 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ multiFlagValue2 ) + + + # MultiFlagClass may be created by combining MultiFlagClass and OneFlagClass, left or right + assert_type_of_value_multiFlag( multiFlagValue1 | oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 & oneFlagValue1 ) + assert_type_of_value_multiFlag( multiFlagValue1 ^ oneFlagValue1 ) + + if SUPPORTS_ONE_OP_MULTI: + assert_type_of_value_multiFlag( oneFlagValue1 | multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 & multiFlagValue1 ) + assert_type_of_value_multiFlag( oneFlagValue1 ^ multiFlagValue1 ) + + + # MultClassFlag may be created by combining MultiFlagClass and int, right only + assert_type_of_value_multiFlag(multiFlagValue1 | 1) + assert_type_of_value_multiFlag(multiFlagValue1 & 1) + assert_type_of_value_multiFlag(multiFlagValue1 ^ 1) + + + # this is rejected by mypy and is slightly annoying: you can not pass a OneFlagClass variable to a method expecting a MultiFlagClass + # explicit typing must be used on those methods to accept both OneFlagClass and MultiFlagClass + multiFlagValueTest = oneFlagValue1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(oneFlagValue1) + assert_type_of_value_multiFlag(multiFlagValueTest) + + # this is rejected for the same reason as for OneFlagClass. + intValue = multiFlagValueTest # type: ignore + + # correct way to do it + intValue = int(multiFlagValueTest) + assert_type_of_value_int(intValue) + + # rejected by mypy rightfully + multiFlagValueTest = 1 # type: ignore + + # correct way to do it + multiFlagValueTest = MultiFlagClass(1) + + # assignments operations with OneFlagClass + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= oneFlagValue1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + # assignments operations with int + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest |= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest &= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + assert_type_of_value_multiFlag(multiFlagValueTest) + multiFlagValueTest ^= 1 + assert_type_of_value_multiFlag(multiFlagValueTest) + + #########################################################1 + # + # Exploring errors + # + #########################################################1 + + if not SUPPORTS_ONE_OP_MULTI: + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + + pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 ^ multiFlagValue1 ) # type: ignore[operator] + + # This checks the following: + # + and - operations are not supported on MultiFlagClass + # combining int with MultiFlagClass does not work + pytest.raises(TypeError, lambda: multiFlagValue1 + multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - multiFlagValue2 ) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - oneFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 + 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: multiFlagValue1 - 1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 - multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 + multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: 1 - multiFlagValue1) # type: ignore[operator] + + def f1() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += oneFlagValue1 # type: ignore[assignment, operator] + def f2() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest += 1 # type: ignore[assignment, operator] + def f3() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= oneFlagValue1 # type: ignore[assignment, operator] + def f4() -> None: + multiFlagValueTest = MultiFlagClass() + multiFlagValueTest -= 1 # type: ignore[assignment, operator] + + pytest.raises(TypeError, f1) + pytest.raises(TypeError, f2) + pytest.raises(TypeError, f3) + pytest.raises(TypeError, f4) + From 6722fda6a22170c375fd272485416bbd8b9507d4 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 22:17:57 +0100 Subject: [PATCH 365/421] Result of latest QFlags added --- .../qflags/generate_qflags_stubs_and_tests.py | 2 + tests/qflags/qflags_process_result.json | 161 ++++++++++++++++++ tests/qflags/qflags_to_process.json | 4 +- 3 files changed, 165 insertions(+), 2 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 5666def8..457f6a8e 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -19,6 +19,8 @@ QtPositioning, QtLocation, QtMultimedia, QtSerialPort, + QtDesigner, + QtWebEngineWidgets, QtWebEngineCore, ) try: import libcst as cst diff --git a/tests/qflags/qflags_process_result.json b/tests/qflags/qflags_process_result.json index e12b81da..c74657ad 100644 --- a/tests/qflags/qflags_process_result.json +++ b/tests/qflags/qflags_process_result.json @@ -3937,6 +3937,111 @@ "or_int_converts_to_multi": false, "int_or_converts_to_multi": true, "supports_one_op_multi": true + }, + { + "qflag_class": "Flags", + "enum_class": "Flag", + "human_hint_qflag_full_class_name": "QWebEngineUrlScheme.Flags", + "human_hint_enum_full_class_name": "QWebEngineUrlScheme.Flag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "QWebEngineUrlScheme.Flags", + "enum_full_class_name": "QWebEngineUrlScheme.Flag", + "enum_value1": "SecureScheme", + "enum_value2": "LocalScheme", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebEngineCore", + "module_path": "../../PyQt5-stubs/QtWebEngineCore.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "MediaFlags", + "enum_class": "MediaFlag", + "human_hint_qflag_full_class_name": "QWebEngineContextMenuData.MediaFlags", + "human_hint_enum_full_class_name": "QWebEngineContextMenuData.MediaFlag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "QWebEngineContextMenuData.MediaFlags", + "enum_full_class_name": "QWebEngineContextMenuData.MediaFlag", + "enum_value1": "MediaInError", + "enum_value2": "MediaPaused", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebEngineWidgets", + "module_path": "../../PyQt5-stubs/QtWebEngineWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "EditFlags", + "enum_class": "EditFlag", + "human_hint_qflag_full_class_name": "QWebEngineContextMenuData.EditFlags", + "human_hint_enum_full_class_name": "QWebEngineContextMenuData.EditFlag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "QWebEngineContextMenuData.EditFlags", + "enum_full_class_name": "QWebEngineContextMenuData.EditFlag", + "enum_value1": "CanUndo", + "enum_value2": "CanRedo", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebEngineWidgets", + "module_path": "../../PyQt5-stubs/QtWebEngineWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "FindFlags", + "enum_class": "FindFlag", + "human_hint_qflag_full_class_name": "QWebEnginePage.FindFlags", + "human_hint_enum_full_class_name": "QWebEnginePage.FindFlag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "QWebEnginePage.FindFlags", + "enum_full_class_name": "QWebEnginePage.FindFlag", + "enum_value1": "FindBackward", + "enum_value2": "FindCaseSensitively", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebEngineWidgets", + "module_path": "../../PyQt5-stubs/QtWebEngineWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true + }, + { + "qflag_class": "Feature", + "enum_class": "FeatureFlag", + "human_hint_qflag_full_class_name": "QDesignerFormWindowInterface.Feature", + "human_hint_enum_full_class_name": "QDesignerFormWindowInterface.FeatureFlag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "QDesignerFormWindowInterface.Feature", + "enum_full_class_name": "QDesignerFormWindowInterface.FeatureFlag", + "enum_value1": "EditFeature", + "enum_value2": "GridFeature", + "module_count": 1, + "module_idx": 0, + "module_name": "QtDesigner", + "module_path": "../../PyQt5-stubs/QtDesigner.pyi", + "or_converts_to_multi": false, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": false, + "supports_one_op_multi": true } ], "qflag_process_error": [ @@ -4015,6 +4120,62 @@ "error": [ "Could not locate class DirtyState" ] + }, + { + "qflag_class": "RenderLayers", + "enum_class": "RenderLayer", + "human_hint_qflag_full_class_name": "QWebFrame.RenderLayers", + "human_hint_enum_full_class_name": "QWebFrame.RenderLayer", + "grep_line": [ + "" + ], + "qflag_full_class_name": "QWebFrame.RenderLayers", + "enum_full_class_name": "QWebFrame.RenderLayer", + "enum_value1": "ContentsLayer", + "enum_value2": "ScrollBarLayer", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebKitWiddgets", + "module_path": "../../PyQt5-stubs/QtWebKitWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true, + "error": [ + "Traceback (most recent call last):", + " File \"generate_qflags_stubs_and_tests.py\", line 601, in generate_missing_stubs", + " flag_info.or_converts_to_multi = not eval('''type({qtmodule}.{oneFlagName}.{value1} | {qtmodule}.{oneFlagName}.{value2}) == int'''.format(", + " File \"\", line 1, in ", + "NameError: name 'QtWebKitWiddgets' is not defined" + ] + }, + { + "qflag_class": "FindFlags", + "enum_class": "FindFlag", + "human_hint_qflag_full_class_name": "QWebPage.FindFlags", + "human_hint_enum_full_class_name": "QWebPage.FindFlag", + "grep_line": [ + "" + ], + "qflag_full_class_name": "QWebPage.FindFlags", + "enum_full_class_name": "QWebPage.FindFlag", + "enum_value1": "FindBackward", + "enum_value2": "FindCaseSensitively", + "module_count": 1, + "module_idx": 0, + "module_name": "QtWebKitWiddgets", + "module_path": "../../PyQt5-stubs/QtWebKitWidgets.pyi", + "or_converts_to_multi": true, + "or_int_converts_to_multi": false, + "int_or_converts_to_multi": true, + "supports_one_op_multi": true, + "error": [ + "Traceback (most recent call last):", + " File \"generate_qflags_stubs_and_tests.py\", line 601, in generate_missing_stubs", + " flag_info.or_converts_to_multi = not eval('''type({qtmodule}.{oneFlagName}.{value1} | {qtmodule}.{oneFlagName}.{value2}) == int'''.format(", + " File \"\", line 1, in ", + "NameError: name 'QtWebKitWiddgets' is not defined" + ] } ] } \ No newline at end of file diff --git a/tests/qflags/qflags_to_process.json b/tests/qflags/qflags_to_process.json index 94cfcec7..7ef0c0b1 100644 --- a/tests/qflags/qflags_to_process.json +++ b/tests/qflags/qflags_to_process.json @@ -3467,8 +3467,8 @@ "enum_value2": "", "module_count": 1, "module_idx": 0, - "module_name": "QtWebKitWiddgets", - "module_path": "../../PyQt5-stubs/QtWebKitWidgets.pyi" + "module_name": "QtDesigner", + "module_path": "../../PyQt5-stubs/QtDesigner.pyi" } ], "qflags_to_skip": [ From c867406f685a8a8d28b5a6d559d0e94226f510c6 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 22:22:05 +0100 Subject: [PATCH 366/421] Enable CI on this branch --- .github/workflows/ci.yml | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d746d422..bbdfda91 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,19 +1,16 @@ name: CI on: + workflow_dispatch: push: branches: - master + - more-qflags tags: - v* pull_request: branches: - "*" - schedule: - # Daily at 06:14. This is just an arbitrary time to stagger - # relative to other daily builds in any given organization. - - cron: '14 6 * * *' - jobs: test: name: ${{ matrix.os.name }} ${{ matrix.python.name }} @@ -24,15 +21,6 @@ jobs: os: - name: Linux runs-on: ubuntu-latest - matrix: linux -# https://github.com/python-qt-tools/PyQt5-stubs/issues/122 -# - name: Windows -# runs-on: windows-latest -# matrix: windows -# https://github.com/python-qt-tools/PyQt5-stubs/issues/122 -# - name: macOS -# runs-on: macos-latest -# matrix: macos python: - name: CPython 3.6 tox: py36 @@ -46,6 +34,24 @@ jobs: - name: CPython 3.9 tox: py39 action: 3.9 + - name: CPython 3.10 + tox: py310 + action: '3.10' + include: + - os: + name: Windows + runs-on: windows-latest + python: + name: CPython 3.6 + tox: py36 + action: 3.6 + - os: + name: Windows + runs-on: windows-latest + python: + name: CPython 3.9 + tox: py39 + action: '3.9' steps: - uses: actions/checkout@v2 - name: Set up ${{ matrix.python.name }} @@ -55,7 +61,7 @@ jobs: architecture: x64 - uses: twisted/python-info-action@v1.0.1 - name: Install Linux Qt5 dependencies - if: matrix.os.matrix == 'linux' + if: matrix.os.name == 'Linux' run: | sudo apt-get update --yes sudo apt-get install --yes libgl1 From c338898ad5ff6449111402db9a1debf801e01ac3 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 22:26:41 +0100 Subject: [PATCH 367/421] CI fix --- PyQt5-stubs/Qt3DRender.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/PyQt5-stubs/Qt3DRender.pyi b/PyQt5-stubs/Qt3DRender.pyi index a5ab75a5..8ca86f56 100644 --- a/PyQt5-stubs/Qt3DRender.pyi +++ b/PyQt5-stubs/Qt3DRender.pyi @@ -989,8 +989,6 @@ class QClearBuffers('QFrameGraphNode'): def __init__(self, a0: 'QClearBuffers.BufferTypeFlags') -> None: ... @typing.overload def __init__(self, f: int) -> None: ... - @typing.overload - def __init__(self, f: int) -> None: ... def __hash__(self) -> int: ... def __bool__(self) -> int: ... From 2aa1e415b5a2edc4c74edcad2be772d816e001c6 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 23:04:19 +0100 Subject: [PATCH 368/421] Do not run this CI on Windows --- .github/workflows/ci.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbdfda91..5dabd5d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,21 +37,6 @@ jobs: - name: CPython 3.10 tox: py310 action: '3.10' - include: - - os: - name: Windows - runs-on: windows-latest - python: - name: CPython 3.6 - tox: py36 - action: 3.6 - - os: - name: Windows - runs-on: windows-latest - python: - name: CPython 3.9 - tox: py39 - action: '3.9' steps: - uses: actions/checkout@v2 - name: Set up ${{ matrix.python.name }} From 0e6b7807b9489410e1d5ee7e5c81f52be9bb68fc Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 23:06:34 +0100 Subject: [PATCH 369/421] Make mypy happy --- tests/qflags/qflags_test_template.py | 6 +++--- tests/qflags/test_Qt3DCore_ChangeFlags_ChangeFlag.py | 6 +++--- tests/qflags/test_Qt3DCore_DeliveryFlags_DeliveryFlag.py | 6 +++--- tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py | 6 +++--- ..._QtBluetooth_AttAccessConstraints_AttAccessConstraint.py | 6 +++--- ...test_QtBluetooth_CoreConfigurations_CoreConfiguration.py | 6 +++--- tests/qflags/test_QtBluetooth_Fields_Field.py | 6 +++--- tests/qflags/test_QtBluetooth_PropertyTypes_PropertyType.py | 6 +++--- tests/qflags/test_QtBluetooth_SecurityFlags_Security.py | 6 +++--- .../qflags/test_QtBluetooth_ServiceClasses_ServiceClass.py | 6 +++--- tests/qflags/test_QtBluetooth_ServiceTypes_ServiceType.py | 6 +++--- .../qflags/test_QtChart_AnimationOptions_AnimationOption.py | 6 +++--- tests/qflags/test_QtChart_AxisTypes_AxisType.py | 6 +++--- .../test_QtChart_PolarOrientations_PolarOrientation.py | 6 +++--- tests/qflags/test_QtChart_RubberBands_RubberBand.py | 6 +++--- tests/qflags/test_QtDataVisualization_DrawFlags_DrawFlag.py | 6 +++--- ...tDataVisualization_OptimizationHints_OptimizationHint.py | 6 +++--- ...test_QtDataVisualization_SelectionFlags_SelectionFlag.py | 6 +++--- tests/qflags/test_QtDesigner_Feature_FeatureFlag.py | 6 +++--- tests/qflags/test_QtLocation_FeatureTypes_FeatureType.py | 6 +++--- .../qflags/test_QtLocation_FeatureWeights_FeatureWeight.py | 6 +++--- .../test_QtLocation_GeocodingFeatures_GeocodingFeature.py | 6 +++--- .../test_QtLocation_ManeuverDetails_ManeuverDetail.py | 6 +++--- .../test_QtLocation_MappingFeatures_MappingFeature.py | 6 +++--- .../test_QtLocation_NavigationFeatures_NavigationFeature.py | 6 +++--- .../qflags/test_QtLocation_PlacesFeatures_PlacesFeature.py | 6 +++--- .../test_QtLocation_RouteOptimizations_RouteOptimization.py | 6 +++--- .../test_QtLocation_RoutingFeatures_RoutingFeature.py | 6 +++--- .../qflags/test_QtLocation_SegmentDetails_SegmentDetail.py | 6 +++--- tests/qflags/test_QtLocation_TravelModes_TravelMode.py | 6 +++--- tests/qflags/test_QtLocation_VisibilityScope_Visibility.py | 6 +++--- ...t_QtMultimedia_CaptureDestinations_CaptureDestination.py | 6 +++--- tests/qflags/test_QtMultimedia_CaptureModes_CaptureMode.py | 6 +++--- tests/qflags/test_QtMultimedia_Flags_Flag.py | 6 +++--- tests/qflags/test_QtMultimedia_FlashModes_FlashMode.py | 6 +++--- tests/qflags/test_QtMultimedia_FocusModes_FocusMode.py | 6 +++--- tests/qflags/test_QtMultimedia_LockTypes_LockType.py | 6 +++--- tests/qflags/test_QtMultimedia_RunFlags_RunFlag.py | 6 +++--- tests/qflags/test_QtNfc_AccessMethods_AccessMethod.py | 6 +++--- tests/qflags/test_QtNfc_ShareModes_ShareMode.py | 6 +++--- .../qflags/test_QtNfc_TargetAccessModes_TargetAccessMode.py | 6 +++--- ..._QtPositioning_AreaMonitorFeatures_AreaMonitorFeature.py | 6 +++--- ...st_QtPositioning_PositioningMethods_PositioningMethod.py | 6 +++--- tests/qflags/test_QtQml_Extensions_Extension.py | 6 +++--- tests/qflags/test_QtQml_Flags_Flag.py | 6 +++--- tests/qflags/test_QtQuick_ClearMode_ClearModeBit.py | 6 +++--- tests/qflags/test_QtQuick_ColorMask_ColorMaskComponent.py | 6 +++--- ...test_QtQuick_CreateTextureOptions_CreateTextureOption.py | 6 +++--- tests/qflags/test_QtQuick_DirtyState_DirtyStateBit.py | 6 +++--- tests/qflags/test_QtQuick_Flags_Flag.py | 6 +++--- ...test_QtQuick_MatrixTransformFlags_MatrixTransformFlag.py | 6 +++--- .../qflags/test_QtQuick_PerformanceHints_PerformanceHint.py | 6 +++--- tests/qflags/test_QtQuick_RenderingFlags_RenderingFlag.py | 6 +++--- ..._QtQuick_ShaderCompilationTypes_ShaderCompilationType.py | 6 +++--- .../test_QtQuick_ShaderSourceTypes_ShaderSourceType.py | 6 +++--- tests/qflags/test_QtQuick_StateFlags_StateFlag.py | 6 +++--- ...rdinatesTransformMode_TextureCoordinatesTransformFlag.py | 6 +++--- tests/qflags/test_QtSerialPort_Directions_Direction.py | 6 +++--- .../qflags/test_QtSerialPort_PinoutSignals_PinoutSignal.py | 6 +++--- tests/qflags/test_QtWebEngineCore_Flags_Flag.py | 6 +++--- tests/qflags/test_QtWebEngineWidgets_EditFlags_EditFlag.py | 6 +++--- tests/qflags/test_QtWebEngineWidgets_FindFlags_FindFlag.py | 6 +++--- .../qflags/test_QtWebEngineWidgets_MediaFlags_MediaFlag.py | 6 +++--- 63 files changed, 189 insertions(+), 189 deletions(-) diff --git a/tests/qflags/qflags_test_template.py b/tests/qflags/qflags_test_template.py index af38d2e3..935a1d5a 100644 --- a/tests/qflags/qflags_test_template.py +++ b/tests/qflags/qflags_test_template.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_Qt3DCore_ChangeFlags_ChangeFlag.py b/tests/qflags/test_Qt3DCore_ChangeFlags_ChangeFlag.py index f2552e1d..abba7e99 100644 --- a/tests/qflags/test_Qt3DCore_ChangeFlags_ChangeFlag.py +++ b/tests/qflags/test_Qt3DCore_ChangeFlags_ChangeFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_Qt3DCore_DeliveryFlags_DeliveryFlag.py b/tests/qflags/test_Qt3DCore_DeliveryFlags_DeliveryFlag.py index 833617e7..b1107b68 100644 --- a/tests/qflags/test_Qt3DCore_DeliveryFlags_DeliveryFlag.py +++ b/tests/qflags/test_Qt3DCore_DeliveryFlags_DeliveryFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py b/tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py index 267b5f8c..88fe5ef2 100644 --- a/tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py +++ b/tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtBluetooth_AttAccessConstraints_AttAccessConstraint.py b/tests/qflags/test_QtBluetooth_AttAccessConstraints_AttAccessConstraint.py index 30f09868..69239abc 100644 --- a/tests/qflags/test_QtBluetooth_AttAccessConstraints_AttAccessConstraint.py +++ b/tests/qflags/test_QtBluetooth_AttAccessConstraints_AttAccessConstraint.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtBluetooth_CoreConfigurations_CoreConfiguration.py b/tests/qflags/test_QtBluetooth_CoreConfigurations_CoreConfiguration.py index 37cda47a..f73e2689 100644 --- a/tests/qflags/test_QtBluetooth_CoreConfigurations_CoreConfiguration.py +++ b/tests/qflags/test_QtBluetooth_CoreConfigurations_CoreConfiguration.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtBluetooth_Fields_Field.py b/tests/qflags/test_QtBluetooth_Fields_Field.py index b2df8359..604ae64e 100644 --- a/tests/qflags/test_QtBluetooth_Fields_Field.py +++ b/tests/qflags/test_QtBluetooth_Fields_Field.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtBluetooth_PropertyTypes_PropertyType.py b/tests/qflags/test_QtBluetooth_PropertyTypes_PropertyType.py index 08e34deb..74f32536 100644 --- a/tests/qflags/test_QtBluetooth_PropertyTypes_PropertyType.py +++ b/tests/qflags/test_QtBluetooth_PropertyTypes_PropertyType.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtBluetooth_SecurityFlags_Security.py b/tests/qflags/test_QtBluetooth_SecurityFlags_Security.py index d22b315b..94eb00f0 100644 --- a/tests/qflags/test_QtBluetooth_SecurityFlags_Security.py +++ b/tests/qflags/test_QtBluetooth_SecurityFlags_Security.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtBluetooth_ServiceClasses_ServiceClass.py b/tests/qflags/test_QtBluetooth_ServiceClasses_ServiceClass.py index a0029ef8..bc42e486 100644 --- a/tests/qflags/test_QtBluetooth_ServiceClasses_ServiceClass.py +++ b/tests/qflags/test_QtBluetooth_ServiceClasses_ServiceClass.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtBluetooth_ServiceTypes_ServiceType.py b/tests/qflags/test_QtBluetooth_ServiceTypes_ServiceType.py index 8bf18411..951fd10f 100644 --- a/tests/qflags/test_QtBluetooth_ServiceTypes_ServiceType.py +++ b/tests/qflags/test_QtBluetooth_ServiceTypes_ServiceType.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtChart_AnimationOptions_AnimationOption.py b/tests/qflags/test_QtChart_AnimationOptions_AnimationOption.py index 027e1d03..c6186825 100644 --- a/tests/qflags/test_QtChart_AnimationOptions_AnimationOption.py +++ b/tests/qflags/test_QtChart_AnimationOptions_AnimationOption.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtChart_AxisTypes_AxisType.py b/tests/qflags/test_QtChart_AxisTypes_AxisType.py index 11c4c2f3..ff38ca2a 100644 --- a/tests/qflags/test_QtChart_AxisTypes_AxisType.py +++ b/tests/qflags/test_QtChart_AxisTypes_AxisType.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtChart_PolarOrientations_PolarOrientation.py b/tests/qflags/test_QtChart_PolarOrientations_PolarOrientation.py index fb3d2c6a..0f667166 100644 --- a/tests/qflags/test_QtChart_PolarOrientations_PolarOrientation.py +++ b/tests/qflags/test_QtChart_PolarOrientations_PolarOrientation.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtChart_RubberBands_RubberBand.py b/tests/qflags/test_QtChart_RubberBands_RubberBand.py index 0a3f64bf..06dc4d63 100644 --- a/tests/qflags/test_QtChart_RubberBands_RubberBand.py +++ b/tests/qflags/test_QtChart_RubberBands_RubberBand.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtDataVisualization_DrawFlags_DrawFlag.py b/tests/qflags/test_QtDataVisualization_DrawFlags_DrawFlag.py index addcc08d..025881e2 100644 --- a/tests/qflags/test_QtDataVisualization_DrawFlags_DrawFlag.py +++ b/tests/qflags/test_QtDataVisualization_DrawFlags_DrawFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtDataVisualization_OptimizationHints_OptimizationHint.py b/tests/qflags/test_QtDataVisualization_OptimizationHints_OptimizationHint.py index bf20974f..0b8319f1 100644 --- a/tests/qflags/test_QtDataVisualization_OptimizationHints_OptimizationHint.py +++ b/tests/qflags/test_QtDataVisualization_OptimizationHints_OptimizationHint.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtDataVisualization_SelectionFlags_SelectionFlag.py b/tests/qflags/test_QtDataVisualization_SelectionFlags_SelectionFlag.py index 780647e1..bfa70436 100644 --- a/tests/qflags/test_QtDataVisualization_SelectionFlags_SelectionFlag.py +++ b/tests/qflags/test_QtDataVisualization_SelectionFlags_SelectionFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtDesigner_Feature_FeatureFlag.py b/tests/qflags/test_QtDesigner_Feature_FeatureFlag.py index 6f8a70b0..8ae431f3 100644 --- a/tests/qflags/test_QtDesigner_Feature_FeatureFlag.py +++ b/tests/qflags/test_QtDesigner_Feature_FeatureFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_FeatureTypes_FeatureType.py b/tests/qflags/test_QtLocation_FeatureTypes_FeatureType.py index 39a84147..cae1fd69 100644 --- a/tests/qflags/test_QtLocation_FeatureTypes_FeatureType.py +++ b/tests/qflags/test_QtLocation_FeatureTypes_FeatureType.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_FeatureWeights_FeatureWeight.py b/tests/qflags/test_QtLocation_FeatureWeights_FeatureWeight.py index aba2845a..2e810ff4 100644 --- a/tests/qflags/test_QtLocation_FeatureWeights_FeatureWeight.py +++ b/tests/qflags/test_QtLocation_FeatureWeights_FeatureWeight.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_GeocodingFeatures_GeocodingFeature.py b/tests/qflags/test_QtLocation_GeocodingFeatures_GeocodingFeature.py index 1080e987..e261ef5e 100644 --- a/tests/qflags/test_QtLocation_GeocodingFeatures_GeocodingFeature.py +++ b/tests/qflags/test_QtLocation_GeocodingFeatures_GeocodingFeature.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_ManeuverDetails_ManeuverDetail.py b/tests/qflags/test_QtLocation_ManeuverDetails_ManeuverDetail.py index 8c48f8a2..ff2be1b6 100644 --- a/tests/qflags/test_QtLocation_ManeuverDetails_ManeuverDetail.py +++ b/tests/qflags/test_QtLocation_ManeuverDetails_ManeuverDetail.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_MappingFeatures_MappingFeature.py b/tests/qflags/test_QtLocation_MappingFeatures_MappingFeature.py index add03fb7..4d911ffe 100644 --- a/tests/qflags/test_QtLocation_MappingFeatures_MappingFeature.py +++ b/tests/qflags/test_QtLocation_MappingFeatures_MappingFeature.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_NavigationFeatures_NavigationFeature.py b/tests/qflags/test_QtLocation_NavigationFeatures_NavigationFeature.py index e31cddbc..a46ec582 100644 --- a/tests/qflags/test_QtLocation_NavigationFeatures_NavigationFeature.py +++ b/tests/qflags/test_QtLocation_NavigationFeatures_NavigationFeature.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_PlacesFeatures_PlacesFeature.py b/tests/qflags/test_QtLocation_PlacesFeatures_PlacesFeature.py index 38cc9181..663daacf 100644 --- a/tests/qflags/test_QtLocation_PlacesFeatures_PlacesFeature.py +++ b/tests/qflags/test_QtLocation_PlacesFeatures_PlacesFeature.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_RouteOptimizations_RouteOptimization.py b/tests/qflags/test_QtLocation_RouteOptimizations_RouteOptimization.py index 3587be58..547ebd37 100644 --- a/tests/qflags/test_QtLocation_RouteOptimizations_RouteOptimization.py +++ b/tests/qflags/test_QtLocation_RouteOptimizations_RouteOptimization.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_RoutingFeatures_RoutingFeature.py b/tests/qflags/test_QtLocation_RoutingFeatures_RoutingFeature.py index 2a730201..1d95b466 100644 --- a/tests/qflags/test_QtLocation_RoutingFeatures_RoutingFeature.py +++ b/tests/qflags/test_QtLocation_RoutingFeatures_RoutingFeature.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_SegmentDetails_SegmentDetail.py b/tests/qflags/test_QtLocation_SegmentDetails_SegmentDetail.py index 693260e5..05046780 100644 --- a/tests/qflags/test_QtLocation_SegmentDetails_SegmentDetail.py +++ b/tests/qflags/test_QtLocation_SegmentDetails_SegmentDetail.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_TravelModes_TravelMode.py b/tests/qflags/test_QtLocation_TravelModes_TravelMode.py index 472101f9..cf59ca96 100644 --- a/tests/qflags/test_QtLocation_TravelModes_TravelMode.py +++ b/tests/qflags/test_QtLocation_TravelModes_TravelMode.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtLocation_VisibilityScope_Visibility.py b/tests/qflags/test_QtLocation_VisibilityScope_Visibility.py index c881626a..3a66ca49 100644 --- a/tests/qflags/test_QtLocation_VisibilityScope_Visibility.py +++ b/tests/qflags/test_QtLocation_VisibilityScope_Visibility.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtMultimedia_CaptureDestinations_CaptureDestination.py b/tests/qflags/test_QtMultimedia_CaptureDestinations_CaptureDestination.py index 773f9357..a4a9210b 100644 --- a/tests/qflags/test_QtMultimedia_CaptureDestinations_CaptureDestination.py +++ b/tests/qflags/test_QtMultimedia_CaptureDestinations_CaptureDestination.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtMultimedia_CaptureModes_CaptureMode.py b/tests/qflags/test_QtMultimedia_CaptureModes_CaptureMode.py index 6aa911a5..5734ba91 100644 --- a/tests/qflags/test_QtMultimedia_CaptureModes_CaptureMode.py +++ b/tests/qflags/test_QtMultimedia_CaptureModes_CaptureMode.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtMultimedia_Flags_Flag.py b/tests/qflags/test_QtMultimedia_Flags_Flag.py index e83b75d0..0ec3bc98 100644 --- a/tests/qflags/test_QtMultimedia_Flags_Flag.py +++ b/tests/qflags/test_QtMultimedia_Flags_Flag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtMultimedia_FlashModes_FlashMode.py b/tests/qflags/test_QtMultimedia_FlashModes_FlashMode.py index ddb745bd..9d1f5ee6 100644 --- a/tests/qflags/test_QtMultimedia_FlashModes_FlashMode.py +++ b/tests/qflags/test_QtMultimedia_FlashModes_FlashMode.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtMultimedia_FocusModes_FocusMode.py b/tests/qflags/test_QtMultimedia_FocusModes_FocusMode.py index 2eda0dfb..8ea29e5e 100644 --- a/tests/qflags/test_QtMultimedia_FocusModes_FocusMode.py +++ b/tests/qflags/test_QtMultimedia_FocusModes_FocusMode.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtMultimedia_LockTypes_LockType.py b/tests/qflags/test_QtMultimedia_LockTypes_LockType.py index b98b1a4a..acaa6b1f 100644 --- a/tests/qflags/test_QtMultimedia_LockTypes_LockType.py +++ b/tests/qflags/test_QtMultimedia_LockTypes_LockType.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtMultimedia_RunFlags_RunFlag.py b/tests/qflags/test_QtMultimedia_RunFlags_RunFlag.py index 02ea1caa..67de9c24 100644 --- a/tests/qflags/test_QtMultimedia_RunFlags_RunFlag.py +++ b/tests/qflags/test_QtMultimedia_RunFlags_RunFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtNfc_AccessMethods_AccessMethod.py b/tests/qflags/test_QtNfc_AccessMethods_AccessMethod.py index b822707b..435189f1 100644 --- a/tests/qflags/test_QtNfc_AccessMethods_AccessMethod.py +++ b/tests/qflags/test_QtNfc_AccessMethods_AccessMethod.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtNfc_ShareModes_ShareMode.py b/tests/qflags/test_QtNfc_ShareModes_ShareMode.py index 47351437..83b6de06 100644 --- a/tests/qflags/test_QtNfc_ShareModes_ShareMode.py +++ b/tests/qflags/test_QtNfc_ShareModes_ShareMode.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtNfc_TargetAccessModes_TargetAccessMode.py b/tests/qflags/test_QtNfc_TargetAccessModes_TargetAccessMode.py index d3205f07..91ba2167 100644 --- a/tests/qflags/test_QtNfc_TargetAccessModes_TargetAccessMode.py +++ b/tests/qflags/test_QtNfc_TargetAccessModes_TargetAccessMode.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtPositioning_AreaMonitorFeatures_AreaMonitorFeature.py b/tests/qflags/test_QtPositioning_AreaMonitorFeatures_AreaMonitorFeature.py index 066c4240..a0813aea 100644 --- a/tests/qflags/test_QtPositioning_AreaMonitorFeatures_AreaMonitorFeature.py +++ b/tests/qflags/test_QtPositioning_AreaMonitorFeatures_AreaMonitorFeature.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtPositioning_PositioningMethods_PositioningMethod.py b/tests/qflags/test_QtPositioning_PositioningMethods_PositioningMethod.py index a7c9486f..511d532e 100644 --- a/tests/qflags/test_QtPositioning_PositioningMethods_PositioningMethod.py +++ b/tests/qflags/test_QtPositioning_PositioningMethods_PositioningMethod.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQml_Extensions_Extension.py b/tests/qflags/test_QtQml_Extensions_Extension.py index 7815319a..d1e25c7d 100644 --- a/tests/qflags/test_QtQml_Extensions_Extension.py +++ b/tests/qflags/test_QtQml_Extensions_Extension.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQml_Flags_Flag.py b/tests/qflags/test_QtQml_Flags_Flag.py index c766de9c..f4abeeb6 100644 --- a/tests/qflags/test_QtQml_Flags_Flag.py +++ b/tests/qflags/test_QtQml_Flags_Flag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_ClearMode_ClearModeBit.py b/tests/qflags/test_QtQuick_ClearMode_ClearModeBit.py index 3c9fe22f..2dda0ff1 100644 --- a/tests/qflags/test_QtQuick_ClearMode_ClearModeBit.py +++ b/tests/qflags/test_QtQuick_ClearMode_ClearModeBit.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_ColorMask_ColorMaskComponent.py b/tests/qflags/test_QtQuick_ColorMask_ColorMaskComponent.py index 9ebf4acc..6e77a54d 100644 --- a/tests/qflags/test_QtQuick_ColorMask_ColorMaskComponent.py +++ b/tests/qflags/test_QtQuick_ColorMask_ColorMaskComponent.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py b/tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py index e3311ce4..822cf323 100644 --- a/tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py +++ b/tests/qflags/test_QtQuick_CreateTextureOptions_CreateTextureOption.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_DirtyState_DirtyStateBit.py b/tests/qflags/test_QtQuick_DirtyState_DirtyStateBit.py index 74e12ad0..e6811c98 100644 --- a/tests/qflags/test_QtQuick_DirtyState_DirtyStateBit.py +++ b/tests/qflags/test_QtQuick_DirtyState_DirtyStateBit.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_Flags_Flag.py b/tests/qflags/test_QtQuick_Flags_Flag.py index 11d2ebf2..3e047b10 100644 --- a/tests/qflags/test_QtQuick_Flags_Flag.py +++ b/tests/qflags/test_QtQuick_Flags_Flag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_MatrixTransformFlags_MatrixTransformFlag.py b/tests/qflags/test_QtQuick_MatrixTransformFlags_MatrixTransformFlag.py index 0662ab5f..1c8a7b05 100644 --- a/tests/qflags/test_QtQuick_MatrixTransformFlags_MatrixTransformFlag.py +++ b/tests/qflags/test_QtQuick_MatrixTransformFlags_MatrixTransformFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_PerformanceHints_PerformanceHint.py b/tests/qflags/test_QtQuick_PerformanceHints_PerformanceHint.py index 6a81ab3d..d6d19f48 100644 --- a/tests/qflags/test_QtQuick_PerformanceHints_PerformanceHint.py +++ b/tests/qflags/test_QtQuick_PerformanceHints_PerformanceHint.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_RenderingFlags_RenderingFlag.py b/tests/qflags/test_QtQuick_RenderingFlags_RenderingFlag.py index 5373ebe4..53900aec 100644 --- a/tests/qflags/test_QtQuick_RenderingFlags_RenderingFlag.py +++ b/tests/qflags/test_QtQuick_RenderingFlags_RenderingFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_ShaderCompilationTypes_ShaderCompilationType.py b/tests/qflags/test_QtQuick_ShaderCompilationTypes_ShaderCompilationType.py index 73a2e1d6..30e909f3 100644 --- a/tests/qflags/test_QtQuick_ShaderCompilationTypes_ShaderCompilationType.py +++ b/tests/qflags/test_QtQuick_ShaderCompilationTypes_ShaderCompilationType.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_ShaderSourceTypes_ShaderSourceType.py b/tests/qflags/test_QtQuick_ShaderSourceTypes_ShaderSourceType.py index e0cf2e41..7a7689e3 100644 --- a/tests/qflags/test_QtQuick_ShaderSourceTypes_ShaderSourceType.py +++ b/tests/qflags/test_QtQuick_ShaderSourceTypes_ShaderSourceType.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_StateFlags_StateFlag.py b/tests/qflags/test_QtQuick_StateFlags_StateFlag.py index cbcb4f19..aad01618 100644 --- a/tests/qflags/test_QtQuick_StateFlags_StateFlag.py +++ b/tests/qflags/test_QtQuick_StateFlags_StateFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py b/tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py index 5ead690b..a3bc3338 100644 --- a/tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py +++ b/tests/qflags/test_QtQuick_TextureCoordinatesTransformMode_TextureCoordinatesTransformFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtSerialPort_Directions_Direction.py b/tests/qflags/test_QtSerialPort_Directions_Direction.py index cb09c81d..f85a0d56 100644 --- a/tests/qflags/test_QtSerialPort_Directions_Direction.py +++ b/tests/qflags/test_QtSerialPort_Directions_Direction.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtSerialPort_PinoutSignals_PinoutSignal.py b/tests/qflags/test_QtSerialPort_PinoutSignals_PinoutSignal.py index 24a8fbaf..1db5c045 100644 --- a/tests/qflags/test_QtSerialPort_PinoutSignals_PinoutSignal.py +++ b/tests/qflags/test_QtSerialPort_PinoutSignals_PinoutSignal.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtWebEngineCore_Flags_Flag.py b/tests/qflags/test_QtWebEngineCore_Flags_Flag.py index 7219f3b2..3678f783 100644 --- a/tests/qflags/test_QtWebEngineCore_Flags_Flag.py +++ b/tests/qflags/test_QtWebEngineCore_Flags_Flag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtWebEngineWidgets_EditFlags_EditFlag.py b/tests/qflags/test_QtWebEngineWidgets_EditFlags_EditFlag.py index 40454479..6717cc6f 100644 --- a/tests/qflags/test_QtWebEngineWidgets_EditFlags_EditFlag.py +++ b/tests/qflags/test_QtWebEngineWidgets_EditFlags_EditFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtWebEngineWidgets_FindFlags_FindFlag.py b/tests/qflags/test_QtWebEngineWidgets_FindFlags_FindFlag.py index 0ff413cd..f911102a 100644 --- a/tests/qflags/test_QtWebEngineWidgets_FindFlags_FindFlag.py +++ b/tests/qflags/test_QtWebEngineWidgets_FindFlags_FindFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] diff --git a/tests/qflags/test_QtWebEngineWidgets_MediaFlags_MediaFlag.py b/tests/qflags/test_QtWebEngineWidgets_MediaFlags_MediaFlag.py index 1e37eb14..c8541810 100644 --- a/tests/qflags/test_QtWebEngineWidgets_MediaFlags_MediaFlag.py +++ b/tests/qflags/test_QtWebEngineWidgets_MediaFlags_MediaFlag.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] From 4a369ef78c82654267f5c07b851ac8d0b80d9be1 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 19 Nov 2021 23:10:09 +0100 Subject: [PATCH 370/421] type: ignore comments are needed here --- tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py b/tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py index 88fe5ef2..267b5f8c 100644 --- a/tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py +++ b/tests/qflags/test_Qt3DRender_BufferTypeFlags_BufferType.py @@ -230,9 +230,9 @@ def test_on_multi_flag_class() -> None: #########################################################1 if not SUPPORTS_ONE_OP_MULTI: - pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) - pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) - pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) + pytest.raises(TypeError, lambda: oneFlagValue1 | multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 & multiFlagValue1) # type: ignore[operator] + pytest.raises(TypeError, lambda: oneFlagValue1 ^ multiFlagValue1) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 | multiFlagValue1 ) # type: ignore[operator] pytest.raises(TypeError, lambda: 1 & multiFlagValue1 ) # type: ignore[operator] From ec16ba21bb431b9ee519ced2824ae26633d69ed7 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 28 Nov 2021 09:44:58 -0500 Subject: [PATCH 371/421] Remove tests_require tests_require isn't really a thing that is done anymore. --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 6d97f94d..85cfe08e 100644 --- a/setup.py +++ b/setup.py @@ -50,7 +50,6 @@ def find_version(*file_paths): python_requires=">= 3.5", package_data={"PyQt5-stubs": ['*.pyi']}, packages=["PyQt5-stubs"], - tests_require=["PyQt5==5.14.*"], extras_require={"build": ["docker==4.2.0"]}, classifiers=[ "Development Status :: 4 - Beta", From 146018d87f35a189728694958665d9554b678a2f Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 28 Nov 2021 10:46:08 -0500 Subject: [PATCH 372/421] drop requirements files and pin to the supported 5.15.3 --- requirements/develop.in | 3 --- requirements/develop.txt | 36 ------------------------------------ requirements/production.in | 1 - requirements/production.txt | 12 ------------ setup.py | 5 ++++- tox.ini | 5 +++-- 6 files changed, 7 insertions(+), 55 deletions(-) delete mode 100644 requirements/develop.in delete mode 100644 requirements/develop.txt delete mode 100644 requirements/production.in delete mode 100644 requirements/production.txt diff --git a/requirements/develop.in b/requirements/develop.in deleted file mode 100644 index 8669f94f..00000000 --- a/requirements/develop.in +++ /dev/null @@ -1,3 +0,0 @@ --r production.txt -mypy -pytest diff --git a/requirements/develop.txt b/requirements/develop.txt deleted file mode 100644 index b12fe1ef..00000000 --- a/requirements/develop.txt +++ /dev/null @@ -1,36 +0,0 @@ -# -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: -# -# pip-compile --output-file=requirements/develop.txt requirements/develop.in -# -attrs==21.2.0 - # via pytest -iniconfig==1.1.1 - # via pytest -mypy==0.910 - # via -r requirements/develop.in -mypy-extensions==0.4.3 - # via mypy -packaging==21.0 - # via pytest -pluggy==0.13.1 - # via pytest -py==1.10.0 - # via pytest -pyparsing==2.4.7 - # via packaging -pyqt5==5.14.2 - # via -r requirements/production.txt -pyqt5-sip==12.9.0 - # via - # -r requirements/production.txt - # pyqt5 -pytest==6.2.4 - # via -r requirements/develop.in -toml==0.10.2 - # via - # mypy - # pytest -typing-extensions==3.10.0.0 - # via mypy diff --git a/requirements/production.in b/requirements/production.in deleted file mode 100644 index 927b7660..00000000 --- a/requirements/production.in +++ /dev/null @@ -1 +0,0 @@ -PyQt5==5.15.* diff --git a/requirements/production.txt b/requirements/production.txt deleted file mode 100644 index c66b0197..00000000 --- a/requirements/production.txt +++ /dev/null @@ -1,12 +0,0 @@ -# -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: -# -# pip-compile --output-file=requirements/production.txt requirements/production.in -# -pyqt5==5.15.4 - # via -r requirements/production.in -pyqt5-qt5==5.15.2 - # via pyqt5 -pyqt5-sip==12.9.0 - # via pyqt5 diff --git a/setup.py b/setup.py index 6d97f94d..fc38a9e8 100644 --- a/setup.py +++ b/setup.py @@ -51,7 +51,10 @@ def find_version(*file_paths): package_data={"PyQt5-stubs": ['*.pyi']}, packages=["PyQt5-stubs"], tests_require=["PyQt5==5.14.*"], - extras_require={"build": ["docker==4.2.0"]}, + extras_require={ + "build": ["docker==4.2.0"], + "dev": ["mypy", "pytest"], + }, classifiers=[ "Development Status :: 4 - Beta", "Intended Audience :: Developers", diff --git a/tox.ini b/tox.ini index 12680fec..9f31f16f 100644 --- a/tox.ini +++ b/tox.ini @@ -3,10 +3,11 @@ envlist = py3{5,6,7,8,9} [testenv] deps = - -r requirements/develop.txt pip>=20.0 +extras = + dev commands = - pip install PyQt5==5.15.* PyQt3D==5.15.* PyQtChart==5.15.* PyQtDataVisualization==5.15.* PyQtNetworkAuth==5.15.* PyQtPurchasing==5.15.* PyQtWebEngine==5.15.* + pip install PyQt5==5.15.3 PyQt3D==5.15.3 PyQtChart==5.15.3 PyQtDataVisualization==5.15.3 PyQtNetworkAuth==5.15.3 PyQtPurchasing==5.15.3 PyQtWebEngine==5.15.3 mypy --show-error-codes -p PyQt5-stubs stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review PyQt5 pytest --capture=no --verbose {posargs} From 16e1de88d6ec598c4cf63bea38ad8b15af171b5b Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 28 Nov 2021 10:52:26 -0500 Subject: [PATCH 373/421] pip freeze --all in tox --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 9f31f16f..01555c5e 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,7 @@ extras = dev commands = pip install PyQt5==5.15.3 PyQt3D==5.15.3 PyQtChart==5.15.3 PyQtDataVisualization==5.15.3 PyQtNetworkAuth==5.15.3 PyQtPurchasing==5.15.3 PyQtWebEngine==5.15.3 + pip freeze --all mypy --show-error-codes -p PyQt5-stubs stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review PyQt5 pytest --capture=no --verbose {posargs} From 0ce23797e4bbeeee8c4b2cecc90638d8e171be98 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 28 Nov 2021 16:26:48 -0500 Subject: [PATCH 374/421] update tox.ini to 5.15.4 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 01555c5e..e280dd8b 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ deps = extras = dev commands = - pip install PyQt5==5.15.3 PyQt3D==5.15.3 PyQtChart==5.15.3 PyQtDataVisualization==5.15.3 PyQtNetworkAuth==5.15.3 PyQtPurchasing==5.15.3 PyQtWebEngine==5.15.3 + pip install PyQt5==5.15.4 PyQt3D==5.15.4 PyQtChart==5.15.4 PyQtDataVisualization==5.15.4 PyQtNetworkAuth==5.15.4 PyQtPurchasing==5.15.4 PyQtWebEngine==5.15.4 pip freeze --all mypy --show-error-codes -p PyQt5-stubs stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review PyQt5 From 70c1d0531b05b30b47186cc68474a8597b0e49a2 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 29 Nov 2021 09:12:54 -0500 Subject: [PATCH 375/421] 5.15.5 --- Dockerfile | 59 +- PyQt5-stubs/Qt3DAnimation.pyi | 823 ++--- PyQt5-stubs/Qt3DCore.pyi | 795 ++--- PyQt5-stubs/Qt3DExtras.pyi | 1518 ++++----- PyQt5-stubs/Qt3DInput.pyi | 692 ++-- PyQt5-stubs/Qt3DLogic.pyi | 13 +- PyQt5-stubs/Qt3DRender.pyi | 4511 ++++++++++++++------------- PyQt5-stubs/QtBluetooth.pyi | 2 +- PyQt5-stubs/QtChart.pyi | 2823 ++++++++--------- PyQt5-stubs/QtCore.pyi | 2 +- PyQt5-stubs/QtDBus.pyi | 2 +- PyQt5-stubs/QtDataVisualization.pyi | 2719 ++++++++-------- PyQt5-stubs/QtDesigner.pyi | 2 +- PyQt5-stubs/QtGui.pyi | 5 +- PyQt5-stubs/QtHelp.pyi | 2 +- PyQt5-stubs/QtLocation.pyi | 2 +- PyQt5-stubs/QtMultimedia.pyi | 2 +- PyQt5-stubs/QtMultimediaWidgets.pyi | 2 +- PyQt5-stubs/QtNetwork.pyi | 2 +- PyQt5-stubs/QtNetworkAuth.pyi | 79 +- PyQt5-stubs/QtNfc.pyi | 2 +- PyQt5-stubs/QtOpenGL.pyi | 2 +- PyQt5-stubs/QtPositioning.pyi | 2 +- PyQt5-stubs/QtPrintSupport.pyi | 2 +- PyQt5-stubs/QtPurchasing.pyi | 2 +- PyQt5-stubs/QtQml.pyi | 2 +- PyQt5-stubs/QtQuick.pyi | 2 +- PyQt5-stubs/QtQuickWidgets.pyi | 2 +- PyQt5-stubs/QtRemoteObjects.pyi | 2 +- PyQt5-stubs/QtSensors.pyi | 2 +- PyQt5-stubs/QtSerialPort.pyi | 2 +- PyQt5-stubs/QtSql.pyi | 2 +- PyQt5-stubs/QtSvg.pyi | 2 +- PyQt5-stubs/QtTest.pyi | 2 +- PyQt5-stubs/QtWebChannel.pyi | 2 +- PyQt5-stubs/QtWebEngine.pyi | 2 +- PyQt5-stubs/QtWebEngineCore.pyi | 5 +- PyQt5-stubs/QtWebEngineWidgets.pyi | 2 +- PyQt5-stubs/QtWebKit.pyi | 2 +- PyQt5-stubs/QtWebKitWidgets.pyi | 2 +- PyQt5-stubs/QtWebSockets.pyi | 2 +- PyQt5-stubs/QtWidgets.pyi | 6 +- PyQt5-stubs/QtX11Extras.pyi | 2 +- PyQt5-stubs/QtXml.pyi | 2 +- PyQt5-stubs/QtXmlPatterns.pyi | 2 +- PyQt5-stubs/__init__.pyi | 2 +- 46 files changed, 7229 insertions(+), 6885 deletions(-) diff --git a/Dockerfile b/Dockerfile index 88859565..72d80203 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,18 +2,19 @@ # https://hub.docker.com/_/archlinux?tab=tags&page=1&ordering=last_updated # BUILD_DATE is a path from: # https://archive.archlinux.org/repos/ -ARG ARCH_VERSION="base-20210221.0.15908" -ARG BUILD_DATE="2021/03/13" - -ARG SIP_VERSION="6.0.3" -# Also the major.minor of PyQt5-sip -ARG SIP_ABI_VERSION="12.8" -ARG PYQT_VERSION="5.15.4" -ARG PYQT_3D_VERSION="5.15.4" -ARG PYQT_CHART_VERSION="5.15.4" -ARG PYQT_DATA_VISUALIZATION_VERSION="5.15.4" -ARG PYQT_PURCHASING_VERSION="5.15.4" -ARG PYQT_WEB_ENGINE_VERSION="5.15.4" +ARG ARCH_VERSION="base-20211017.0.36769" +ARG BUILD_DATE="2021/10/28" + +ARG SIP_VERSION="6.3.1" +# Also the major of PyQt5-sip +ARG SIP_ABI_VERSION="12" +ARG PYQT_VERSION="5.15.5" +ARG PYQT_3D_VERSION="5.15.5" +ARG PYQT_CHART_VERSION="5.15.5" +ARG PYQT_DATA_VISUALIZATION_VERSION="5.15.5" +ARG PYQT_PURCHASING_VERSION="5.15.5" +ARG PYQT_WEB_ENGINE_VERSION="5.15.5" +ARG PYQT_NETWORK_AUTH_VERSION="5.15.5" ARG MAKEFLAGS="" @@ -301,6 +302,39 @@ RUN sip-install \ WORKDIR /output/ RUN find /upstream/ -name \*.pyi -exec cp {} . \; +################################################################################ +# PyQtNetworkAuth +################################################################################ + +FROM build-dep AS pyqt-network-auth + +# Reuse arguments from previous build scope +ARG MAKEFLAGS +ARG PYQT_NETWORK_AUTH_VERSION + +# Download source tar +RUN wget --no-verbose \ + --output-document upstream.tar.gz \ + https://pypi.io/packages/source/p/pyqtnetworkauth/PyQtNetworkAuth-${PYQT_NETWORK_AUTH_VERSION}.tar.gz +RUN mkdir /upstream/ && \ + tar -xf \ + upstream.tar.gz \ + --directory /upstream/ \ + --strip-components 1 + +# Build PyQtNetworkAuth with stubs +# TODO: Find way to build only stubs +WORKDIR /upstream/ +RUN sip-install \ + --qmake /usr/bin/qmake-qt5 \ + --pep484-pyi \ + --build-dir ./build \ + --verbose + +# Copy all .pyi files to output dir +WORKDIR /output/ +RUN find /upstream/ -name \*.pyi -exec cp {} . \; + ################################################################################ # Output ################################################################################ @@ -316,6 +350,7 @@ COPY --from=pyqt-chart /output/* ./ COPY --from=pyqt-data-visualization /output/* ./ COPY --from=pyqt-purchasing /output/* ./ COPY --from=pyqt-web-engine /output/* ./ +COPY --from=pyqt-network-auth /output/* ./ # Required to run the image (which we need to do to get the files) CMD /bin/true diff --git a/PyQt5-stubs/Qt3DAnimation.pyi b/PyQt5-stubs/Qt3DAnimation.pyi index 14e31f71..44c209f7 100644 --- a/PyQt5-stubs/Qt3DAnimation.pyi +++ b/PyQt5-stubs/Qt3DAnimation.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DAnimation module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -42,408 +42,433 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], typing.Sequence[float], PyQt5.sip.Buffer, int, None] -class Qt3DAnimation(PyQt5.sip.simplewrapper): +class QAbstractAnimation(QtCore.QObject): - class QAbstractAnimation(QtCore.QObject): + class AnimationType(int): + KeyframeAnimation = ... # type: QAbstractAnimation.AnimationType + MorphingAnimation = ... # type: QAbstractAnimation.AnimationType + VertexBlendAnimation = ... # type: QAbstractAnimation.AnimationType - class AnimationType(int): - KeyframeAnimation = ... # type: QAbstractAnimation.AnimationType - MorphingAnimation = ... # type: QAbstractAnimation.AnimationType - VertexBlendAnimation = ... # type: QAbstractAnimation.AnimationType + def durationChanged(self, duration: float) -> None: ... + def positionChanged(self, position: float) -> None: ... + def animationNameChanged(self, name: str) -> None: ... + def setDuration(self, duration: float) -> None: ... + def setPosition(self, position: float) -> None: ... + def setAnimationName(self, name: str) -> None: ... + def duration(self) -> float: ... + def position(self) -> float: ... + def animationType(self) -> 'QAbstractAnimation.AnimationType': ... + def animationName(self) -> str: ... - def durationChanged(self, duration: float) -> None: ... - def positionChanged(self, position: float) -> None: ... - def animationNameChanged(self, name: str) -> None: ... - def setDuration(self, duration: float) -> None: ... - def setPosition(self, position: float) -> None: ... - def setAnimationName(self, name: str) -> None: ... - def duration(self) -> float: ... - def position(self) -> float: ... - def animationType(self) -> 'QAbstractAnimation.AnimationType': ... - def animationName(self) -> str: ... - class QAbstractAnimationClip(Qt3DCore.QNode): +class QAbstractAnimationClip(Qt3DCore.QNode): - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def durationChanged(self, duration: float) -> None: ... - def duration(self) -> float: ... + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def durationChanged(self, duration: float) -> None: ... + def duration(self) -> float: ... - class QAbstractChannelMapping(Qt3DCore.QNode): ... - class QAbstractClipAnimator(Qt3DCore.QComponent): - - class Loops(int): - Infinite = ... # type: QAbstractClipAnimator.Loops - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def normalizedTimeChanged(self, index: float) -> None: ... - def clockChanged(self, clock: 'QClock') -> None: ... - def loopCountChanged(self, loops: int) -> None: ... - def channelMapperChanged(self, channelMapper: 'QChannelMapper') -> None: ... - def runningChanged(self, running: bool) -> None: ... - def stop(self) -> None: ... - def start(self) -> None: ... - def setNormalizedTime(self, timeFraction: float) -> None: ... - def setClock(self, clock: 'QClock') -> None: ... - def setLoopCount(self, loops: int) -> None: ... - def setChannelMapper(self, channelMapper: 'QChannelMapper') -> None: ... - def setRunning(self, running: bool) -> None: ... - def normalizedTime(self) -> float: ... - def clock(self) -> 'QClock': ... - def loopCount(self) -> int: ... - def channelMapper(self) -> 'QChannelMapper': ... - def isRunning(self) -> bool: ... - - class QAbstractClipBlendNode(Qt3DCore.QNode): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QAdditiveClipBlend('QAbstractClipBlendNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def additiveClipChanged(self, additiveClip: 'QAbstractClipBlendNode') -> None: ... - def baseClipChanged(self, baseClip: 'QAbstractClipBlendNode') -> None: ... - def additiveFactorChanged(self, additiveFactor: float) -> None: ... - def setAdditiveClip(self, additiveClip: 'QAbstractClipBlendNode') -> None: ... - def setBaseClip(self, baseClip: 'QAbstractClipBlendNode') -> None: ... - def setAdditiveFactor(self, additiveFactor: float) -> None: ... - def additiveClip(self) -> 'QAbstractClipBlendNode': ... - def baseClip(self) -> 'QAbstractClipBlendNode': ... - def additiveFactor(self) -> float: ... - - class QAnimationAspect(Qt3DCore.QAbstractAspect): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - class QAnimationClip('QAbstractAnimationClip'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def clipDataChanged(self, clipData: 'QAnimationClipData') -> None: ... - def setClipData(self, clipData: 'QAnimationClipData') -> None: ... - def clipData(self) -> 'QAnimationClipData': ... - - class QAnimationClipData(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, a0: 'QAnimationClipData') -> None: ... - - def isValid(self) -> bool: ... - def clearChannels(self) -> None: ... - def removeChannel(self, index: int) -> None: ... - def insertChannel(self, index: int, c: 'QChannel') -> None: ... - def appendChannel(self, c: 'QChannel') -> None: ... - def channelCount(self) -> int: ... - def name(self) -> str: ... - def setName(self, name: str) -> None: ... - - class QAnimationClipLoader('QAbstractAnimationClip'): - - class Status(int): - NotReady = ... # type: QAnimationClipLoader.Status - Ready = ... # type: QAnimationClipLoader.Status - Error = ... # type: QAnimationClipLoader.Status - - @typing.overload - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - @typing.overload - def __init__(self, source: QtCore.QUrl, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QAnimationClipLoader.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... - def setSource(self, source: QtCore.QUrl) -> None: ... - def status(self) -> 'QAnimationClipLoader.Status': ... - def source(self) -> QtCore.QUrl: ... - - class QAnimationController(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def recursiveChanged(self, recursive: bool) -> None: ... - def entityChanged(self, entity: Qt3DCore.QEntity) -> None: ... - def positionOffsetChanged(self, offset: float) -> None: ... - def positionScaleChanged(self, scale: float) -> None: ... - def positionChanged(self, position: float) -> None: ... - def activeAnimationGroupChanged(self, index: int) -> None: ... - def setRecursive(self, recursive: bool) -> None: ... - def setEntity(self, entity: Qt3DCore.QEntity) -> None: ... - def setPositionOffset(self, offset: float) -> None: ... - def setPositionScale(self, scale: float) -> None: ... - def setPosition(self, position: float) -> None: ... - def setActiveAnimationGroup(self, index: int) -> None: ... - def getGroup(self, index: int) -> 'QAnimationGroup': ... - def getAnimationIndex(self, name: str) -> int: ... - def removeAnimationGroup(self, animationGroups: 'QAnimationGroup') -> None: ... - def addAnimationGroup(self, animationGroups: 'QAnimationGroup') -> None: ... - def setAnimationGroups(self, animationGroups: typing.Iterable['QAnimationGroup']) -> None: ... - def recursive(self) -> bool: ... - def entity(self) -> Qt3DCore.QEntity: ... - def positionOffset(self) -> float: ... - def positionScale(self) -> float: ... - def position(self) -> float: ... - def activeAnimationGroup(self) -> int: ... - def animationGroupList(self) -> typing.List['QAnimationGroup']: ... - - class QAnimationGroup(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def durationChanged(self, duration: float) -> None: ... - def positionChanged(self, position: float) -> None: ... - def nameChanged(self, name: str) -> None: ... - def setPosition(self, position: float) -> None: ... - def setName(self, name: str) -> None: ... - def removeAnimation(self, animation: 'QAbstractAnimation') -> None: ... - def addAnimation(self, animation: 'QAbstractAnimation') -> None: ... - def setAnimations(self, animations: typing.Iterable['QAbstractAnimation']) -> None: ... - def duration(self) -> float: ... - def position(self) -> float: ... - def animationList(self) -> typing.List['QAbstractAnimation']: ... - def name(self) -> str: ... - - class QBlendedClipAnimator('QAbstractClipAnimator'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def blendTreeChanged(self, blendTree: 'QAbstractClipBlendNode') -> None: ... - def setBlendTree(self, blendTree: 'QAbstractClipBlendNode') -> None: ... - def blendTree(self) -> 'QAbstractClipBlendNode': ... - - class QChannel(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, name: str) -> None: ... - @typing.overload - def __init__(self, a0: 'QChannel') -> None: ... - - def clearChannelComponents(self) -> None: ... - def removeChannelComponent(self, index: int) -> None: ... - def insertChannelComponent(self, index: int, component: 'QChannelComponent') -> None: ... - def appendChannelComponent(self, component: 'QChannelComponent') -> None: ... - def channelComponentCount(self) -> int: ... - def jointIndex(self) -> int: ... - def setJointIndex(self, jointIndex: int) -> None: ... - def name(self) -> str: ... - def setName(self, name: str) -> None: ... - - class QChannelComponent(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, name: str) -> None: ... - @typing.overload - def __init__(self, a0: 'QChannelComponent') -> None: ... - - def clearKeyFrames(self) -> None: ... - def removeKeyFrame(self, index: int) -> None: ... - def insertKeyFrame(self, index: int, kf: 'QKeyFrame') -> None: ... - def appendKeyFrame(self, kf: 'QKeyFrame') -> None: ... - def keyFrameCount(self) -> int: ... - def name(self) -> str: ... - def setName(self, name: str) -> None: ... - - class QChannelMapper(Qt3DCore.QNode): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def mappings(self) -> typing.List['QAbstractChannelMapping']: ... - def removeMapping(self, mapping: 'QAbstractChannelMapping') -> None: ... - def addMapping(self, mapping: 'QAbstractChannelMapping') -> None: ... - - class QChannelMapping('QAbstractChannelMapping'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def propertyChanged(self, property: str) -> None: ... - def targetChanged(self, target: Qt3DCore.QNode) -> None: ... - def channelNameChanged(self, channelName: str) -> None: ... - def setProperty(self, property: str) -> None: ... - def setTarget(self, target: Qt3DCore.QNode) -> None: ... - def setChannelName(self, channelName: str) -> None: ... - def property(self) -> str: ... - def target(self) -> Qt3DCore.QNode: ... - def channelName(self) -> str: ... - - class QClipAnimator('QAbstractClipAnimator'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def clipChanged(self, clip: 'QAbstractAnimationClip') -> None: ... - def setClip(self, clip: 'QAbstractAnimationClip') -> None: ... - def clip(self) -> 'QAbstractAnimationClip': ... - - class QClipBlendNodeCreatedChangeBase(Qt3DCore.QNodeCreatedChangeBase): - - def __init__(self, node: 'QAbstractClipBlendNode') -> None: ... - - class QClipBlendValue('QAbstractClipBlendNode'): - - @typing.overload - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - @typing.overload - def __init__(self, clip: 'QAbstractAnimationClip', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def clipChanged(self, clip: 'QAbstractAnimationClip') -> None: ... - def setClip(self, clip: 'QAbstractAnimationClip') -> None: ... - def clip(self) -> 'QAbstractAnimationClip': ... - - class QClock(Qt3DCore.QNode): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def playbackRateChanged(self, playbackRate: float) -> None: ... - def setPlaybackRate(self, playbackRate: float) -> None: ... - def playbackRate(self) -> float: ... - - class QKeyFrame(sip.simplewrapper): - - class InterpolationType(int): - ConstantInterpolation = ... # type: QKeyFrame.InterpolationType - LinearInterpolation = ... # type: QKeyFrame.InterpolationType - BezierInterpolation = ... # type: QKeyFrame.InterpolationType - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, coords: QtGui.QVector2D) -> None: ... - @typing.overload - def __init__(self, coords: QtGui.QVector2D, lh: QtGui.QVector2D, rh: QtGui.QVector2D) -> None: ... - @typing.overload - def __init__(self, a0: 'QKeyFrame') -> None: ... - - def interpolationType(self) -> 'QKeyFrame.InterpolationType': ... - def setInterpolationType(self, interp: 'QKeyFrame.InterpolationType') -> None: ... - def rightControlPoint(self) -> QtGui.QVector2D: ... - def setRightControlPoint(self, rh: QtGui.QVector2D) -> None: ... - def leftControlPoint(self) -> QtGui.QVector2D: ... - def setLeftControlPoint(self, lh: QtGui.QVector2D) -> None: ... - def coordinates(self) -> QtGui.QVector2D: ... - def setCoordinates(self, coords: QtGui.QVector2D) -> None: ... - - class QKeyframeAnimation('QAbstractAnimation'): - - class RepeatMode(int): - None_ = ... # type: QKeyframeAnimation.RepeatMode - Constant = ... # type: QKeyframeAnimation.RepeatMode - Repeat = ... # type: QKeyframeAnimation.RepeatMode - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def endModeChanged(self, endMode: 'QKeyframeAnimation.RepeatMode') -> None: ... - def startModeChanged(self, startMode: 'QKeyframeAnimation.RepeatMode') -> None: ... - def targetNameChanged(self, name: str) -> None: ... - def easingChanged(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... - def targetChanged(self, target: Qt3DCore.QTransform) -> None: ... - def framePositionsChanged(self, positions: typing.Iterable[float]) -> None: ... - def setEndMode(self, mode: 'QKeyframeAnimation.RepeatMode') -> None: ... - def setStartMode(self, mode: 'QKeyframeAnimation.RepeatMode') -> None: ... - def setTargetName(self, name: str) -> None: ... - def setEasing(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... - def setTarget(self, target: Qt3DCore.QTransform) -> None: ... - def setFramePositions(self, positions: typing.Iterable[float]) -> None: ... - def removeKeyframe(self, keyframe: Qt3DCore.QTransform) -> None: ... - def addKeyframe(self, keyframe: Qt3DCore.QTransform) -> None: ... - def setKeyframes(self, keyframes: typing.Iterable[Qt3DCore.QTransform]) -> None: ... - def endMode(self) -> 'QKeyframeAnimation.RepeatMode': ... - def startMode(self) -> 'QKeyframeAnimation.RepeatMode': ... - def targetName(self) -> str: ... - def easing(self) -> QtCore.QEasingCurve: ... - def target(self) -> Qt3DCore.QTransform: ... - def keyframeList(self) -> typing.List[Qt3DCore.QTransform]: ... - def framePositions(self) -> typing.List[float]: ... - - class QLerpClipBlend('QAbstractClipBlendNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def endClipChanged(self, endClip: 'QAbstractClipBlendNode') -> None: ... - def startClipChanged(self, startClip: 'QAbstractClipBlendNode') -> None: ... - def blendFactorChanged(self, blendFactor: float) -> None: ... - def setEndClip(self, endClip: 'QAbstractClipBlendNode') -> None: ... - def setStartClip(self, startClip: 'QAbstractClipBlendNode') -> None: ... - def setBlendFactor(self, blendFactor: float) -> None: ... - def endClip(self) -> 'QAbstractClipBlendNode': ... - def startClip(self) -> 'QAbstractClipBlendNode': ... - def blendFactor(self) -> float: ... - - class QMorphingAnimation('QAbstractAnimation'): - - class Method(int): - Normalized = ... # type: QMorphingAnimation.Method - Relative = ... # type: QMorphingAnimation.Method - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def easingChanged(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... - def methodChanged(self, method: 'QMorphingAnimation.Method') -> None: ... - def targetNameChanged(self, name: str) -> None: ... - def targetChanged(self, target: Qt3DRender.QGeometryRenderer) -> None: ... - def interpolatorChanged(self, interpolator: float) -> None: ... - def targetPositionsChanged(self, targetPositions: typing.Iterable[float]) -> None: ... - def setEasing(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... - def setMethod(self, method: 'QMorphingAnimation.Method') -> None: ... - def setTargetName(self, name: str) -> None: ... - def setTarget(self, target: Qt3DRender.QGeometryRenderer) -> None: ... - def setTargetPositions(self, targetPositions: typing.Iterable[float]) -> None: ... - def morphTargetList(self) -> typing.List['QMorphTarget']: ... - def getWeights(self, positionIndex: int) -> typing.List[float]: ... - def setWeights(self, positionIndex: int, weights: typing.Iterable[float]) -> None: ... - def removeMorphTarget(self, target: 'QMorphTarget') -> None: ... - def addMorphTarget(self, target: 'QMorphTarget') -> None: ... - def setMorphTargets(self, targets: typing.Iterable['QMorphTarget']) -> None: ... - def easing(self) -> QtCore.QEasingCurve: ... - def method(self) -> 'QMorphingAnimation.Method': ... - def targetName(self) -> str: ... - def target(self) -> Qt3DRender.QGeometryRenderer: ... - def interpolator(self) -> float: ... - def targetPositions(self) -> typing.List[float]: ... - - class QMorphTarget(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def attributeNamesChanged(self, attributeNames: typing.Iterable[str]) -> None: ... - @staticmethod - def fromGeometry(geometry: Qt3DRender.QGeometry, attributes: typing.Iterable[str]) -> 'QMorphTarget': ... - def removeAttribute(self, attribute: Qt3DRender.QAttribute) -> None: ... - def addAttribute(self, attribute: Qt3DRender.QAttribute) -> None: ... - def setAttributes(self, attributes: typing.Iterable[Qt3DRender.QAttribute]) -> None: ... - def attributeNames(self) -> typing.List[str]: ... - def attributeList(self) -> typing.List[Qt3DRender.QAttribute]: ... - - class QSkeletonMapping('QAbstractChannelMapping'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def skeletonChanged(self, skeleton: Qt3DCore.QAbstractSkeleton) -> None: ... - def setSkeleton(self, skeleton: Qt3DCore.QAbstractSkeleton) -> None: ... - def skeleton(self) -> Qt3DCore.QAbstractSkeleton: ... - - class QVertexBlendAnimation('QAbstractAnimation'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def targetNameChanged(self, name: str) -> None: ... - def targetChanged(self, target: Qt3DRender.QGeometryRenderer) -> None: ... - def interpolatorChanged(self, interpolator: float) -> None: ... - def targetPositionsChanged(self, targetPositions: typing.Iterable[float]) -> None: ... - def setTargetName(self, name: str) -> None: ... - def setTarget(self, target: Qt3DRender.QGeometryRenderer) -> None: ... - def setTargetPositions(self, targetPositions: typing.Iterable[float]) -> None: ... - def morphTargetList(self) -> typing.List['QMorphTarget']: ... - def removeMorphTarget(self, target: 'QMorphTarget') -> None: ... - def addMorphTarget(self, target: 'QMorphTarget') -> None: ... - def setMorphTargets(self, targets: typing.Iterable['QMorphTarget']) -> None: ... - def targetName(self) -> str: ... - def target(self) -> Qt3DRender.QGeometryRenderer: ... - def interpolator(self) -> float: ... - def targetPositions(self) -> typing.List[float]: ... +class QAbstractChannelMapping(Qt3DCore.QNode): ... + + +class QAbstractClipAnimator(Qt3DCore.QComponent): + + class Loops(int): + Infinite = ... # type: QAbstractClipAnimator.Loops + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def normalizedTimeChanged(self, index: float) -> None: ... + def clockChanged(self, clock: 'QClock') -> None: ... + def loopCountChanged(self, loops: int) -> None: ... + def channelMapperChanged(self, channelMapper: 'QChannelMapper') -> None: ... + def runningChanged(self, running: bool) -> None: ... + def stop(self) -> None: ... + def start(self) -> None: ... + def setNormalizedTime(self, timeFraction: float) -> None: ... + def setClock(self, clock: 'QClock') -> None: ... + def setLoopCount(self, loops: int) -> None: ... + def setChannelMapper(self, channelMapper: 'QChannelMapper') -> None: ... + def setRunning(self, running: bool) -> None: ... + def normalizedTime(self) -> float: ... + def clock(self) -> 'QClock': ... + def loopCount(self) -> int: ... + def channelMapper(self) -> 'QChannelMapper': ... + def isRunning(self) -> bool: ... + + +class QAbstractClipBlendNode(Qt3DCore.QNode): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QAdditiveClipBlend('QAbstractClipBlendNode'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def additiveClipChanged(self, additiveClip: 'QAbstractClipBlendNode') -> None: ... + def baseClipChanged(self, baseClip: 'QAbstractClipBlendNode') -> None: ... + def additiveFactorChanged(self, additiveFactor: float) -> None: ... + def setAdditiveClip(self, additiveClip: 'QAbstractClipBlendNode') -> None: ... + def setBaseClip(self, baseClip: 'QAbstractClipBlendNode') -> None: ... + def setAdditiveFactor(self, additiveFactor: float) -> None: ... + def additiveClip(self) -> 'QAbstractClipBlendNode': ... + def baseClip(self) -> 'QAbstractClipBlendNode': ... + def additiveFactor(self) -> float: ... + + +class QAnimationAspect(Qt3DCore.QAbstractAspect): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + +class QAnimationClip('QAbstractAnimationClip'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def clipDataChanged(self, clipData: 'QAnimationClipData') -> None: ... + def setClipData(self, clipData: 'QAnimationClipData') -> None: ... + def clipData(self) -> 'QAnimationClipData': ... + + +class QAnimationClipData(sip.simplewrapper): + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, a0: 'QAnimationClipData') -> None: ... + + def isValid(self) -> bool: ... + def clearChannels(self) -> None: ... + def removeChannel(self, index: int) -> None: ... + def insertChannel(self, index: int, c: 'QChannel') -> None: ... + def appendChannel(self, c: 'QChannel') -> None: ... + def channelCount(self) -> int: ... + def name(self) -> str: ... + def setName(self, name: str) -> None: ... + + +class QAnimationClipLoader('QAbstractAnimationClip'): + + class Status(int): + NotReady = ... # type: QAnimationClipLoader.Status + Ready = ... # type: QAnimationClipLoader.Status + Error = ... # type: QAnimationClipLoader.Status + + @typing.overload + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self, source: QtCore.QUrl, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def statusChanged(self, status: 'QAnimationClipLoader.Status') -> None: ... + def sourceChanged(self, source: QtCore.QUrl) -> None: ... + def setSource(self, source: QtCore.QUrl) -> None: ... + def status(self) -> 'QAnimationClipLoader.Status': ... + def source(self) -> QtCore.QUrl: ... + + +class QAnimationController(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def recursiveChanged(self, recursive: bool) -> None: ... + def entityChanged(self, entity: Qt3DCore.QEntity) -> None: ... + def positionOffsetChanged(self, offset: float) -> None: ... + def positionScaleChanged(self, scale: float) -> None: ... + def positionChanged(self, position: float) -> None: ... + def activeAnimationGroupChanged(self, index: int) -> None: ... + def setRecursive(self, recursive: bool) -> None: ... + def setEntity(self, entity: Qt3DCore.QEntity) -> None: ... + def setPositionOffset(self, offset: float) -> None: ... + def setPositionScale(self, scale: float) -> None: ... + def setPosition(self, position: float) -> None: ... + def setActiveAnimationGroup(self, index: int) -> None: ... + def getGroup(self, index: int) -> 'QAnimationGroup': ... + def getAnimationIndex(self, name: str) -> int: ... + def removeAnimationGroup(self, animationGroups: 'QAnimationGroup') -> None: ... + def addAnimationGroup(self, animationGroups: 'QAnimationGroup') -> None: ... + def setAnimationGroups(self, animationGroups: typing.Iterable['QAnimationGroup']) -> None: ... + def recursive(self) -> bool: ... + def entity(self) -> Qt3DCore.QEntity: ... + def positionOffset(self) -> float: ... + def positionScale(self) -> float: ... + def position(self) -> float: ... + def activeAnimationGroup(self) -> int: ... + def animationGroupList(self) -> typing.List['QAnimationGroup']: ... + + +class QAnimationGroup(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def durationChanged(self, duration: float) -> None: ... + def positionChanged(self, position: float) -> None: ... + def nameChanged(self, name: str) -> None: ... + def setPosition(self, position: float) -> None: ... + def setName(self, name: str) -> None: ... + def removeAnimation(self, animation: 'QAbstractAnimation') -> None: ... + def addAnimation(self, animation: 'QAbstractAnimation') -> None: ... + def setAnimations(self, animations: typing.Iterable['QAbstractAnimation']) -> None: ... + def duration(self) -> float: ... + def position(self) -> float: ... + def animationList(self) -> typing.List['QAbstractAnimation']: ... + def name(self) -> str: ... + + +class QBlendedClipAnimator('QAbstractClipAnimator'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def blendTreeChanged(self, blendTree: 'QAbstractClipBlendNode') -> None: ... + def setBlendTree(self, blendTree: 'QAbstractClipBlendNode') -> None: ... + def blendTree(self) -> 'QAbstractClipBlendNode': ... + + +class QChannel(sip.simplewrapper): + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, name: str) -> None: ... + @typing.overload + def __init__(self, a0: 'QChannel') -> None: ... + + def clearChannelComponents(self) -> None: ... + def removeChannelComponent(self, index: int) -> None: ... + def insertChannelComponent(self, index: int, component: 'QChannelComponent') -> None: ... + def appendChannelComponent(self, component: 'QChannelComponent') -> None: ... + def channelComponentCount(self) -> int: ... + def jointIndex(self) -> int: ... + def setJointIndex(self, jointIndex: int) -> None: ... + def name(self) -> str: ... + def setName(self, name: str) -> None: ... + + +class QChannelComponent(sip.simplewrapper): + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, name: str) -> None: ... + @typing.overload + def __init__(self, a0: 'QChannelComponent') -> None: ... + + def clearKeyFrames(self) -> None: ... + def removeKeyFrame(self, index: int) -> None: ... + def insertKeyFrame(self, index: int, kf: 'QKeyFrame') -> None: ... + def appendKeyFrame(self, kf: 'QKeyFrame') -> None: ... + def keyFrameCount(self) -> int: ... + def name(self) -> str: ... + def setName(self, name: str) -> None: ... + + +class QChannelMapper(Qt3DCore.QNode): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def mappings(self) -> typing.List['QAbstractChannelMapping']: ... + def removeMapping(self, mapping: 'QAbstractChannelMapping') -> None: ... + def addMapping(self, mapping: 'QAbstractChannelMapping') -> None: ... + + +class QChannelMapping('QAbstractChannelMapping'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def propertyChanged(self, property: str) -> None: ... + def targetChanged(self, target: Qt3DCore.QNode) -> None: ... + def channelNameChanged(self, channelName: str) -> None: ... + def setProperty(self, property: str) -> None: ... + def setTarget(self, target: Qt3DCore.QNode) -> None: ... + def setChannelName(self, channelName: str) -> None: ... + def property(self) -> str: ... + def target(self) -> Qt3DCore.QNode: ... + def channelName(self) -> str: ... + + +class QClipAnimator('QAbstractClipAnimator'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def clipChanged(self, clip: 'QAbstractAnimationClip') -> None: ... + def setClip(self, clip: 'QAbstractAnimationClip') -> None: ... + def clip(self) -> 'QAbstractAnimationClip': ... + + +class QClipBlendNodeCreatedChangeBase(Qt3DCore.QNodeCreatedChangeBase): + + def __init__(self, node: 'QAbstractClipBlendNode') -> None: ... + + +class QClipBlendValue('QAbstractClipBlendNode'): + + @typing.overload + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self, clip: 'QAbstractAnimationClip', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def clipChanged(self, clip: 'QAbstractAnimationClip') -> None: ... + def setClip(self, clip: 'QAbstractAnimationClip') -> None: ... + def clip(self) -> 'QAbstractAnimationClip': ... + + +class QClock(Qt3DCore.QNode): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def playbackRateChanged(self, playbackRate: float) -> None: ... + def setPlaybackRate(self, playbackRate: float) -> None: ... + def playbackRate(self) -> float: ... + + +class QKeyFrame(sip.simplewrapper): + + class InterpolationType(int): + ConstantInterpolation = ... # type: QKeyFrame.InterpolationType + LinearInterpolation = ... # type: QKeyFrame.InterpolationType + BezierInterpolation = ... # type: QKeyFrame.InterpolationType + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, coords: QtGui.QVector2D) -> None: ... + @typing.overload + def __init__(self, coords: QtGui.QVector2D, lh: QtGui.QVector2D, rh: QtGui.QVector2D) -> None: ... + @typing.overload + def __init__(self, a0: 'QKeyFrame') -> None: ... + + def interpolationType(self) -> 'QKeyFrame.InterpolationType': ... + def setInterpolationType(self, interp: 'QKeyFrame.InterpolationType') -> None: ... + def rightControlPoint(self) -> QtGui.QVector2D: ... + def setRightControlPoint(self, rh: QtGui.QVector2D) -> None: ... + def leftControlPoint(self) -> QtGui.QVector2D: ... + def setLeftControlPoint(self, lh: QtGui.QVector2D) -> None: ... + def coordinates(self) -> QtGui.QVector2D: ... + def setCoordinates(self, coords: QtGui.QVector2D) -> None: ... + + +class QKeyframeAnimation('QAbstractAnimation'): + + class RepeatMode(int): + None_ = ... # type: QKeyframeAnimation.RepeatMode + Constant = ... # type: QKeyframeAnimation.RepeatMode + Repeat = ... # type: QKeyframeAnimation.RepeatMode + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def endModeChanged(self, endMode: 'QKeyframeAnimation.RepeatMode') -> None: ... + def startModeChanged(self, startMode: 'QKeyframeAnimation.RepeatMode') -> None: ... + def targetNameChanged(self, name: str) -> None: ... + def easingChanged(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... + def targetChanged(self, target: Qt3DCore.QTransform) -> None: ... + def framePositionsChanged(self, positions: typing.Iterable[float]) -> None: ... + def setEndMode(self, mode: 'QKeyframeAnimation.RepeatMode') -> None: ... + def setStartMode(self, mode: 'QKeyframeAnimation.RepeatMode') -> None: ... + def setTargetName(self, name: str) -> None: ... + def setEasing(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... + def setTarget(self, target: Qt3DCore.QTransform) -> None: ... + def setFramePositions(self, positions: typing.Iterable[float]) -> None: ... + def removeKeyframe(self, keyframe: Qt3DCore.QTransform) -> None: ... + def addKeyframe(self, keyframe: Qt3DCore.QTransform) -> None: ... + def setKeyframes(self, keyframes: typing.Iterable[Qt3DCore.QTransform]) -> None: ... + def endMode(self) -> 'QKeyframeAnimation.RepeatMode': ... + def startMode(self) -> 'QKeyframeAnimation.RepeatMode': ... + def targetName(self) -> str: ... + def easing(self) -> QtCore.QEasingCurve: ... + def target(self) -> Qt3DCore.QTransform: ... + def keyframeList(self) -> typing.List[Qt3DCore.QTransform]: ... + def framePositions(self) -> typing.List[float]: ... + + +class QLerpClipBlend('QAbstractClipBlendNode'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def endClipChanged(self, endClip: 'QAbstractClipBlendNode') -> None: ... + def startClipChanged(self, startClip: 'QAbstractClipBlendNode') -> None: ... + def blendFactorChanged(self, blendFactor: float) -> None: ... + def setEndClip(self, endClip: 'QAbstractClipBlendNode') -> None: ... + def setStartClip(self, startClip: 'QAbstractClipBlendNode') -> None: ... + def setBlendFactor(self, blendFactor: float) -> None: ... + def endClip(self) -> 'QAbstractClipBlendNode': ... + def startClip(self) -> 'QAbstractClipBlendNode': ... + def blendFactor(self) -> float: ... + + +class QMorphingAnimation('QAbstractAnimation'): + + class Method(int): + Normalized = ... # type: QMorphingAnimation.Method + Relative = ... # type: QMorphingAnimation.Method + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def easingChanged(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... + def methodChanged(self, method: 'QMorphingAnimation.Method') -> None: ... + def targetNameChanged(self, name: str) -> None: ... + def targetChanged(self, target: Qt3DRender.QGeometryRenderer) -> None: ... + def interpolatorChanged(self, interpolator: float) -> None: ... + def targetPositionsChanged(self, targetPositions: typing.Iterable[float]) -> None: ... + def setEasing(self, easing: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... + def setMethod(self, method: 'QMorphingAnimation.Method') -> None: ... + def setTargetName(self, name: str) -> None: ... + def setTarget(self, target: Qt3DRender.QGeometryRenderer) -> None: ... + def setTargetPositions(self, targetPositions: typing.Iterable[float]) -> None: ... + def morphTargetList(self) -> typing.List['QMorphTarget']: ... + def getWeights(self, positionIndex: int) -> typing.List[float]: ... + def setWeights(self, positionIndex: int, weights: typing.Iterable[float]) -> None: ... + def removeMorphTarget(self, target: 'QMorphTarget') -> None: ... + def addMorphTarget(self, target: 'QMorphTarget') -> None: ... + def setMorphTargets(self, targets: typing.Iterable['QMorphTarget']) -> None: ... + def easing(self) -> QtCore.QEasingCurve: ... + def method(self) -> 'QMorphingAnimation.Method': ... + def targetName(self) -> str: ... + def target(self) -> Qt3DRender.QGeometryRenderer: ... + def interpolator(self) -> float: ... + def targetPositions(self) -> typing.List[float]: ... + + +class QMorphTarget(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def attributeNamesChanged(self, attributeNames: typing.Iterable[str]) -> None: ... + @staticmethod + def fromGeometry(geometry: Qt3DRender.QGeometry, attributes: typing.Iterable[str]) -> 'QMorphTarget': ... + def removeAttribute(self, attribute: Qt3DRender.QAttribute) -> None: ... + def addAttribute(self, attribute: Qt3DRender.QAttribute) -> None: ... + def setAttributes(self, attributes: typing.Iterable[Qt3DRender.QAttribute]) -> None: ... + def attributeNames(self) -> typing.List[str]: ... + def attributeList(self) -> typing.List[Qt3DRender.QAttribute]: ... + + +class QSkeletonMapping('QAbstractChannelMapping'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def skeletonChanged(self, skeleton: Qt3DCore.QAbstractSkeleton) -> None: ... + def setSkeleton(self, skeleton: Qt3DCore.QAbstractSkeleton) -> None: ... + def skeleton(self) -> Qt3DCore.QAbstractSkeleton: ... + + +class QVertexBlendAnimation('QAbstractAnimation'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def targetNameChanged(self, name: str) -> None: ... + def targetChanged(self, target: Qt3DRender.QGeometryRenderer) -> None: ... + def interpolatorChanged(self, interpolator: float) -> None: ... + def targetPositionsChanged(self, targetPositions: typing.Iterable[float]) -> None: ... + def setTargetName(self, name: str) -> None: ... + def setTarget(self, target: Qt3DRender.QGeometryRenderer) -> None: ... + def setTargetPositions(self, targetPositions: typing.Iterable[float]) -> None: ... + def morphTargetList(self) -> typing.List['QMorphTarget']: ... + def removeMorphTarget(self, target: 'QMorphTarget') -> None: ... + def addMorphTarget(self, target: 'QMorphTarget') -> None: ... + def setMorphTargets(self, targets: typing.Iterable['QMorphTarget']) -> None: ... + def targetName(self) -> str: ... + def target(self) -> Qt3DRender.QGeometryRenderer: ... + def interpolator(self) -> float: ... + def targetPositions(self) -> typing.List[float]: ... diff --git a/PyQt5-stubs/Qt3DCore.pyi b/PyQt5-stubs/Qt3DCore.pyi index cbe8c673..d4cc77d6 100644 --- a/PyQt5-stubs/Qt3DCore.pyi +++ b/PyQt5-stubs/Qt3DCore.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DCore module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -41,463 +41,496 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], typing.Sequence[float], PyQt5.sip.Buffer, int, None] -class Qt3DCore(PyQt5.sip.simplewrapper): +class ChangeFlag(int): + NodeCreated = ... # type: ChangeFlag + NodeDeleted = ... # type: ChangeFlag + PropertyUpdated = ... # type: ChangeFlag + PropertyValueAdded = ... # type: ChangeFlag + PropertyValueRemoved = ... # type: ChangeFlag + ComponentAdded = ... # type: ChangeFlag + ComponentRemoved = ... # type: ChangeFlag + CommandRequested = ... # type: ChangeFlag + CallbackTriggered = ... # type: ChangeFlag + AllChanges = ... # type: ChangeFlag - class ChangeFlag(int): - NodeCreated = ... # type: ChangeFlag - NodeDeleted = ... # type: ChangeFlag - PropertyUpdated = ... # type: ChangeFlag - PropertyValueAdded = ... # type: ChangeFlag - PropertyValueRemoved = ... # type: ChangeFlag - ComponentAdded = ... # type: ChangeFlag - ComponentRemoved = ... # type: ChangeFlag - CommandRequested = ... # type: ChangeFlag - CallbackTriggered = ... # type: ChangeFlag - AllChanges = ... # type: ChangeFlag - class QAbstractAspect(QtCore.QObject): +class QAbstractAspect(QtCore.QObject): - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - def unregisterBackendType(self, a0: QtCore.QMetaObject) -> None: ... - @typing.overload - def registerBackendType(self, a0: QtCore.QMetaObject, functor: 'QBackendNodeMapper') -> None: ... - @typing.overload - def registerBackendType(self, obj: QtCore.QMetaObject, functor: 'QBackendNodeMapper', supportsSyncing: bool) -> None: ... - def rootEntityId(self) -> 'QNodeId': ... + def unregisterBackendType(self, a0: QtCore.QMetaObject) -> None: ... + @typing.overload + def registerBackendType(self, a0: QtCore.QMetaObject, functor: 'QBackendNodeMapper') -> None: ... + @typing.overload + def registerBackendType(self, obj: QtCore.QMetaObject, functor: 'QBackendNodeMapper', supportsSyncing: bool) -> None: ... + def rootEntityId(self) -> 'QNodeId': ... - class QAspectEngine(QtCore.QObject): - class RunMode(int): - Manual = ... # type: QAspectEngine.RunMode - Automatic = ... # type: QAspectEngine.RunMode +class QAspectEngine(QtCore.QObject): - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + class RunMode(int): + Manual = ... # type: QAspectEngine.RunMode + Automatic = ... # type: QAspectEngine.RunMode - def processFrame(self) -> None: ... - def runMode(self) -> 'QAspectEngine.RunMode': ... - def setRunMode(self, mode: 'QAspectEngine.RunMode') -> None: ... - def executeCommand(self, command: str) -> typing.Any: ... - def aspects(self) -> typing.List['QAbstractAspect']: ... - @typing.overload - def unregisterAspect(self, aspect: 'QAbstractAspect') -> None: ... - @typing.overload - def unregisterAspect(self, name: str) -> None: ... - @typing.overload - def registerAspect(self, aspect: 'QAbstractAspect') -> None: ... - @typing.overload - def registerAspect(self, name: str) -> None: ... - def rootEntity(self) -> 'QEntity': ... - def setRootEntity(self, root: 'QEntity') -> None: ... - - class QNode(QtCore.QObject): - - class PropertyTrackingMode(int): - TrackFinalValues = ... # type: QNode.PropertyTrackingMode - DontTrackValues = ... # type: QNode.PropertyTrackingMode - TrackAllValues = ... # type: QNode.PropertyTrackingMode - - def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - - def sendReply(self, command: 'QNodeCommand') -> None: ... - def sendCommand(self, name: str, data: typing.Any = ..., replyTo: int = ...) -> int: ... - def defaultPropertyTrackingModeChanged(self, mode: 'QNode.PropertyTrackingMode') -> None: ... - def setDefaultPropertyTrackingMode(self, mode: 'QNode.PropertyTrackingMode') -> None: ... - def clearPropertyTrackings(self) -> None: ... - def clearPropertyTracking(self, propertyName: str) -> None: ... - def propertyTracking(self, propertyName: str) -> 'QNode.PropertyTrackingMode': ... - def setPropertyTracking(self, propertyName: str, trackMode: 'QNode.PropertyTrackingMode') -> None: ... - def defaultPropertyTrackingMode(self) -> 'QNode.PropertyTrackingMode': ... - def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - def notifyObservers(self, change: 'QSceneChange') -> None: ... - def nodeDestroyed(self) -> None: ... - def enabledChanged(self, enabled: bool) -> None: ... - def parentChanged(self, parent: QtCore.QObject) -> None: ... - def setEnabled(self, isEnabled: bool) -> None: ... - def setParent(self, parent: 'QNode') -> None: ... - def isEnabled(self) -> bool: ... - def childNodes(self) -> typing.List['QNode']: ... - def blockNotifications(self, block: bool) -> bool: ... - def notificationsBlocked(self) -> bool: ... - def parentNode(self) -> 'QNode': ... - def id(self) -> 'QNodeId': ... - - class QAbstractSkeleton('QNode'): - - def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - def jointCountChanged(self, jointCount: int) -> None: ... - def jointCount(self) -> int: ... - - class QComponent('QNode'): - - def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - - def removedFromEntity(self, entity: 'QEntity') -> None: ... - def addedToEntity(self, entity: 'QEntity') -> None: ... - def shareableChanged(self, isShareable: bool) -> None: ... - def setShareable(self, isShareable: bool) -> None: ... - def entities(self) -> typing.List['QEntity']: ... - def isShareable(self) -> bool: ... - - class QArmature('QComponent'): - - def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - - def skeletonChanged(self, skeleton: 'QAbstractSkeleton') -> None: ... - def setSkeleton(self, skeleton: 'QAbstractSkeleton') -> None: ... - def skeleton(self) -> 'QAbstractSkeleton': ... - - class QBackendNodeMapper(sip.simplewrapper): + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, a0: 'QBackendNodeMapper') -> None: ... + def processFrame(self) -> None: ... + def runMode(self) -> 'QAspectEngine.RunMode': ... + def setRunMode(self, mode: 'QAspectEngine.RunMode') -> None: ... + def executeCommand(self, command: str) -> typing.Any: ... + def aspects(self) -> typing.List['QAbstractAspect']: ... + @typing.overload + def unregisterAspect(self, aspect: 'QAbstractAspect') -> None: ... + @typing.overload + def unregisterAspect(self, name: str) -> None: ... + @typing.overload + def registerAspect(self, aspect: 'QAbstractAspect') -> None: ... + @typing.overload + def registerAspect(self, name: str) -> None: ... + def rootEntity(self) -> 'QEntity': ... + def setRootEntity(self, root: 'QEntity') -> None: ... - def destroy(self, id: 'QNodeId') -> None: ... - def get(self, id: 'QNodeId') -> 'QBackendNode': ... - def create(self, change: 'QNodeCreatedChangeBase') -> 'QBackendNode': ... - class QBackendNode(sip.simplewrapper): +class QNode(QtCore.QObject): - class Mode(int): - ReadOnly = ... # type: QBackendNode.Mode - ReadWrite = ... # type: QBackendNode.Mode + class PropertyTrackingMode(int): + TrackFinalValues = ... # type: QNode.PropertyTrackingMode + DontTrackValues = ... # type: QNode.PropertyTrackingMode + TrackAllValues = ... # type: QNode.PropertyTrackingMode - def __init__(self, mode: 'QBackendNode.Mode' = ...) -> None: ... + def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - def sendReply(self, command: 'QNodeCommand') -> None: ... - def sendCommand(self, name: str, data: typing.Any, replyTo: int = ...) -> int: ... - def sceneChangeEvent(self, e: 'QSceneChange') -> None: ... - def notifyObservers(self, e: 'QSceneChange') -> None: ... - def mode(self) -> 'QBackendNode.Mode': ... - def isEnabled(self) -> bool: ... - def setEnabled(self, enabled: bool) -> None: ... - def peerId(self) -> 'QNodeId': ... + def sendReply(self, command: 'QNodeCommand') -> None: ... + def sendCommand(self, name: str, data: typing.Any = ..., replyTo: int = ...) -> int: ... + def defaultPropertyTrackingModeChanged(self, mode: 'QNode.PropertyTrackingMode') -> None: ... + def setDefaultPropertyTrackingMode(self, mode: 'QNode.PropertyTrackingMode') -> None: ... + def clearPropertyTrackings(self) -> None: ... + def clearPropertyTracking(self, propertyName: str) -> None: ... + def propertyTracking(self, propertyName: str) -> 'QNode.PropertyTrackingMode': ... + def setPropertyTracking(self, propertyName: str, trackMode: 'QNode.PropertyTrackingMode') -> None: ... + def defaultPropertyTrackingMode(self) -> 'QNode.PropertyTrackingMode': ... + def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... + def notifyObservers(self, change: 'QSceneChange') -> None: ... + def nodeDestroyed(self) -> None: ... + def enabledChanged(self, enabled: bool) -> None: ... + def parentChanged(self, parent: QtCore.QObject) -> None: ... + def setEnabled(self, isEnabled: bool) -> None: ... + def setParent(self, parent: 'QNode') -> None: ... + def isEnabled(self) -> bool: ... + def childNodes(self) -> typing.List['QNode']: ... + def blockNotifications(self, block: bool) -> bool: ... + def notificationsBlocked(self) -> bool: ... + def parentNode(self) -> 'QNode': ... + def id(self) -> 'QNodeId': ... - class QSceneChange(sip.simplewrapper): - class DeliveryFlag(int): - BackendNodes = ... # type: QSceneChange.DeliveryFlag - Nodes = ... # type: QSceneChange.DeliveryFlag - DeliverToAll = ... # type: QSceneChange.DeliveryFlag +class QAbstractSkeleton('QNode'): - class DeliveryFlags(sip.simplewrapper): + def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... + def jointCountChanged(self, jointCount: int) -> None: ... + def jointCount(self) -> int: ... - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, f: typing.Union['QSceneChange.DeliveryFlags', 'QSceneChange.DeliveryFlag']) -> None: ... - @typing.overload - def __init__(self, a0: 'QSceneChange.DeliveryFlags') -> None: ... - def __hash__(self) -> int: ... - def __bool__(self) -> int: ... - def __invert__(self) -> 'QSceneChange.DeliveryFlags': ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... +class QComponent('QNode'): - def __init__(self, type: 'ChangeFlag', subjectId: 'QNodeId') -> None: ... + def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - def subjectId(self) -> 'QNodeId': ... - def deliveryFlags(self) -> 'QSceneChange.DeliveryFlags': ... - def setDeliveryFlags(self, flags: typing.Union['QSceneChange.DeliveryFlags', 'QSceneChange.DeliveryFlag']) -> None: ... - def type(self) -> 'ChangeFlag': ... + def removedFromEntity(self, entity: 'QEntity') -> None: ... + def addedToEntity(self, entity: 'QEntity') -> None: ... + def shareableChanged(self, isShareable: bool) -> None: ... + def setShareable(self, isShareable: bool) -> None: ... + def entities(self) -> typing.List['QEntity']: ... + def isShareable(self) -> bool: ... - class QComponentAddedChange('QSceneChange'): - @typing.overload - def __init__(self, entity: 'QEntity', component: 'QComponent') -> None: ... - @typing.overload - def __init__(self, component: 'QComponent', entity: 'QEntity') -> None: ... +class QArmature('QComponent'): - def componentMetaObject(self) -> QtCore.QMetaObject: ... - def componentId(self) -> 'QNodeId': ... - def entityId(self) -> 'QNodeId': ... + def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - class QComponentRemovedChange('QSceneChange'): + def skeletonChanged(self, skeleton: 'QAbstractSkeleton') -> None: ... + def setSkeleton(self, skeleton: 'QAbstractSkeleton') -> None: ... + def skeleton(self) -> 'QAbstractSkeleton': ... - @typing.overload - def __init__(self, entity: 'QEntity', component: 'QComponent') -> None: ... - @typing.overload - def __init__(self, component: 'QComponent', entity: 'QEntity') -> None: ... - - def componentMetaObject(self) -> QtCore.QMetaObject: ... - def componentId(self) -> 'QNodeId': ... - def entityId(self) -> 'QNodeId': ... - - class QPropertyUpdatedChangeBase('QSceneChange'): - - def __init__(self, subjectId: 'QNodeId') -> None: ... - - class QDynamicPropertyUpdatedChange('QPropertyUpdatedChangeBase'): - - def __init__(self, subjectId: 'QNodeId') -> None: ... - - def setValue(self, value: typing.Any) -> None: ... - def value(self) -> typing.Any: ... - def setPropertyName(self, name: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def propertyName(self) -> QtCore.QByteArray: ... - - class QEntity('QNode'): - - def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - - def parentEntity(self) -> 'QEntity': ... - def removeComponent(self, comp: 'QComponent') -> None: ... - def addComponent(self, comp: 'QComponent') -> None: ... - def components(self) -> typing.List['QComponent']: ... - - class QJoint('QNode'): - - def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - - def nameChanged(self, name: str) -> None: ... - def rotationZChanged(self, rotationZ: float) -> None: ... - def rotationYChanged(self, rotationY: float) -> None: ... - def rotationXChanged(self, rotationX: float) -> None: ... - def inverseBindMatrixChanged(self, inverseBindMatrix: QtGui.QMatrix4x4) -> None: ... - def translationChanged(self, translation: QtGui.QVector3D) -> None: ... - def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def scaleChanged(self, scale: QtGui.QVector3D) -> None: ... - def setToIdentity(self) -> None: ... - def setName(self, name: str) -> None: ... - def setRotationZ(self, rotationZ: float) -> None: ... - def setRotationY(self, rotationY: float) -> None: ... - def setRotationX(self, rotationX: float) -> None: ... - def setInverseBindMatrix(self, inverseBindMatrix: QtGui.QMatrix4x4) -> None: ... - def setTranslation(self, translation: QtGui.QVector3D) -> None: ... - def setRotation(self, rotation: QtGui.QQuaternion) -> None: ... - def setScale(self, scale: QtGui.QVector3D) -> None: ... - def childJoints(self) -> typing.List['QJoint']: ... - def removeChildJoint(self, joint: 'QJoint') -> None: ... - def addChildJoint(self, joint: 'QJoint') -> None: ... - def name(self) -> str: ... - def rotationZ(self) -> float: ... - def rotationY(self) -> float: ... - def rotationX(self) -> float: ... - def inverseBindMatrix(self) -> QtGui.QMatrix4x4: ... - def translation(self) -> QtGui.QVector3D: ... - def rotation(self) -> QtGui.QQuaternion: ... - def scale(self) -> QtGui.QVector3D: ... - - class QNodeIdTypePair(sip.simplewrapper): - - id = ... # type: 'QNodeId' - type = ... # type: QtCore.QMetaObject - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, _id: 'QNodeId', _type: QtCore.QMetaObject) -> None: ... - @typing.overload - def __init__(self, a0: 'QNodeIdTypePair') -> None: ... +class QBackendNodeMapper(sip.simplewrapper): - class QNodeCommand('QSceneChange'): + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, a0: 'QBackendNodeMapper') -> None: ... - def __init__(self, id: 'QNodeId') -> None: ... + def destroy(self, id: 'QNodeId') -> None: ... + def get(self, id: 'QNodeId') -> 'QBackendNode': ... + def create(self, change: 'QNodeCreatedChangeBase') -> 'QBackendNode': ... - def setReplyToCommandId(self, id: int) -> None: ... - def inReplyTo(self) -> int: ... - def setData(self, data: typing.Any) -> None: ... - def data(self) -> typing.Any: ... - def setName(self, name: str) -> None: ... - def name(self) -> str: ... - def commandId(self) -> int: ... - class QNodeCreatedChangeBase('QSceneChange'): +class QBackendNode(sip.simplewrapper): - def __init__(self, node: 'QNode') -> None: ... + class Mode(int): + ReadOnly = ... # type: QBackendNode.Mode + ReadWrite = ... # type: QBackendNode.Mode - def isNodeEnabled(self) -> bool: ... - def metaObject(self) -> QtCore.QMetaObject: ... - def parentId(self) -> 'QNodeId': ... + def __init__(self, mode: 'QBackendNode.Mode' = ...) -> None: ... - class QNodeDestroyedChange('QSceneChange'): + def sendReply(self, command: 'QNodeCommand') -> None: ... + def sendCommand(self, name: str, data: typing.Any, replyTo: int = ...) -> int: ... + def sceneChangeEvent(self, e: 'QSceneChange') -> None: ... + def notifyObservers(self, e: 'QSceneChange') -> None: ... + def mode(self) -> 'QBackendNode.Mode': ... + def isEnabled(self) -> bool: ... + def setEnabled(self, enabled: bool) -> None: ... + def peerId(self) -> 'QNodeId': ... - def __init__(self, node: 'QNode', subtreeIdsAndTypes: typing.Iterable['QNodeIdTypePair']) -> None: ... - def subtreeIdsAndTypes(self) -> typing.List['QNodeIdTypePair']: ... +class QSceneChange(sip.simplewrapper): - class QNodeId(sip.simplewrapper): + class DeliveryFlag(int): + BackendNodes = ... # type: QSceneChange.DeliveryFlag + Nodes = ... # type: QSceneChange.DeliveryFlag + DeliverToAll = ... # type: QSceneChange.DeliveryFlag + + class DeliveryFlags(sip.simplewrapper): @typing.overload def __init__(self) -> None: ... @typing.overload - def __init__(self, a0: 'QNodeId') -> None: ... + def __init__(self, f: typing.Union['QSceneChange.DeliveryFlags', 'QSceneChange.DeliveryFlag']) -> None: ... + @typing.overload + def __init__(self, a0: 'QSceneChange.DeliveryFlags') -> None: ... def __hash__(self) -> int: ... - def __int__(self) -> bool: ... - def id(self) -> int: ... - def isNull(self) -> bool: ... - @staticmethod - def createId() -> 'QNodeId': ... + def __bool__(self) -> int: ... + def __invert__(self) -> 'QSceneChange.DeliveryFlags': ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... - class QPropertyValueAddedChangeBase('QSceneChange'): + def __init__(self, type: 'ChangeFlag', subjectId: 'QNodeId') -> None: ... - def __init__(self, subjectId: 'QNodeId') -> None: ... + def subjectId(self) -> 'QNodeId': ... + def deliveryFlags(self) -> 'QSceneChange.DeliveryFlags': ... + def setDeliveryFlags(self, flags: typing.Union['QSceneChange.DeliveryFlags', 'QSceneChange.DeliveryFlag']) -> None: ... + def type(self) -> 'ChangeFlag': ... - class QStaticPropertyValueAddedChangeBase('QPropertyValueAddedChangeBase'): - def __init__(self, subjectId: 'QNodeId') -> None: ... +class QComponentAddedChange('QSceneChange'): - def setPropertyName(self, name: str) -> None: ... - def propertyName(self) -> str: ... + @typing.overload + def __init__(self, entity: 'QEntity', component: 'QComponent') -> None: ... + @typing.overload + def __init__(self, component: 'QComponent', entity: 'QEntity') -> None: ... - class QPropertyNodeAddedChange('QStaticPropertyValueAddedChangeBase'): + def componentMetaObject(self) -> QtCore.QMetaObject: ... + def componentId(self) -> 'QNodeId': ... + def entityId(self) -> 'QNodeId': ... - def __init__(self, subjectId: 'QNodeId', node: 'QNode') -> None: ... - def metaObject(self) -> QtCore.QMetaObject: ... - def addedNodeId(self) -> 'QNodeId': ... +class QComponentRemovedChange('QSceneChange'): - class QPropertyValueRemovedChangeBase('QSceneChange'): + @typing.overload + def __init__(self, entity: 'QEntity', component: 'QComponent') -> None: ... + @typing.overload + def __init__(self, component: 'QComponent', entity: 'QEntity') -> None: ... - def __init__(self, subjectId: 'QNodeId') -> None: ... + def componentMetaObject(self) -> QtCore.QMetaObject: ... + def componentId(self) -> 'QNodeId': ... + def entityId(self) -> 'QNodeId': ... - class QStaticPropertyValueRemovedChangeBase('QPropertyValueRemovedChangeBase'): - def __init__(self, subjectId: 'QNodeId') -> None: ... +class QPropertyUpdatedChangeBase('QSceneChange'): - def setPropertyName(self, name: str) -> None: ... - def propertyName(self) -> str: ... + def __init__(self, subjectId: 'QNodeId') -> None: ... - class QPropertyNodeRemovedChange('QStaticPropertyValueRemovedChangeBase'): - def __init__(self, subjectId: 'QNodeId', node: 'QNode') -> None: ... +class QDynamicPropertyUpdatedChange('QPropertyUpdatedChangeBase'): - def metaObject(self) -> QtCore.QMetaObject: ... - def removedNodeId(self) -> 'QNodeId': ... + def __init__(self, subjectId: 'QNodeId') -> None: ... - class QStaticPropertyUpdatedChangeBase('QPropertyUpdatedChangeBase'): + def setValue(self, value: typing.Any) -> None: ... + def value(self) -> typing.Any: ... + def setPropertyName(self, name: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def propertyName(self) -> QtCore.QByteArray: ... - def __init__(self, subjectId: 'QNodeId') -> None: ... - def setPropertyName(self, name: str) -> None: ... - def propertyName(self) -> str: ... +class QEntity('QNode'): - class QPropertyUpdatedChange('QStaticPropertyUpdatedChangeBase'): + def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - def __init__(self, subjectId: 'QNodeId') -> None: ... + def parentEntity(self) -> 'QEntity': ... + def removeComponent(self, comp: 'QComponent') -> None: ... + def addComponent(self, comp: 'QComponent') -> None: ... + def components(self) -> typing.List['QComponent']: ... - def setValue(self, value: typing.Any) -> None: ... - def value(self) -> typing.Any: ... - class QPropertyValueAddedChange('QStaticPropertyValueAddedChangeBase'): +class QJoint('QNode'): - def __init__(self, subjectId: 'QNodeId') -> None: ... + def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - def addedValue(self) -> typing.Any: ... - def setAddedValue(self, value: typing.Any) -> None: ... + def nameChanged(self, name: str) -> None: ... + def rotationZChanged(self, rotationZ: float) -> None: ... + def rotationYChanged(self, rotationY: float) -> None: ... + def rotationXChanged(self, rotationX: float) -> None: ... + def inverseBindMatrixChanged(self, inverseBindMatrix: QtGui.QMatrix4x4) -> None: ... + def translationChanged(self, translation: QtGui.QVector3D) -> None: ... + def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... + def scaleChanged(self, scale: QtGui.QVector3D) -> None: ... + def setToIdentity(self) -> None: ... + def setName(self, name: str) -> None: ... + def setRotationZ(self, rotationZ: float) -> None: ... + def setRotationY(self, rotationY: float) -> None: ... + def setRotationX(self, rotationX: float) -> None: ... + def setInverseBindMatrix(self, inverseBindMatrix: QtGui.QMatrix4x4) -> None: ... + def setTranslation(self, translation: QtGui.QVector3D) -> None: ... + def setRotation(self, rotation: QtGui.QQuaternion) -> None: ... + def setScale(self, scale: QtGui.QVector3D) -> None: ... + def childJoints(self) -> typing.List['QJoint']: ... + def removeChildJoint(self, joint: 'QJoint') -> None: ... + def addChildJoint(self, joint: 'QJoint') -> None: ... + def name(self) -> str: ... + def rotationZ(self) -> float: ... + def rotationY(self) -> float: ... + def rotationX(self) -> float: ... + def inverseBindMatrix(self) -> QtGui.QMatrix4x4: ... + def translation(self) -> QtGui.QVector3D: ... + def rotation(self) -> QtGui.QQuaternion: ... + def scale(self) -> QtGui.QVector3D: ... - class QPropertyValueRemovedChange('QStaticPropertyValueRemovedChangeBase'): - def __init__(self, subjectId: 'QNodeId') -> None: ... +class QNodeIdTypePair(sip.simplewrapper): - def removedValue(self) -> typing.Any: ... - def setRemovedValue(self, value: typing.Any) -> None: ... + id = ... # type: 'QNodeId' + type = ... # type: QtCore.QMetaObject - class ChangeFlags(sip.simplewrapper): + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, _id: 'QNodeId', _type: QtCore.QMetaObject) -> None: ... + @typing.overload + def __init__(self, a0: 'QNodeIdTypePair') -> None: ... - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, f: typing.Union['ChangeFlags', 'ChangeFlag']) -> None: ... - @typing.overload - def __init__(self, a0: 'ChangeFlags') -> None: ... - def __hash__(self) -> int: ... - def __bool__(self) -> int: ... - def __invert__(self) -> 'ChangeFlags': ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... +class QNodeCommand('QSceneChange'): - class QSkeleton('QAbstractSkeleton'): + def __init__(self, id: 'QNodeId') -> None: ... - def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... + def setReplyToCommandId(self, id: int) -> None: ... + def inReplyTo(self) -> int: ... + def setData(self, data: typing.Any) -> None: ... + def data(self) -> typing.Any: ... + def setName(self, name: str) -> None: ... + def name(self) -> str: ... + def commandId(self) -> int: ... - def rootJointChanged(self, rootJoint: 'QJoint') -> None: ... - def setRootJoint(self, rootJoint: 'QJoint') -> None: ... - def rootJoint(self) -> 'QJoint': ... - class QSkeletonLoader('QAbstractSkeleton'): +class QNodeCreatedChangeBase('QSceneChange'): - class Status(int): - NotReady = ... # type: QSkeletonLoader.Status - Ready = ... # type: QSkeletonLoader.Status - Error = ... # type: QSkeletonLoader.Status + def __init__(self, node: 'QNode') -> None: ... - @typing.overload - def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - @typing.overload - def __init__(self, source: QtCore.QUrl, parent: typing.Optional['QNode'] = ...) -> None: ... - - def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - def rootJointChanged(self, rootJoint: 'QJoint') -> None: ... - def createJointsEnabledChanged(self, createJointsEnabled: bool) -> None: ... - def statusChanged(self, status: 'QSkeletonLoader.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... - def setCreateJointsEnabled(self, enabled: bool) -> None: ... - def setSource(self, source: QtCore.QUrl) -> None: ... - def rootJoint(self) -> 'QJoint': ... - def isCreateJointsEnabled(self) -> bool: ... - def status(self) -> 'QSkeletonLoader.Status': ... - def source(self) -> QtCore.QUrl: ... - - class QTransform('QComponent'): - - def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... - - def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... - def worldMatrixChanged(self, worldMatrix: QtGui.QMatrix4x4) -> None: ... - def worldMatrix(self) -> QtGui.QMatrix4x4: ... - def rotationZChanged(self, rotationZ: float) -> None: ... - def rotationYChanged(self, rotationY: float) -> None: ... - def rotationXChanged(self, rotationX: float) -> None: ... - def matrixChanged(self) -> None: ... - def translationChanged(self, translation: QtGui.QVector3D) -> None: ... - def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def scale3DChanged(self, scale: QtGui.QVector3D) -> None: ... - def scaleChanged(self, scale: float) -> None: ... - def setRotationZ(self, rotationZ: float) -> None: ... - def setRotationY(self, rotationY: float) -> None: ... - def setRotationX(self, rotationX: float) -> None: ... - def setMatrix(self, matrix: QtGui.QMatrix4x4) -> None: ... - def setTranslation(self, translation: QtGui.QVector3D) -> None: ... - def setRotation(self, rotation: QtGui.QQuaternion) -> None: ... - def setScale3D(self, scale: QtGui.QVector3D) -> None: ... - def setScale(self, scale: float) -> None: ... - def rotationZ(self) -> float: ... - def rotationY(self) -> float: ... - def rotationX(self) -> float: ... - def matrix(self) -> QtGui.QMatrix4x4: ... - @staticmethod - def rotateFromAxes(xAxis: QtGui.QVector3D, yAxis: QtGui.QVector3D, zAxis: QtGui.QVector3D) -> QtGui.QMatrix4x4: ... - @staticmethod - def rotateAround(point: QtGui.QVector3D, angle: float, axis: QtGui.QVector3D) -> QtGui.QMatrix4x4: ... - @typing.overload - @staticmethod - def fromEulerAngles(eulerAngles: QtGui.QVector3D) -> QtGui.QQuaternion: ... - @typing.overload - @staticmethod - def fromEulerAngles(pitch: float, yaw: float, roll: float) -> QtGui.QQuaternion: ... - @typing.overload - @staticmethod - def fromAxesAndAngles(axis1: QtGui.QVector3D, angle1: float, axis2: QtGui.QVector3D, angle2: float) -> QtGui.QQuaternion: ... - @typing.overload - @staticmethod - def fromAxesAndAngles(axis1: QtGui.QVector3D, angle1: float, axis2: QtGui.QVector3D, angle2: float, axis3: QtGui.QVector3D, angle3: float) -> QtGui.QQuaternion: ... - @typing.overload - @staticmethod - def fromAxisAndAngle(axis: QtGui.QVector3D, angle: float) -> QtGui.QQuaternion: ... - @typing.overload - @staticmethod - def fromAxisAndAngle(x: float, y: float, z: float, angle: float) -> QtGui.QQuaternion: ... - @staticmethod - def fromAxes(xAxis: QtGui.QVector3D, yAxis: QtGui.QVector3D, zAxis: QtGui.QVector3D) -> QtGui.QQuaternion: ... - def translation(self) -> QtGui.QVector3D: ... - def rotation(self) -> QtGui.QQuaternion: ... - def scale3D(self) -> QtGui.QVector3D: ... - def scale(self) -> float: ... - - def qIdForNode(self, node: 'QNode') -> 'QNodeId': ... + def isNodeEnabled(self) -> bool: ... + def metaObject(self) -> QtCore.QMetaObject: ... + def parentId(self) -> 'QNodeId': ... + + +class QNodeDestroyedChange('QSceneChange'): + + def __init__(self, node: 'QNode', subtreeIdsAndTypes: typing.Iterable['QNodeIdTypePair']) -> None: ... + + def subtreeIdsAndTypes(self) -> typing.List['QNodeIdTypePair']: ... + + +class QNodeId(sip.simplewrapper): + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, a0: 'QNodeId') -> None: ... + + def __hash__(self) -> int: ... + def __int__(self) -> bool: ... + def id(self) -> int: ... + def isNull(self) -> bool: ... + @staticmethod + def createId() -> 'QNodeId': ... + + +class QPropertyValueAddedChangeBase('QSceneChange'): + + def __init__(self, subjectId: 'QNodeId') -> None: ... + + +class QStaticPropertyValueAddedChangeBase('QPropertyValueAddedChangeBase'): + + def __init__(self, subjectId: 'QNodeId') -> None: ... + + def setPropertyName(self, name: str) -> None: ... + def propertyName(self) -> str: ... + + +class QPropertyNodeAddedChange('QStaticPropertyValueAddedChangeBase'): + + def __init__(self, subjectId: 'QNodeId', node: 'QNode') -> None: ... + + def metaObject(self) -> QtCore.QMetaObject: ... + def addedNodeId(self) -> 'QNodeId': ... + + +class QPropertyValueRemovedChangeBase('QSceneChange'): + + def __init__(self, subjectId: 'QNodeId') -> None: ... + + +class QStaticPropertyValueRemovedChangeBase('QPropertyValueRemovedChangeBase'): + + def __init__(self, subjectId: 'QNodeId') -> None: ... + + def setPropertyName(self, name: str) -> None: ... + def propertyName(self) -> str: ... + + +class QPropertyNodeRemovedChange('QStaticPropertyValueRemovedChangeBase'): + + def __init__(self, subjectId: 'QNodeId', node: 'QNode') -> None: ... + + def metaObject(self) -> QtCore.QMetaObject: ... + def removedNodeId(self) -> 'QNodeId': ... + + +class QStaticPropertyUpdatedChangeBase('QPropertyUpdatedChangeBase'): + + def __init__(self, subjectId: 'QNodeId') -> None: ... + + def setPropertyName(self, name: str) -> None: ... + def propertyName(self) -> str: ... + + +class QPropertyUpdatedChange('QStaticPropertyUpdatedChangeBase'): + + def __init__(self, subjectId: 'QNodeId') -> None: ... + + def setValue(self, value: typing.Any) -> None: ... + def value(self) -> typing.Any: ... + + +class QPropertyValueAddedChange('QStaticPropertyValueAddedChangeBase'): + + def __init__(self, subjectId: 'QNodeId') -> None: ... + + def addedValue(self) -> typing.Any: ... + def setAddedValue(self, value: typing.Any) -> None: ... + + +class QPropertyValueRemovedChange('QStaticPropertyValueRemovedChangeBase'): + + def __init__(self, subjectId: 'QNodeId') -> None: ... + + def removedValue(self) -> typing.Any: ... + def setRemovedValue(self, value: typing.Any) -> None: ... + + +class ChangeFlags(sip.simplewrapper): + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, f: typing.Union['ChangeFlags', 'ChangeFlag']) -> None: ... + @typing.overload + def __init__(self, a0: 'ChangeFlags') -> None: ... + + def __hash__(self) -> int: ... + def __bool__(self) -> int: ... + def __invert__(self) -> 'ChangeFlags': ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + + +class QSkeleton('QAbstractSkeleton'): + + def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... + + def rootJointChanged(self, rootJoint: 'QJoint') -> None: ... + def setRootJoint(self, rootJoint: 'QJoint') -> None: ... + def rootJoint(self) -> 'QJoint': ... + + +class QSkeletonLoader('QAbstractSkeleton'): + + class Status(int): + NotReady = ... # type: QSkeletonLoader.Status + Ready = ... # type: QSkeletonLoader.Status + Error = ... # type: QSkeletonLoader.Status + + @typing.overload + def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... + @typing.overload + def __init__(self, source: QtCore.QUrl, parent: typing.Optional['QNode'] = ...) -> None: ... + + def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... + def rootJointChanged(self, rootJoint: 'QJoint') -> None: ... + def createJointsEnabledChanged(self, createJointsEnabled: bool) -> None: ... + def statusChanged(self, status: 'QSkeletonLoader.Status') -> None: ... + def sourceChanged(self, source: QtCore.QUrl) -> None: ... + def setCreateJointsEnabled(self, enabled: bool) -> None: ... + def setSource(self, source: QtCore.QUrl) -> None: ... + def rootJoint(self) -> 'QJoint': ... + def isCreateJointsEnabled(self) -> bool: ... + def status(self) -> 'QSkeletonLoader.Status': ... + def source(self) -> QtCore.QUrl: ... + + +class QTransform('QComponent'): + + def __init__(self, parent: typing.Optional['QNode'] = ...) -> None: ... + + def sceneChangeEvent(self, change: 'QSceneChange') -> None: ... + def worldMatrixChanged(self, worldMatrix: QtGui.QMatrix4x4) -> None: ... + def worldMatrix(self) -> QtGui.QMatrix4x4: ... + def rotationZChanged(self, rotationZ: float) -> None: ... + def rotationYChanged(self, rotationY: float) -> None: ... + def rotationXChanged(self, rotationX: float) -> None: ... + def matrixChanged(self) -> None: ... + def translationChanged(self, translation: QtGui.QVector3D) -> None: ... + def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... + def scale3DChanged(self, scale: QtGui.QVector3D) -> None: ... + def scaleChanged(self, scale: float) -> None: ... + def setRotationZ(self, rotationZ: float) -> None: ... + def setRotationY(self, rotationY: float) -> None: ... + def setRotationX(self, rotationX: float) -> None: ... + def setMatrix(self, matrix: QtGui.QMatrix4x4) -> None: ... + def setTranslation(self, translation: QtGui.QVector3D) -> None: ... + def setRotation(self, rotation: QtGui.QQuaternion) -> None: ... + def setScale3D(self, scale: QtGui.QVector3D) -> None: ... + def setScale(self, scale: float) -> None: ... + def rotationZ(self) -> float: ... + def rotationY(self) -> float: ... + def rotationX(self) -> float: ... + def matrix(self) -> QtGui.QMatrix4x4: ... + @staticmethod + def rotateFromAxes(xAxis: QtGui.QVector3D, yAxis: QtGui.QVector3D, zAxis: QtGui.QVector3D) -> QtGui.QMatrix4x4: ... + @staticmethod + def rotateAround(point: QtGui.QVector3D, angle: float, axis: QtGui.QVector3D) -> QtGui.QMatrix4x4: ... + @typing.overload + @staticmethod + def fromEulerAngles(eulerAngles: QtGui.QVector3D) -> QtGui.QQuaternion: ... + @typing.overload + @staticmethod + def fromEulerAngles(pitch: float, yaw: float, roll: float) -> QtGui.QQuaternion: ... + @typing.overload + @staticmethod + def fromAxesAndAngles(axis1: QtGui.QVector3D, angle1: float, axis2: QtGui.QVector3D, angle2: float) -> QtGui.QQuaternion: ... + @typing.overload + @staticmethod + def fromAxesAndAngles(axis1: QtGui.QVector3D, angle1: float, axis2: QtGui.QVector3D, angle2: float, axis3: QtGui.QVector3D, angle3: float) -> QtGui.QQuaternion: ... + @typing.overload + @staticmethod + def fromAxisAndAngle(axis: QtGui.QVector3D, angle: float) -> QtGui.QQuaternion: ... + @typing.overload + @staticmethod + def fromAxisAndAngle(x: float, y: float, z: float, angle: float) -> QtGui.QQuaternion: ... + @staticmethod + def fromAxes(xAxis: QtGui.QVector3D, yAxis: QtGui.QVector3D, zAxis: QtGui.QVector3D) -> QtGui.QQuaternion: ... + def translation(self) -> QtGui.QVector3D: ... + def rotation(self) -> QtGui.QQuaternion: ... + def scale3D(self) -> QtGui.QVector3D: ... + def scale(self) -> float: ... + + +def qIdForNode(self, node: 'QNode') -> 'QNodeId': ... diff --git a/PyQt5-stubs/Qt3DExtras.pyi b/PyQt5-stubs/Qt3DExtras.pyi index 6e71ae6d..485367ea 100644 --- a/PyQt5-stubs/Qt3DExtras.pyi +++ b/PyQt5-stubs/Qt3DExtras.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DExtras module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -44,743 +44,779 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], typing.Sequence[float], PyQt5.sip.Buffer, int, None] -class Qt3DExtras(PyQt5.sip.simplewrapper): - - class QAbstractCameraController(Qt3DCore.QEntity): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def mouseDevice(self) -> Qt3DInput.QMouseDevice: ... - def keyboardDevice(self) -> Qt3DInput.QKeyboardDevice: ... - def decelerationChanged(self, deceleration: float) -> None: ... - def accelerationChanged(self, acceleration: float) -> None: ... - def lookSpeedChanged(self) -> None: ... - def linearSpeedChanged(self) -> None: ... - def cameraChanged(self) -> None: ... - def setDeceleration(self, deceleration: float) -> None: ... - def setAcceleration(self, acceleration: float) -> None: ... - def setLookSpeed(self, lookSpeed: float) -> None: ... - def setLinearSpeed(self, linearSpeed: float) -> None: ... - def setCamera(self, camera: Qt3DRender.QCamera) -> None: ... - def deceleration(self) -> float: ... - def acceleration(self) -> float: ... - def lookSpeed(self) -> float: ... - def linearSpeed(self) -> float: ... - def camera(self) -> Qt3DRender.QCamera: ... - - class QAbstractSpriteSheet(Qt3DCore.QNode): - - def currentIndexChanged(self, currentIndex: int) -> None: ... - def textureTransformChanged(self, textureTransform: QtGui.QMatrix3x3) -> None: ... - def textureChanged(self, texture: Qt3DRender.QAbstractTexture) -> None: ... - def setCurrentIndex(self, currentIndex: int) -> None: ... - def setTexture(self, texture: Qt3DRender.QAbstractTexture) -> None: ... - def currentIndex(self) -> int: ... - def textureTransform(self) -> QtGui.QMatrix3x3: ... - def texture(self) -> Qt3DRender.QAbstractTexture: ... - - class QConeGeometry(Qt3DRender.QGeometry): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def bottomRadiusChanged(self, bottomRadius: float) -> None: ... - def topRadiusChanged(self, topRadius: float) -> None: ... - def hasBottomEndcapChanged(self, hasBottomEndcap: bool) -> None: ... - def hasTopEndcapChanged(self, hasTopEndcap: bool) -> None: ... - def setLength(self, length: float) -> None: ... - def setSlices(self, slices: int) -> None: ... - def setRings(self, rings: int) -> None: ... - def setBottomRadius(self, bottomRadius: float) -> None: ... - def setTopRadius(self, topRadius: float) -> None: ... - def setHasBottomEndcap(self, hasBottomEndcap: bool) -> None: ... - def setHasTopEndcap(self, hasTopEndcap: bool) -> None: ... - def indexAttribute(self) -> Qt3DRender.QAttribute: ... - def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... - def normalAttribute(self) -> Qt3DRender.QAttribute: ... - def positionAttribute(self) -> Qt3DRender.QAttribute: ... - def length(self) -> float: ... - def slices(self) -> int: ... - def rings(self) -> int: ... - def bottomRadius(self) -> float: ... - def topRadius(self) -> float: ... - def hasBottomEndcap(self) -> bool: ... - def hasTopEndcap(self) -> bool: ... - def updateIndices(self) -> None: ... - def updateVertices(self) -> None: ... - - class QConeMesh(Qt3DRender.QGeometryRenderer): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def bottomRadiusChanged(self, bottomRadius: float) -> None: ... - def topRadiusChanged(self, topRadius: float) -> None: ... - def hasBottomEndcapChanged(self, hasBottomEndcap: bool) -> None: ... - def hasTopEndcapChanged(self, hasTopEndcap: bool) -> None: ... - def setLength(self, length: float) -> None: ... - def setSlices(self, slices: int) -> None: ... - def setRings(self, rings: int) -> None: ... - def setBottomRadius(self, bottomRadius: float) -> None: ... - def setTopRadius(self, topRadius: float) -> None: ... - def setHasBottomEndcap(self, hasBottomEndcap: bool) -> None: ... - def setHasTopEndcap(self, hasTopEndcap: bool) -> None: ... - def length(self) -> float: ... - def bottomRadius(self) -> float: ... - def topRadius(self) -> float: ... - def hasBottomEndcap(self) -> bool: ... - def hasTopEndcap(self) -> bool: ... - def slices(self) -> int: ... - def rings(self) -> int: ... - - class QCuboidGeometry(Qt3DRender.QGeometry): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def xyMeshResolutionChanged(self, xyMeshResolution: QtCore.QSize) -> None: ... - def xzMeshResolutionChanged(self, xzMeshResolution: QtCore.QSize) -> None: ... - def yzMeshResolutionChanged(self, yzMeshResolution: QtCore.QSize) -> None: ... - def zExtentChanged(self, zExtent: float) -> None: ... - def yExtentChanged(self, yExtent: float) -> None: ... - def xExtentChanged(self, xExtent: float) -> None: ... - def setXYMeshResolution(self, resolution: QtCore.QSize) -> None: ... - def setXZMeshResolution(self, resolution: QtCore.QSize) -> None: ... - def setYZMeshResolution(self, resolution: QtCore.QSize) -> None: ... - def setZExtent(self, zExtent: float) -> None: ... - def setYExtent(self, yExtent: float) -> None: ... - def setXExtent(self, xExtent: float) -> None: ... - def indexAttribute(self) -> Qt3DRender.QAttribute: ... - def tangentAttribute(self) -> Qt3DRender.QAttribute: ... - def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... - def normalAttribute(self) -> Qt3DRender.QAttribute: ... - def positionAttribute(self) -> Qt3DRender.QAttribute: ... - def xzMeshResolution(self) -> QtCore.QSize: ... - def xyMeshResolution(self) -> QtCore.QSize: ... - def yzMeshResolution(self) -> QtCore.QSize: ... - def zExtent(self) -> float: ... - def yExtent(self) -> float: ... - def xExtent(self) -> float: ... - def updateVertices(self) -> None: ... - def updateIndices(self) -> None: ... - - class QCuboidMesh(Qt3DRender.QGeometryRenderer): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def xyMeshResolutionChanged(self, xyMeshResolution: QtCore.QSize) -> None: ... - def xzMeshResolutionChanged(self, xzMeshResolution: QtCore.QSize) -> None: ... - def yzMeshResolutionChanged(self, yzMeshResolution: QtCore.QSize) -> None: ... - def zExtentChanged(self, zExtent: float) -> None: ... - def yExtentChanged(self, yExtent: float) -> None: ... - def xExtentChanged(self, xExtent: float) -> None: ... - def setXYMeshResolution(self, resolution: QtCore.QSize) -> None: ... - def setXZMeshResolution(self, resolution: QtCore.QSize) -> None: ... - def setYZMeshResolution(self, resolution: QtCore.QSize) -> None: ... - def setZExtent(self, zExtent: float) -> None: ... - def setYExtent(self, yExtent: float) -> None: ... - def setXExtent(self, xExtent: float) -> None: ... - def xyMeshResolution(self) -> QtCore.QSize: ... - def xzMeshResolution(self) -> QtCore.QSize: ... - def yzMeshResolution(self) -> QtCore.QSize: ... - def zExtent(self) -> float: ... - def yExtent(self) -> float: ... - def xExtent(self) -> float: ... - - class QCylinderGeometry(Qt3DRender.QGeometry): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... - def setLength(self, length: float) -> None: ... - def setRadius(self, radius: float) -> None: ... - def setSlices(self, slices: int) -> None: ... - def setRings(self, rings: int) -> None: ... - def indexAttribute(self) -> Qt3DRender.QAttribute: ... - def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... - def normalAttribute(self) -> Qt3DRender.QAttribute: ... - def positionAttribute(self) -> Qt3DRender.QAttribute: ... - def length(self) -> float: ... - def radius(self) -> float: ... - def slices(self) -> int: ... - def rings(self) -> int: ... - def updateIndices(self) -> None: ... - def updateVertices(self) -> None: ... - - class QCylinderMesh(Qt3DRender.QGeometryRenderer): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def lengthChanged(self, length: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... - def setLength(self, length: float) -> None: ... - def setRadius(self, radius: float) -> None: ... - def setSlices(self, slices: int) -> None: ... - def setRings(self, rings: int) -> None: ... - def length(self) -> float: ... - def radius(self) -> float: ... - def slices(self) -> int: ... - def rings(self) -> int: ... - - class QDiffuseMapMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setTextureScale(self, textureScale: float) -> None: ... - def setDiffuse(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def setShininess(self, shininess: float) -> None: ... - def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setAmbient(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def textureScale(self) -> float: ... - def diffuse(self) -> Qt3DRender.QAbstractTexture: ... - def shininess(self) -> float: ... - def specular(self) -> QtGui.QColor: ... - def ambient(self) -> QtGui.QColor: ... - - class QDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: Qt3DRender.QAbstractTexture) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setTextureScale(self, textureScale: float) -> None: ... - def setShininess(self, shininess: float) -> None: ... - def setSpecular(self, specular: Qt3DRender.QAbstractTexture) -> None: ... - def setDiffuse(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def textureScale(self) -> float: ... - def shininess(self) -> float: ... - def specular(self) -> Qt3DRender.QAbstractTexture: ... - def diffuse(self) -> Qt3DRender.QAbstractTexture: ... - def ambient(self) -> QtGui.QColor: ... - - class QDiffuseSpecularMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def alphaBlendingEnabledChanged(self, enabled: bool) -> None: ... - def textureScaleChanged(self, textureScale: float) -> None: ... - def normalChanged(self, normal: typing.Any) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Any) -> None: ... - def diffuseChanged(self, diffuse: typing.Any) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setAlphaBlendingEnabled(self, enabled: bool) -> None: ... - def setTextureScale(self, textureScale: float) -> None: ... - def setNormal(self, normal: typing.Any) -> None: ... - def setShininess(self, shininess: float) -> None: ... - def setSpecular(self, specular: typing.Any) -> None: ... - def setDiffuse(self, diffuse: typing.Any) -> None: ... - def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def isAlphaBlendingEnabled(self) -> bool: ... - def textureScale(self) -> float: ... - def normal(self) -> typing.Any: ... - def shininess(self) -> float: ... - def specular(self) -> typing.Any: ... - def diffuse(self) -> typing.Any: ... - def ambient(self) -> QtGui.QColor: ... - - class QExtrudedTextGeometry(Qt3DRender.QGeometry): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def depthChanged(self, extrusionLength: float) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def textChanged(self, text: str) -> None: ... - def setDepth(self, extrusionLength: float) -> None: ... - def setFont(self, font: QtGui.QFont) -> None: ... - def setText(self, text: str) -> None: ... - def extrusionLength(self) -> float: ... - def font(self) -> QtGui.QFont: ... - def text(self) -> str: ... - def indexAttribute(self) -> Qt3DRender.QAttribute: ... - def normalAttribute(self) -> Qt3DRender.QAttribute: ... - def positionAttribute(self) -> Qt3DRender.QAttribute: ... - - class QExtrudedTextMesh(Qt3DRender.QGeometryRenderer): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def depthChanged(self, depth: float) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def textChanged(self, text: str) -> None: ... - def setDepth(self, depth: float) -> None: ... - def setFont(self, font: QtGui.QFont) -> None: ... - def setText(self, text: str) -> None: ... - def depth(self) -> float: ... - def font(self) -> QtGui.QFont: ... - def text(self) -> str: ... - - class QFirstPersonCameraController('QAbstractCameraController'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QForwardRenderer(Qt3DRender.QTechniqueFilter): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def showDebugOverlayChanged(self, showDebugOverlay: bool) -> None: ... - def setShowDebugOverlay(self, showDebugOverlay: bool) -> None: ... - def showDebugOverlay(self) -> bool: ... - def buffersToClearChanged(self, a0: Qt3DRender.QClearBuffers.BufferType) -> None: ... - def setBuffersToClear(self, a0: Qt3DRender.QClearBuffers.BufferType) -> None: ... - def buffersToClear(self) -> Qt3DRender.QClearBuffers.BufferType: ... - def gammaChanged(self, gamma: float) -> None: ... - def frustumCullingEnabledChanged(self, enabled: bool) -> None: ... - def setGamma(self, gamma: float) -> None: ... - def setFrustumCullingEnabled(self, enabled: bool) -> None: ... - def gamma(self) -> float: ... - def isFrustumCullingEnabled(self) -> bool: ... - def externalRenderTargetSizeChanged(self, size: QtCore.QSize) -> None: ... - def surfaceChanged(self, surface: QtCore.QObject) -> None: ... - def cameraChanged(self, camera: Qt3DCore.QEntity) -> None: ... - def clearColorChanged(self, clearColor: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def viewportRectChanged(self, viewportRect: QtCore.QRectF) -> None: ... - def setExternalRenderTargetSize(self, size: QtCore.QSize) -> None: ... - def setSurface(self, surface: QtCore.QObject) -> None: ... - def setCamera(self, camera: Qt3DCore.QEntity) -> None: ... - def setClearColor(self, clearColor: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setViewportRect(self, viewportRect: QtCore.QRectF) -> None: ... - def externalRenderTargetSize(self) -> QtCore.QSize: ... - def surface(self) -> QtCore.QObject: ... - def camera(self) -> Qt3DCore.QEntity: ... - def clearColor(self) -> QtGui.QColor: ... - def viewportRect(self) -> QtCore.QRectF: ... - - class QGoochMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def shininessChanged(self, shininess: float) -> None: ... - def betaChanged(self, beta: float) -> None: ... - def alphaChanged(self, alpha: float) -> None: ... - def warmChanged(self, warm: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def coolChanged(self, cool: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setShininess(self, shininess: float) -> None: ... - def setBeta(self, beta: float) -> None: ... - def setAlpha(self, alpha: float) -> None: ... - def setWarm(self, warm: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setCool(self, cool: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setDiffuse(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def shininess(self) -> float: ... - def beta(self) -> float: ... - def alpha(self) -> float: ... - def warm(self) -> QtGui.QColor: ... - def cool(self) -> QtGui.QColor: ... - def specular(self) -> QtGui.QColor: ... - def diffuse(self) -> QtGui.QColor: ... - - class QMetalRoughMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def textureScaleChanged(self, textureScale: float) -> None: ... - def normalChanged(self, normal: typing.Any) -> None: ... - def ambientOcclusionChanged(self, ambientOcclusion: typing.Any) -> None: ... - def roughnessChanged(self, roughness: typing.Any) -> None: ... - def metalnessChanged(self, metalness: typing.Any) -> None: ... - def baseColorChanged(self, baseColor: typing.Any) -> None: ... - def setTextureScale(self, textureScale: float) -> None: ... - def setNormal(self, normal: typing.Any) -> None: ... - def setAmbientOcclusion(self, ambientOcclusion: typing.Any) -> None: ... - def setRoughness(self, roughness: typing.Any) -> None: ... - def setMetalness(self, metalness: typing.Any) -> None: ... - def setBaseColor(self, baseColor: typing.Any) -> None: ... - def textureScale(self) -> float: ... - def normal(self) -> typing.Any: ... - def ambientOcclusion(self) -> typing.Any: ... - def roughness(self) -> typing.Any: ... - def metalness(self) -> typing.Any: ... - def baseColor(self) -> typing.Any: ... - - class QMorphPhongMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def interpolatorChanged(self, interpolator: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setInterpolator(self, interpolator: float) -> None: ... - def setShininess(self, shininess: float) -> None: ... - def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setDiffuse(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def interpolator(self) -> float: ... - def shininess(self) -> float: ... - def specular(self) -> QtGui.QColor: ... - def diffuse(self) -> QtGui.QColor: ... - def ambient(self) -> QtGui.QColor: ... - - class QNormalDiffuseMapMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def normalChanged(self, normal: Qt3DRender.QAbstractTexture) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setTextureScale(self, textureScale: float) -> None: ... - def setShininess(self, shininess: float) -> None: ... - def setNormal(self, normal: Qt3DRender.QAbstractTexture) -> None: ... - def setDiffuse(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def textureScale(self) -> float: ... - def shininess(self) -> float: ... - def normal(self) -> Qt3DRender.QAbstractTexture: ... - def diffuse(self) -> Qt3DRender.QAbstractTexture: ... - def specular(self) -> QtGui.QColor: ... - def ambient(self) -> QtGui.QColor: ... - - class QNormalDiffuseMapAlphaMaterial('QNormalDiffuseMapMaterial'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QNormalDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def textureScaleChanged(self, textureScale: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: Qt3DRender.QAbstractTexture) -> None: ... - def normalChanged(self, normal: Qt3DRender.QAbstractTexture) -> None: ... - def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setTextureScale(self, textureScale: float) -> None: ... - def setShininess(self, shininess: float) -> None: ... - def setSpecular(self, specular: Qt3DRender.QAbstractTexture) -> None: ... - def setNormal(self, normal: Qt3DRender.QAbstractTexture) -> None: ... - def setDiffuse(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... - def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def textureScale(self) -> float: ... - def shininess(self) -> float: ... - def specular(self) -> Qt3DRender.QAbstractTexture: ... - def normal(self) -> Qt3DRender.QAbstractTexture: ... - def diffuse(self) -> Qt3DRender.QAbstractTexture: ... - def ambient(self) -> QtGui.QColor: ... - - class QOrbitCameraController('QAbstractCameraController'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def zoomInLimitChanged(self) -> None: ... - def setZoomInLimit(self, zoomInLimit: float) -> None: ... - def zoomInLimit(self) -> float: ... - - class QPerVertexColorMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QPhongAlphaMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def blendFunctionArgChanged(self, blendFunctionArg: Qt3DRender.QBlendEquation.BlendFunction) -> None: ... - def destinationAlphaArgChanged(self, destinationAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def sourceAlphaArgChanged(self, sourceAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def destinationRgbArgChanged(self, destinationRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def sourceRgbArgChanged(self, sourceRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def setBlendFunctionArg(self, blendFunctionArg: Qt3DRender.QBlendEquation.BlendFunction) -> None: ... - def setDestinationAlphaArg(self, destinationAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def setSourceAlphaArg(self, sourceAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def setDestinationRgbArg(self, destinationRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def setSourceRgbArg(self, sourceRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... - def blendFunctionArg(self) -> Qt3DRender.QBlendEquation.BlendFunction: ... - def destinationAlphaArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... - def sourceAlphaArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... - def destinationRgbArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... - def sourceRgbArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... - def alphaChanged(self, alpha: float) -> None: ... - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setAlpha(self, alpha: float) -> None: ... - def setShininess(self, shininess: float) -> None: ... - def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setDiffuse(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def alpha(self) -> float: ... - def shininess(self) -> float: ... - def specular(self) -> QtGui.QColor: ... - def diffuse(self) -> QtGui.QColor: ... - def ambient(self) -> QtGui.QColor: ... - - class QPhongMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def shininessChanged(self, shininess: float) -> None: ... - def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setShininess(self, shininess: float) -> None: ... - def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setDiffuse(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def shininess(self) -> float: ... - def specular(self) -> QtGui.QColor: ... - def diffuse(self) -> QtGui.QColor: ... - def ambient(self) -> QtGui.QColor: ... - - class QPlaneGeometry(Qt3DRender.QGeometry): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def mirroredChanged(self, mirrored: bool) -> None: ... - def setMirrored(self, mirrored: bool) -> None: ... - def mirrored(self) -> bool: ... - def heightChanged(self, height: float) -> None: ... - def widthChanged(self, width: float) -> None: ... - def resolutionChanged(self, resolution: QtCore.QSize) -> None: ... - def setHeight(self, height: float) -> None: ... - def setWidth(self, width: float) -> None: ... - def setResolution(self, resolution: QtCore.QSize) -> None: ... - def indexAttribute(self) -> Qt3DRender.QAttribute: ... - def tangentAttribute(self) -> Qt3DRender.QAttribute: ... - def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... - def normalAttribute(self) -> Qt3DRender.QAttribute: ... - def positionAttribute(self) -> Qt3DRender.QAttribute: ... - def height(self) -> float: ... - def width(self) -> float: ... - def resolution(self) -> QtCore.QSize: ... - def updateIndices(self) -> None: ... - def updateVertices(self) -> None: ... - - class QPlaneMesh(Qt3DRender.QGeometryRenderer): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def mirroredChanged(self, mirrored: bool) -> None: ... - def setMirrored(self, mirrored: bool) -> None: ... - def mirrored(self) -> bool: ... - def heightChanged(self, height: float) -> None: ... - def widthChanged(self, width: float) -> None: ... - def meshResolutionChanged(self, meshResolution: QtCore.QSize) -> None: ... - def setMeshResolution(self, resolution: QtCore.QSize) -> None: ... - def setHeight(self, height: float) -> None: ... - def setWidth(self, width: float) -> None: ... - def meshResolution(self) -> QtCore.QSize: ... - def height(self) -> float: ... - def width(self) -> float: ... - - class QSkyboxEntity(Qt3DCore.QEntity): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def gammaCorrectEnabledChanged(self, enabled: bool) -> None: ... - def baseNameChanged(self, path: str) -> None: ... - def setGammaCorrectEnabled(self, enabled: bool) -> None: ... - def isGammaCorrectEnabled(self) -> bool: ... - def extensionChanged(self, extension: str) -> None: ... - def extension(self) -> str: ... - def setExtension(self, extension: str) -> None: ... - def baseName(self) -> str: ... - def setBaseName(self, path: str) -> None: ... - - class QSphereGeometry(Qt3DRender.QGeometry): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def generateTangentsChanged(self, generateTangents: bool) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... - def setGenerateTangents(self, gen: bool) -> None: ... - def setRadius(self, radius: float) -> None: ... - def setSlices(self, slices: int) -> None: ... - def setRings(self, rings: int) -> None: ... - def indexAttribute(self) -> Qt3DRender.QAttribute: ... - def tangentAttribute(self) -> Qt3DRender.QAttribute: ... - def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... - def normalAttribute(self) -> Qt3DRender.QAttribute: ... - def positionAttribute(self) -> Qt3DRender.QAttribute: ... - def radius(self) -> float: ... - def slices(self) -> int: ... - def rings(self) -> int: ... - def generateTangents(self) -> bool: ... - def updateIndices(self) -> None: ... - def updateVertices(self) -> None: ... - - class QSphereMesh(Qt3DRender.QGeometryRenderer): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def generateTangentsChanged(self, generateTangents: bool) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... - def setGenerateTangents(self, gen: bool) -> None: ... - def setRadius(self, radius: float) -> None: ... - def setSlices(self, slices: int) -> None: ... - def setRings(self, rings: int) -> None: ... - def generateTangents(self) -> bool: ... - def radius(self) -> float: ... - def slices(self) -> int: ... - def rings(self) -> int: ... - - class QSpriteGrid('QAbstractSpriteSheet'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def columnsChanged(self, columns: int) -> None: ... - def rowsChanged(self, rows: int) -> None: ... - def setColumns(self, columns: int) -> None: ... - def setRows(self, rows: int) -> None: ... - def columns(self) -> int: ... - def rows(self) -> int: ... - - class QSpriteSheet('QAbstractSpriteSheet'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def spritesChanged(self, sprites: typing.Iterable['QSpriteSheetItem']) -> None: ... - def setSprites(self, sprites: typing.Iterable['QSpriteSheetItem']) -> None: ... - def removeSprite(self, sprite: 'QSpriteSheetItem') -> None: ... - @typing.overload - def addSprite(self, x: int, y: int, width: int, height: int) -> 'QSpriteSheetItem': ... - @typing.overload - def addSprite(self, sprite: 'QSpriteSheetItem') -> None: ... - def sprites(self) -> typing.List['QSpriteSheetItem']: ... - - class QSpriteSheetItem(Qt3DCore.QNode): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def heightChanged(self, height: int) -> None: ... - def widthChanged(self, width: int) -> None: ... - def yChanged(self, y: int) -> None: ... - def xChanged(self, x: int) -> None: ... - def setHeight(self, height: int) -> None: ... - def setWidth(self, width: int) -> None: ... - def setY(self, y: int) -> None: ... - def setX(self, x: int) -> None: ... - def height(self) -> int: ... - def width(self) -> int: ... - def y(self) -> int: ... - def x(self) -> int: ... - - class Qt3DWindow(QtGui.QWindow): - - def __init__(self, screen: typing.Optional[QtGui.QScreen] = ...) -> None: ... - - def event(self, e: QtCore.QEvent) -> bool: ... - def resizeEvent(self, a0: QtGui.QResizeEvent) -> None: ... - def showEvent(self, e: QtGui.QShowEvent) -> None: ... - def renderSettings(self) -> Qt3DRender.QRenderSettings: ... - def camera(self) -> Qt3DRender.QCamera: ... - def defaultFrameGraph(self) -> 'QForwardRenderer': ... - def activeFrameGraph(self) -> Qt3DRender.QFrameGraphNode: ... - def setActiveFrameGraph(self, activeFrameGraph: Qt3DRender.QFrameGraphNode) -> None: ... - def setRootEntity(self, root: Qt3DCore.QEntity) -> None: ... - @typing.overload - def registerAspect(self, aspect: Qt3DCore.QAbstractAspect) -> None: ... - @typing.overload - def registerAspect(self, name: str) -> None: ... - - class QText2DEntity(Qt3DCore.QEntity): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def heightChanged(self, height: float) -> None: ... - def widthChanged(self, width: float) -> None: ... - def textChanged(self, text: str) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def setHeight(self, height: float) -> None: ... - def setWidth(self, width: float) -> None: ... - def height(self) -> float: ... - def width(self) -> float: ... - def setText(self, text: str) -> None: ... - def text(self) -> str: ... - def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def color(self) -> QtGui.QColor: ... - def setFont(self, font: QtGui.QFont) -> None: ... - def font(self) -> QtGui.QFont: ... - - class QTexturedMetalRoughMaterial('QMetalRoughMaterial'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def normalChanged(self, normal: typing.Any) -> None: ... - def ambientOcclusionChanged(self, ambientOcclusion: typing.Any) -> None: ... - - class QTextureMaterial(Qt3DRender.QMaterial): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def alphaBlendingEnabledChanged(self, enabled: bool) -> None: ... - def textureTransformChanged(self, textureTransform: QtGui.QMatrix3x3) -> None: ... - def textureOffsetChanged(self, textureOffset: QtGui.QVector2D) -> None: ... - def textureChanged(self, texture: Qt3DRender.QAbstractTexture) -> None: ... - def setAlphaBlendingEnabled(self, enabled: bool) -> None: ... - def setTextureTransform(self, matrix: QtGui.QMatrix3x3) -> None: ... - def setTextureOffset(self, textureOffset: QtGui.QVector2D) -> None: ... - def setTexture(self, texture: Qt3DRender.QAbstractTexture) -> None: ... - def isAlphaBlendingEnabled(self) -> bool: ... - def textureTransform(self) -> QtGui.QMatrix3x3: ... - def textureOffset(self) -> QtGui.QVector2D: ... - def texture(self) -> Qt3DRender.QAbstractTexture: ... - - class QTorusGeometry(Qt3DRender.QGeometry): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def minorRadiusChanged(self, minorRadius: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... - def setMinorRadius(self, minorRadius: float) -> None: ... - def setRadius(self, radius: float) -> None: ... - def setSlices(self, slices: int) -> None: ... - def setRings(self, rings: int) -> None: ... - def indexAttribute(self) -> Qt3DRender.QAttribute: ... - def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... - def normalAttribute(self) -> Qt3DRender.QAttribute: ... - def positionAttribute(self) -> Qt3DRender.QAttribute: ... - def minorRadius(self) -> float: ... - def radius(self) -> float: ... - def slices(self) -> int: ... - def rings(self) -> int: ... - def updateIndices(self) -> None: ... - def updateVertices(self) -> None: ... - - class QTorusMesh(Qt3DRender.QGeometryRenderer): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def minorRadiusChanged(self, minorRadius: float) -> None: ... - def slicesChanged(self, slices: int) -> None: ... - def ringsChanged(self, rings: int) -> None: ... - def radiusChanged(self, radius: float) -> None: ... - def setMinorRadius(self, minorRadius: float) -> None: ... - def setRadius(self, radius: float) -> None: ... - def setSlices(self, slices: int) -> None: ... - def setRings(self, rings: int) -> None: ... - def minorRadius(self) -> float: ... - def radius(self) -> float: ... - def slices(self) -> int: ... - def rings(self) -> int: ... +class QAbstractCameraController(Qt3DCore.QEntity): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def mouseDevice(self) -> Qt3DInput.QMouseDevice: ... + def keyboardDevice(self) -> Qt3DInput.QKeyboardDevice: ... + def decelerationChanged(self, deceleration: float) -> None: ... + def accelerationChanged(self, acceleration: float) -> None: ... + def lookSpeedChanged(self) -> None: ... + def linearSpeedChanged(self) -> None: ... + def cameraChanged(self) -> None: ... + def setDeceleration(self, deceleration: float) -> None: ... + def setAcceleration(self, acceleration: float) -> None: ... + def setLookSpeed(self, lookSpeed: float) -> None: ... + def setLinearSpeed(self, linearSpeed: float) -> None: ... + def setCamera(self, camera: Qt3DRender.QCamera) -> None: ... + def deceleration(self) -> float: ... + def acceleration(self) -> float: ... + def lookSpeed(self) -> float: ... + def linearSpeed(self) -> float: ... + def camera(self) -> Qt3DRender.QCamera: ... + + +class QAbstractSpriteSheet(Qt3DCore.QNode): + + def currentIndexChanged(self, currentIndex: int) -> None: ... + def textureTransformChanged(self, textureTransform: QtGui.QMatrix3x3) -> None: ... + def textureChanged(self, texture: Qt3DRender.QAbstractTexture) -> None: ... + def setCurrentIndex(self, currentIndex: int) -> None: ... + def setTexture(self, texture: Qt3DRender.QAbstractTexture) -> None: ... + def currentIndex(self) -> int: ... + def textureTransform(self) -> QtGui.QMatrix3x3: ... + def texture(self) -> Qt3DRender.QAbstractTexture: ... + + +class QConeGeometry(Qt3DRender.QGeometry): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def lengthChanged(self, length: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def bottomRadiusChanged(self, bottomRadius: float) -> None: ... + def topRadiusChanged(self, topRadius: float) -> None: ... + def hasBottomEndcapChanged(self, hasBottomEndcap: bool) -> None: ... + def hasTopEndcapChanged(self, hasTopEndcap: bool) -> None: ... + def setLength(self, length: float) -> None: ... + def setSlices(self, slices: int) -> None: ... + def setRings(self, rings: int) -> None: ... + def setBottomRadius(self, bottomRadius: float) -> None: ... + def setTopRadius(self, topRadius: float) -> None: ... + def setHasBottomEndcap(self, hasBottomEndcap: bool) -> None: ... + def setHasTopEndcap(self, hasTopEndcap: bool) -> None: ... + def indexAttribute(self) -> Qt3DRender.QAttribute: ... + def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... + def normalAttribute(self) -> Qt3DRender.QAttribute: ... + def positionAttribute(self) -> Qt3DRender.QAttribute: ... + def length(self) -> float: ... + def slices(self) -> int: ... + def rings(self) -> int: ... + def bottomRadius(self) -> float: ... + def topRadius(self) -> float: ... + def hasBottomEndcap(self) -> bool: ... + def hasTopEndcap(self) -> bool: ... + def updateIndices(self) -> None: ... + def updateVertices(self) -> None: ... + + +class QConeMesh(Qt3DRender.QGeometryRenderer): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def lengthChanged(self, length: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def bottomRadiusChanged(self, bottomRadius: float) -> None: ... + def topRadiusChanged(self, topRadius: float) -> None: ... + def hasBottomEndcapChanged(self, hasBottomEndcap: bool) -> None: ... + def hasTopEndcapChanged(self, hasTopEndcap: bool) -> None: ... + def setLength(self, length: float) -> None: ... + def setSlices(self, slices: int) -> None: ... + def setRings(self, rings: int) -> None: ... + def setBottomRadius(self, bottomRadius: float) -> None: ... + def setTopRadius(self, topRadius: float) -> None: ... + def setHasBottomEndcap(self, hasBottomEndcap: bool) -> None: ... + def setHasTopEndcap(self, hasTopEndcap: bool) -> None: ... + def length(self) -> float: ... + def bottomRadius(self) -> float: ... + def topRadius(self) -> float: ... + def hasBottomEndcap(self) -> bool: ... + def hasTopEndcap(self) -> bool: ... + def slices(self) -> int: ... + def rings(self) -> int: ... + + +class QCuboidGeometry(Qt3DRender.QGeometry): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def xyMeshResolutionChanged(self, xyMeshResolution: QtCore.QSize) -> None: ... + def xzMeshResolutionChanged(self, xzMeshResolution: QtCore.QSize) -> None: ... + def yzMeshResolutionChanged(self, yzMeshResolution: QtCore.QSize) -> None: ... + def zExtentChanged(self, zExtent: float) -> None: ... + def yExtentChanged(self, yExtent: float) -> None: ... + def xExtentChanged(self, xExtent: float) -> None: ... + def setXYMeshResolution(self, resolution: QtCore.QSize) -> None: ... + def setXZMeshResolution(self, resolution: QtCore.QSize) -> None: ... + def setYZMeshResolution(self, resolution: QtCore.QSize) -> None: ... + def setZExtent(self, zExtent: float) -> None: ... + def setYExtent(self, yExtent: float) -> None: ... + def setXExtent(self, xExtent: float) -> None: ... + def indexAttribute(self) -> Qt3DRender.QAttribute: ... + def tangentAttribute(self) -> Qt3DRender.QAttribute: ... + def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... + def normalAttribute(self) -> Qt3DRender.QAttribute: ... + def positionAttribute(self) -> Qt3DRender.QAttribute: ... + def xzMeshResolution(self) -> QtCore.QSize: ... + def xyMeshResolution(self) -> QtCore.QSize: ... + def yzMeshResolution(self) -> QtCore.QSize: ... + def zExtent(self) -> float: ... + def yExtent(self) -> float: ... + def xExtent(self) -> float: ... + def updateVertices(self) -> None: ... + def updateIndices(self) -> None: ... + + +class QCuboidMesh(Qt3DRender.QGeometryRenderer): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def xyMeshResolutionChanged(self, xyMeshResolution: QtCore.QSize) -> None: ... + def xzMeshResolutionChanged(self, xzMeshResolution: QtCore.QSize) -> None: ... + def yzMeshResolutionChanged(self, yzMeshResolution: QtCore.QSize) -> None: ... + def zExtentChanged(self, zExtent: float) -> None: ... + def yExtentChanged(self, yExtent: float) -> None: ... + def xExtentChanged(self, xExtent: float) -> None: ... + def setXYMeshResolution(self, resolution: QtCore.QSize) -> None: ... + def setXZMeshResolution(self, resolution: QtCore.QSize) -> None: ... + def setYZMeshResolution(self, resolution: QtCore.QSize) -> None: ... + def setZExtent(self, zExtent: float) -> None: ... + def setYExtent(self, yExtent: float) -> None: ... + def setXExtent(self, xExtent: float) -> None: ... + def xyMeshResolution(self) -> QtCore.QSize: ... + def xzMeshResolution(self) -> QtCore.QSize: ... + def yzMeshResolution(self) -> QtCore.QSize: ... + def zExtent(self) -> float: ... + def yExtent(self) -> float: ... + def xExtent(self) -> float: ... + + +class QCylinderGeometry(Qt3DRender.QGeometry): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def lengthChanged(self, length: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... + def setLength(self, length: float) -> None: ... + def setRadius(self, radius: float) -> None: ... + def setSlices(self, slices: int) -> None: ... + def setRings(self, rings: int) -> None: ... + def indexAttribute(self) -> Qt3DRender.QAttribute: ... + def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... + def normalAttribute(self) -> Qt3DRender.QAttribute: ... + def positionAttribute(self) -> Qt3DRender.QAttribute: ... + def length(self) -> float: ... + def radius(self) -> float: ... + def slices(self) -> int: ... + def rings(self) -> int: ... + def updateIndices(self) -> None: ... + def updateVertices(self) -> None: ... + + +class QCylinderMesh(Qt3DRender.QGeometryRenderer): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def lengthChanged(self, length: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... + def setLength(self, length: float) -> None: ... + def setRadius(self, radius: float) -> None: ... + def setSlices(self, slices: int) -> None: ... + def setRings(self, rings: int) -> None: ... + def length(self) -> float: ... + def radius(self) -> float: ... + def slices(self) -> int: ... + def rings(self) -> int: ... + + +class QDiffuseMapMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def textureScaleChanged(self, textureScale: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setTextureScale(self, textureScale: float) -> None: ... + def setDiffuse(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def setShininess(self, shininess: float) -> None: ... + def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setAmbient(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def textureScale(self) -> float: ... + def diffuse(self) -> Qt3DRender.QAbstractTexture: ... + def shininess(self) -> float: ... + def specular(self) -> QtGui.QColor: ... + def ambient(self) -> QtGui.QColor: ... + + +class QDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def textureScaleChanged(self, textureScale: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: Qt3DRender.QAbstractTexture) -> None: ... + def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setTextureScale(self, textureScale: float) -> None: ... + def setShininess(self, shininess: float) -> None: ... + def setSpecular(self, specular: Qt3DRender.QAbstractTexture) -> None: ... + def setDiffuse(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def textureScale(self) -> float: ... + def shininess(self) -> float: ... + def specular(self) -> Qt3DRender.QAbstractTexture: ... + def diffuse(self) -> Qt3DRender.QAbstractTexture: ... + def ambient(self) -> QtGui.QColor: ... + + +class QDiffuseSpecularMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def alphaBlendingEnabledChanged(self, enabled: bool) -> None: ... + def textureScaleChanged(self, textureScale: float) -> None: ... + def normalChanged(self, normal: typing.Any) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Any) -> None: ... + def diffuseChanged(self, diffuse: typing.Any) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setAlphaBlendingEnabled(self, enabled: bool) -> None: ... + def setTextureScale(self, textureScale: float) -> None: ... + def setNormal(self, normal: typing.Any) -> None: ... + def setShininess(self, shininess: float) -> None: ... + def setSpecular(self, specular: typing.Any) -> None: ... + def setDiffuse(self, diffuse: typing.Any) -> None: ... + def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def isAlphaBlendingEnabled(self) -> bool: ... + def textureScale(self) -> float: ... + def normal(self) -> typing.Any: ... + def shininess(self) -> float: ... + def specular(self) -> typing.Any: ... + def diffuse(self) -> typing.Any: ... + def ambient(self) -> QtGui.QColor: ... + + +class QExtrudedTextGeometry(Qt3DRender.QGeometry): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def depthChanged(self, extrusionLength: float) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... + def textChanged(self, text: str) -> None: ... + def setDepth(self, extrusionLength: float) -> None: ... + def setFont(self, font: QtGui.QFont) -> None: ... + def setText(self, text: str) -> None: ... + def extrusionLength(self) -> float: ... + def font(self) -> QtGui.QFont: ... + def text(self) -> str: ... + def indexAttribute(self) -> Qt3DRender.QAttribute: ... + def normalAttribute(self) -> Qt3DRender.QAttribute: ... + def positionAttribute(self) -> Qt3DRender.QAttribute: ... + + +class QExtrudedTextMesh(Qt3DRender.QGeometryRenderer): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def depthChanged(self, depth: float) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... + def textChanged(self, text: str) -> None: ... + def setDepth(self, depth: float) -> None: ... + def setFont(self, font: QtGui.QFont) -> None: ... + def setText(self, text: str) -> None: ... + def depth(self) -> float: ... + def font(self) -> QtGui.QFont: ... + def text(self) -> str: ... + + +class QFirstPersonCameraController('QAbstractCameraController'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QForwardRenderer(Qt3DRender.QTechniqueFilter): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def showDebugOverlayChanged(self, showDebugOverlay: bool) -> None: ... + def setShowDebugOverlay(self, showDebugOverlay: bool) -> None: ... + def showDebugOverlay(self) -> bool: ... + def buffersToClearChanged(self, a0: Qt3DRender.QClearBuffers.BufferType) -> None: ... + def setBuffersToClear(self, a0: Qt3DRender.QClearBuffers.BufferType) -> None: ... + def buffersToClear(self) -> Qt3DRender.QClearBuffers.BufferType: ... + def gammaChanged(self, gamma: float) -> None: ... + def frustumCullingEnabledChanged(self, enabled: bool) -> None: ... + def setGamma(self, gamma: float) -> None: ... + def setFrustumCullingEnabled(self, enabled: bool) -> None: ... + def gamma(self) -> float: ... + def isFrustumCullingEnabled(self) -> bool: ... + def externalRenderTargetSizeChanged(self, size: QtCore.QSize) -> None: ... + def surfaceChanged(self, surface: QtCore.QObject) -> None: ... + def cameraChanged(self, camera: Qt3DCore.QEntity) -> None: ... + def clearColorChanged(self, clearColor: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def viewportRectChanged(self, viewportRect: QtCore.QRectF) -> None: ... + def setExternalRenderTargetSize(self, size: QtCore.QSize) -> None: ... + def setSurface(self, surface: QtCore.QObject) -> None: ... + def setCamera(self, camera: Qt3DCore.QEntity) -> None: ... + def setClearColor(self, clearColor: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setViewportRect(self, viewportRect: QtCore.QRectF) -> None: ... + def externalRenderTargetSize(self) -> QtCore.QSize: ... + def surface(self) -> QtCore.QObject: ... + def camera(self) -> Qt3DCore.QEntity: ... + def clearColor(self) -> QtGui.QColor: ... + def viewportRect(self) -> QtCore.QRectF: ... + + +class QGoochMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def shininessChanged(self, shininess: float) -> None: ... + def betaChanged(self, beta: float) -> None: ... + def alphaChanged(self, alpha: float) -> None: ... + def warmChanged(self, warm: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def coolChanged(self, cool: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setShininess(self, shininess: float) -> None: ... + def setBeta(self, beta: float) -> None: ... + def setAlpha(self, alpha: float) -> None: ... + def setWarm(self, warm: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setCool(self, cool: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setDiffuse(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def shininess(self) -> float: ... + def beta(self) -> float: ... + def alpha(self) -> float: ... + def warm(self) -> QtGui.QColor: ... + def cool(self) -> QtGui.QColor: ... + def specular(self) -> QtGui.QColor: ... + def diffuse(self) -> QtGui.QColor: ... + + +class QMetalRoughMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def textureScaleChanged(self, textureScale: float) -> None: ... + def normalChanged(self, normal: typing.Any) -> None: ... + def ambientOcclusionChanged(self, ambientOcclusion: typing.Any) -> None: ... + def roughnessChanged(self, roughness: typing.Any) -> None: ... + def metalnessChanged(self, metalness: typing.Any) -> None: ... + def baseColorChanged(self, baseColor: typing.Any) -> None: ... + def setTextureScale(self, textureScale: float) -> None: ... + def setNormal(self, normal: typing.Any) -> None: ... + def setAmbientOcclusion(self, ambientOcclusion: typing.Any) -> None: ... + def setRoughness(self, roughness: typing.Any) -> None: ... + def setMetalness(self, metalness: typing.Any) -> None: ... + def setBaseColor(self, baseColor: typing.Any) -> None: ... + def textureScale(self) -> float: ... + def normal(self) -> typing.Any: ... + def ambientOcclusion(self) -> typing.Any: ... + def roughness(self) -> typing.Any: ... + def metalness(self) -> typing.Any: ... + def baseColor(self) -> typing.Any: ... + + +class QMorphPhongMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def interpolatorChanged(self, interpolator: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setInterpolator(self, interpolator: float) -> None: ... + def setShininess(self, shininess: float) -> None: ... + def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setDiffuse(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def interpolator(self) -> float: ... + def shininess(self) -> float: ... + def specular(self) -> QtGui.QColor: ... + def diffuse(self) -> QtGui.QColor: ... + def ambient(self) -> QtGui.QColor: ... + + +class QNormalDiffuseMapMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def textureScaleChanged(self, textureScale: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def normalChanged(self, normal: Qt3DRender.QAbstractTexture) -> None: ... + def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setTextureScale(self, textureScale: float) -> None: ... + def setShininess(self, shininess: float) -> None: ... + def setNormal(self, normal: Qt3DRender.QAbstractTexture) -> None: ... + def setDiffuse(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def textureScale(self) -> float: ... + def shininess(self) -> float: ... + def normal(self) -> Qt3DRender.QAbstractTexture: ... + def diffuse(self) -> Qt3DRender.QAbstractTexture: ... + def specular(self) -> QtGui.QColor: ... + def ambient(self) -> QtGui.QColor: ... + + +class QNormalDiffuseMapAlphaMaterial('QNormalDiffuseMapMaterial'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QNormalDiffuseSpecularMapMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def textureScaleChanged(self, textureScale: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: Qt3DRender.QAbstractTexture) -> None: ... + def normalChanged(self, normal: Qt3DRender.QAbstractTexture) -> None: ... + def diffuseChanged(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setTextureScale(self, textureScale: float) -> None: ... + def setShininess(self, shininess: float) -> None: ... + def setSpecular(self, specular: Qt3DRender.QAbstractTexture) -> None: ... + def setNormal(self, normal: Qt3DRender.QAbstractTexture) -> None: ... + def setDiffuse(self, diffuse: Qt3DRender.QAbstractTexture) -> None: ... + def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def textureScale(self) -> float: ... + def shininess(self) -> float: ... + def specular(self) -> Qt3DRender.QAbstractTexture: ... + def normal(self) -> Qt3DRender.QAbstractTexture: ... + def diffuse(self) -> Qt3DRender.QAbstractTexture: ... + def ambient(self) -> QtGui.QColor: ... + + +class QOrbitCameraController('QAbstractCameraController'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def zoomInLimitChanged(self) -> None: ... + def setZoomInLimit(self, zoomInLimit: float) -> None: ... + def zoomInLimit(self) -> float: ... + + +class QPerVertexColorMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QPhongAlphaMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def blendFunctionArgChanged(self, blendFunctionArg: Qt3DRender.QBlendEquation.BlendFunction) -> None: ... + def destinationAlphaArgChanged(self, destinationAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + def sourceAlphaArgChanged(self, sourceAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + def destinationRgbArgChanged(self, destinationRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + def sourceRgbArgChanged(self, sourceRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + def setBlendFunctionArg(self, blendFunctionArg: Qt3DRender.QBlendEquation.BlendFunction) -> None: ... + def setDestinationAlphaArg(self, destinationAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + def setSourceAlphaArg(self, sourceAlphaArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + def setDestinationRgbArg(self, destinationRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + def setSourceRgbArg(self, sourceRgbArg: Qt3DRender.QBlendEquationArguments.Blending) -> None: ... + def blendFunctionArg(self) -> Qt3DRender.QBlendEquation.BlendFunction: ... + def destinationAlphaArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... + def sourceAlphaArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... + def destinationRgbArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... + def sourceRgbArg(self) -> Qt3DRender.QBlendEquationArguments.Blending: ... + def alphaChanged(self, alpha: float) -> None: ... + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setAlpha(self, alpha: float) -> None: ... + def setShininess(self, shininess: float) -> None: ... + def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setDiffuse(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def alpha(self) -> float: ... + def shininess(self) -> float: ... + def specular(self) -> QtGui.QColor: ... + def diffuse(self) -> QtGui.QColor: ... + def ambient(self) -> QtGui.QColor: ... + + +class QPhongMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def shininessChanged(self, shininess: float) -> None: ... + def specularChanged(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def diffuseChanged(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def ambientChanged(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setShininess(self, shininess: float) -> None: ... + def setSpecular(self, specular: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setDiffuse(self, diffuse: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setAmbient(self, ambient: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def shininess(self) -> float: ... + def specular(self) -> QtGui.QColor: ... + def diffuse(self) -> QtGui.QColor: ... + def ambient(self) -> QtGui.QColor: ... + + +class QPlaneGeometry(Qt3DRender.QGeometry): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def mirroredChanged(self, mirrored: bool) -> None: ... + def setMirrored(self, mirrored: bool) -> None: ... + def mirrored(self) -> bool: ... + def heightChanged(self, height: float) -> None: ... + def widthChanged(self, width: float) -> None: ... + def resolutionChanged(self, resolution: QtCore.QSize) -> None: ... + def setHeight(self, height: float) -> None: ... + def setWidth(self, width: float) -> None: ... + def setResolution(self, resolution: QtCore.QSize) -> None: ... + def indexAttribute(self) -> Qt3DRender.QAttribute: ... + def tangentAttribute(self) -> Qt3DRender.QAttribute: ... + def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... + def normalAttribute(self) -> Qt3DRender.QAttribute: ... + def positionAttribute(self) -> Qt3DRender.QAttribute: ... + def height(self) -> float: ... + def width(self) -> float: ... + def resolution(self) -> QtCore.QSize: ... + def updateIndices(self) -> None: ... + def updateVertices(self) -> None: ... + + +class QPlaneMesh(Qt3DRender.QGeometryRenderer): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def mirroredChanged(self, mirrored: bool) -> None: ... + def setMirrored(self, mirrored: bool) -> None: ... + def mirrored(self) -> bool: ... + def heightChanged(self, height: float) -> None: ... + def widthChanged(self, width: float) -> None: ... + def meshResolutionChanged(self, meshResolution: QtCore.QSize) -> None: ... + def setMeshResolution(self, resolution: QtCore.QSize) -> None: ... + def setHeight(self, height: float) -> None: ... + def setWidth(self, width: float) -> None: ... + def meshResolution(self) -> QtCore.QSize: ... + def height(self) -> float: ... + def width(self) -> float: ... + + +class QSkyboxEntity(Qt3DCore.QEntity): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def gammaCorrectEnabledChanged(self, enabled: bool) -> None: ... + def baseNameChanged(self, path: str) -> None: ... + def setGammaCorrectEnabled(self, enabled: bool) -> None: ... + def isGammaCorrectEnabled(self) -> bool: ... + def extensionChanged(self, extension: str) -> None: ... + def extension(self) -> str: ... + def setExtension(self, extension: str) -> None: ... + def baseName(self) -> str: ... + def setBaseName(self, path: str) -> None: ... + + +class QSphereGeometry(Qt3DRender.QGeometry): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def generateTangentsChanged(self, generateTangents: bool) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... + def setGenerateTangents(self, gen: bool) -> None: ... + def setRadius(self, radius: float) -> None: ... + def setSlices(self, slices: int) -> None: ... + def setRings(self, rings: int) -> None: ... + def indexAttribute(self) -> Qt3DRender.QAttribute: ... + def tangentAttribute(self) -> Qt3DRender.QAttribute: ... + def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... + def normalAttribute(self) -> Qt3DRender.QAttribute: ... + def positionAttribute(self) -> Qt3DRender.QAttribute: ... + def radius(self) -> float: ... + def slices(self) -> int: ... + def rings(self) -> int: ... + def generateTangents(self) -> bool: ... + def updateIndices(self) -> None: ... + def updateVertices(self) -> None: ... + + +class QSphereMesh(Qt3DRender.QGeometryRenderer): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def generateTangentsChanged(self, generateTangents: bool) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... + def setGenerateTangents(self, gen: bool) -> None: ... + def setRadius(self, radius: float) -> None: ... + def setSlices(self, slices: int) -> None: ... + def setRings(self, rings: int) -> None: ... + def generateTangents(self) -> bool: ... + def radius(self) -> float: ... + def slices(self) -> int: ... + def rings(self) -> int: ... + + +class QSpriteGrid('QAbstractSpriteSheet'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def columnsChanged(self, columns: int) -> None: ... + def rowsChanged(self, rows: int) -> None: ... + def setColumns(self, columns: int) -> None: ... + def setRows(self, rows: int) -> None: ... + def columns(self) -> int: ... + def rows(self) -> int: ... + + +class QSpriteSheet('QAbstractSpriteSheet'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def spritesChanged(self, sprites: typing.Iterable['QSpriteSheetItem']) -> None: ... + def setSprites(self, sprites: typing.Iterable['QSpriteSheetItem']) -> None: ... + def removeSprite(self, sprite: 'QSpriteSheetItem') -> None: ... + @typing.overload + def addSprite(self, x: int, y: int, width: int, height: int) -> 'QSpriteSheetItem': ... + @typing.overload + def addSprite(self, sprite: 'QSpriteSheetItem') -> None: ... + def sprites(self) -> typing.List['QSpriteSheetItem']: ... + + +class QSpriteSheetItem(Qt3DCore.QNode): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def heightChanged(self, height: int) -> None: ... + def widthChanged(self, width: int) -> None: ... + def yChanged(self, y: int) -> None: ... + def xChanged(self, x: int) -> None: ... + def setHeight(self, height: int) -> None: ... + def setWidth(self, width: int) -> None: ... + def setY(self, y: int) -> None: ... + def setX(self, x: int) -> None: ... + def height(self) -> int: ... + def width(self) -> int: ... + def y(self) -> int: ... + def x(self) -> int: ... + + +class Qt3DWindow(QtGui.QWindow): + + def __init__(self, screen: typing.Optional[QtGui.QScreen] = ...) -> None: ... + + def event(self, e: QtCore.QEvent) -> bool: ... + def resizeEvent(self, a0: QtGui.QResizeEvent) -> None: ... + def showEvent(self, e: QtGui.QShowEvent) -> None: ... + def renderSettings(self) -> Qt3DRender.QRenderSettings: ... + def camera(self) -> Qt3DRender.QCamera: ... + def defaultFrameGraph(self) -> 'QForwardRenderer': ... + def activeFrameGraph(self) -> Qt3DRender.QFrameGraphNode: ... + def setActiveFrameGraph(self, activeFrameGraph: Qt3DRender.QFrameGraphNode) -> None: ... + def setRootEntity(self, root: Qt3DCore.QEntity) -> None: ... + @typing.overload + def registerAspect(self, aspect: Qt3DCore.QAbstractAspect) -> None: ... + @typing.overload + def registerAspect(self, name: str) -> None: ... + + +class QText2DEntity(Qt3DCore.QEntity): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def heightChanged(self, height: float) -> None: ... + def widthChanged(self, width: float) -> None: ... + def textChanged(self, text: str) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... + def setHeight(self, height: float) -> None: ... + def setWidth(self, width: float) -> None: ... + def height(self) -> float: ... + def width(self) -> float: ... + def setText(self, text: str) -> None: ... + def text(self) -> str: ... + def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def color(self) -> QtGui.QColor: ... + def setFont(self, font: QtGui.QFont) -> None: ... + def font(self) -> QtGui.QFont: ... + + +class QTexturedMetalRoughMaterial('QMetalRoughMaterial'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def normalChanged(self, normal: typing.Any) -> None: ... + def ambientOcclusionChanged(self, ambientOcclusion: typing.Any) -> None: ... + + +class QTextureMaterial(Qt3DRender.QMaterial): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def alphaBlendingEnabledChanged(self, enabled: bool) -> None: ... + def textureTransformChanged(self, textureTransform: QtGui.QMatrix3x3) -> None: ... + def textureOffsetChanged(self, textureOffset: QtGui.QVector2D) -> None: ... + def textureChanged(self, texture: Qt3DRender.QAbstractTexture) -> None: ... + def setAlphaBlendingEnabled(self, enabled: bool) -> None: ... + def setTextureTransform(self, matrix: QtGui.QMatrix3x3) -> None: ... + def setTextureOffset(self, textureOffset: QtGui.QVector2D) -> None: ... + def setTexture(self, texture: Qt3DRender.QAbstractTexture) -> None: ... + def isAlphaBlendingEnabled(self) -> bool: ... + def textureTransform(self) -> QtGui.QMatrix3x3: ... + def textureOffset(self) -> QtGui.QVector2D: ... + def texture(self) -> Qt3DRender.QAbstractTexture: ... + + +class QTorusGeometry(Qt3DRender.QGeometry): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def minorRadiusChanged(self, minorRadius: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... + def setMinorRadius(self, minorRadius: float) -> None: ... + def setRadius(self, radius: float) -> None: ... + def setSlices(self, slices: int) -> None: ... + def setRings(self, rings: int) -> None: ... + def indexAttribute(self) -> Qt3DRender.QAttribute: ... + def texCoordAttribute(self) -> Qt3DRender.QAttribute: ... + def normalAttribute(self) -> Qt3DRender.QAttribute: ... + def positionAttribute(self) -> Qt3DRender.QAttribute: ... + def minorRadius(self) -> float: ... + def radius(self) -> float: ... + def slices(self) -> int: ... + def rings(self) -> int: ... + def updateIndices(self) -> None: ... + def updateVertices(self) -> None: ... + + +class QTorusMesh(Qt3DRender.QGeometryRenderer): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def minorRadiusChanged(self, minorRadius: float) -> None: ... + def slicesChanged(self, slices: int) -> None: ... + def ringsChanged(self, rings: int) -> None: ... + def radiusChanged(self, radius: float) -> None: ... + def setMinorRadius(self, minorRadius: float) -> None: ... + def setRadius(self, radius: float) -> None: ... + def setSlices(self, slices: int) -> None: ... + def setRings(self, rings: int) -> None: ... + def minorRadius(self) -> float: ... + def radius(self) -> float: ... + def slices(self) -> int: ... + def rings(self) -> int: ... diff --git a/PyQt5-stubs/Qt3DInput.pyi b/PyQt5-stubs/Qt3DInput.pyi index a64f8bed..153c70db 100644 --- a/PyQt5-stubs/Qt3DInput.pyi +++ b/PyQt5-stubs/Qt3DInput.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DInput module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -42,363 +42,383 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], typing.Sequence[float], PyQt5.sip.Buffer, int, None] -class Qt3DInput(PyQt5.sip.simplewrapper): +class QAbstractActionInput(Qt3DCore.QNode): ... - class QAbstractActionInput(Qt3DCore.QNode): ... - class QAbstractAxisInput(Qt3DCore.QNode): +class QAbstractAxisInput(Qt3DCore.QNode): - def sourceDeviceChanged(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... - def setSourceDevice(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... - def sourceDevice(self) -> 'QAbstractPhysicalDevice': ... + def sourceDeviceChanged(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... + def setSourceDevice(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... + def sourceDevice(self) -> 'QAbstractPhysicalDevice': ... - class QAbstractPhysicalDevice(Qt3DCore.QNode): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... +class QAbstractPhysicalDevice(Qt3DCore.QNode): - def axisSettings(self) -> typing.List['QAxisSetting']: ... - def removeAxisSetting(self, axisSetting: 'QAxisSetting') -> None: ... - def addAxisSetting(self, axisSetting: 'QAxisSetting') -> None: ... - def buttonIdentifier(self, name: str) -> int: ... - def axisIdentifier(self, name: str) -> int: ... - def buttonNames(self) -> typing.List[str]: ... - def axisNames(self) -> typing.List[str]: ... - def buttonCount(self) -> int: ... - def axisCount(self) -> int: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QAction(Qt3DCore.QNode): + def axisSettings(self) -> typing.List['QAxisSetting']: ... + def removeAxisSetting(self, axisSetting: 'QAxisSetting') -> None: ... + def addAxisSetting(self, axisSetting: 'QAxisSetting') -> None: ... + def buttonIdentifier(self, name: str) -> int: ... + def axisIdentifier(self, name: str) -> int: ... + def buttonNames(self) -> typing.List[str]: ... + def axisNames(self) -> typing.List[str]: ... + def buttonCount(self) -> int: ... + def axisCount(self) -> int: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def activeChanged(self, isActive: bool) -> None: ... - def inputs(self) -> typing.List['QAbstractActionInput']: ... - def removeInput(self, input: 'QAbstractActionInput') -> None: ... - def addInput(self, input: 'QAbstractActionInput') -> None: ... - def isActive(self) -> bool: ... +class QAction(Qt3DCore.QNode): - class QActionInput('QAbstractActionInput'): + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def activeChanged(self, isActive: bool) -> None: ... + def inputs(self) -> typing.List['QAbstractActionInput']: ... + def removeInput(self, input: 'QAbstractActionInput') -> None: ... + def addInput(self, input: 'QAbstractActionInput') -> None: ... + def isActive(self) -> bool: ... - def buttonsChanged(self, buttons: typing.Iterable[int]) -> None: ... - def sourceDeviceChanged(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... - def setButtons(self, buttons: typing.Iterable[int]) -> None: ... - def setSourceDevice(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... - def buttons(self) -> typing.List[int]: ... - def sourceDevice(self) -> 'QAbstractPhysicalDevice': ... - class QAnalogAxisInput('QAbstractAxisInput'): +class QActionInput('QAbstractActionInput'): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def axisChanged(self, axis: int) -> None: ... - def setAxis(self, axis: int) -> None: ... - def axis(self) -> int: ... + def buttonsChanged(self, buttons: typing.Iterable[int]) -> None: ... + def sourceDeviceChanged(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... + def setButtons(self, buttons: typing.Iterable[int]) -> None: ... + def setSourceDevice(self, sourceDevice: 'QAbstractPhysicalDevice') -> None: ... + def buttons(self) -> typing.List[int]: ... + def sourceDevice(self) -> 'QAbstractPhysicalDevice': ... - class QAxis(Qt3DCore.QNode): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... +class QAnalogAxisInput('QAbstractAxisInput'): - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def valueChanged(self, value: float) -> None: ... - def value(self) -> float: ... - def inputs(self) -> typing.List['QAbstractAxisInput']: ... - def removeInput(self, input: 'QAbstractAxisInput') -> None: ... - def addInput(self, input: 'QAbstractAxisInput') -> None: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QAxisAccumulator(Qt3DCore.QComponent): + def axisChanged(self, axis: int) -> None: ... + def setAxis(self, axis: int) -> None: ... + def axis(self) -> int: ... - class SourceAxisType(int): - Velocity = ... # type: QAxisAccumulator.SourceAxisType - Acceleration = ... # type: QAxisAccumulator.SourceAxisType - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... +class QAxis(Qt3DCore.QNode): - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def scaleChanged(self, scale: float) -> None: ... - def velocityChanged(self, value: float) -> None: ... - def valueChanged(self, value: float) -> None: ... - def sourceAxisTypeChanged(self, sourceAxisType: 'QAxisAccumulator.SourceAxisType') -> None: ... - def sourceAxisChanged(self, sourceAxis: 'QAxis') -> None: ... - def setScale(self, scale: float) -> None: ... - def setSourceAxisType(self, sourceAxisType: 'QAxisAccumulator.SourceAxisType') -> None: ... - def setSourceAxis(self, sourceAxis: 'QAxis') -> None: ... - def scale(self) -> float: ... - def velocity(self) -> float: ... - def value(self) -> float: ... - def sourceAxisType(self) -> 'QAxisAccumulator.SourceAxisType': ... - def sourceAxis(self) -> 'QAxis': ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QAxisSetting(Qt3DCore.QNode): + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def valueChanged(self, value: float) -> None: ... + def value(self) -> float: ... + def inputs(self) -> typing.List['QAbstractAxisInput']: ... + def removeInput(self, input: 'QAbstractAxisInput') -> None: ... + def addInput(self, input: 'QAbstractAxisInput') -> None: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def smoothChanged(self, smooth: bool) -> None: ... - def axesChanged(self, axes: typing.Iterable[int]) -> None: ... - def deadZoneRadiusChanged(self, deadZoneRadius: float) -> None: ... - def setSmoothEnabled(self, enabled: bool) -> None: ... - def setAxes(self, axes: typing.Iterable[int]) -> None: ... - def setDeadZoneRadius(self, deadZoneRadius: float) -> None: ... - def isSmoothEnabled(self) -> bool: ... - def axes(self) -> typing.List[int]: ... - def deadZoneRadius(self) -> float: ... - - class QButtonAxisInput('QAbstractAxisInput'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def decelerationChanged(self, deceleration: float) -> None: ... - def accelerationChanged(self, acceleration: float) -> None: ... - def buttonsChanged(self, buttons: typing.Iterable[int]) -> None: ... - def scaleChanged(self, scale: float) -> None: ... - def setDeceleration(self, deceleration: float) -> None: ... - def setAcceleration(self, acceleration: float) -> None: ... - def setButtons(self, buttons: typing.Iterable[int]) -> None: ... - def setScale(self, scale: float) -> None: ... - def deceleration(self) -> float: ... - def acceleration(self) -> float: ... - def buttons(self) -> typing.List[int]: ... - def scale(self) -> float: ... - - class QInputAspect(Qt3DCore.QAbstractAspect): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def availablePhysicalDevices(self) -> typing.List[str]: ... - def createPhysicalDevice(self, name: str) -> 'QAbstractPhysicalDevice': ... - - class QInputChord('QAbstractActionInput'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def timeoutChanged(self, timeout: int) -> None: ... - def setTimeout(self, timeout: int) -> None: ... - def chords(self) -> typing.List['QAbstractActionInput']: ... - def removeChord(self, input: 'QAbstractActionInput') -> None: ... - def addChord(self, input: 'QAbstractActionInput') -> None: ... - def timeout(self) -> int: ... - - class QInputSequence('QAbstractActionInput'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def buttonIntervalChanged(self, buttonInterval: int) -> None: ... - def timeoutChanged(self, timeout: int) -> None: ... - def setButtonInterval(self, buttonInterval: int) -> None: ... - def setTimeout(self, timeout: int) -> None: ... - def sequences(self) -> typing.List['QAbstractActionInput']: ... - def removeSequence(self, input: 'QAbstractActionInput') -> None: ... - def addSequence(self, input: 'QAbstractActionInput') -> None: ... - def buttonInterval(self) -> int: ... - def timeout(self) -> int: ... - - class QInputSettings(Qt3DCore.QComponent): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def eventSourceChanged(self, a0: QtCore.QObject) -> None: ... - def setEventSource(self, eventSource: QtCore.QObject) -> None: ... - def eventSource(self) -> QtCore.QObject: ... - - class QKeyboardDevice('QAbstractPhysicalDevice'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def activeInputChanged(self, activeInput: 'QKeyboardHandler') -> None: ... - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def buttonIdentifier(self, name: str) -> int: ... - def axisIdentifier(self, name: str) -> int: ... - def buttonNames(self) -> typing.List[str]: ... - def axisNames(self) -> typing.List[str]: ... - def buttonCount(self) -> int: ... - def axisCount(self) -> int: ... - def activeInput(self) -> 'QKeyboardHandler': ... - - class QKeyboardHandler(Qt3DCore.QComponent): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def released(self, event: 'QKeyEvent') -> None: ... - def pressed(self, event: 'QKeyEvent') -> None: ... - def volumeDownPressed(self, event: 'QKeyEvent') -> None: ... - def volumeUpPressed(self, event: 'QKeyEvent') -> None: ... - def menuPressed(self, event: 'QKeyEvent') -> None: ... - def flipPressed(self, event: 'QKeyEvent') -> None: ... - def hangupPressed(self, event: 'QKeyEvent') -> None: ... - def callPressed(self, event: 'QKeyEvent') -> None: ... - def context4Pressed(self, event: 'QKeyEvent') -> None: ... - def context3Pressed(self, event: 'QKeyEvent') -> None: ... - def context2Pressed(self, event: 'QKeyEvent') -> None: ... - def context1Pressed(self, event: 'QKeyEvent') -> None: ... - def noPressed(self, event: 'QKeyEvent') -> None: ... - def yesPressed(self, event: 'QKeyEvent') -> None: ... - def selectPressed(self, event: 'QKeyEvent') -> None: ... - def cancelPressed(self, event: 'QKeyEvent') -> None: ... - def backPressed(self, event: 'QKeyEvent') -> None: ... - def spacePressed(self, event: 'QKeyEvent') -> None: ... - def deletePressed(self, event: 'QKeyEvent') -> None: ... - def enterPressed(self, event: 'QKeyEvent') -> None: ... - def returnPressed(self, event: 'QKeyEvent') -> None: ... - def escapePressed(self, event: 'QKeyEvent') -> None: ... - def numberSignPressed(self, event: 'QKeyEvent') -> None: ... - def asteriskPressed(self, event: 'QKeyEvent') -> None: ... - def backtabPressed(self, event: 'QKeyEvent') -> None: ... - def tabPressed(self, event: 'QKeyEvent') -> None: ... - def downPressed(self, event: 'QKeyEvent') -> None: ... - def upPressed(self, event: 'QKeyEvent') -> None: ... - def rightPressed(self, event: 'QKeyEvent') -> None: ... - def leftPressed(self, event: 'QKeyEvent') -> None: ... - def digit9Pressed(self, event: 'QKeyEvent') -> None: ... - def digit8Pressed(self, event: 'QKeyEvent') -> None: ... - def digit7Pressed(self, event: 'QKeyEvent') -> None: ... - def digit6Pressed(self, event: 'QKeyEvent') -> None: ... - def digit5Pressed(self, event: 'QKeyEvent') -> None: ... - def digit4Pressed(self, event: 'QKeyEvent') -> None: ... - def digit3Pressed(self, event: 'QKeyEvent') -> None: ... - def digit2Pressed(self, event: 'QKeyEvent') -> None: ... - def digit1Pressed(self, event: 'QKeyEvent') -> None: ... - def digit0Pressed(self, event: 'QKeyEvent') -> None: ... - def focusChanged(self, focus: bool) -> None: ... - def sourceDeviceChanged(self, keyboardDevice: 'QKeyboardDevice') -> None: ... - def setFocus(self, focus: bool) -> None: ... - def setSourceDevice(self, keyboardDevice: 'QKeyboardDevice') -> None: ... - def focus(self) -> bool: ... - def sourceDevice(self) -> 'QKeyboardDevice': ... - - class QKeyEvent(QtCore.QObject): - - @typing.overload - def __init__(self, type: QtCore.QEvent.Type, key: int, modifiers: typing.Union[QtCore.Qt.KeyboardModifiers, QtCore.Qt.KeyboardModifier], text: str = ..., autorep: bool = ..., count: int = ...) -> None: ... - @typing.overload - def __init__(self, ke: QtGui.QKeyEvent) -> None: ... - - def matches(self, key_: QtGui.QKeySequence.StandardKey) -> bool: ... - def type(self) -> QtCore.QEvent.Type: ... - def setAccepted(self, accepted: bool) -> None: ... - def isAccepted(self) -> bool: ... - def nativeScanCode(self) -> int: ... - def count(self) -> int: ... - def isAutoRepeat(self) -> bool: ... - def modifiers(self) -> int: ... - def text(self) -> str: ... - def key(self) -> int: ... - - class QLogicalDevice(Qt3DCore.QComponent): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def axes(self) -> typing.List['QAxis']: ... - def removeAxis(self, axis: 'QAxis') -> None: ... - def addAxis(self, axis: 'QAxis') -> None: ... - def actions(self) -> typing.List['QAction']: ... - def removeAction(self, action: 'QAction') -> None: ... - def addAction(self, action: 'QAction') -> None: ... - - class QMouseDevice('QAbstractPhysicalDevice'): - - class Axis(int): - X = ... # type: QMouseDevice.Axis - Y = ... # type: QMouseDevice.Axis - WheelX = ... # type: QMouseDevice.Axis - WheelY = ... # type: QMouseDevice.Axis - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def updateAxesContinuouslyChanged(self, updateAxesContinuously: bool) -> None: ... - def setUpdateAxesContinuously(self, updateAxesContinuously: bool) -> None: ... - def updateAxesContinuously(self) -> bool: ... - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def sensitivityChanged(self, value: float) -> None: ... - def setSensitivity(self, value: float) -> None: ... - def sensitivity(self) -> float: ... - def buttonIdentifier(self, name: str) -> int: ... - def axisIdentifier(self, name: str) -> int: ... - def buttonNames(self) -> typing.List[str]: ... - def axisNames(self) -> typing.List[str]: ... - def buttonCount(self) -> int: ... - def axisCount(self) -> int: ... - - class QMouseEvent(QtCore.QObject): - - class Modifiers(int): - NoModifier = ... # type: QMouseEvent.Modifiers - ShiftModifier = ... # type: QMouseEvent.Modifiers - ControlModifier = ... # type: QMouseEvent.Modifiers - AltModifier = ... # type: QMouseEvent.Modifiers - MetaModifier = ... # type: QMouseEvent.Modifiers - KeypadModifier = ... # type: QMouseEvent.Modifiers - - class Buttons(int): - LeftButton = ... # type: QMouseEvent.Buttons - RightButton = ... # type: QMouseEvent.Buttons - MiddleButton = ... # type: QMouseEvent.Buttons - BackButton = ... # type: QMouseEvent.Buttons - NoButton = ... # type: QMouseEvent.Buttons - - def __init__(self, e: QtGui.QMouseEvent) -> None: ... - - def type(self) -> QtCore.QEvent.Type: ... - def setAccepted(self, accepted: bool) -> None: ... - def isAccepted(self) -> bool: ... - def modifiers(self) -> 'QMouseEvent.Modifiers': ... - def buttons(self) -> int: ... - def button(self) -> 'QMouseEvent.Buttons': ... - def wasHeld(self) -> bool: ... - def y(self) -> int: ... - def x(self) -> int: ... - - class QWheelEvent(QtCore.QObject): - - class Modifiers(int): - NoModifier = ... # type: QWheelEvent.Modifiers - ShiftModifier = ... # type: QWheelEvent.Modifiers - ControlModifier = ... # type: QWheelEvent.Modifiers - AltModifier = ... # type: QWheelEvent.Modifiers - MetaModifier = ... # type: QWheelEvent.Modifiers - KeypadModifier = ... # type: QWheelEvent.Modifiers - - class Buttons(int): - LeftButton = ... # type: QWheelEvent.Buttons - RightButton = ... # type: QWheelEvent.Buttons - MiddleButton = ... # type: QWheelEvent.Buttons - BackButton = ... # type: QWheelEvent.Buttons - NoButton = ... # type: QWheelEvent.Buttons - - def __init__(self, e: QtGui.QWheelEvent) -> None: ... - - def type(self) -> QtCore.QEvent.Type: ... - def setAccepted(self, accepted: bool) -> None: ... - def isAccepted(self) -> bool: ... - def modifiers(self) -> 'QWheelEvent.Modifiers': ... - def buttons(self) -> int: ... - def angleDelta(self) -> QtCore.QPoint: ... - def y(self) -> int: ... - def x(self) -> int: ... - - class QMouseHandler(Qt3DCore.QComponent): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def wheel(self, wheel: 'QWheelEvent') -> None: ... - def positionChanged(self, mouse: 'QMouseEvent') -> None: ... - def pressAndHold(self, mouse: 'QMouseEvent') -> None: ... - def released(self, mouse: 'QMouseEvent') -> None: ... - def pressed(self, mouse: 'QMouseEvent') -> None: ... - def exited(self) -> None: ... - def entered(self) -> None: ... - def doubleClicked(self, mouse: 'QMouseEvent') -> None: ... - def clicked(self, mouse: 'QMouseEvent') -> None: ... - def containsMouseChanged(self, containsMouse: bool) -> None: ... - def sourceDeviceChanged(self, mouseDevice: 'QMouseDevice') -> None: ... - def setSourceDevice(self, mouseDevice: 'QMouseDevice') -> None: ... - def containsMouse(self) -> bool: ... - def sourceDevice(self) -> 'QMouseDevice': ... - - class QPhysicalDeviceCreatedChangeBase(Qt3DCore.QNodeCreatedChangeBase): - - def __init__(self, device: 'QAbstractPhysicalDevice') -> None: ... - - def axisSettingIds(self) -> typing.List[Qt3DCore.QNodeId]: ... +class QAxisAccumulator(Qt3DCore.QComponent): + + class SourceAxisType(int): + Velocity = ... # type: QAxisAccumulator.SourceAxisType + Acceleration = ... # type: QAxisAccumulator.SourceAxisType + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def scaleChanged(self, scale: float) -> None: ... + def velocityChanged(self, value: float) -> None: ... + def valueChanged(self, value: float) -> None: ... + def sourceAxisTypeChanged(self, sourceAxisType: 'QAxisAccumulator.SourceAxisType') -> None: ... + def sourceAxisChanged(self, sourceAxis: 'QAxis') -> None: ... + def setScale(self, scale: float) -> None: ... + def setSourceAxisType(self, sourceAxisType: 'QAxisAccumulator.SourceAxisType') -> None: ... + def setSourceAxis(self, sourceAxis: 'QAxis') -> None: ... + def scale(self) -> float: ... + def velocity(self) -> float: ... + def value(self) -> float: ... + def sourceAxisType(self) -> 'QAxisAccumulator.SourceAxisType': ... + def sourceAxis(self) -> 'QAxis': ... + + +class QAxisSetting(Qt3DCore.QNode): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def smoothChanged(self, smooth: bool) -> None: ... + def axesChanged(self, axes: typing.Iterable[int]) -> None: ... + def deadZoneRadiusChanged(self, deadZoneRadius: float) -> None: ... + def setSmoothEnabled(self, enabled: bool) -> None: ... + def setAxes(self, axes: typing.Iterable[int]) -> None: ... + def setDeadZoneRadius(self, deadZoneRadius: float) -> None: ... + def isSmoothEnabled(self) -> bool: ... + def axes(self) -> typing.List[int]: ... + def deadZoneRadius(self) -> float: ... + + +class QButtonAxisInput('QAbstractAxisInput'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def decelerationChanged(self, deceleration: float) -> None: ... + def accelerationChanged(self, acceleration: float) -> None: ... + def buttonsChanged(self, buttons: typing.Iterable[int]) -> None: ... + def scaleChanged(self, scale: float) -> None: ... + def setDeceleration(self, deceleration: float) -> None: ... + def setAcceleration(self, acceleration: float) -> None: ... + def setButtons(self, buttons: typing.Iterable[int]) -> None: ... + def setScale(self, scale: float) -> None: ... + def deceleration(self) -> float: ... + def acceleration(self) -> float: ... + def buttons(self) -> typing.List[int]: ... + def scale(self) -> float: ... + + +class QInputAspect(Qt3DCore.QAbstractAspect): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def availablePhysicalDevices(self) -> typing.List[str]: ... + def createPhysicalDevice(self, name: str) -> 'QAbstractPhysicalDevice': ... + + +class QInputChord('QAbstractActionInput'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def timeoutChanged(self, timeout: int) -> None: ... + def setTimeout(self, timeout: int) -> None: ... + def chords(self) -> typing.List['QAbstractActionInput']: ... + def removeChord(self, input: 'QAbstractActionInput') -> None: ... + def addChord(self, input: 'QAbstractActionInput') -> None: ... + def timeout(self) -> int: ... + + +class QInputSequence('QAbstractActionInput'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def buttonIntervalChanged(self, buttonInterval: int) -> None: ... + def timeoutChanged(self, timeout: int) -> None: ... + def setButtonInterval(self, buttonInterval: int) -> None: ... + def setTimeout(self, timeout: int) -> None: ... + def sequences(self) -> typing.List['QAbstractActionInput']: ... + def removeSequence(self, input: 'QAbstractActionInput') -> None: ... + def addSequence(self, input: 'QAbstractActionInput') -> None: ... + def buttonInterval(self) -> int: ... + def timeout(self) -> int: ... + + +class QInputSettings(Qt3DCore.QComponent): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def eventSourceChanged(self, a0: QtCore.QObject) -> None: ... + def setEventSource(self, eventSource: QtCore.QObject) -> None: ... + def eventSource(self) -> QtCore.QObject: ... + + +class QKeyboardDevice('QAbstractPhysicalDevice'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def activeInputChanged(self, activeInput: 'QKeyboardHandler') -> None: ... + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def buttonIdentifier(self, name: str) -> int: ... + def axisIdentifier(self, name: str) -> int: ... + def buttonNames(self) -> typing.List[str]: ... + def axisNames(self) -> typing.List[str]: ... + def buttonCount(self) -> int: ... + def axisCount(self) -> int: ... + def activeInput(self) -> 'QKeyboardHandler': ... + + +class QKeyboardHandler(Qt3DCore.QComponent): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def released(self, event: 'QKeyEvent') -> None: ... + def pressed(self, event: 'QKeyEvent') -> None: ... + def volumeDownPressed(self, event: 'QKeyEvent') -> None: ... + def volumeUpPressed(self, event: 'QKeyEvent') -> None: ... + def menuPressed(self, event: 'QKeyEvent') -> None: ... + def flipPressed(self, event: 'QKeyEvent') -> None: ... + def hangupPressed(self, event: 'QKeyEvent') -> None: ... + def callPressed(self, event: 'QKeyEvent') -> None: ... + def context4Pressed(self, event: 'QKeyEvent') -> None: ... + def context3Pressed(self, event: 'QKeyEvent') -> None: ... + def context2Pressed(self, event: 'QKeyEvent') -> None: ... + def context1Pressed(self, event: 'QKeyEvent') -> None: ... + def noPressed(self, event: 'QKeyEvent') -> None: ... + def yesPressed(self, event: 'QKeyEvent') -> None: ... + def selectPressed(self, event: 'QKeyEvent') -> None: ... + def cancelPressed(self, event: 'QKeyEvent') -> None: ... + def backPressed(self, event: 'QKeyEvent') -> None: ... + def spacePressed(self, event: 'QKeyEvent') -> None: ... + def deletePressed(self, event: 'QKeyEvent') -> None: ... + def enterPressed(self, event: 'QKeyEvent') -> None: ... + def returnPressed(self, event: 'QKeyEvent') -> None: ... + def escapePressed(self, event: 'QKeyEvent') -> None: ... + def numberSignPressed(self, event: 'QKeyEvent') -> None: ... + def asteriskPressed(self, event: 'QKeyEvent') -> None: ... + def backtabPressed(self, event: 'QKeyEvent') -> None: ... + def tabPressed(self, event: 'QKeyEvent') -> None: ... + def downPressed(self, event: 'QKeyEvent') -> None: ... + def upPressed(self, event: 'QKeyEvent') -> None: ... + def rightPressed(self, event: 'QKeyEvent') -> None: ... + def leftPressed(self, event: 'QKeyEvent') -> None: ... + def digit9Pressed(self, event: 'QKeyEvent') -> None: ... + def digit8Pressed(self, event: 'QKeyEvent') -> None: ... + def digit7Pressed(self, event: 'QKeyEvent') -> None: ... + def digit6Pressed(self, event: 'QKeyEvent') -> None: ... + def digit5Pressed(self, event: 'QKeyEvent') -> None: ... + def digit4Pressed(self, event: 'QKeyEvent') -> None: ... + def digit3Pressed(self, event: 'QKeyEvent') -> None: ... + def digit2Pressed(self, event: 'QKeyEvent') -> None: ... + def digit1Pressed(self, event: 'QKeyEvent') -> None: ... + def digit0Pressed(self, event: 'QKeyEvent') -> None: ... + def focusChanged(self, focus: bool) -> None: ... + def sourceDeviceChanged(self, keyboardDevice: 'QKeyboardDevice') -> None: ... + def setFocus(self, focus: bool) -> None: ... + def setSourceDevice(self, keyboardDevice: 'QKeyboardDevice') -> None: ... + def focus(self) -> bool: ... + def sourceDevice(self) -> 'QKeyboardDevice': ... + + +class QKeyEvent(QtCore.QObject): + + @typing.overload + def __init__(self, type: QtCore.QEvent.Type, key: int, modifiers: typing.Union[QtCore.Qt.KeyboardModifiers, QtCore.Qt.KeyboardModifier], text: str = ..., autorep: bool = ..., count: int = ...) -> None: ... + @typing.overload + def __init__(self, ke: QtGui.QKeyEvent) -> None: ... + + def matches(self, key_: QtGui.QKeySequence.StandardKey) -> bool: ... + def type(self) -> QtCore.QEvent.Type: ... + def setAccepted(self, accepted: bool) -> None: ... + def isAccepted(self) -> bool: ... + def nativeScanCode(self) -> int: ... + def count(self) -> int: ... + def isAutoRepeat(self) -> bool: ... + def modifiers(self) -> int: ... + def text(self) -> str: ... + def key(self) -> int: ... + + +class QLogicalDevice(Qt3DCore.QComponent): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def axes(self) -> typing.List['QAxis']: ... + def removeAxis(self, axis: 'QAxis') -> None: ... + def addAxis(self, axis: 'QAxis') -> None: ... + def actions(self) -> typing.List['QAction']: ... + def removeAction(self, action: 'QAction') -> None: ... + def addAction(self, action: 'QAction') -> None: ... + + +class QMouseDevice('QAbstractPhysicalDevice'): + + class Axis(int): + X = ... # type: QMouseDevice.Axis + Y = ... # type: QMouseDevice.Axis + WheelX = ... # type: QMouseDevice.Axis + WheelY = ... # type: QMouseDevice.Axis + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def updateAxesContinuouslyChanged(self, updateAxesContinuously: bool) -> None: ... + def setUpdateAxesContinuously(self, updateAxesContinuously: bool) -> None: ... + def updateAxesContinuously(self) -> bool: ... + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def sensitivityChanged(self, value: float) -> None: ... + def setSensitivity(self, value: float) -> None: ... + def sensitivity(self) -> float: ... + def buttonIdentifier(self, name: str) -> int: ... + def axisIdentifier(self, name: str) -> int: ... + def buttonNames(self) -> typing.List[str]: ... + def axisNames(self) -> typing.List[str]: ... + def buttonCount(self) -> int: ... + def axisCount(self) -> int: ... + + +class QMouseEvent(QtCore.QObject): + + class Modifiers(int): + NoModifier = ... # type: QMouseEvent.Modifiers + ShiftModifier = ... # type: QMouseEvent.Modifiers + ControlModifier = ... # type: QMouseEvent.Modifiers + AltModifier = ... # type: QMouseEvent.Modifiers + MetaModifier = ... # type: QMouseEvent.Modifiers + KeypadModifier = ... # type: QMouseEvent.Modifiers + + class Buttons(int): + LeftButton = ... # type: QMouseEvent.Buttons + RightButton = ... # type: QMouseEvent.Buttons + MiddleButton = ... # type: QMouseEvent.Buttons + BackButton = ... # type: QMouseEvent.Buttons + NoButton = ... # type: QMouseEvent.Buttons + + def __init__(self, e: QtGui.QMouseEvent) -> None: ... + + def type(self) -> QtCore.QEvent.Type: ... + def setAccepted(self, accepted: bool) -> None: ... + def isAccepted(self) -> bool: ... + def modifiers(self) -> 'QMouseEvent.Modifiers': ... + def buttons(self) -> int: ... + def button(self) -> 'QMouseEvent.Buttons': ... + def wasHeld(self) -> bool: ... + def y(self) -> int: ... + def x(self) -> int: ... + + +class QWheelEvent(QtCore.QObject): + + class Modifiers(int): + NoModifier = ... # type: QWheelEvent.Modifiers + ShiftModifier = ... # type: QWheelEvent.Modifiers + ControlModifier = ... # type: QWheelEvent.Modifiers + AltModifier = ... # type: QWheelEvent.Modifiers + MetaModifier = ... # type: QWheelEvent.Modifiers + KeypadModifier = ... # type: QWheelEvent.Modifiers + + class Buttons(int): + LeftButton = ... # type: QWheelEvent.Buttons + RightButton = ... # type: QWheelEvent.Buttons + MiddleButton = ... # type: QWheelEvent.Buttons + BackButton = ... # type: QWheelEvent.Buttons + NoButton = ... # type: QWheelEvent.Buttons + + def __init__(self, e: QtGui.QWheelEvent) -> None: ... + + def type(self) -> QtCore.QEvent.Type: ... + def setAccepted(self, accepted: bool) -> None: ... + def isAccepted(self) -> bool: ... + def modifiers(self) -> 'QWheelEvent.Modifiers': ... + def buttons(self) -> int: ... + def angleDelta(self) -> QtCore.QPoint: ... + def y(self) -> int: ... + def x(self) -> int: ... + + +class QMouseHandler(Qt3DCore.QComponent): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def wheel(self, wheel: 'QWheelEvent') -> None: ... + def positionChanged(self, mouse: 'QMouseEvent') -> None: ... + def pressAndHold(self, mouse: 'QMouseEvent') -> None: ... + def released(self, mouse: 'QMouseEvent') -> None: ... + def pressed(self, mouse: 'QMouseEvent') -> None: ... + def exited(self) -> None: ... + def entered(self) -> None: ... + def doubleClicked(self, mouse: 'QMouseEvent') -> None: ... + def clicked(self, mouse: 'QMouseEvent') -> None: ... + def containsMouseChanged(self, containsMouse: bool) -> None: ... + def sourceDeviceChanged(self, mouseDevice: 'QMouseDevice') -> None: ... + def setSourceDevice(self, mouseDevice: 'QMouseDevice') -> None: ... + def containsMouse(self) -> bool: ... + def sourceDevice(self) -> 'QMouseDevice': ... + + +class QPhysicalDeviceCreatedChangeBase(Qt3DCore.QNodeCreatedChangeBase): + + def __init__(self, device: 'QAbstractPhysicalDevice') -> None: ... + + def axisSettingIds(self) -> typing.List[Qt3DCore.QNodeId]: ... diff --git a/PyQt5-stubs/Qt3DLogic.pyi b/PyQt5-stubs/Qt3DLogic.pyi index 8c652545..1b712824 100644 --- a/PyQt5-stubs/Qt3DLogic.pyi +++ b/PyQt5-stubs/Qt3DLogic.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DLogic module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -40,14 +40,13 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], typing.Sequence[float], PyQt5.sip.Buffer, int, None] -class Qt3DLogic(PyQt5.sip.simplewrapper): +class QFrameAction(Qt3DCore.QComponent): - class QFrameAction(Qt3DCore.QComponent): + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def triggered(self, dt: float) -> None: ... - def triggered(self, dt: float) -> None: ... - class QLogicAspect(Qt3DCore.QAbstractAspect): +class QLogicAspect(Qt3DCore.QAbstractAspect): - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... diff --git a/PyQt5-stubs/Qt3DRender.pyi b/PyQt5-stubs/Qt3DRender.pyi index 8b1afa5a..93382b93 100644 --- a/PyQt5-stubs/Qt3DRender.pyi +++ b/PyQt5-stubs/Qt3DRender.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DRender module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -42,2322 +42,2439 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], typing.Sequence[float], PyQt5.sip.Buffer, int, None] -class Qt3DRender(PyQt5.sip.simplewrapper): - - class QAbstractFunctor(sip.simplewrapper): +class QAbstractFunctor(sip.simplewrapper): + + def __init__(self) -> None: ... + + def id(self) -> PyQt5.sip.voidptr: ... + + +class QAbstractLight(Qt3DCore.QComponent): + + class Type(int): + PointLight = ... # type: QAbstractLight.Type + DirectionalLight = ... # type: QAbstractLight.Type + SpotLight = ... # type: QAbstractLight.Type + + def intensityChanged(self, intensity: float) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setIntensity(self, intensity: float) -> None: ... + def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def intensity(self) -> float: ... + def color(self) -> QtGui.QColor: ... + def type(self) -> 'QAbstractLight.Type': ... + + +class QAbstractRayCaster(Qt3DCore.QComponent): + + class FilterMode(int): + AcceptAnyMatchingLayers = ... # type: QAbstractRayCaster.FilterMode + AcceptAllMatchingLayers = ... # type: QAbstractRayCaster.FilterMode + DiscardAnyMatchingLayers = ... # type: QAbstractRayCaster.FilterMode + DiscardAllMatchingLayers = ... # type: QAbstractRayCaster.FilterMode + + class RunMode(int): + Continuous = ... # type: QAbstractRayCaster.RunMode + SingleShot = ... # type: QAbstractRayCaster.RunMode + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def filterModeChanged(self, filterMode: 'QAbstractRayCaster.FilterMode') -> None: ... + def hitsChanged(self, hits: typing.Iterable['QRayCasterHit']) -> None: ... + def runModeChanged(self, runMode: 'QAbstractRayCaster.RunMode') -> None: ... + def setFilterMode(self, filterMode: 'QAbstractRayCaster.FilterMode') -> None: ... + def setRunMode(self, runMode: 'QAbstractRayCaster.RunMode') -> None: ... + def layers(self) -> typing.List['QLayer']: ... + def removeLayer(self, layer: 'QLayer') -> None: ... + def addLayer(self, layer: 'QLayer') -> None: ... + def hits(self) -> typing.List['QRayCasterHit']: ... + def filterMode(self) -> 'QAbstractRayCaster.FilterMode': ... + def runMode(self) -> 'QAbstractRayCaster.RunMode': ... + + +class QAbstractTexture(Qt3DCore.QNode): + + class HandleType(int): + NoHandle = ... # type: QAbstractTexture.HandleType + OpenGLTextureId = ... # type: QAbstractTexture.HandleType + + class ComparisonMode(int): + CompareRefToTexture = ... # type: QAbstractTexture.ComparisonMode + CompareNone = ... # type: QAbstractTexture.ComparisonMode + + class ComparisonFunction(int): + CompareLessEqual = ... # type: QAbstractTexture.ComparisonFunction + CompareGreaterEqual = ... # type: QAbstractTexture.ComparisonFunction + CompareLess = ... # type: QAbstractTexture.ComparisonFunction + CompareGreater = ... # type: QAbstractTexture.ComparisonFunction + CompareEqual = ... # type: QAbstractTexture.ComparisonFunction + CommpareNotEqual = ... # type: QAbstractTexture.ComparisonFunction + CompareAlways = ... # type: QAbstractTexture.ComparisonFunction + CompareNever = ... # type: QAbstractTexture.ComparisonFunction + + class CubeMapFace(int): + CubeMapPositiveX = ... # type: QAbstractTexture.CubeMapFace + CubeMapNegativeX = ... # type: QAbstractTexture.CubeMapFace + CubeMapPositiveY = ... # type: QAbstractTexture.CubeMapFace + CubeMapNegativeY = ... # type: QAbstractTexture.CubeMapFace + CubeMapPositiveZ = ... # type: QAbstractTexture.CubeMapFace + CubeMapNegativeZ = ... # type: QAbstractTexture.CubeMapFace + AllFaces = ... # type: QAbstractTexture.CubeMapFace + + class Filter(int): + Nearest = ... # type: QAbstractTexture.Filter + Linear = ... # type: QAbstractTexture.Filter + NearestMipMapNearest = ... # type: QAbstractTexture.Filter + NearestMipMapLinear = ... # type: QAbstractTexture.Filter + LinearMipMapNearest = ... # type: QAbstractTexture.Filter + LinearMipMapLinear = ... # type: QAbstractTexture.Filter + + class TextureFormat(int): + NoFormat = ... # type: QAbstractTexture.TextureFormat + Automatic = ... # type: QAbstractTexture.TextureFormat + R8_UNorm = ... # type: QAbstractTexture.TextureFormat + RG8_UNorm = ... # type: QAbstractTexture.TextureFormat + RGB8_UNorm = ... # type: QAbstractTexture.TextureFormat + RGBA8_UNorm = ... # type: QAbstractTexture.TextureFormat + R16_UNorm = ... # type: QAbstractTexture.TextureFormat + RG16_UNorm = ... # type: QAbstractTexture.TextureFormat + RGB16_UNorm = ... # type: QAbstractTexture.TextureFormat + RGBA16_UNorm = ... # type: QAbstractTexture.TextureFormat + R8_SNorm = ... # type: QAbstractTexture.TextureFormat + RG8_SNorm = ... # type: QAbstractTexture.TextureFormat + RGB8_SNorm = ... # type: QAbstractTexture.TextureFormat + RGBA8_SNorm = ... # type: QAbstractTexture.TextureFormat + R16_SNorm = ... # type: QAbstractTexture.TextureFormat + RG16_SNorm = ... # type: QAbstractTexture.TextureFormat + RGB16_SNorm = ... # type: QAbstractTexture.TextureFormat + RGBA16_SNorm = ... # type: QAbstractTexture.TextureFormat + R8U = ... # type: QAbstractTexture.TextureFormat + RG8U = ... # type: QAbstractTexture.TextureFormat + RGB8U = ... # type: QAbstractTexture.TextureFormat + RGBA8U = ... # type: QAbstractTexture.TextureFormat + R16U = ... # type: QAbstractTexture.TextureFormat + RG16U = ... # type: QAbstractTexture.TextureFormat + RGB16U = ... # type: QAbstractTexture.TextureFormat + RGBA16U = ... # type: QAbstractTexture.TextureFormat + R32U = ... # type: QAbstractTexture.TextureFormat + RG32U = ... # type: QAbstractTexture.TextureFormat + RGB32U = ... # type: QAbstractTexture.TextureFormat + RGBA32U = ... # type: QAbstractTexture.TextureFormat + R8I = ... # type: QAbstractTexture.TextureFormat + RG8I = ... # type: QAbstractTexture.TextureFormat + RGB8I = ... # type: QAbstractTexture.TextureFormat + RGBA8I = ... # type: QAbstractTexture.TextureFormat + R16I = ... # type: QAbstractTexture.TextureFormat + RG16I = ... # type: QAbstractTexture.TextureFormat + RGB16I = ... # type: QAbstractTexture.TextureFormat + RGBA16I = ... # type: QAbstractTexture.TextureFormat + R32I = ... # type: QAbstractTexture.TextureFormat + RG32I = ... # type: QAbstractTexture.TextureFormat + RGB32I = ... # type: QAbstractTexture.TextureFormat + RGBA32I = ... # type: QAbstractTexture.TextureFormat + R16F = ... # type: QAbstractTexture.TextureFormat + RG16F = ... # type: QAbstractTexture.TextureFormat + RGB16F = ... # type: QAbstractTexture.TextureFormat + RGBA16F = ... # type: QAbstractTexture.TextureFormat + R32F = ... # type: QAbstractTexture.TextureFormat + RG32F = ... # type: QAbstractTexture.TextureFormat + RGB32F = ... # type: QAbstractTexture.TextureFormat + RGBA32F = ... # type: QAbstractTexture.TextureFormat + RGB9E5 = ... # type: QAbstractTexture.TextureFormat + RG11B10F = ... # type: QAbstractTexture.TextureFormat + RG3B2 = ... # type: QAbstractTexture.TextureFormat + R5G6B5 = ... # type: QAbstractTexture.TextureFormat + RGB5A1 = ... # type: QAbstractTexture.TextureFormat + RGBA4 = ... # type: QAbstractTexture.TextureFormat + RGB10A2 = ... # type: QAbstractTexture.TextureFormat + D16 = ... # type: QAbstractTexture.TextureFormat + D24 = ... # type: QAbstractTexture.TextureFormat + D24S8 = ... # type: QAbstractTexture.TextureFormat + D32 = ... # type: QAbstractTexture.TextureFormat + D32F = ... # type: QAbstractTexture.TextureFormat + D32FS8X24 = ... # type: QAbstractTexture.TextureFormat + RGB_DXT1 = ... # type: QAbstractTexture.TextureFormat + RGBA_DXT1 = ... # type: QAbstractTexture.TextureFormat + RGBA_DXT3 = ... # type: QAbstractTexture.TextureFormat + RGBA_DXT5 = ... # type: QAbstractTexture.TextureFormat + R_ATI1N_UNorm = ... # type: QAbstractTexture.TextureFormat + R_ATI1N_SNorm = ... # type: QAbstractTexture.TextureFormat + RG_ATI2N_UNorm = ... # type: QAbstractTexture.TextureFormat + RG_ATI2N_SNorm = ... # type: QAbstractTexture.TextureFormat + RGB_BP_UNSIGNED_FLOAT = ... # type: QAbstractTexture.TextureFormat + RGB_BP_SIGNED_FLOAT = ... # type: QAbstractTexture.TextureFormat + RGB_BP_UNorm = ... # type: QAbstractTexture.TextureFormat + R11_EAC_UNorm = ... # type: QAbstractTexture.TextureFormat + R11_EAC_SNorm = ... # type: QAbstractTexture.TextureFormat + RG11_EAC_UNorm = ... # type: QAbstractTexture.TextureFormat + RG11_EAC_SNorm = ... # type: QAbstractTexture.TextureFormat + RGB8_ETC2 = ... # type: QAbstractTexture.TextureFormat + SRGB8_ETC2 = ... # type: QAbstractTexture.TextureFormat + RGB8_PunchThrough_Alpha1_ETC2 = ... # type: QAbstractTexture.TextureFormat + SRGB8_PunchThrough_Alpha1_ETC2 = ... # type: QAbstractTexture.TextureFormat + RGBA8_ETC2_EAC = ... # type: QAbstractTexture.TextureFormat + SRGB8_Alpha8_ETC2_EAC = ... # type: QAbstractTexture.TextureFormat + RGB8_ETC1 = ... # type: QAbstractTexture.TextureFormat + SRGB8 = ... # type: QAbstractTexture.TextureFormat + SRGB8_Alpha8 = ... # type: QAbstractTexture.TextureFormat + SRGB_DXT1 = ... # type: QAbstractTexture.TextureFormat + SRGB_Alpha_DXT1 = ... # type: QAbstractTexture.TextureFormat + SRGB_Alpha_DXT3 = ... # type: QAbstractTexture.TextureFormat + SRGB_Alpha_DXT5 = ... # type: QAbstractTexture.TextureFormat + SRGB_BP_UNorm = ... # type: QAbstractTexture.TextureFormat + DepthFormat = ... # type: QAbstractTexture.TextureFormat + AlphaFormat = ... # type: QAbstractTexture.TextureFormat + RGBFormat = ... # type: QAbstractTexture.TextureFormat + RGBAFormat = ... # type: QAbstractTexture.TextureFormat + LuminanceFormat = ... # type: QAbstractTexture.TextureFormat + LuminanceAlphaFormat = ... # type: QAbstractTexture.TextureFormat + RGB10A2U = ... # type: QAbstractTexture.TextureFormat + + class Target(int): + TargetAutomatic = ... # type: QAbstractTexture.Target + Target1D = ... # type: QAbstractTexture.Target + Target1DArray = ... # type: QAbstractTexture.Target + Target2D = ... # type: QAbstractTexture.Target + Target2DArray = ... # type: QAbstractTexture.Target + Target3D = ... # type: QAbstractTexture.Target + TargetCubeMap = ... # type: QAbstractTexture.Target + TargetCubeMapArray = ... # type: QAbstractTexture.Target + Target2DMultisample = ... # type: QAbstractTexture.Target + Target2DMultisampleArray = ... # type: QAbstractTexture.Target + TargetRectangle = ... # type: QAbstractTexture.Target + TargetBuffer = ... # type: QAbstractTexture.Target + + class Status(int): + None_ = ... # type: QAbstractTexture.Status + Loading = ... # type: QAbstractTexture.Status + Ready = ... # type: QAbstractTexture.Status + Error = ... # type: QAbstractTexture.Status + + @typing.overload + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self, target: 'QAbstractTexture.Target', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def updateData(self, update: 'QTextureDataUpdate') -> None: ... + def handleChanged(self, handle: typing.Any) -> None: ... + def handleTypeChanged(self, handleType: 'QAbstractTexture.HandleType') -> None: ... + def handle(self) -> typing.Any: ... + def handleType(self) -> 'QAbstractTexture.HandleType': ... + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def setStatus(self, status: 'QAbstractTexture.Status') -> None: ... + def samplesChanged(self, samples: int) -> None: ... + def layersChanged(self, layers: int) -> None: ... + def comparisonModeChanged(self, comparisonMode: 'QAbstractTexture.ComparisonMode') -> None: ... + def comparisonFunctionChanged(self, comparisonFunction: 'QAbstractTexture.ComparisonFunction') -> None: ... + def maximumAnisotropyChanged(self, maximumAnisotropy: float) -> None: ... + def minificationFilterChanged(self, minificationFilter: 'QAbstractTexture.Filter') -> None: ... + def magnificationFilterChanged(self, magnificationFilter: 'QAbstractTexture.Filter') -> None: ... + def depthChanged(self, depth: int) -> None: ... + def heightChanged(self, height: int) -> None: ... + def widthChanged(self, width: int) -> None: ... + def generateMipMapsChanged(self, generateMipMaps: bool) -> None: ... + def statusChanged(self, status: 'QAbstractTexture.Status') -> None: ... + def formatChanged(self, format: 'QAbstractTexture.TextureFormat') -> None: ... + def setSamples(self, samples: int) -> None: ... + def setLayers(self, layers: int) -> None: ... + def setComparisonMode(self, mode: 'QAbstractTexture.ComparisonMode') -> None: ... + def setComparisonFunction(self, function: 'QAbstractTexture.ComparisonFunction') -> None: ... + def setMaximumAnisotropy(self, anisotropy: float) -> None: ... + def setMagnificationFilter(self, f: 'QAbstractTexture.Filter') -> None: ... + def setMinificationFilter(self, f: 'QAbstractTexture.Filter') -> None: ... + def setDepth(self, depth: int) -> None: ... + def setHeight(self, height: int) -> None: ... + def setWidth(self, width: int) -> None: ... + def setGenerateMipMaps(self, gen: bool) -> None: ... + def setFormat(self, format: 'QAbstractTexture.TextureFormat') -> None: ... + def dataGenerator(self) -> 'QTextureGenerator': ... + def samples(self) -> int: ... + def layers(self) -> int: ... + def depth(self) -> int: ... + def height(self) -> int: ... + def width(self) -> int: ... + def comparisonMode(self) -> 'QAbstractTexture.ComparisonMode': ... + def comparisonFunction(self) -> 'QAbstractTexture.ComparisonFunction': ... + def maximumAnisotropy(self) -> float: ... + def magnificationFilter(self) -> 'QAbstractTexture.Filter': ... + def minificationFilter(self) -> 'QAbstractTexture.Filter': ... + def setSize(self, width: int, height: int = ..., depth: int = ...) -> None: ... + def wrapMode(self) -> 'QTextureWrapMode': ... + def setWrapMode(self, wrapMode: 'QTextureWrapMode') -> None: ... + def textureImages(self) -> typing.List['QAbstractTextureImage']: ... + def removeTextureImage(self, textureImage: 'QAbstractTextureImage') -> None: ... + def addTextureImage(self, textureImage: 'QAbstractTextureImage') -> None: ... + def status(self) -> 'QAbstractTexture.Status': ... + def generateMipMaps(self) -> bool: ... + def format(self) -> 'QAbstractTexture.TextureFormat': ... + def target(self) -> 'QAbstractTexture.Target': ... + + +class QAbstractTextureImage(Qt3DCore.QNode): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def dataGenerator(self) -> 'QTextureImageDataGenerator': ... + def notifyDataGeneratorChanged(self) -> None: ... + def faceChanged(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... + def layerChanged(self, layer: int) -> None: ... + def mipLevelChanged(self, mipLevel: int) -> None: ... + def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... + def setLayer(self, layer: int) -> None: ... + def setMipLevel(self, level: int) -> None: ... + def face(self) -> 'QAbstractTexture.CubeMapFace': ... + def layer(self) -> int: ... + def mipLevel(self) -> int: ... + + +class QRenderState(Qt3DCore.QNode): ... + + +class QAlphaCoverage('QRenderState'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QAlphaTest('QRenderState'): + + class AlphaFunction(int): + Never = ... # type: QAlphaTest.AlphaFunction + Always = ... # type: QAlphaTest.AlphaFunction + Less = ... # type: QAlphaTest.AlphaFunction + LessOrEqual = ... # type: QAlphaTest.AlphaFunction + Equal = ... # type: QAlphaTest.AlphaFunction + GreaterOrEqual = ... # type: QAlphaTest.AlphaFunction + Greater = ... # type: QAlphaTest.AlphaFunction + NotEqual = ... # type: QAlphaTest.AlphaFunction + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def referenceValueChanged(self, referenceValue: float) -> None: ... + def alphaFunctionChanged(self, alphaFunction: 'QAlphaTest.AlphaFunction') -> None: ... + def setReferenceValue(self, referenceValue: float) -> None: ... + def setAlphaFunction(self, alphaFunction: 'QAlphaTest.AlphaFunction') -> None: ... + def referenceValue(self) -> float: ... + def alphaFunction(self) -> 'QAlphaTest.AlphaFunction': ... + + +class QAttribute(Qt3DCore.QNode): + + class VertexBaseType(int): + Byte = ... # type: QAttribute.VertexBaseType + UnsignedByte = ... # type: QAttribute.VertexBaseType + Short = ... # type: QAttribute.VertexBaseType + UnsignedShort = ... # type: QAttribute.VertexBaseType + Int = ... # type: QAttribute.VertexBaseType + UnsignedInt = ... # type: QAttribute.VertexBaseType + HalfFloat = ... # type: QAttribute.VertexBaseType + Float = ... # type: QAttribute.VertexBaseType + Double = ... # type: QAttribute.VertexBaseType + + class AttributeType(int): + VertexAttribute = ... # type: QAttribute.AttributeType + IndexAttribute = ... # type: QAttribute.AttributeType + DrawIndirectAttribute = ... # type: QAttribute.AttributeType + + @typing.overload + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self, buf: 'QBuffer', vertexBaseType: 'QAttribute.VertexBaseType', vertexSize: int, count: int, offset: int = ..., stride: int = ..., parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self, buf: 'QBuffer', name: str, vertexBaseType: 'QAttribute.VertexBaseType', vertexSize: int, count: int, offset: int = ..., stride: int = ..., parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def vertexSizeChanged(self, vertexSize: int) -> None: ... + def vertexBaseTypeChanged(self, vertexBaseType: 'QAttribute.VertexBaseType') -> None: ... + def attributeTypeChanged(self, attributeType: 'QAttribute.AttributeType') -> None: ... + def divisorChanged(self, divisor: int) -> None: ... + def byteOffsetChanged(self, byteOffset: int) -> None: ... + def byteStrideChanged(self, byteStride: int) -> None: ... + def countChanged(self, count: int) -> None: ... + def dataSizeChanged(self, vertexSize: int) -> None: ... + def dataTypeChanged(self, vertexBaseType: 'QAttribute.VertexBaseType') -> None: ... + def nameChanged(self, name: str) -> None: ... + def bufferChanged(self, buffer: 'QBuffer') -> None: ... + def setVertexSize(self, size: int) -> None: ... + def setVertexBaseType(self, type: 'QAttribute.VertexBaseType') -> None: ... + def setAttributeType(self, attributeType: 'QAttribute.AttributeType') -> None: ... + def setDivisor(self, divisor: int) -> None: ... + def setByteOffset(self, byteOffset: int) -> None: ... + def setByteStride(self, byteStride: int) -> None: ... + def setCount(self, count: int) -> None: ... + def setDataSize(self, size: int) -> None: ... + def setDataType(self, type: 'QAttribute.VertexBaseType') -> None: ... + def setName(self, name: str) -> None: ... + def setBuffer(self, buffer: 'QBuffer') -> None: ... + @staticmethod + def defaultJointWeightsAttributeName() -> str: ... + @staticmethod + def defaultJointIndicesAttributeName() -> str: ... + @staticmethod + def defaultTangentAttributeName() -> str: ... + @staticmethod + def defaultTextureCoordinate2AttributeName() -> str: ... + @staticmethod + def defaultTextureCoordinate1AttributeName() -> str: ... + @staticmethod + def defaultTextureCoordinateAttributeName() -> str: ... + @staticmethod + def defaultColorAttributeName() -> str: ... + @staticmethod + def defaultNormalAttributeName() -> str: ... + @staticmethod + def defaultPositionAttributeName() -> str: ... + def attributeType(self) -> 'QAttribute.AttributeType': ... + def divisor(self) -> int: ... + def byteOffset(self) -> int: ... + def byteStride(self) -> int: ... + def count(self) -> int: ... + def vertexSize(self) -> int: ... + def vertexBaseType(self) -> 'QAttribute.VertexBaseType': ... + def name(self) -> str: ... + def buffer(self) -> 'QBuffer': ... + + +class QBlendEquation('QRenderState'): + + class BlendFunction(int): + Add = ... # type: QBlendEquation.BlendFunction + Subtract = ... # type: QBlendEquation.BlendFunction + ReverseSubtract = ... # type: QBlendEquation.BlendFunction + Min = ... # type: QBlendEquation.BlendFunction + Max = ... # type: QBlendEquation.BlendFunction + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def blendFunctionChanged(self, blendFunction: 'QBlendEquation.BlendFunction') -> None: ... + def setBlendFunction(self, blendFunction: 'QBlendEquation.BlendFunction') -> None: ... + def blendFunction(self) -> 'QBlendEquation.BlendFunction': ... + + +class QBlendEquationArguments('QRenderState'): + + class Blending(int): + Zero = ... # type: QBlendEquationArguments.Blending + One = ... # type: QBlendEquationArguments.Blending + SourceColor = ... # type: QBlendEquationArguments.Blending + SourceAlpha = ... # type: QBlendEquationArguments.Blending + Source1Alpha = ... # type: QBlendEquationArguments.Blending + Source1Color = ... # type: QBlendEquationArguments.Blending + DestinationColor = ... # type: QBlendEquationArguments.Blending + DestinationAlpha = ... # type: QBlendEquationArguments.Blending + SourceAlphaSaturate = ... # type: QBlendEquationArguments.Blending + ConstantColor = ... # type: QBlendEquationArguments.Blending + ConstantAlpha = ... # type: QBlendEquationArguments.Blending + OneMinusSourceColor = ... # type: QBlendEquationArguments.Blending + OneMinusSourceAlpha = ... # type: QBlendEquationArguments.Blending + OneMinusDestinationAlpha = ... # type: QBlendEquationArguments.Blending + OneMinusDestinationColor = ... # type: QBlendEquationArguments.Blending + OneMinusConstantColor = ... # type: QBlendEquationArguments.Blending + OneMinusConstantAlpha = ... # type: QBlendEquationArguments.Blending + OneMinusSource1Alpha = ... # type: QBlendEquationArguments.Blending + OneMinusSource1Color0 = ... # type: QBlendEquationArguments.Blending + OneMinusSource1Color = ... # type: QBlendEquationArguments.Blending + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def bufferIndexChanged(self, index: int) -> None: ... + def destinationRgbaChanged(self, destinationRgba: 'QBlendEquationArguments.Blending') -> None: ... + def sourceRgbaChanged(self, sourceRgba: 'QBlendEquationArguments.Blending') -> None: ... + def destinationAlphaChanged(self, destinationAlpha: 'QBlendEquationArguments.Blending') -> None: ... + def destinationRgbChanged(self, destinationRgb: 'QBlendEquationArguments.Blending') -> None: ... + def sourceAlphaChanged(self, sourceAlpha: 'QBlendEquationArguments.Blending') -> None: ... + def sourceRgbChanged(self, sourceRgb: 'QBlendEquationArguments.Blending') -> None: ... + def setBufferIndex(self, index: int) -> None: ... + def setDestinationRgba(self, destinationRgba: 'QBlendEquationArguments.Blending') -> None: ... + def setSourceRgba(self, sourceRgba: 'QBlendEquationArguments.Blending') -> None: ... + def setDestinationAlpha(self, destinationAlpha: 'QBlendEquationArguments.Blending') -> None: ... + def setSourceAlpha(self, sourceAlpha: 'QBlendEquationArguments.Blending') -> None: ... + def setDestinationRgb(self, destinationRgb: 'QBlendEquationArguments.Blending') -> None: ... + def setSourceRgb(self, sourceRgb: 'QBlendEquationArguments.Blending') -> None: ... + def bufferIndex(self) -> int: ... + def destinationAlpha(self) -> 'QBlendEquationArguments.Blending': ... + def sourceAlpha(self) -> 'QBlendEquationArguments.Blending': ... + def destinationRgb(self) -> 'QBlendEquationArguments.Blending': ... + def sourceRgb(self) -> 'QBlendEquationArguments.Blending': ... + + +class QFrameGraphNode(Qt3DCore.QNode): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def parentFrameGraphNode(self) -> 'QFrameGraphNode': ... + + +class QBlitFramebuffer('QFrameGraphNode'): + + class InterpolationMethod(int): + Nearest = ... # type: QBlitFramebuffer.InterpolationMethod + Linear = ... # type: QBlitFramebuffer.InterpolationMethod + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def interpolationMethodChanged(self) -> None: ... + def destinationAttachmentPointChanged(self) -> None: ... + def sourceAttachmentPointChanged(self) -> None: ... + def destinationRectChanged(self) -> None: ... + def sourceRectChanged(self) -> None: ... + def destinationChanged(self) -> None: ... + def sourceChanged(self) -> None: ... + def setInterpolationMethod(self, interpolationMethod: 'QBlitFramebuffer.InterpolationMethod') -> None: ... + def setDestinationAttachmentPoint(self, destinationAttachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... + def setSourceAttachmentPoint(self, sourceAttachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... + def setDestinationRect(self, destinationRect: QtCore.QRectF) -> None: ... + def setSourceRect(self, sourceRect: QtCore.QRectF) -> None: ... + def setDestination(self, destination: 'QRenderTarget') -> None: ... + def setSource(self, source: 'QRenderTarget') -> None: ... + def interpolationMethod(self) -> 'QBlitFramebuffer.InterpolationMethod': ... + def destinationAttachmentPoint(self) -> 'QRenderTargetOutput.AttachmentPoint': ... + def sourceAttachmentPoint(self) -> 'QRenderTargetOutput.AttachmentPoint': ... + def destinationRect(self) -> QtCore.QRectF: ... + def sourceRect(self) -> QtCore.QRectF: ... + def destination(self) -> 'QRenderTarget': ... + def source(self) -> 'QRenderTarget': ... + + +class QBuffer(Qt3DCore.QNode): + + class AccessType(int): + Write = ... # type: QBuffer.AccessType + Read = ... # type: QBuffer.AccessType + ReadWrite = ... # type: QBuffer.AccessType + + class UsageType(int): + StreamDraw = ... # type: QBuffer.UsageType + StreamRead = ... # type: QBuffer.UsageType + StreamCopy = ... # type: QBuffer.UsageType + StaticDraw = ... # type: QBuffer.UsageType + StaticRead = ... # type: QBuffer.UsageType + StaticCopy = ... # type: QBuffer.UsageType + DynamicDraw = ... # type: QBuffer.UsageType + DynamicRead = ... # type: QBuffer.UsageType + DynamicCopy = ... # type: QBuffer.UsageType + + class BufferType(int): + VertexBuffer = ... # type: QBuffer.BufferType + IndexBuffer = ... # type: QBuffer.BufferType + PixelPackBuffer = ... # type: QBuffer.BufferType + PixelUnpackBuffer = ... # type: QBuffer.BufferType + UniformBuffer = ... # type: QBuffer.BufferType + ShaderStorageBuffer = ... # type: QBuffer.BufferType + DrawIndirectBuffer = ... # type: QBuffer.BufferType + + @typing.overload + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self, ty: 'QBuffer.BufferType', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def dataAvailable(self) -> None: ... + def accessTypeChanged(self, access: 'QBuffer.AccessType') -> None: ... + def setAccessType(self, access: 'QBuffer.AccessType') -> None: ... + def accessType(self) -> 'QBuffer.AccessType': ... + def updateData(self, offset: int, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def syncDataChanged(self, syncData: bool) -> None: ... + def usageChanged(self, usage: 'QBuffer.UsageType') -> None: ... + def typeChanged(self, type: 'QBuffer.BufferType') -> None: ... + def dataChanged(self, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def setSyncData(self, syncData: bool) -> None: ... + def setUsage(self, usage: 'QBuffer.UsageType') -> None: ... + def setType(self, type: 'QBuffer.BufferType') -> None: ... + def dataGenerator(self) -> 'QBufferDataGenerator': ... + def setDataGenerator(self, functor: 'QBufferDataGenerator') -> None: ... + def data(self) -> QtCore.QByteArray: ... + def setData(self, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def isSyncData(self) -> bool: ... + def type(self) -> 'QBuffer.BufferType': ... + def usage(self) -> 'QBuffer.UsageType': ... + + +class QBufferDataGenerator('QAbstractFunctor'): + + def __call__(self) -> QtCore.QByteArray: ... + + +class QCamera(Qt3DCore.QEntity): + + class CameraTranslationOption(int): + TranslateViewCenter = ... # type: QCamera.CameraTranslationOption + DontTranslateViewCenter = ... # type: QCamera.CameraTranslationOption + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def viewEntity(self, entity: Qt3DCore.QEntity) -> None: ... + def viewSphere(self, center: QtGui.QVector3D, radius: float) -> None: ... + def viewAll(self) -> None: ... + def exposureChanged(self, exposure: float) -> None: ... + def setExposure(self, exposure: float) -> None: ... + def exposure(self) -> float: ... + def viewMatrixChanged(self) -> None: ... + def viewVectorChanged(self, viewVector: QtGui.QVector3D) -> None: ... + def viewCenterChanged(self, viewCenter: QtGui.QVector3D) -> None: ... + def upVectorChanged(self, upVector: QtGui.QVector3D) -> None: ... + def positionChanged(self, position: QtGui.QVector3D) -> None: ... + def projectionMatrixChanged(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... + def topChanged(self, top: float) -> None: ... + def bottomChanged(self, bottom: float) -> None: ... + def rightChanged(self, right: float) -> None: ... + def leftChanged(self, left: float) -> None: ... + def aspectRatioChanged(self, aspectRatio: float) -> None: ... + def fieldOfViewChanged(self, fieldOfView: float) -> None: ... + def farPlaneChanged(self, farPlane: float) -> None: ... + def nearPlaneChanged(self, nearPlane: float) -> None: ... + def projectionTypeChanged(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... + def setViewCenter(self, viewCenter: QtGui.QVector3D) -> None: ... + def setUpVector(self, upVector: QtGui.QVector3D) -> None: ... + def setPosition(self, position: QtGui.QVector3D) -> None: ... + def setProjectionMatrix(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... + def setTop(self, top: float) -> None: ... + def setBottom(self, bottom: float) -> None: ... + def setRight(self, right: float) -> None: ... + def setLeft(self, left: float) -> None: ... + def setAspectRatio(self, aspectRatio: float) -> None: ... + def setFieldOfView(self, fieldOfView: float) -> None: ... + def setFarPlane(self, farPlane: float) -> None: ... + def setNearPlane(self, nearPlane: float) -> None: ... + def setProjectionType(self, type: 'QCameraLens.ProjectionType') -> None: ... + def viewMatrix(self) -> QtGui.QMatrix4x4: ... + def viewVector(self) -> QtGui.QVector3D: ... + def viewCenter(self) -> QtGui.QVector3D: ... + def upVector(self) -> QtGui.QVector3D: ... + def position(self) -> QtGui.QVector3D: ... + def projectionMatrix(self) -> QtGui.QMatrix4x4: ... + def top(self) -> float: ... + def bottom(self) -> float: ... + def right(self) -> float: ... + def left(self) -> float: ... + def aspectRatio(self) -> float: ... + def fieldOfView(self) -> float: ... + def farPlane(self) -> float: ... + def nearPlane(self) -> float: ... + def projectionType(self) -> 'QCameraLens.ProjectionType': ... + def rotateAboutViewCenter(self, q: QtGui.QQuaternion) -> None: ... + def rotate(self, q: QtGui.QQuaternion) -> None: ... + def rollAboutViewCenter(self, angle: float) -> None: ... + @typing.overload + def panAboutViewCenter(self, angle: float) -> None: ... + @typing.overload + def panAboutViewCenter(self, angle: float, axis: QtGui.QVector3D) -> None: ... + def tiltAboutViewCenter(self, angle: float) -> None: ... + def roll(self, angle: float) -> None: ... + @typing.overload + def pan(self, angle: float) -> None: ... + @typing.overload + def pan(self, angle: float, axis: QtGui.QVector3D) -> None: ... + def tilt(self, angle: float) -> None: ... + def translateWorld(self, vWorld: QtGui.QVector3D, option: 'QCamera.CameraTranslationOption' = ...) -> None: ... + def translate(self, vLocal: QtGui.QVector3D, option: 'QCamera.CameraTranslationOption' = ...) -> None: ... + def rotation(self, angle: float, axis: QtGui.QVector3D) -> QtGui.QQuaternion: ... + def rollRotation(self, angle: float) -> QtGui.QQuaternion: ... + def panRotation(self, angle: float) -> QtGui.QQuaternion: ... + def tiltRotation(self, angle: float) -> QtGui.QQuaternion: ... + def transform(self) -> Qt3DCore.QTransform: ... + def lens(self) -> 'QCameraLens': ... + + +class QCameraLens(Qt3DCore.QComponent): + + class ProjectionType(int): + OrthographicProjection = ... # type: QCameraLens.ProjectionType + PerspectiveProjection = ... # type: QCameraLens.ProjectionType + FrustumProjection = ... # type: QCameraLens.ProjectionType + CustomProjection = ... # type: QCameraLens.ProjectionType + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def viewSphere(self, center: QtGui.QVector3D, radius: float) -> None: ... + def viewEntity(self, entityId: Qt3DCore.QNodeId, cameraId: Qt3DCore.QNodeId) -> None: ... + def viewAll(self, cameraId: Qt3DCore.QNodeId) -> None: ... + def exposureChanged(self, exposure: float) -> None: ... + def setExposure(self, exposure: float) -> None: ... + def exposure(self) -> float: ... + def projectionMatrixChanged(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... + def topChanged(self, top: float) -> None: ... + def bottomChanged(self, bottom: float) -> None: ... + def rightChanged(self, right: float) -> None: ... + def leftChanged(self, left: float) -> None: ... + def aspectRatioChanged(self, aspectRatio: float) -> None: ... + def fieldOfViewChanged(self, fieldOfView: float) -> None: ... + def farPlaneChanged(self, farPlane: float) -> None: ... + def nearPlaneChanged(self, nearPlane: float) -> None: ... + def projectionTypeChanged(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... + def setProjectionMatrix(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... + def setTop(self, top: float) -> None: ... + def setBottom(self, bottom: float) -> None: ... + def setRight(self, right: float) -> None: ... + def setLeft(self, left: float) -> None: ... + def setAspectRatio(self, aspectRatio: float) -> None: ... + def setFieldOfView(self, fieldOfView: float) -> None: ... + def setFarPlane(self, farPlane: float) -> None: ... + def setNearPlane(self, nearPlane: float) -> None: ... + def setProjectionType(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... + def setPerspectiveProjection(self, fieldOfView: float, aspect: float, nearPlane: float, farPlane: float) -> None: ... + def setFrustumProjection(self, left: float, right: float, bottom: float, top: float, nearPlane: float, farPlane: float) -> None: ... + def setOrthographicProjection(self, left: float, right: float, bottom: float, top: float, nearPlane: float, farPlane: float) -> None: ... + def projectionMatrix(self) -> QtGui.QMatrix4x4: ... + def top(self) -> float: ... + def bottom(self) -> float: ... + def right(self) -> float: ... + def left(self) -> float: ... + def aspectRatio(self) -> float: ... + def fieldOfView(self) -> float: ... + def farPlane(self) -> float: ... + def nearPlane(self) -> float: ... + def projectionType(self) -> 'QCameraLens.ProjectionType': ... + + +class QCameraSelector('QFrameGraphNode'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def cameraChanged(self, camera: Qt3DCore.QEntity) -> None: ... + def setCamera(self, camera: Qt3DCore.QEntity) -> None: ... + def camera(self) -> Qt3DCore.QEntity: ... + + +class QClearBuffers('QFrameGraphNode'): + + class BufferType(int): + None_ = ... # type: QClearBuffers.BufferType + ColorBuffer = ... # type: QClearBuffers.BufferType + DepthBuffer = ... # type: QClearBuffers.BufferType + StencilBuffer = ... # type: QClearBuffers.BufferType + DepthStencilBuffer = ... # type: QClearBuffers.BufferType + ColorDepthBuffer = ... # type: QClearBuffers.BufferType + ColorDepthStencilBuffer = ... # type: QClearBuffers.BufferType + AllBuffers = ... # type: QClearBuffers.BufferType + + class BufferTypeFlags(sip.simplewrapper): + @typing.overload def __init__(self) -> None: ... - - def id(self) -> PyQt5.sip.voidptr: ... - - class QAbstractLight(Qt3DCore.QComponent): - - class Type(int): - PointLight = ... # type: QAbstractLight.Type - DirectionalLight = ... # type: QAbstractLight.Type - SpotLight = ... # type: QAbstractLight.Type - - def intensityChanged(self, intensity: float) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setIntensity(self, intensity: float) -> None: ... - def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def intensity(self) -> float: ... - def color(self) -> QtGui.QColor: ... - def type(self) -> 'QAbstractLight.Type': ... - - class QAbstractRayCaster(Qt3DCore.QComponent): - - class FilterMode(int): - AcceptAnyMatchingLayers = ... # type: QAbstractRayCaster.FilterMode - AcceptAllMatchingLayers = ... # type: QAbstractRayCaster.FilterMode - DiscardAnyMatchingLayers = ... # type: QAbstractRayCaster.FilterMode - DiscardAllMatchingLayers = ... # type: QAbstractRayCaster.FilterMode - - class RunMode(int): - Continuous = ... # type: QAbstractRayCaster.RunMode - SingleShot = ... # type: QAbstractRayCaster.RunMode - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def filterModeChanged(self, filterMode: 'QAbstractRayCaster.FilterMode') -> None: ... - def hitsChanged(self, hits: typing.Iterable['QRayCasterHit']) -> None: ... - def runModeChanged(self, runMode: 'QAbstractRayCaster.RunMode') -> None: ... - def setFilterMode(self, filterMode: 'QAbstractRayCaster.FilterMode') -> None: ... - def setRunMode(self, runMode: 'QAbstractRayCaster.RunMode') -> None: ... - def layers(self) -> typing.List['QLayer']: ... - def removeLayer(self, layer: 'QLayer') -> None: ... - def addLayer(self, layer: 'QLayer') -> None: ... - def hits(self) -> typing.List['QRayCasterHit']: ... - def filterMode(self) -> 'QAbstractRayCaster.FilterMode': ... - def runMode(self) -> 'QAbstractRayCaster.RunMode': ... - - class QAbstractTexture(Qt3DCore.QNode): - - class HandleType(int): - NoHandle = ... # type: QAbstractTexture.HandleType - OpenGLTextureId = ... # type: QAbstractTexture.HandleType - - class ComparisonMode(int): - CompareRefToTexture = ... # type: QAbstractTexture.ComparisonMode - CompareNone = ... # type: QAbstractTexture.ComparisonMode - - class ComparisonFunction(int): - CompareLessEqual = ... # type: QAbstractTexture.ComparisonFunction - CompareGreaterEqual = ... # type: QAbstractTexture.ComparisonFunction - CompareLess = ... # type: QAbstractTexture.ComparisonFunction - CompareGreater = ... # type: QAbstractTexture.ComparisonFunction - CompareEqual = ... # type: QAbstractTexture.ComparisonFunction - CommpareNotEqual = ... # type: QAbstractTexture.ComparisonFunction - CompareAlways = ... # type: QAbstractTexture.ComparisonFunction - CompareNever = ... # type: QAbstractTexture.ComparisonFunction - - class CubeMapFace(int): - CubeMapPositiveX = ... # type: QAbstractTexture.CubeMapFace - CubeMapNegativeX = ... # type: QAbstractTexture.CubeMapFace - CubeMapPositiveY = ... # type: QAbstractTexture.CubeMapFace - CubeMapNegativeY = ... # type: QAbstractTexture.CubeMapFace - CubeMapPositiveZ = ... # type: QAbstractTexture.CubeMapFace - CubeMapNegativeZ = ... # type: QAbstractTexture.CubeMapFace - AllFaces = ... # type: QAbstractTexture.CubeMapFace - - class Filter(int): - Nearest = ... # type: QAbstractTexture.Filter - Linear = ... # type: QAbstractTexture.Filter - NearestMipMapNearest = ... # type: QAbstractTexture.Filter - NearestMipMapLinear = ... # type: QAbstractTexture.Filter - LinearMipMapNearest = ... # type: QAbstractTexture.Filter - LinearMipMapLinear = ... # type: QAbstractTexture.Filter - - class TextureFormat(int): - NoFormat = ... # type: QAbstractTexture.TextureFormat - Automatic = ... # type: QAbstractTexture.TextureFormat - R8_UNorm = ... # type: QAbstractTexture.TextureFormat - RG8_UNorm = ... # type: QAbstractTexture.TextureFormat - RGB8_UNorm = ... # type: QAbstractTexture.TextureFormat - RGBA8_UNorm = ... # type: QAbstractTexture.TextureFormat - R16_UNorm = ... # type: QAbstractTexture.TextureFormat - RG16_UNorm = ... # type: QAbstractTexture.TextureFormat - RGB16_UNorm = ... # type: QAbstractTexture.TextureFormat - RGBA16_UNorm = ... # type: QAbstractTexture.TextureFormat - R8_SNorm = ... # type: QAbstractTexture.TextureFormat - RG8_SNorm = ... # type: QAbstractTexture.TextureFormat - RGB8_SNorm = ... # type: QAbstractTexture.TextureFormat - RGBA8_SNorm = ... # type: QAbstractTexture.TextureFormat - R16_SNorm = ... # type: QAbstractTexture.TextureFormat - RG16_SNorm = ... # type: QAbstractTexture.TextureFormat - RGB16_SNorm = ... # type: QAbstractTexture.TextureFormat - RGBA16_SNorm = ... # type: QAbstractTexture.TextureFormat - R8U = ... # type: QAbstractTexture.TextureFormat - RG8U = ... # type: QAbstractTexture.TextureFormat - RGB8U = ... # type: QAbstractTexture.TextureFormat - RGBA8U = ... # type: QAbstractTexture.TextureFormat - R16U = ... # type: QAbstractTexture.TextureFormat - RG16U = ... # type: QAbstractTexture.TextureFormat - RGB16U = ... # type: QAbstractTexture.TextureFormat - RGBA16U = ... # type: QAbstractTexture.TextureFormat - R32U = ... # type: QAbstractTexture.TextureFormat - RG32U = ... # type: QAbstractTexture.TextureFormat - RGB32U = ... # type: QAbstractTexture.TextureFormat - RGBA32U = ... # type: QAbstractTexture.TextureFormat - R8I = ... # type: QAbstractTexture.TextureFormat - RG8I = ... # type: QAbstractTexture.TextureFormat - RGB8I = ... # type: QAbstractTexture.TextureFormat - RGBA8I = ... # type: QAbstractTexture.TextureFormat - R16I = ... # type: QAbstractTexture.TextureFormat - RG16I = ... # type: QAbstractTexture.TextureFormat - RGB16I = ... # type: QAbstractTexture.TextureFormat - RGBA16I = ... # type: QAbstractTexture.TextureFormat - R32I = ... # type: QAbstractTexture.TextureFormat - RG32I = ... # type: QAbstractTexture.TextureFormat - RGB32I = ... # type: QAbstractTexture.TextureFormat - RGBA32I = ... # type: QAbstractTexture.TextureFormat - R16F = ... # type: QAbstractTexture.TextureFormat - RG16F = ... # type: QAbstractTexture.TextureFormat - RGB16F = ... # type: QAbstractTexture.TextureFormat - RGBA16F = ... # type: QAbstractTexture.TextureFormat - R32F = ... # type: QAbstractTexture.TextureFormat - RG32F = ... # type: QAbstractTexture.TextureFormat - RGB32F = ... # type: QAbstractTexture.TextureFormat - RGBA32F = ... # type: QAbstractTexture.TextureFormat - RGB9E5 = ... # type: QAbstractTexture.TextureFormat - RG11B10F = ... # type: QAbstractTexture.TextureFormat - RG3B2 = ... # type: QAbstractTexture.TextureFormat - R5G6B5 = ... # type: QAbstractTexture.TextureFormat - RGB5A1 = ... # type: QAbstractTexture.TextureFormat - RGBA4 = ... # type: QAbstractTexture.TextureFormat - RGB10A2 = ... # type: QAbstractTexture.TextureFormat - D16 = ... # type: QAbstractTexture.TextureFormat - D24 = ... # type: QAbstractTexture.TextureFormat - D24S8 = ... # type: QAbstractTexture.TextureFormat - D32 = ... # type: QAbstractTexture.TextureFormat - D32F = ... # type: QAbstractTexture.TextureFormat - D32FS8X24 = ... # type: QAbstractTexture.TextureFormat - RGB_DXT1 = ... # type: QAbstractTexture.TextureFormat - RGBA_DXT1 = ... # type: QAbstractTexture.TextureFormat - RGBA_DXT3 = ... # type: QAbstractTexture.TextureFormat - RGBA_DXT5 = ... # type: QAbstractTexture.TextureFormat - R_ATI1N_UNorm = ... # type: QAbstractTexture.TextureFormat - R_ATI1N_SNorm = ... # type: QAbstractTexture.TextureFormat - RG_ATI2N_UNorm = ... # type: QAbstractTexture.TextureFormat - RG_ATI2N_SNorm = ... # type: QAbstractTexture.TextureFormat - RGB_BP_UNSIGNED_FLOAT = ... # type: QAbstractTexture.TextureFormat - RGB_BP_SIGNED_FLOAT = ... # type: QAbstractTexture.TextureFormat - RGB_BP_UNorm = ... # type: QAbstractTexture.TextureFormat - R11_EAC_UNorm = ... # type: QAbstractTexture.TextureFormat - R11_EAC_SNorm = ... # type: QAbstractTexture.TextureFormat - RG11_EAC_UNorm = ... # type: QAbstractTexture.TextureFormat - RG11_EAC_SNorm = ... # type: QAbstractTexture.TextureFormat - RGB8_ETC2 = ... # type: QAbstractTexture.TextureFormat - SRGB8_ETC2 = ... # type: QAbstractTexture.TextureFormat - RGB8_PunchThrough_Alpha1_ETC2 = ... # type: QAbstractTexture.TextureFormat - SRGB8_PunchThrough_Alpha1_ETC2 = ... # type: QAbstractTexture.TextureFormat - RGBA8_ETC2_EAC = ... # type: QAbstractTexture.TextureFormat - SRGB8_Alpha8_ETC2_EAC = ... # type: QAbstractTexture.TextureFormat - RGB8_ETC1 = ... # type: QAbstractTexture.TextureFormat - SRGB8 = ... # type: QAbstractTexture.TextureFormat - SRGB8_Alpha8 = ... # type: QAbstractTexture.TextureFormat - SRGB_DXT1 = ... # type: QAbstractTexture.TextureFormat - SRGB_Alpha_DXT1 = ... # type: QAbstractTexture.TextureFormat - SRGB_Alpha_DXT3 = ... # type: QAbstractTexture.TextureFormat - SRGB_Alpha_DXT5 = ... # type: QAbstractTexture.TextureFormat - SRGB_BP_UNorm = ... # type: QAbstractTexture.TextureFormat - DepthFormat = ... # type: QAbstractTexture.TextureFormat - AlphaFormat = ... # type: QAbstractTexture.TextureFormat - RGBFormat = ... # type: QAbstractTexture.TextureFormat - RGBAFormat = ... # type: QAbstractTexture.TextureFormat - LuminanceFormat = ... # type: QAbstractTexture.TextureFormat - LuminanceAlphaFormat = ... # type: QAbstractTexture.TextureFormat - RGB10A2U = ... # type: QAbstractTexture.TextureFormat - - class Target(int): - TargetAutomatic = ... # type: QAbstractTexture.Target - Target1D = ... # type: QAbstractTexture.Target - Target1DArray = ... # type: QAbstractTexture.Target - Target2D = ... # type: QAbstractTexture.Target - Target2DArray = ... # type: QAbstractTexture.Target - Target3D = ... # type: QAbstractTexture.Target - TargetCubeMap = ... # type: QAbstractTexture.Target - TargetCubeMapArray = ... # type: QAbstractTexture.Target - Target2DMultisample = ... # type: QAbstractTexture.Target - Target2DMultisampleArray = ... # type: QAbstractTexture.Target - TargetRectangle = ... # type: QAbstractTexture.Target - TargetBuffer = ... # type: QAbstractTexture.Target - - class Status(int): - None_ = ... # type: QAbstractTexture.Status - Loading = ... # type: QAbstractTexture.Status - Ready = ... # type: QAbstractTexture.Status - Error = ... # type: QAbstractTexture.Status - @typing.overload - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def __init__(self, f: typing.Union['QClearBuffers.BufferTypeFlags', 'QClearBuffers.BufferType']) -> None: ... @typing.overload - def __init__(self, target: 'QAbstractTexture.Target', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def updateData(self, update: 'QTextureDataUpdate') -> None: ... - def handleChanged(self, handle: typing.Any) -> None: ... - def handleTypeChanged(self, handleType: 'QAbstractTexture.HandleType') -> None: ... - def handle(self) -> typing.Any: ... - def handleType(self) -> 'QAbstractTexture.HandleType': ... - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def setStatus(self, status: 'QAbstractTexture.Status') -> None: ... - def samplesChanged(self, samples: int) -> None: ... - def layersChanged(self, layers: int) -> None: ... - def comparisonModeChanged(self, comparisonMode: 'QAbstractTexture.ComparisonMode') -> None: ... - def comparisonFunctionChanged(self, comparisonFunction: 'QAbstractTexture.ComparisonFunction') -> None: ... - def maximumAnisotropyChanged(self, maximumAnisotropy: float) -> None: ... - def minificationFilterChanged(self, minificationFilter: 'QAbstractTexture.Filter') -> None: ... - def magnificationFilterChanged(self, magnificationFilter: 'QAbstractTexture.Filter') -> None: ... - def depthChanged(self, depth: int) -> None: ... - def heightChanged(self, height: int) -> None: ... - def widthChanged(self, width: int) -> None: ... - def generateMipMapsChanged(self, generateMipMaps: bool) -> None: ... - def statusChanged(self, status: 'QAbstractTexture.Status') -> None: ... - def formatChanged(self, format: 'QAbstractTexture.TextureFormat') -> None: ... - def setSamples(self, samples: int) -> None: ... - def setLayers(self, layers: int) -> None: ... - def setComparisonMode(self, mode: 'QAbstractTexture.ComparisonMode') -> None: ... - def setComparisonFunction(self, function: 'QAbstractTexture.ComparisonFunction') -> None: ... - def setMaximumAnisotropy(self, anisotropy: float) -> None: ... - def setMagnificationFilter(self, f: 'QAbstractTexture.Filter') -> None: ... - def setMinificationFilter(self, f: 'QAbstractTexture.Filter') -> None: ... - def setDepth(self, depth: int) -> None: ... - def setHeight(self, height: int) -> None: ... - def setWidth(self, width: int) -> None: ... - def setGenerateMipMaps(self, gen: bool) -> None: ... - def setFormat(self, format: 'QAbstractTexture.TextureFormat') -> None: ... - def dataGenerator(self) -> 'QTextureGenerator': ... - def samples(self) -> int: ... - def layers(self) -> int: ... - def depth(self) -> int: ... - def height(self) -> int: ... - def width(self) -> int: ... - def comparisonMode(self) -> 'QAbstractTexture.ComparisonMode': ... - def comparisonFunction(self) -> 'QAbstractTexture.ComparisonFunction': ... - def maximumAnisotropy(self) -> float: ... - def magnificationFilter(self) -> 'QAbstractTexture.Filter': ... - def minificationFilter(self) -> 'QAbstractTexture.Filter': ... - def setSize(self, width: int, height: int = ..., depth: int = ...) -> None: ... - def wrapMode(self) -> 'QTextureWrapMode': ... - def setWrapMode(self, wrapMode: 'QTextureWrapMode') -> None: ... - def textureImages(self) -> typing.List['QAbstractTextureImage']: ... - def removeTextureImage(self, textureImage: 'QAbstractTextureImage') -> None: ... - def addTextureImage(self, textureImage: 'QAbstractTextureImage') -> None: ... - def status(self) -> 'QAbstractTexture.Status': ... - def generateMipMaps(self) -> bool: ... - def format(self) -> 'QAbstractTexture.TextureFormat': ... - def target(self) -> 'QAbstractTexture.Target': ... - - class QAbstractTextureImage(Qt3DCore.QNode): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def dataGenerator(self) -> 'QTextureImageDataGenerator': ... - def notifyDataGeneratorChanged(self) -> None: ... - def faceChanged(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... - def layerChanged(self, layer: int) -> None: ... - def mipLevelChanged(self, mipLevel: int) -> None: ... - def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... - def setLayer(self, layer: int) -> None: ... - def setMipLevel(self, level: int) -> None: ... - def face(self) -> 'QAbstractTexture.CubeMapFace': ... - def layer(self) -> int: ... - def mipLevel(self) -> int: ... - - class QRenderState(Qt3DCore.QNode): ... - - class QAlphaCoverage('QRenderState'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QAlphaTest('QRenderState'): - - class AlphaFunction(int): - Never = ... # type: QAlphaTest.AlphaFunction - Always = ... # type: QAlphaTest.AlphaFunction - Less = ... # type: QAlphaTest.AlphaFunction - LessOrEqual = ... # type: QAlphaTest.AlphaFunction - Equal = ... # type: QAlphaTest.AlphaFunction - GreaterOrEqual = ... # type: QAlphaTest.AlphaFunction - Greater = ... # type: QAlphaTest.AlphaFunction - NotEqual = ... # type: QAlphaTest.AlphaFunction - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def referenceValueChanged(self, referenceValue: float) -> None: ... - def alphaFunctionChanged(self, alphaFunction: 'QAlphaTest.AlphaFunction') -> None: ... - def setReferenceValue(self, referenceValue: float) -> None: ... - def setAlphaFunction(self, alphaFunction: 'QAlphaTest.AlphaFunction') -> None: ... - def referenceValue(self) -> float: ... - def alphaFunction(self) -> 'QAlphaTest.AlphaFunction': ... - - class QAttribute(Qt3DCore.QNode): - - class VertexBaseType(int): - Byte = ... # type: QAttribute.VertexBaseType - UnsignedByte = ... # type: QAttribute.VertexBaseType - Short = ... # type: QAttribute.VertexBaseType - UnsignedShort = ... # type: QAttribute.VertexBaseType - Int = ... # type: QAttribute.VertexBaseType - UnsignedInt = ... # type: QAttribute.VertexBaseType - HalfFloat = ... # type: QAttribute.VertexBaseType - Float = ... # type: QAttribute.VertexBaseType - Double = ... # type: QAttribute.VertexBaseType - - class AttributeType(int): - VertexAttribute = ... # type: QAttribute.AttributeType - IndexAttribute = ... # type: QAttribute.AttributeType - DrawIndirectAttribute = ... # type: QAttribute.AttributeType + def __init__(self, a0: 'QClearBuffers.BufferTypeFlags') -> None: ... + + def __hash__(self) -> int: ... + def __bool__(self) -> int: ... + def __invert__(self) -> 'QClearBuffers.BufferTypeFlags': ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def colorBufferChanged(self, buffer: 'QRenderTargetOutput') -> None: ... + def clearStencilValueChanged(self, clearStencilValue: int) -> None: ... + def clearDepthValueChanged(self, clearDepthValue: float) -> None: ... + def clearColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def buffersChanged(self, buffers: 'QClearBuffers.BufferType') -> None: ... + def setColorBuffer(self, buffer: 'QRenderTargetOutput') -> None: ... + def setClearStencilValue(self, clearStencilValue: int) -> None: ... + def setClearDepthValue(self, clearDepthValue: float) -> None: ... + def setClearColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setBuffers(self, buffers: 'QClearBuffers.BufferType') -> None: ... + def colorBuffer(self) -> 'QRenderTargetOutput': ... + def clearStencilValue(self) -> int: ... + def clearDepthValue(self) -> float: ... + def clearColor(self) -> QtGui.QColor: ... + def buffers(self) -> 'QClearBuffers.BufferType': ... + + +class QClipPlane('QRenderState'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def distanceChanged(self, distance: float) -> None: ... + def normalChanged(self, normal: QtGui.QVector3D) -> None: ... + def planeIndexChanged(self, planeIndex: int) -> None: ... + def setDistance(self, a0: float) -> None: ... + def setNormal(self, a0: QtGui.QVector3D) -> None: ... + def setPlaneIndex(self, a0: int) -> None: ... + def distance(self) -> float: ... + def normal(self) -> QtGui.QVector3D: ... + def planeIndex(self) -> int: ... - @typing.overload - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - @typing.overload - def __init__(self, buf: 'QBuffer', vertexBaseType: 'QAttribute.VertexBaseType', vertexSize: int, count: int, offset: int = ..., stride: int = ..., parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - @typing.overload - def __init__(self, buf: 'QBuffer', name: str, vertexBaseType: 'QAttribute.VertexBaseType', vertexSize: int, count: int, offset: int = ..., stride: int = ..., parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def vertexSizeChanged(self, vertexSize: int) -> None: ... - def vertexBaseTypeChanged(self, vertexBaseType: 'QAttribute.VertexBaseType') -> None: ... - def attributeTypeChanged(self, attributeType: 'QAttribute.AttributeType') -> None: ... - def divisorChanged(self, divisor: int) -> None: ... - def byteOffsetChanged(self, byteOffset: int) -> None: ... - def byteStrideChanged(self, byteStride: int) -> None: ... - def countChanged(self, count: int) -> None: ... - def dataSizeChanged(self, vertexSize: int) -> None: ... - def dataTypeChanged(self, vertexBaseType: 'QAttribute.VertexBaseType') -> None: ... - def nameChanged(self, name: str) -> None: ... - def bufferChanged(self, buffer: 'QBuffer') -> None: ... - def setVertexSize(self, size: int) -> None: ... - def setVertexBaseType(self, type: 'QAttribute.VertexBaseType') -> None: ... - def setAttributeType(self, attributeType: 'QAttribute.AttributeType') -> None: ... - def setDivisor(self, divisor: int) -> None: ... - def setByteOffset(self, byteOffset: int) -> None: ... - def setByteStride(self, byteStride: int) -> None: ... - def setCount(self, count: int) -> None: ... - def setDataSize(self, size: int) -> None: ... - def setDataType(self, type: 'QAttribute.VertexBaseType') -> None: ... - def setName(self, name: str) -> None: ... - def setBuffer(self, buffer: 'QBuffer') -> None: ... - @staticmethod - def defaultJointWeightsAttributeName() -> str: ... - @staticmethod - def defaultJointIndicesAttributeName() -> str: ... - @staticmethod - def defaultTangentAttributeName() -> str: ... - @staticmethod - def defaultTextureCoordinate2AttributeName() -> str: ... - @staticmethod - def defaultTextureCoordinate1AttributeName() -> str: ... - @staticmethod - def defaultTextureCoordinateAttributeName() -> str: ... - @staticmethod - def defaultColorAttributeName() -> str: ... - @staticmethod - def defaultNormalAttributeName() -> str: ... - @staticmethod - def defaultPositionAttributeName() -> str: ... - def attributeType(self) -> 'QAttribute.AttributeType': ... - def divisor(self) -> int: ... - def byteOffset(self) -> int: ... - def byteStride(self) -> int: ... - def count(self) -> int: ... - def vertexSize(self) -> int: ... - def vertexBaseType(self) -> 'QAttribute.VertexBaseType': ... - def name(self) -> str: ... - def buffer(self) -> 'QBuffer': ... - - class QBlendEquation('QRenderState'): - - class BlendFunction(int): - Add = ... # type: QBlendEquation.BlendFunction - Subtract = ... # type: QBlendEquation.BlendFunction - ReverseSubtract = ... # type: QBlendEquation.BlendFunction - Min = ... # type: QBlendEquation.BlendFunction - Max = ... # type: QBlendEquation.BlendFunction - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def blendFunctionChanged(self, blendFunction: 'QBlendEquation.BlendFunction') -> None: ... - def setBlendFunction(self, blendFunction: 'QBlendEquation.BlendFunction') -> None: ... - def blendFunction(self) -> 'QBlendEquation.BlendFunction': ... - - class QBlendEquationArguments('QRenderState'): - - class Blending(int): - Zero = ... # type: QBlendEquationArguments.Blending - One = ... # type: QBlendEquationArguments.Blending - SourceColor = ... # type: QBlendEquationArguments.Blending - SourceAlpha = ... # type: QBlendEquationArguments.Blending - Source1Alpha = ... # type: QBlendEquationArguments.Blending - Source1Color = ... # type: QBlendEquationArguments.Blending - DestinationColor = ... # type: QBlendEquationArguments.Blending - DestinationAlpha = ... # type: QBlendEquationArguments.Blending - SourceAlphaSaturate = ... # type: QBlendEquationArguments.Blending - ConstantColor = ... # type: QBlendEquationArguments.Blending - ConstantAlpha = ... # type: QBlendEquationArguments.Blending - OneMinusSourceColor = ... # type: QBlendEquationArguments.Blending - OneMinusSourceAlpha = ... # type: QBlendEquationArguments.Blending - OneMinusDestinationAlpha = ... # type: QBlendEquationArguments.Blending - OneMinusDestinationColor = ... # type: QBlendEquationArguments.Blending - OneMinusConstantColor = ... # type: QBlendEquationArguments.Blending - OneMinusConstantAlpha = ... # type: QBlendEquationArguments.Blending - OneMinusSource1Alpha = ... # type: QBlendEquationArguments.Blending - OneMinusSource1Color0 = ... # type: QBlendEquationArguments.Blending - OneMinusSource1Color = ... # type: QBlendEquationArguments.Blending - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def bufferIndexChanged(self, index: int) -> None: ... - def destinationRgbaChanged(self, destinationRgba: 'QBlendEquationArguments.Blending') -> None: ... - def sourceRgbaChanged(self, sourceRgba: 'QBlendEquationArguments.Blending') -> None: ... - def destinationAlphaChanged(self, destinationAlpha: 'QBlendEquationArguments.Blending') -> None: ... - def destinationRgbChanged(self, destinationRgb: 'QBlendEquationArguments.Blending') -> None: ... - def sourceAlphaChanged(self, sourceAlpha: 'QBlendEquationArguments.Blending') -> None: ... - def sourceRgbChanged(self, sourceRgb: 'QBlendEquationArguments.Blending') -> None: ... - def setBufferIndex(self, index: int) -> None: ... - def setDestinationRgba(self, destinationRgba: 'QBlendEquationArguments.Blending') -> None: ... - def setSourceRgba(self, sourceRgba: 'QBlendEquationArguments.Blending') -> None: ... - def setDestinationAlpha(self, destinationAlpha: 'QBlendEquationArguments.Blending') -> None: ... - def setSourceAlpha(self, sourceAlpha: 'QBlendEquationArguments.Blending') -> None: ... - def setDestinationRgb(self, destinationRgb: 'QBlendEquationArguments.Blending') -> None: ... - def setSourceRgb(self, sourceRgb: 'QBlendEquationArguments.Blending') -> None: ... - def bufferIndex(self) -> int: ... - def destinationAlpha(self) -> 'QBlendEquationArguments.Blending': ... - def sourceAlpha(self) -> 'QBlendEquationArguments.Blending': ... - def destinationRgb(self) -> 'QBlendEquationArguments.Blending': ... - def sourceRgb(self) -> 'QBlendEquationArguments.Blending': ... - - class QFrameGraphNode(Qt3DCore.QNode): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def parentFrameGraphNode(self) -> 'QFrameGraphNode': ... - - class QBlitFramebuffer('QFrameGraphNode'): - - class InterpolationMethod(int): - Nearest = ... # type: QBlitFramebuffer.InterpolationMethod - Linear = ... # type: QBlitFramebuffer.InterpolationMethod - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def interpolationMethodChanged(self) -> None: ... - def destinationAttachmentPointChanged(self) -> None: ... - def sourceAttachmentPointChanged(self) -> None: ... - def destinationRectChanged(self) -> None: ... - def sourceRectChanged(self) -> None: ... - def destinationChanged(self) -> None: ... - def sourceChanged(self) -> None: ... - def setInterpolationMethod(self, interpolationMethod: 'QBlitFramebuffer.InterpolationMethod') -> None: ... - def setDestinationAttachmentPoint(self, destinationAttachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... - def setSourceAttachmentPoint(self, sourceAttachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... - def setDestinationRect(self, destinationRect: QtCore.QRectF) -> None: ... - def setSourceRect(self, sourceRect: QtCore.QRectF) -> None: ... - def setDestination(self, destination: 'QRenderTarget') -> None: ... - def setSource(self, source: 'QRenderTarget') -> None: ... - def interpolationMethod(self) -> 'QBlitFramebuffer.InterpolationMethod': ... - def destinationAttachmentPoint(self) -> 'QRenderTargetOutput.AttachmentPoint': ... - def sourceAttachmentPoint(self) -> 'QRenderTargetOutput.AttachmentPoint': ... - def destinationRect(self) -> QtCore.QRectF: ... - def sourceRect(self) -> QtCore.QRectF: ... - def destination(self) -> 'QRenderTarget': ... - def source(self) -> 'QRenderTarget': ... - - class QBuffer(Qt3DCore.QNode): - - class AccessType(int): - Write = ... # type: QBuffer.AccessType - Read = ... # type: QBuffer.AccessType - ReadWrite = ... # type: QBuffer.AccessType - - class UsageType(int): - StreamDraw = ... # type: QBuffer.UsageType - StreamRead = ... # type: QBuffer.UsageType - StreamCopy = ... # type: QBuffer.UsageType - StaticDraw = ... # type: QBuffer.UsageType - StaticRead = ... # type: QBuffer.UsageType - StaticCopy = ... # type: QBuffer.UsageType - DynamicDraw = ... # type: QBuffer.UsageType - DynamicRead = ... # type: QBuffer.UsageType - DynamicCopy = ... # type: QBuffer.UsageType - - class BufferType(int): - VertexBuffer = ... # type: QBuffer.BufferType - IndexBuffer = ... # type: QBuffer.BufferType - PixelPackBuffer = ... # type: QBuffer.BufferType - PixelUnpackBuffer = ... # type: QBuffer.BufferType - UniformBuffer = ... # type: QBuffer.BufferType - ShaderStorageBuffer = ... # type: QBuffer.BufferType - DrawIndirectBuffer = ... # type: QBuffer.BufferType - @typing.overload - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - @typing.overload - def __init__(self, ty: 'QBuffer.BufferType', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def dataAvailable(self) -> None: ... - def accessTypeChanged(self, access: 'QBuffer.AccessType') -> None: ... - def setAccessType(self, access: 'QBuffer.AccessType') -> None: ... - def accessType(self) -> 'QBuffer.AccessType': ... - def updateData(self, offset: int, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def syncDataChanged(self, syncData: bool) -> None: ... - def usageChanged(self, usage: 'QBuffer.UsageType') -> None: ... - def typeChanged(self, type: 'QBuffer.BufferType') -> None: ... - def dataChanged(self, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def setSyncData(self, syncData: bool) -> None: ... - def setUsage(self, usage: 'QBuffer.UsageType') -> None: ... - def setType(self, type: 'QBuffer.BufferType') -> None: ... - def dataGenerator(self) -> 'QBufferDataGenerator': ... - def setDataGenerator(self, functor: 'QBufferDataGenerator') -> None: ... - def data(self) -> QtCore.QByteArray: ... - def setData(self, bytes: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def isSyncData(self) -> bool: ... - def type(self) -> 'QBuffer.BufferType': ... - def usage(self) -> 'QBuffer.UsageType': ... - - class QBufferDataGenerator('QAbstractFunctor'): - - def __call__(self) -> QtCore.QByteArray: ... - - class QCamera(Qt3DCore.QEntity): - - class CameraTranslationOption(int): - TranslateViewCenter = ... # type: QCamera.CameraTranslationOption - DontTranslateViewCenter = ... # type: QCamera.CameraTranslationOption - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def viewEntity(self, entity: Qt3DCore.QEntity) -> None: ... - def viewSphere(self, center: QtGui.QVector3D, radius: float) -> None: ... - def viewAll(self) -> None: ... - def exposureChanged(self, exposure: float) -> None: ... - def setExposure(self, exposure: float) -> None: ... - def exposure(self) -> float: ... - def viewMatrixChanged(self) -> None: ... - def viewVectorChanged(self, viewVector: QtGui.QVector3D) -> None: ... - def viewCenterChanged(self, viewCenter: QtGui.QVector3D) -> None: ... - def upVectorChanged(self, upVector: QtGui.QVector3D) -> None: ... - def positionChanged(self, position: QtGui.QVector3D) -> None: ... - def projectionMatrixChanged(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... - def topChanged(self, top: float) -> None: ... - def bottomChanged(self, bottom: float) -> None: ... - def rightChanged(self, right: float) -> None: ... - def leftChanged(self, left: float) -> None: ... - def aspectRatioChanged(self, aspectRatio: float) -> None: ... - def fieldOfViewChanged(self, fieldOfView: float) -> None: ... - def farPlaneChanged(self, farPlane: float) -> None: ... - def nearPlaneChanged(self, nearPlane: float) -> None: ... - def projectionTypeChanged(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... - def setViewCenter(self, viewCenter: QtGui.QVector3D) -> None: ... - def setUpVector(self, upVector: QtGui.QVector3D) -> None: ... - def setPosition(self, position: QtGui.QVector3D) -> None: ... - def setProjectionMatrix(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... - def setTop(self, top: float) -> None: ... - def setBottom(self, bottom: float) -> None: ... - def setRight(self, right: float) -> None: ... - def setLeft(self, left: float) -> None: ... - def setAspectRatio(self, aspectRatio: float) -> None: ... - def setFieldOfView(self, fieldOfView: float) -> None: ... - def setFarPlane(self, farPlane: float) -> None: ... - def setNearPlane(self, nearPlane: float) -> None: ... - def setProjectionType(self, type: 'QCameraLens.ProjectionType') -> None: ... - def viewMatrix(self) -> QtGui.QMatrix4x4: ... - def viewVector(self) -> QtGui.QVector3D: ... - def viewCenter(self) -> QtGui.QVector3D: ... - def upVector(self) -> QtGui.QVector3D: ... - def position(self) -> QtGui.QVector3D: ... - def projectionMatrix(self) -> QtGui.QMatrix4x4: ... - def top(self) -> float: ... - def bottom(self) -> float: ... - def right(self) -> float: ... - def left(self) -> float: ... - def aspectRatio(self) -> float: ... - def fieldOfView(self) -> float: ... - def farPlane(self) -> float: ... - def nearPlane(self) -> float: ... - def projectionType(self) -> 'QCameraLens.ProjectionType': ... - def rotateAboutViewCenter(self, q: QtGui.QQuaternion) -> None: ... - def rotate(self, q: QtGui.QQuaternion) -> None: ... - def rollAboutViewCenter(self, angle: float) -> None: ... - @typing.overload - def panAboutViewCenter(self, angle: float) -> None: ... - @typing.overload - def panAboutViewCenter(self, angle: float, axis: QtGui.QVector3D) -> None: ... - def tiltAboutViewCenter(self, angle: float) -> None: ... - def roll(self, angle: float) -> None: ... - @typing.overload - def pan(self, angle: float) -> None: ... - @typing.overload - def pan(self, angle: float, axis: QtGui.QVector3D) -> None: ... - def tilt(self, angle: float) -> None: ... - def translateWorld(self, vWorld: QtGui.QVector3D, option: 'QCamera.CameraTranslationOption' = ...) -> None: ... - def translate(self, vLocal: QtGui.QVector3D, option: 'QCamera.CameraTranslationOption' = ...) -> None: ... - def rotation(self, angle: float, axis: QtGui.QVector3D) -> QtGui.QQuaternion: ... - def rollRotation(self, angle: float) -> QtGui.QQuaternion: ... - def panRotation(self, angle: float) -> QtGui.QQuaternion: ... - def tiltRotation(self, angle: float) -> QtGui.QQuaternion: ... - def transform(self) -> Qt3DCore.QTransform: ... - def lens(self) -> 'QCameraLens': ... - - class QCameraLens(Qt3DCore.QComponent): - - class ProjectionType(int): - OrthographicProjection = ... # type: QCameraLens.ProjectionType - PerspectiveProjection = ... # type: QCameraLens.ProjectionType - FrustumProjection = ... # type: QCameraLens.ProjectionType - CustomProjection = ... # type: QCameraLens.ProjectionType - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def viewSphere(self, center: QtGui.QVector3D, radius: float) -> None: ... - def viewEntity(self, entityId: Qt3DCore.QNodeId, cameraId: Qt3DCore.QNodeId) -> None: ... - def viewAll(self, cameraId: Qt3DCore.QNodeId) -> None: ... - def exposureChanged(self, exposure: float) -> None: ... - def setExposure(self, exposure: float) -> None: ... - def exposure(self) -> float: ... - def projectionMatrixChanged(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... - def topChanged(self, top: float) -> None: ... - def bottomChanged(self, bottom: float) -> None: ... - def rightChanged(self, right: float) -> None: ... - def leftChanged(self, left: float) -> None: ... - def aspectRatioChanged(self, aspectRatio: float) -> None: ... - def fieldOfViewChanged(self, fieldOfView: float) -> None: ... - def farPlaneChanged(self, farPlane: float) -> None: ... - def nearPlaneChanged(self, nearPlane: float) -> None: ... - def projectionTypeChanged(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... - def setProjectionMatrix(self, projectionMatrix: QtGui.QMatrix4x4) -> None: ... - def setTop(self, top: float) -> None: ... - def setBottom(self, bottom: float) -> None: ... - def setRight(self, right: float) -> None: ... - def setLeft(self, left: float) -> None: ... - def setAspectRatio(self, aspectRatio: float) -> None: ... - def setFieldOfView(self, fieldOfView: float) -> None: ... - def setFarPlane(self, farPlane: float) -> None: ... - def setNearPlane(self, nearPlane: float) -> None: ... - def setProjectionType(self, projectionType: 'QCameraLens.ProjectionType') -> None: ... - def setPerspectiveProjection(self, fieldOfView: float, aspect: float, nearPlane: float, farPlane: float) -> None: ... - def setFrustumProjection(self, left: float, right: float, bottom: float, top: float, nearPlane: float, farPlane: float) -> None: ... - def setOrthographicProjection(self, left: float, right: float, bottom: float, top: float, nearPlane: float, farPlane: float) -> None: ... - def projectionMatrix(self) -> QtGui.QMatrix4x4: ... - def top(self) -> float: ... - def bottom(self) -> float: ... - def right(self) -> float: ... - def left(self) -> float: ... - def aspectRatio(self) -> float: ... - def fieldOfView(self) -> float: ... - def farPlane(self) -> float: ... - def nearPlane(self) -> float: ... - def projectionType(self) -> 'QCameraLens.ProjectionType': ... - - class QCameraSelector('QFrameGraphNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def cameraChanged(self, camera: Qt3DCore.QEntity) -> None: ... - def setCamera(self, camera: Qt3DCore.QEntity) -> None: ... - def camera(self) -> Qt3DCore.QEntity: ... - - class QClearBuffers('QFrameGraphNode'): - - class BufferType(int): - None_ = ... # type: QClearBuffers.BufferType - ColorBuffer = ... # type: QClearBuffers.BufferType - DepthBuffer = ... # type: QClearBuffers.BufferType - StencilBuffer = ... # type: QClearBuffers.BufferType - DepthStencilBuffer = ... # type: QClearBuffers.BufferType - ColorDepthBuffer = ... # type: QClearBuffers.BufferType - ColorDepthStencilBuffer = ... # type: QClearBuffers.BufferType - AllBuffers = ... # type: QClearBuffers.BufferType - - class BufferTypeFlags(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, f: typing.Union['QClearBuffers.BufferTypeFlags', 'QClearBuffers.BufferType']) -> None: ... - @typing.overload - def __init__(self, a0: 'QClearBuffers.BufferTypeFlags') -> None: ... - - def __hash__(self) -> int: ... - def __bool__(self) -> int: ... - def __invert__(self) -> 'QClearBuffers.BufferTypeFlags': ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def colorBufferChanged(self, buffer: 'QRenderTargetOutput') -> None: ... - def clearStencilValueChanged(self, clearStencilValue: int) -> None: ... - def clearDepthValueChanged(self, clearDepthValue: float) -> None: ... - def clearColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def buffersChanged(self, buffers: 'QClearBuffers.BufferType') -> None: ... - def setColorBuffer(self, buffer: 'QRenderTargetOutput') -> None: ... - def setClearStencilValue(self, clearStencilValue: int) -> None: ... - def setClearDepthValue(self, clearDepthValue: float) -> None: ... - def setClearColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setBuffers(self, buffers: 'QClearBuffers.BufferType') -> None: ... - def colorBuffer(self) -> 'QRenderTargetOutput': ... - def clearStencilValue(self) -> int: ... - def clearDepthValue(self) -> float: ... - def clearColor(self) -> QtGui.QColor: ... - def buffers(self) -> 'QClearBuffers.BufferType': ... - - class QClipPlane('QRenderState'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def distanceChanged(self, distance: float) -> None: ... - def normalChanged(self, normal: QtGui.QVector3D) -> None: ... - def planeIndexChanged(self, planeIndex: int) -> None: ... - def setDistance(self, a0: float) -> None: ... - def setNormal(self, a0: QtGui.QVector3D) -> None: ... - def setPlaneIndex(self, a0: int) -> None: ... - def distance(self) -> float: ... - def normal(self) -> QtGui.QVector3D: ... - def planeIndex(self) -> int: ... - - class QComputeCommand(Qt3DCore.QComponent): - - class RunType(int): - Continuous = ... # type: QComputeCommand.RunType - Manual = ... # type: QComputeCommand.RunType - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def runTypeChanged(self) -> None: ... - @typing.overload - def trigger(self, frameCount: int = ...) -> None: ... - @typing.overload - def trigger(self, workGroupX: int, workGroupY: int, workGroupZ: int, frameCount: int = ...) -> None: ... - def setRunType(self, runType: 'QComputeCommand.RunType') -> None: ... - def runType(self) -> 'QComputeCommand.RunType': ... - def workGroupZChanged(self) -> None: ... - def workGroupYChanged(self) -> None: ... - def workGroupXChanged(self) -> None: ... - def setWorkGroupZ(self, workGroupZ: int) -> None: ... - def setWorkGroupY(self, workGroupY: int) -> None: ... - def setWorkGroupX(self, workGroupX: int) -> None: ... - def workGroupZ(self) -> int: ... - def workGroupY(self) -> int: ... - def workGroupX(self) -> int: ... - - class QColorMask('QRenderState'): +class QComputeCommand(Qt3DCore.QComponent): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def alphaMaskedChanged(self, alphaMasked: bool) -> None: ... - def blueMaskedChanged(self, blueMasked: bool) -> None: ... - def greenMaskedChanged(self, greenMasked: bool) -> None: ... - def redMaskedChanged(self, redMasked: bool) -> None: ... - def setAlphaMasked(self, alphaMasked: bool) -> None: ... - def setBlueMasked(self, blueMasked: bool) -> None: ... - def setGreenMasked(self, greenMasked: bool) -> None: ... - def setRedMasked(self, redMasked: bool) -> None: ... - def isAlphaMasked(self) -> bool: ... - def isBlueMasked(self) -> bool: ... - def isGreenMasked(self) -> bool: ... - def isRedMasked(self) -> bool: ... - - class QCullFace('QRenderState'): - - class CullingMode(int): - NoCulling = ... # type: QCullFace.CullingMode - Front = ... # type: QCullFace.CullingMode - Back = ... # type: QCullFace.CullingMode - FrontAndBack = ... # type: QCullFace.CullingMode + class RunType(int): + Continuous = ... # type: QComputeCommand.RunType + Manual = ... # type: QComputeCommand.RunType - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def modeChanged(self, mode: 'QCullFace.CullingMode') -> None: ... - def setMode(self, mode: 'QCullFace.CullingMode') -> None: ... - def mode(self) -> 'QCullFace.CullingMode': ... + def runTypeChanged(self) -> None: ... + @typing.overload + def trigger(self, frameCount: int = ...) -> None: ... + @typing.overload + def trigger(self, workGroupX: int, workGroupY: int, workGroupZ: int, frameCount: int = ...) -> None: ... + def setRunType(self, runType: 'QComputeCommand.RunType') -> None: ... + def runType(self) -> 'QComputeCommand.RunType': ... + def workGroupZChanged(self) -> None: ... + def workGroupYChanged(self) -> None: ... + def workGroupXChanged(self) -> None: ... + def setWorkGroupZ(self, workGroupZ: int) -> None: ... + def setWorkGroupY(self, workGroupY: int) -> None: ... + def setWorkGroupX(self, workGroupX: int) -> None: ... + def workGroupZ(self) -> int: ... + def workGroupY(self) -> int: ... + def workGroupX(self) -> int: ... - class QDepthRange('QRenderState'): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... +class QColorMask('QRenderState'): - def farValueChanged(self, farValue: float) -> None: ... - def nearValueChanged(self, nearValue: float) -> None: ... - def setFarValue(self, value: float) -> None: ... - def setNearValue(self, value: float) -> None: ... - def farValue(self) -> float: ... - def nearValue(self) -> float: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QDepthTest('QRenderState'): + def alphaMaskedChanged(self, alphaMasked: bool) -> None: ... + def blueMaskedChanged(self, blueMasked: bool) -> None: ... + def greenMaskedChanged(self, greenMasked: bool) -> None: ... + def redMaskedChanged(self, redMasked: bool) -> None: ... + def setAlphaMasked(self, alphaMasked: bool) -> None: ... + def setBlueMasked(self, blueMasked: bool) -> None: ... + def setGreenMasked(self, greenMasked: bool) -> None: ... + def setRedMasked(self, redMasked: bool) -> None: ... + def isAlphaMasked(self) -> bool: ... + def isBlueMasked(self) -> bool: ... + def isGreenMasked(self) -> bool: ... + def isRedMasked(self) -> bool: ... - class DepthFunction(int): - Never = ... # type: QDepthTest.DepthFunction - Always = ... # type: QDepthTest.DepthFunction - Less = ... # type: QDepthTest.DepthFunction - LessOrEqual = ... # type: QDepthTest.DepthFunction - Equal = ... # type: QDepthTest.DepthFunction - GreaterOrEqual = ... # type: QDepthTest.DepthFunction - Greater = ... # type: QDepthTest.DepthFunction - NotEqual = ... # type: QDepthTest.DepthFunction - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... +class QCullFace('QRenderState'): - def depthFunctionChanged(self, depthFunction: 'QDepthTest.DepthFunction') -> None: ... - def setDepthFunction(self, depthFunction: 'QDepthTest.DepthFunction') -> None: ... - def depthFunction(self) -> 'QDepthTest.DepthFunction': ... + class CullingMode(int): + NoCulling = ... # type: QCullFace.CullingMode + Front = ... # type: QCullFace.CullingMode + Back = ... # type: QCullFace.CullingMode + FrontAndBack = ... # type: QCullFace.CullingMode - class QDirectionalLight('QAbstractLight'): + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def modeChanged(self, mode: 'QCullFace.CullingMode') -> None: ... + def setMode(self, mode: 'QCullFace.CullingMode') -> None: ... + def mode(self) -> 'QCullFace.CullingMode': ... - def worldDirectionChanged(self, worldDirection: QtGui.QVector3D) -> None: ... - def setWorldDirection(self, worldDirection: QtGui.QVector3D) -> None: ... - def worldDirection(self) -> QtGui.QVector3D: ... - - class QDispatchCompute('QFrameGraphNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def workGroupZChanged(self) -> None: ... - def workGroupYChanged(self) -> None: ... - def workGroupXChanged(self) -> None: ... - def setWorkGroupZ(self, workGroupZ: int) -> None: ... - def setWorkGroupY(self, workGroupY: int) -> None: ... - def setWorkGroupX(self, workGroupX: int) -> None: ... - def workGroupZ(self) -> int: ... - def workGroupY(self) -> int: ... - def workGroupX(self) -> int: ... - - class QDithering('QRenderState'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QEffect(Qt3DCore.QNode): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def techniques(self) -> typing.List['QTechnique']: ... - def removeTechnique(self, t: 'QTechnique') -> None: ... - def addTechnique(self, t: 'QTechnique') -> None: ... - def parameters(self) -> typing.List['QParameter']: ... - def removeParameter(self, parameter: 'QParameter') -> None: ... - def addParameter(self, parameter: 'QParameter') -> None: ... - - class QEnvironmentLight(Qt3DCore.QComponent): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def specularChanged(self, environmentSpecular: 'QAbstractTexture') -> None: ... - def irradianceChanged(self, environmentIrradiance: 'QAbstractTexture') -> None: ... - def setSpecular(self, specular: 'QAbstractTexture') -> None: ... - def setIrradiance(self, irradiance: 'QAbstractTexture') -> None: ... - def specular(self) -> 'QAbstractTexture': ... - def irradiance(self) -> 'QAbstractTexture': ... - - class QFilterKey(Qt3DCore.QNode): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def valueChanged(self, value: typing.Any) -> None: ... - def nameChanged(self, name: str) -> None: ... - def setName(self, customType: str) -> None: ... - def setValue(self, value: typing.Any) -> None: ... - def name(self) -> str: ... - def value(self) -> typing.Any: ... - - class QFrontFace('QRenderState'): - - class WindingDirection(int): - ClockWise = ... # type: QFrontFace.WindingDirection - CounterClockWise = ... # type: QFrontFace.WindingDirection - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def directionChanged(self, direction: 'QFrontFace.WindingDirection') -> None: ... - def setDirection(self, direction: 'QFrontFace.WindingDirection') -> None: ... - def direction(self) -> 'QFrontFace.WindingDirection': ... - - class QFrustumCulling('QFrameGraphNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QGeometry(Qt3DCore.QNode): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def maxExtentChanged(self, maxExtent: QtGui.QVector3D) -> None: ... - def minExtentChanged(self, minExtent: QtGui.QVector3D) -> None: ... - def maxExtent(self) -> QtGui.QVector3D: ... - def minExtent(self) -> QtGui.QVector3D: ... - def boundingVolumePositionAttributeChanged(self, boundingVolumePositionAttribute: 'QAttribute') -> None: ... - def setBoundingVolumePositionAttribute(self, boundingVolumePositionAttribute: 'QAttribute') -> None: ... - def boundingVolumePositionAttribute(self) -> 'QAttribute': ... - def removeAttribute(self, attribute: 'QAttribute') -> None: ... - def addAttribute(self, attribute: 'QAttribute') -> None: ... - def attributes(self) -> typing.List['QAttribute']: ... - - class QGeometryFactory('QAbstractFunctor'): - - def __call__(self) -> 'QGeometry': ... - - class QGeometryRenderer(Qt3DCore.QComponent): - - class PrimitiveType(int): - Points = ... # type: QGeometryRenderer.PrimitiveType - Lines = ... # type: QGeometryRenderer.PrimitiveType - LineLoop = ... # type: QGeometryRenderer.PrimitiveType - LineStrip = ... # type: QGeometryRenderer.PrimitiveType - Triangles = ... # type: QGeometryRenderer.PrimitiveType - TriangleStrip = ... # type: QGeometryRenderer.PrimitiveType - TriangleFan = ... # type: QGeometryRenderer.PrimitiveType - LinesAdjacency = ... # type: QGeometryRenderer.PrimitiveType - TrianglesAdjacency = ... # type: QGeometryRenderer.PrimitiveType - LineStripAdjacency = ... # type: QGeometryRenderer.PrimitiveType - TriangleStripAdjacency = ... # type: QGeometryRenderer.PrimitiveType - Patches = ... # type: QGeometryRenderer.PrimitiveType - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def indexBufferByteOffsetChanged(self, offset: int) -> None: ... - def setIndexBufferByteOffset(self, offset: int) -> None: ... - def indexBufferByteOffset(self) -> int: ... - def primitiveTypeChanged(self, primitiveType: 'QGeometryRenderer.PrimitiveType') -> None: ... - def geometryChanged(self, geometry: 'QGeometry') -> None: ... - def primitiveRestartEnabledChanged(self, primitiveRestartEnabled: bool) -> None: ... - def verticesPerPatchChanged(self, verticesPerPatch: int) -> None: ... - def restartIndexValueChanged(self, restartIndexValue: int) -> None: ... - def firstVertexChanged(self, firstVertex: int) -> None: ... - def firstInstanceChanged(self, firstInstance: int) -> None: ... - def indexOffsetChanged(self, indexOffset: int) -> None: ... - def vertexCountChanged(self, vertexCount: int) -> None: ... - def instanceCountChanged(self, instanceCount: int) -> None: ... - def setPrimitiveType(self, primitiveType: 'QGeometryRenderer.PrimitiveType') -> None: ... - def setGeometry(self, geometry: 'QGeometry') -> None: ... - def setPrimitiveRestartEnabled(self, enabled: bool) -> None: ... - def setVerticesPerPatch(self, verticesPerPatch: int) -> None: ... - def setRestartIndexValue(self, index: int) -> None: ... - def setFirstVertex(self, firstVertex: int) -> None: ... - def setFirstInstance(self, firstInstance: int) -> None: ... - def setIndexOffset(self, indexOffset: int) -> None: ... - def setVertexCount(self, vertexCount: int) -> None: ... - def setInstanceCount(self, instanceCount: int) -> None: ... - def setGeometryFactory(self, factory: 'QGeometryFactory') -> None: ... - def geometryFactory(self) -> 'QGeometryFactory': ... - def primitiveType(self) -> 'QGeometryRenderer.PrimitiveType': ... - def geometry(self) -> 'QGeometry': ... - def primitiveRestartEnabled(self) -> bool: ... - def verticesPerPatch(self) -> int: ... - def restartIndexValue(self) -> int: ... - def firstVertex(self) -> int: ... - def firstInstance(self) -> int: ... - def indexOffset(self) -> int: ... - def vertexCount(self) -> int: ... - def instanceCount(self) -> int: ... - - class QGraphicsApiFilter(QtCore.QObject): - - class OpenGLProfile(int): - NoProfile = ... # type: QGraphicsApiFilter.OpenGLProfile - CoreProfile = ... # type: QGraphicsApiFilter.OpenGLProfile - CompatibilityProfile = ... # type: QGraphicsApiFilter.OpenGLProfile - - class Api(int): - OpenGLES = ... # type: QGraphicsApiFilter.Api - OpenGL = ... # type: QGraphicsApiFilter.Api - Vulkan = ... # type: QGraphicsApiFilter.Api - DirectX = ... # type: QGraphicsApiFilter.Api - RHI = ... # type: QGraphicsApiFilter.Api - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def graphicsApiFilterChanged(self) -> None: ... - def vendorChanged(self, vendor: str) -> None: ... - def extensionsChanged(self, extensions: typing.Iterable[str]) -> None: ... - def majorVersionChanged(self, majorVersion: int) -> None: ... - def minorVersionChanged(self, minorVersion: int) -> None: ... - def profileChanged(self, profile: 'QGraphicsApiFilter.OpenGLProfile') -> None: ... - def apiChanged(self, api: 'QGraphicsApiFilter.Api') -> None: ... - def setVendor(self, vendor: str) -> None: ... - def setExtensions(self, extensions: typing.Iterable[str]) -> None: ... - def setMajorVersion(self, majorVersion: int) -> None: ... - def setMinorVersion(self, minorVersion: int) -> None: ... - def setProfile(self, profile: 'QGraphicsApiFilter.OpenGLProfile') -> None: ... - def setApi(self, api: 'QGraphicsApiFilter.Api') -> None: ... - def vendor(self) -> str: ... - def extensions(self) -> typing.List[str]: ... - def majorVersion(self) -> int: ... - def minorVersion(self) -> int: ... - def profile(self) -> 'QGraphicsApiFilter.OpenGLProfile': ... - def api(self) -> 'QGraphicsApiFilter.Api': ... - - class QLayer(Qt3DCore.QComponent): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def recursiveChanged(self) -> None: ... - def setRecursive(self, recursive: bool) -> None: ... - def recursive(self) -> bool: ... - - class QLayerFilter('QFrameGraphNode'): - - class FilterMode(int): - AcceptAnyMatchingLayers = ... # type: QLayerFilter.FilterMode - AcceptAllMatchingLayers = ... # type: QLayerFilter.FilterMode - DiscardAnyMatchingLayers = ... # type: QLayerFilter.FilterMode - DiscardAllMatchingLayers = ... # type: QLayerFilter.FilterMode - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def filterModeChanged(self, filterMode: 'QLayerFilter.FilterMode') -> None: ... - def setFilterMode(self, filterMode: 'QLayerFilter.FilterMode') -> None: ... - def filterMode(self) -> 'QLayerFilter.FilterMode': ... - def layers(self) -> typing.List['QLayer']: ... - def removeLayer(self, layer: 'QLayer') -> None: ... - def addLayer(self, layer: 'QLayer') -> None: ... - - class QLevelOfDetail(Qt3DCore.QComponent): - - class ThresholdType(int): - DistanceToCameraThreshold = ... # type: QLevelOfDetail.ThresholdType - ProjectedScreenPixelSizeThreshold = ... # type: QLevelOfDetail.ThresholdType - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def volumeOverrideChanged(self, volumeOverride: 'QLevelOfDetailBoundingSphere') -> None: ... - def thresholdsChanged(self, thresholds: typing.Iterable[float]) -> None: ... - def thresholdTypeChanged(self, thresholdType: 'QLevelOfDetail.ThresholdType') -> None: ... - def currentIndexChanged(self, currentIndex: int) -> None: ... - def cameraChanged(self, camera: 'QCamera') -> None: ... - def setVolumeOverride(self, volumeOverride: 'QLevelOfDetailBoundingSphere') -> None: ... - def setThresholds(self, thresholds: typing.Iterable[float]) -> None: ... - def setThresholdType(self, thresholdType: 'QLevelOfDetail.ThresholdType') -> None: ... - def setCurrentIndex(self, currentIndex: int) -> None: ... - def setCamera(self, camera: 'QCamera') -> None: ... - def createBoundingSphere(self, center: QtGui.QVector3D, radius: float) -> 'QLevelOfDetailBoundingSphere': ... - def volumeOverride(self) -> 'QLevelOfDetailBoundingSphere': ... - def thresholds(self) -> typing.List[float]: ... - def thresholdType(self) -> 'QLevelOfDetail.ThresholdType': ... - def currentIndex(self) -> int: ... - def camera(self) -> 'QCamera': ... - - class QLevelOfDetailBoundingSphere(sip.simplewrapper): - @typing.overload - def __init__(self, center: QtGui.QVector3D = ..., radius: float = ...) -> None: ... - @typing.overload - def __init__(self, other: 'QLevelOfDetailBoundingSphere') -> None: ... +class QDepthRange('QRenderState'): - def isEmpty(self) -> bool: ... - def radius(self) -> float: ... - def center(self) -> QtGui.QVector3D: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QLevelOfDetailSwitch('QLevelOfDetail'): + def farValueChanged(self, farValue: float) -> None: ... + def nearValueChanged(self, nearValue: float) -> None: ... + def setFarValue(self, value: float) -> None: ... + def setNearValue(self, value: float) -> None: ... + def farValue(self) -> float: ... + def nearValue(self) -> float: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... +class QDepthTest('QRenderState'): - class QLineWidth('QRenderState'): + class DepthFunction(int): + Never = ... # type: QDepthTest.DepthFunction + Always = ... # type: QDepthTest.DepthFunction + Less = ... # type: QDepthTest.DepthFunction + LessOrEqual = ... # type: QDepthTest.DepthFunction + Equal = ... # type: QDepthTest.DepthFunction + GreaterOrEqual = ... # type: QDepthTest.DepthFunction + Greater = ... # type: QDepthTest.DepthFunction + NotEqual = ... # type: QDepthTest.DepthFunction - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def smoothChanged(self, enabled: bool) -> None: ... - def valueChanged(self, value: float) -> None: ... - def setSmooth(self, enabled: bool) -> None: ... - def setValue(self, value: float) -> None: ... - def smooth(self) -> bool: ... - def value(self) -> float: ... + def depthFunctionChanged(self, depthFunction: 'QDepthTest.DepthFunction') -> None: ... + def setDepthFunction(self, depthFunction: 'QDepthTest.DepthFunction') -> None: ... + def depthFunction(self) -> 'QDepthTest.DepthFunction': ... - class QMaterial(Qt3DCore.QComponent): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... +class QDirectionalLight('QAbstractLight'): - def effectChanged(self, effect: 'QEffect') -> None: ... - def setEffect(self, effect: 'QEffect') -> None: ... - def parameters(self) -> typing.List['QParameter']: ... - def removeParameter(self, parameter: 'QParameter') -> None: ... - def addParameter(self, parameter: 'QParameter') -> None: ... - def effect(self) -> 'QEffect': ... - - class QMemoryBarrier('QFrameGraphNode'): - - class Operation(int): - None_ = ... # type: QMemoryBarrier.Operation - VertexAttributeArray = ... # type: QMemoryBarrier.Operation - ElementArray = ... # type: QMemoryBarrier.Operation - Uniform = ... # type: QMemoryBarrier.Operation - TextureFetch = ... # type: QMemoryBarrier.Operation - ShaderImageAccess = ... # type: QMemoryBarrier.Operation - Command = ... # type: QMemoryBarrier.Operation - PixelBuffer = ... # type: QMemoryBarrier.Operation - TextureUpdate = ... # type: QMemoryBarrier.Operation - BufferUpdate = ... # type: QMemoryBarrier.Operation - FrameBuffer = ... # type: QMemoryBarrier.Operation - TransformFeedback = ... # type: QMemoryBarrier.Operation - AtomicCounter = ... # type: QMemoryBarrier.Operation - ShaderStorage = ... # type: QMemoryBarrier.Operation - QueryBuffer = ... # type: QMemoryBarrier.Operation - All = ... # type: QMemoryBarrier.Operation - - class Operations(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, f: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... - @typing.overload - def __init__(self, a0: 'QMemoryBarrier.Operations') -> None: ... - - def __hash__(self) -> int: ... - def __bool__(self) -> int: ... - def __invert__(self) -> 'QMemoryBarrier.Operations': ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def waitOperationsChanged(self, barrierTypes: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... - def setWaitOperations(self, operations: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... - def waitOperations(self) -> 'QMemoryBarrier.Operations': ... - - class QMesh('QGeometryRenderer'): - - class Status(int): - None_ = ... # type: QMesh.Status - Loading = ... # type: QMesh.Status - Ready = ... # type: QMesh.Status - Error = ... # type: QMesh.Status - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QMesh.Status') -> None: ... - def status(self) -> 'QMesh.Status': ... - def meshNameChanged(self, meshName: str) -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... - def setMeshName(self, meshName: str) -> None: ... - def setSource(self, source: QtCore.QUrl) -> None: ... - def meshName(self) -> str: ... - def source(self) -> QtCore.QUrl: ... - - class QMultiSampleAntiAliasing('QRenderState'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QNoDepthMask('QRenderState'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QNoDraw('QFrameGraphNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QNoPicking('QFrameGraphNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QObjectPicker(Qt3DCore.QComponent): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def priorityChanged(self, priority: int) -> None: ... - def setPriority(self, priority: int) -> None: ... - def priority(self) -> int: ... - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def containsMouseChanged(self, containsMouse: bool) -> None: ... - def pressedChanged(self, pressed: bool) -> None: ... - def dragEnabledChanged(self, dragEnabled: bool) -> None: ... - def hoverEnabledChanged(self, hoverEnabled: bool) -> None: ... - def exited(self) -> None: ... - def entered(self) -> None: ... - def moved(self, pick: 'QPickEvent') -> None: ... - def clicked(self, pick: 'QPickEvent') -> None: ... - def released(self, pick: 'QPickEvent') -> None: ... - def pressed(self, pick: 'QPickEvent') -> None: ... - def setDragEnabled(self, dragEnabled: bool) -> None: ... - def setHoverEnabled(self, hoverEnabled: bool) -> None: ... - def isPressed(self) -> bool: ... - def containsMouse(self) -> bool: ... - def isDragEnabled(self) -> bool: ... - def isHoverEnabled(self) -> bool: ... - - class QPaintedTextureImage('QAbstractTextureImage'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def paint(self, painter: QtGui.QPainter) -> None: ... - def sizeChanged(self, size: QtCore.QSize) -> None: ... - def heightChanged(self, w: int) -> None: ... - def widthChanged(self, w: int) -> None: ... - def setSize(self, size: QtCore.QSize) -> None: ... - def setHeight(self, h: int) -> None: ... - def setWidth(self, w: int) -> None: ... - def update(self, rect: QtCore.QRect = ...) -> None: ... - def size(self) -> QtCore.QSize: ... - def height(self) -> int: ... - def width(self) -> int: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QParameter(Qt3DCore.QNode): + def worldDirectionChanged(self, worldDirection: QtGui.QVector3D) -> None: ... + def setWorldDirection(self, worldDirection: QtGui.QVector3D) -> None: ... + def worldDirection(self) -> QtGui.QVector3D: ... - @typing.overload - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - @typing.overload - def __init__(self, name: str, value: typing.Any, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - @typing.overload - def __init__(self, name: str, texture: 'QAbstractTexture', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def nameChanged(self, name: str) -> None: ... - def valueChanged(self, value: typing.Any) -> None: ... - def setValue(self, dv: typing.Any) -> None: ... - def setName(self, name: str) -> None: ... - def value(self) -> typing.Any: ... - def name(self) -> str: ... - - class QPickEvent(QtCore.QObject): - - class Modifiers(int): - NoModifier = ... # type: QPickEvent.Modifiers - ShiftModifier = ... # type: QPickEvent.Modifiers - ControlModifier = ... # type: QPickEvent.Modifiers - AltModifier = ... # type: QPickEvent.Modifiers - MetaModifier = ... # type: QPickEvent.Modifiers - KeypadModifier = ... # type: QPickEvent.Modifiers - - class Buttons(int): - LeftButton = ... # type: QPickEvent.Buttons - RightButton = ... # type: QPickEvent.Buttons - MiddleButton = ... # type: QPickEvent.Buttons - BackButton = ... # type: QPickEvent.Buttons - NoButton = ... # type: QPickEvent.Buttons - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float) -> None: ... - @typing.overload - def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float, button: 'QPickEvent.Buttons', buttons: int, modifiers: int) -> None: ... - - def entity(self) -> Qt3DCore.QEntity: ... - def viewport(self) -> 'QViewport': ... - def modifiers(self) -> int: ... - def buttons(self) -> int: ... - def button(self) -> 'QPickEvent.Buttons': ... - def acceptedChanged(self, accepted: bool) -> None: ... - def setAccepted(self, accepted: bool) -> None: ... - def localIntersection(self) -> QtGui.QVector3D: ... - def worldIntersection(self) -> QtGui.QVector3D: ... - def distance(self) -> float: ... - def position(self) -> QtCore.QPointF: ... - def isAccepted(self) -> bool: ... - - class QPickingSettings(Qt3DCore.QNode): - - class FaceOrientationPickingMode(int): - FrontFace = ... # type: QPickingSettings.FaceOrientationPickingMode - BackFace = ... # type: QPickingSettings.FaceOrientationPickingMode - FrontAndBackFace = ... # type: QPickingSettings.FaceOrientationPickingMode - - class PickResultMode(int): - NearestPick = ... # type: QPickingSettings.PickResultMode - AllPicks = ... # type: QPickingSettings.PickResultMode - NearestPriorityPick = ... # type: QPickingSettings.PickResultMode - - class PickMethod(int): - BoundingVolumePicking = ... # type: QPickingSettings.PickMethod - TrianglePicking = ... # type: QPickingSettings.PickMethod - LinePicking = ... # type: QPickingSettings.PickMethod - PointPicking = ... # type: QPickingSettings.PickMethod - PrimitivePicking = ... # type: QPickingSettings.PickMethod - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def worldSpaceToleranceChanged(self, worldSpaceTolerance: float) -> None: ... - def setWorldSpaceTolerance(self, worldSpaceTolerance: float) -> None: ... - def worldSpaceTolerance(self) -> float: ... - def faceOrientationPickingModeChanged(self, faceOrientationPickingMode: 'QPickingSettings.FaceOrientationPickingMode') -> None: ... - def setFaceOrientationPickingMode(self, faceOrientationPickingMode: 'QPickingSettings.FaceOrientationPickingMode') -> None: ... - def faceOrientationPickingMode(self) -> 'QPickingSettings.FaceOrientationPickingMode': ... - def pickResultModeChanged(self, pickResult: 'QPickingSettings.PickResultMode') -> None: ... - def pickMethodChanged(self, pickMethod: 'QPickingSettings.PickMethod') -> None: ... - def setPickResultMode(self, pickResultMode: 'QPickingSettings.PickResultMode') -> None: ... - def setPickMethod(self, pickMethod: 'QPickingSettings.PickMethod') -> None: ... - def pickResultMode(self) -> 'QPickingSettings.PickResultMode': ... - def pickMethod(self) -> 'QPickingSettings.PickMethod': ... - - class QPickLineEvent('QPickEvent'): +class QDispatchCompute('QFrameGraphNode'): - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float, edgeIndex: int, vertex1Index: int, vertex2Index: int, button: 'QPickEvent.Buttons', buttons: int, modifiers: int) -> None: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def vertex2Index(self) -> int: ... - def vertex1Index(self) -> int: ... - def edgeIndex(self) -> int: ... + def workGroupZChanged(self) -> None: ... + def workGroupYChanged(self) -> None: ... + def workGroupXChanged(self) -> None: ... + def setWorkGroupZ(self, workGroupZ: int) -> None: ... + def setWorkGroupY(self, workGroupY: int) -> None: ... + def setWorkGroupX(self, workGroupX: int) -> None: ... + def workGroupZ(self) -> int: ... + def workGroupY(self) -> int: ... + def workGroupX(self) -> int: ... - class QPickPointEvent('QPickEvent'): - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float, pointIndex: int, button: 'QPickEvent.Buttons', buttons: int, modifiers: int) -> None: ... +class QDithering('QRenderState'): - def pointIndex(self) -> int: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QPickTriangleEvent('QPickEvent'): - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float, triangleIndex: int, vertex1Index: int, vertex2Index: int, vertex3Index: int) -> None: ... - @typing.overload - def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float, triangleIndex: int, vertex1Index: int, vertex2Index: int, vertex3Index: int, button: 'QPickEvent.Buttons', buttons: int, modifiers: int, uvw: QtGui.QVector3D) -> None: ... +class QEffect(Qt3DCore.QNode): - def uvw(self) -> QtGui.QVector3D: ... - def vertex3Index(self) -> int: ... - def vertex2Index(self) -> int: ... - def vertex1Index(self) -> int: ... - def triangleIndex(self) -> int: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QPointLight('QAbstractLight'): + def techniques(self) -> typing.List['QTechnique']: ... + def removeTechnique(self, t: 'QTechnique') -> None: ... + def addTechnique(self, t: 'QTechnique') -> None: ... + def parameters(self) -> typing.List['QParameter']: ... + def removeParameter(self, parameter: 'QParameter') -> None: ... + def addParameter(self, parameter: 'QParameter') -> None: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def quadraticAttenuationChanged(self, quadraticAttenuation: float) -> None: ... - def linearAttenuationChanged(self, linearAttenuation: float) -> None: ... - def constantAttenuationChanged(self, constantAttenuation: float) -> None: ... - def setQuadraticAttenuation(self, value: float) -> None: ... - def setLinearAttenuation(self, value: float) -> None: ... - def setConstantAttenuation(self, value: float) -> None: ... - def quadraticAttenuation(self) -> float: ... - def linearAttenuation(self) -> float: ... - def constantAttenuation(self) -> float: ... +class QEnvironmentLight(Qt3DCore.QComponent): - class QPointSize('QRenderState'): + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class SizeMode(int): - Fixed = ... # type: QPointSize.SizeMode - Programmable = ... # type: QPointSize.SizeMode + def specularChanged(self, environmentSpecular: 'QAbstractTexture') -> None: ... + def irradianceChanged(self, environmentIrradiance: 'QAbstractTexture') -> None: ... + def setSpecular(self, specular: 'QAbstractTexture') -> None: ... + def setIrradiance(self, irradiance: 'QAbstractTexture') -> None: ... + def specular(self) -> 'QAbstractTexture': ... + def irradiance(self) -> 'QAbstractTexture': ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def valueChanged(self, value: float) -> None: ... - def sizeModeChanged(self, sizeMode: 'QPointSize.SizeMode') -> None: ... - def setValue(self, value: float) -> None: ... - def setSizeMode(self, sizeMode: 'QPointSize.SizeMode') -> None: ... - def value(self) -> float: ... - def sizeMode(self) -> 'QPointSize.SizeMode': ... +class QFilterKey(Qt3DCore.QNode): - class QPolygonOffset('QRenderState'): + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def valueChanged(self, value: typing.Any) -> None: ... + def nameChanged(self, name: str) -> None: ... + def setName(self, customType: str) -> None: ... + def setValue(self, value: typing.Any) -> None: ... + def name(self) -> str: ... + def value(self) -> typing.Any: ... - def depthStepsChanged(self, depthSteps: float) -> None: ... - def scaleFactorChanged(self, scaleFactor: float) -> None: ... - def setDepthSteps(self, depthSteps: float) -> None: ... - def setScaleFactor(self, scaleFactor: float) -> None: ... - def depthSteps(self) -> float: ... - def scaleFactor(self) -> float: ... - class QProximityFilter('QFrameGraphNode'): +class QFrontFace('QRenderState'): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + class WindingDirection(int): + ClockWise = ... # type: QFrontFace.WindingDirection + CounterClockWise = ... # type: QFrontFace.WindingDirection - def distanceThresholdChanged(self, distanceThreshold: float) -> None: ... - def entityChanged(self, entity: Qt3DCore.QEntity) -> None: ... - def setDistanceThreshold(self, distanceThreshold: float) -> None: ... - def setEntity(self, entity: Qt3DCore.QEntity) -> None: ... - def distanceThreshold(self) -> float: ... - def entity(self) -> Qt3DCore.QEntity: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QRasterMode('QRenderState'): + def directionChanged(self, direction: 'QFrontFace.WindingDirection') -> None: ... + def setDirection(self, direction: 'QFrontFace.WindingDirection') -> None: ... + def direction(self) -> 'QFrontFace.WindingDirection': ... - class FaceMode(int): - Front = ... # type: QRasterMode.FaceMode - Back = ... # type: QRasterMode.FaceMode - FrontAndBack = ... # type: QRasterMode.FaceMode - class RasterMode(int): - Points = ... # type: QRasterMode.RasterMode - Lines = ... # type: QRasterMode.RasterMode - Fill = ... # type: QRasterMode.RasterMode +class QFrustumCulling('QFrameGraphNode'): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def faceModeChanged(self, faceMode: 'QRasterMode.FaceMode') -> None: ... - def rasterModeChanged(self, rasterMode: 'QRasterMode.RasterMode') -> None: ... - def setFaceMode(self, faceMode: 'QRasterMode.FaceMode') -> None: ... - def setRasterMode(self, rasterMode: 'QRasterMode.RasterMode') -> None: ... - def faceMode(self) -> 'QRasterMode.FaceMode': ... - def rasterMode(self) -> 'QRasterMode.RasterMode': ... - class QRayCaster('QAbstractRayCaster'): +class QGeometry(Qt3DCore.QNode): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def lengthChanged(self, length: float) -> None: ... - def directionChanged(self, direction: QtGui.QVector3D) -> None: ... - def originChanged(self, origin: QtGui.QVector3D) -> None: ... - @typing.overload - def trigger(self) -> None: ... - @typing.overload - def trigger(self, origin: QtGui.QVector3D, direction: QtGui.QVector3D, length: float) -> None: ... - def setLength(self, length: float) -> None: ... - def setDirection(self, direction: QtGui.QVector3D) -> None: ... - def setOrigin(self, origin: QtGui.QVector3D) -> None: ... - def length(self) -> float: ... - def direction(self) -> QtGui.QVector3D: ... - def origin(self) -> QtGui.QVector3D: ... - - class QRayCasterHit(sip.simplewrapper): - - class HitType(int): - TriangleHit = ... # type: QRayCasterHit.HitType - LineHit = ... # type: QRayCasterHit.HitType - PointHit = ... # type: QRayCasterHit.HitType - EntityHit = ... # type: QRayCasterHit.HitType + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def maxExtentChanged(self, maxExtent: QtGui.QVector3D) -> None: ... + def minExtentChanged(self, minExtent: QtGui.QVector3D) -> None: ... + def maxExtent(self) -> QtGui.QVector3D: ... + def minExtent(self) -> QtGui.QVector3D: ... + def boundingVolumePositionAttributeChanged(self, boundingVolumePositionAttribute: 'QAttribute') -> None: ... + def setBoundingVolumePositionAttribute(self, boundingVolumePositionAttribute: 'QAttribute') -> None: ... + def boundingVolumePositionAttribute(self) -> 'QAttribute': ... + def removeAttribute(self, attribute: 'QAttribute') -> None: ... + def addAttribute(self, attribute: 'QAttribute') -> None: ... + def attributes(self) -> typing.List['QAttribute']: ... + + +class QGeometryFactory('QAbstractFunctor'): + + def __call__(self) -> 'QGeometry': ... + + +class QGeometryRenderer(Qt3DCore.QComponent): + + class PrimitiveType(int): + Points = ... # type: QGeometryRenderer.PrimitiveType + Lines = ... # type: QGeometryRenderer.PrimitiveType + LineLoop = ... # type: QGeometryRenderer.PrimitiveType + LineStrip = ... # type: QGeometryRenderer.PrimitiveType + Triangles = ... # type: QGeometryRenderer.PrimitiveType + TriangleStrip = ... # type: QGeometryRenderer.PrimitiveType + TriangleFan = ... # type: QGeometryRenderer.PrimitiveType + LinesAdjacency = ... # type: QGeometryRenderer.PrimitiveType + TrianglesAdjacency = ... # type: QGeometryRenderer.PrimitiveType + LineStripAdjacency = ... # type: QGeometryRenderer.PrimitiveType + TriangleStripAdjacency = ... # type: QGeometryRenderer.PrimitiveType + Patches = ... # type: QGeometryRenderer.PrimitiveType + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def indexBufferByteOffsetChanged(self, offset: int) -> None: ... + def setIndexBufferByteOffset(self, offset: int) -> None: ... + def indexBufferByteOffset(self) -> int: ... + def primitiveTypeChanged(self, primitiveType: 'QGeometryRenderer.PrimitiveType') -> None: ... + def geometryChanged(self, geometry: 'QGeometry') -> None: ... + def primitiveRestartEnabledChanged(self, primitiveRestartEnabled: bool) -> None: ... + def verticesPerPatchChanged(self, verticesPerPatch: int) -> None: ... + def restartIndexValueChanged(self, restartIndexValue: int) -> None: ... + def firstVertexChanged(self, firstVertex: int) -> None: ... + def firstInstanceChanged(self, firstInstance: int) -> None: ... + def indexOffsetChanged(self, indexOffset: int) -> None: ... + def vertexCountChanged(self, vertexCount: int) -> None: ... + def instanceCountChanged(self, instanceCount: int) -> None: ... + def setPrimitiveType(self, primitiveType: 'QGeometryRenderer.PrimitiveType') -> None: ... + def setGeometry(self, geometry: 'QGeometry') -> None: ... + def setPrimitiveRestartEnabled(self, enabled: bool) -> None: ... + def setVerticesPerPatch(self, verticesPerPatch: int) -> None: ... + def setRestartIndexValue(self, index: int) -> None: ... + def setFirstVertex(self, firstVertex: int) -> None: ... + def setFirstInstance(self, firstInstance: int) -> None: ... + def setIndexOffset(self, indexOffset: int) -> None: ... + def setVertexCount(self, vertexCount: int) -> None: ... + def setInstanceCount(self, instanceCount: int) -> None: ... + def setGeometryFactory(self, factory: 'QGeometryFactory') -> None: ... + def geometryFactory(self) -> 'QGeometryFactory': ... + def primitiveType(self) -> 'QGeometryRenderer.PrimitiveType': ... + def geometry(self) -> 'QGeometry': ... + def primitiveRestartEnabled(self) -> bool: ... + def verticesPerPatch(self) -> int: ... + def restartIndexValue(self) -> int: ... + def firstVertex(self) -> int: ... + def firstInstance(self) -> int: ... + def indexOffset(self) -> int: ... + def vertexCount(self) -> int: ... + def instanceCount(self) -> int: ... + + +class QGraphicsApiFilter(QtCore.QObject): + + class OpenGLProfile(int): + NoProfile = ... # type: QGraphicsApiFilter.OpenGLProfile + CoreProfile = ... # type: QGraphicsApiFilter.OpenGLProfile + CompatibilityProfile = ... # type: QGraphicsApiFilter.OpenGLProfile + + class Api(int): + OpenGLES = ... # type: QGraphicsApiFilter.Api + OpenGL = ... # type: QGraphicsApiFilter.Api + Vulkan = ... # type: QGraphicsApiFilter.Api + DirectX = ... # type: QGraphicsApiFilter.Api + RHI = ... # type: QGraphicsApiFilter.Api + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def graphicsApiFilterChanged(self) -> None: ... + def vendorChanged(self, vendor: str) -> None: ... + def extensionsChanged(self, extensions: typing.Iterable[str]) -> None: ... + def majorVersionChanged(self, majorVersion: int) -> None: ... + def minorVersionChanged(self, minorVersion: int) -> None: ... + def profileChanged(self, profile: 'QGraphicsApiFilter.OpenGLProfile') -> None: ... + def apiChanged(self, api: 'QGraphicsApiFilter.Api') -> None: ... + def setVendor(self, vendor: str) -> None: ... + def setExtensions(self, extensions: typing.Iterable[str]) -> None: ... + def setMajorVersion(self, majorVersion: int) -> None: ... + def setMinorVersion(self, minorVersion: int) -> None: ... + def setProfile(self, profile: 'QGraphicsApiFilter.OpenGLProfile') -> None: ... + def setApi(self, api: 'QGraphicsApiFilter.Api') -> None: ... + def vendor(self) -> str: ... + def extensions(self) -> typing.List[str]: ... + def majorVersion(self) -> int: ... + def minorVersion(self) -> int: ... + def profile(self) -> 'QGraphicsApiFilter.OpenGLProfile': ... + def api(self) -> 'QGraphicsApiFilter.Api': ... + + +class QLayer(Qt3DCore.QComponent): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def recursiveChanged(self) -> None: ... + def setRecursive(self, recursive: bool) -> None: ... + def recursive(self) -> bool: ... + + +class QLayerFilter('QFrameGraphNode'): + + class FilterMode(int): + AcceptAnyMatchingLayers = ... # type: QLayerFilter.FilterMode + AcceptAllMatchingLayers = ... # type: QLayerFilter.FilterMode + DiscardAnyMatchingLayers = ... # type: QLayerFilter.FilterMode + DiscardAllMatchingLayers = ... # type: QLayerFilter.FilterMode + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def filterModeChanged(self, filterMode: 'QLayerFilter.FilterMode') -> None: ... + def setFilterMode(self, filterMode: 'QLayerFilter.FilterMode') -> None: ... + def filterMode(self) -> 'QLayerFilter.FilterMode': ... + def layers(self) -> typing.List['QLayer']: ... + def removeLayer(self, layer: 'QLayer') -> None: ... + def addLayer(self, layer: 'QLayer') -> None: ... + + +class QLevelOfDetail(Qt3DCore.QComponent): + + class ThresholdType(int): + DistanceToCameraThreshold = ... # type: QLevelOfDetail.ThresholdType + ProjectedScreenPixelSizeThreshold = ... # type: QLevelOfDetail.ThresholdType + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def volumeOverrideChanged(self, volumeOverride: 'QLevelOfDetailBoundingSphere') -> None: ... + def thresholdsChanged(self, thresholds: typing.Iterable[float]) -> None: ... + def thresholdTypeChanged(self, thresholdType: 'QLevelOfDetail.ThresholdType') -> None: ... + def currentIndexChanged(self, currentIndex: int) -> None: ... + def cameraChanged(self, camera: 'QCamera') -> None: ... + def setVolumeOverride(self, volumeOverride: 'QLevelOfDetailBoundingSphere') -> None: ... + def setThresholds(self, thresholds: typing.Iterable[float]) -> None: ... + def setThresholdType(self, thresholdType: 'QLevelOfDetail.ThresholdType') -> None: ... + def setCurrentIndex(self, currentIndex: int) -> None: ... + def setCamera(self, camera: 'QCamera') -> None: ... + def createBoundingSphere(self, center: QtGui.QVector3D, radius: float) -> 'QLevelOfDetailBoundingSphere': ... + def volumeOverride(self) -> 'QLevelOfDetailBoundingSphere': ... + def thresholds(self) -> typing.List[float]: ... + def thresholdType(self) -> 'QLevelOfDetail.ThresholdType': ... + def currentIndex(self) -> int: ... + def camera(self) -> 'QCamera': ... + + +class QLevelOfDetailBoundingSphere(sip.simplewrapper): + + @typing.overload + def __init__(self, center: QtGui.QVector3D = ..., radius: float = ...) -> None: ... + @typing.overload + def __init__(self, other: 'QLevelOfDetailBoundingSphere') -> None: ... + + def isEmpty(self) -> bool: ... + def radius(self) -> float: ... + def center(self) -> QtGui.QVector3D: ... + + +class QLevelOfDetailSwitch('QLevelOfDetail'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + + +class QLineWidth('QRenderState'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def smoothChanged(self, enabled: bool) -> None: ... + def valueChanged(self, value: float) -> None: ... + def setSmooth(self, enabled: bool) -> None: ... + def setValue(self, value: float) -> None: ... + def smooth(self) -> bool: ... + def value(self) -> float: ... + + +class QMaterial(Qt3DCore.QComponent): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def effectChanged(self, effect: 'QEffect') -> None: ... + def setEffect(self, effect: 'QEffect') -> None: ... + def parameters(self) -> typing.List['QParameter']: ... + def removeParameter(self, parameter: 'QParameter') -> None: ... + def addParameter(self, parameter: 'QParameter') -> None: ... + def effect(self) -> 'QEffect': ... + + +class QMemoryBarrier('QFrameGraphNode'): + + class Operation(int): + None_ = ... # type: QMemoryBarrier.Operation + VertexAttributeArray = ... # type: QMemoryBarrier.Operation + ElementArray = ... # type: QMemoryBarrier.Operation + Uniform = ... # type: QMemoryBarrier.Operation + TextureFetch = ... # type: QMemoryBarrier.Operation + ShaderImageAccess = ... # type: QMemoryBarrier.Operation + Command = ... # type: QMemoryBarrier.Operation + PixelBuffer = ... # type: QMemoryBarrier.Operation + TextureUpdate = ... # type: QMemoryBarrier.Operation + BufferUpdate = ... # type: QMemoryBarrier.Operation + FrameBuffer = ... # type: QMemoryBarrier.Operation + TransformFeedback = ... # type: QMemoryBarrier.Operation + AtomicCounter = ... # type: QMemoryBarrier.Operation + ShaderStorage = ... # type: QMemoryBarrier.Operation + QueryBuffer = ... # type: QMemoryBarrier.Operation + All = ... # type: QMemoryBarrier.Operation + + class Operations(sip.simplewrapper): @typing.overload def __init__(self) -> None: ... @typing.overload - def __init__(self, type: 'QRayCasterHit.HitType', id: Qt3DCore.QNodeId, distance: float, localIntersect: QtGui.QVector3D, worldIntersect: QtGui.QVector3D, primitiveIndex: int, v1: int, v2: int, v3: int) -> None: ... + def __init__(self, f: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... @typing.overload - def __init__(self, other: 'QRayCasterHit') -> None: ... + def __init__(self, a0: 'QMemoryBarrier.Operations') -> None: ... - def vertex3Index(self) -> int: ... - def vertex2Index(self) -> int: ... - def vertex1Index(self) -> int: ... - def primitiveIndex(self) -> int: ... - def worldIntersection(self) -> QtGui.QVector3D: ... - def localIntersection(self) -> QtGui.QVector3D: ... - def distance(self) -> float: ... - def entity(self) -> Qt3DCore.QEntity: ... - def entityId(self) -> Qt3DCore.QNodeId: ... - def type(self) -> 'QRayCasterHit.HitType': ... + def __hash__(self) -> int: ... + def __bool__(self) -> int: ... + def __invert__(self) -> 'QMemoryBarrier.Operations': ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... - class Render(PyQt5.sip.simplewrapper): ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QRenderAspect(Qt3DCore.QAbstractAspect): + def waitOperationsChanged(self, barrierTypes: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... + def setWaitOperations(self, operations: typing.Union['QMemoryBarrier.Operations', 'QMemoryBarrier.Operation']) -> None: ... + def waitOperations(self) -> 'QMemoryBarrier.Operations': ... - class RenderType(int): - Synchronous = ... # type: QRenderAspect.RenderType - Threaded = ... # type: QRenderAspect.RenderType - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, type: 'QRenderAspect.RenderType', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - class QRenderCapabilities(QtCore.QObject): - - class Profile(int): - NoProfile = ... # type: QRenderCapabilities.Profile - CoreProfile = ... # type: QRenderCapabilities.Profile - CompatibilityProfile = ... # type: QRenderCapabilities.Profile - - class API(int): - OpenGL = ... # type: QRenderCapabilities.API - OpenGLES = ... # type: QRenderCapabilities.API - Vulkan = ... # type: QRenderCapabilities.API - DirectX = ... # type: QRenderCapabilities.API - RHI = ... # type: QRenderCapabilities.API - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def maxComputeSharedMemorySize(self) -> int: ... - def maxComputeInvocations(self) -> int: ... - def maxWorkGroupSizeZ(self) -> int: ... - def maxWorkGroupSizeY(self) -> int: ... - def maxWorkGroupSizeX(self) -> int: ... - def maxWorkGroupCountZ(self) -> int: ... - def maxWorkGroupCountY(self) -> int: ... - def maxWorkGroupCountX(self) -> int: ... - def supportsCompute(self) -> bool: ... - def maxImageUnits(self) -> int: ... - def supportsImageStore(self) -> bool: ... - def maxSSBOBindings(self) -> int: ... - def maxSSBOSize(self) -> int: ... - def supportsSSBO(self) -> bool: ... - def maxUBOBindings(self) -> int: ... - def maxUBOSize(self) -> int: ... - def supportsUBO(self) -> bool: ... - def maxTextureLayers(self) -> int: ... - def maxTextureUnits(self) -> int: ... - def maxTextureSize(self) -> int: ... - def maxSamples(self) -> int: ... - def glslVersion(self) -> str: ... - def driverVersion(self) -> str: ... - def renderer(self) -> str: ... - def vendor(self) -> str: ... - def extensions(self) -> typing.List[str]: ... - def minorVersion(self) -> int: ... - def majorVersion(self) -> int: ... - def profile(self) -> 'QRenderCapabilities.Profile': ... - def api(self) -> 'QRenderCapabilities.API': ... - def isValid(self) -> bool: ... - - class QRenderCaptureReply(QtCore.QObject): - - def completed(self) -> None: ... - def saveImage(self, fileName: str) -> bool: ... - def completeChanged(self, isComplete: bool) -> None: ... - def saveToFile(self, fileName: str) -> None: ... - def isComplete(self) -> bool: ... - def captureId(self) -> int: ... - def image(self) -> QtGui.QImage: ... - - class QRenderCapture('QFrameGraphNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - @typing.overload - def requestCapture(self, captureId: int) -> 'QRenderCaptureReply': ... - @typing.overload - def requestCapture(self) -> 'QRenderCaptureReply': ... - @typing.overload - def requestCapture(self, rect: QtCore.QRect) -> 'QRenderCaptureReply': ... - - class QRenderPass(Qt3DCore.QNode): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def shaderProgramChanged(self, shaderProgram: 'QShaderProgram') -> None: ... - def setShaderProgram(self, shaderProgram: 'QShaderProgram') -> None: ... - def parameters(self) -> typing.List['QParameter']: ... - def removeParameter(self, p: 'QParameter') -> None: ... - def addParameter(self, p: 'QParameter') -> None: ... - def renderStates(self) -> typing.List['QRenderState']: ... - def removeRenderState(self, state: 'QRenderState') -> None: ... - def addRenderState(self, state: 'QRenderState') -> None: ... - def filterKeys(self) -> typing.List['QFilterKey']: ... - def removeFilterKey(self, filterKey: 'QFilterKey') -> None: ... - def addFilterKey(self, filterKey: 'QFilterKey') -> None: ... - def shaderProgram(self) -> 'QShaderProgram': ... - - class QRenderPassFilter('QFrameGraphNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def parameters(self) -> typing.List['QParameter']: ... - def removeParameter(self, parameter: 'QParameter') -> None: ... - def addParameter(self, parameter: 'QParameter') -> None: ... - def removeMatch(self, filterKey: 'QFilterKey') -> None: ... - def addMatch(self, filterKey: 'QFilterKey') -> None: ... - def matchAny(self) -> typing.List['QFilterKey']: ... - - class QRenderSettings(Qt3DCore.QComponent): - - class RenderPolicy(int): - OnDemand = ... # type: QRenderSettings.RenderPolicy - Always = ... # type: QRenderSettings.RenderPolicy - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def renderPolicyChanged(self, renderPolicy: 'QRenderSettings.RenderPolicy') -> None: ... - def activeFrameGraphChanged(self, activeFrameGraph: 'QFrameGraphNode') -> None: ... - def setRenderPolicy(self, renderPolicy: 'QRenderSettings.RenderPolicy') -> None: ... - def setActiveFrameGraph(self, activeFrameGraph: 'QFrameGraphNode') -> None: ... - def renderCapabilities(self) -> 'QRenderCapabilities': ... - def renderPolicy(self) -> 'QRenderSettings.RenderPolicy': ... - def activeFrameGraph(self) -> 'QFrameGraphNode': ... - def pickingSettings(self) -> 'QPickingSettings': ... - - class QRenderStateSet('QFrameGraphNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def renderStates(self) -> typing.List['QRenderState']: ... - def removeRenderState(self, state: 'QRenderState') -> None: ... - def addRenderState(self, state: 'QRenderState') -> None: ... - - class QRenderSurfaceSelector('QFrameGraphNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def surfacePixelRatioChanged(self, ratio: float) -> None: ... - def externalRenderTargetSizeChanged(self, size: QtCore.QSize) -> None: ... - def surfaceChanged(self, surface: QtCore.QObject) -> None: ... - def setSurfacePixelRatio(self, ratio: float) -> None: ... - def setSurface(self, surfaceObject: QtCore.QObject) -> None: ... - def setExternalRenderTargetSize(self, size: QtCore.QSize) -> None: ... - def surfacePixelRatio(self) -> float: ... - def externalRenderTargetSize(self) -> QtCore.QSize: ... - def surface(self) -> QtCore.QObject: ... - - class QRenderTarget(Qt3DCore.QComponent): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def outputs(self) -> typing.List['QRenderTargetOutput']: ... - def removeOutput(self, output: 'QRenderTargetOutput') -> None: ... - def addOutput(self, output: 'QRenderTargetOutput') -> None: ... - - class QRenderTargetOutput(Qt3DCore.QNode): - - class AttachmentPoint(int): - Color0 = ... # type: QRenderTargetOutput.AttachmentPoint - Color1 = ... # type: QRenderTargetOutput.AttachmentPoint - Color2 = ... # type: QRenderTargetOutput.AttachmentPoint - Color3 = ... # type: QRenderTargetOutput.AttachmentPoint - Color4 = ... # type: QRenderTargetOutput.AttachmentPoint - Color5 = ... # type: QRenderTargetOutput.AttachmentPoint - Color6 = ... # type: QRenderTargetOutput.AttachmentPoint - Color7 = ... # type: QRenderTargetOutput.AttachmentPoint - Color8 = ... # type: QRenderTargetOutput.AttachmentPoint - Color9 = ... # type: QRenderTargetOutput.AttachmentPoint - Color10 = ... # type: QRenderTargetOutput.AttachmentPoint - Color11 = ... # type: QRenderTargetOutput.AttachmentPoint - Color12 = ... # type: QRenderTargetOutput.AttachmentPoint - Color13 = ... # type: QRenderTargetOutput.AttachmentPoint - Color14 = ... # type: QRenderTargetOutput.AttachmentPoint - Color15 = ... # type: QRenderTargetOutput.AttachmentPoint - Depth = ... # type: QRenderTargetOutput.AttachmentPoint - Stencil = ... # type: QRenderTargetOutput.AttachmentPoint - DepthStencil = ... # type: QRenderTargetOutput.AttachmentPoint - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def faceChanged(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... - def layerChanged(self, layer: int) -> None: ... - def mipLevelChanged(self, mipLevel: int) -> None: ... - def textureChanged(self, texture: 'QAbstractTexture') -> None: ... - def attachmentPointChanged(self, attachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... - def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... - def setLayer(self, layer: int) -> None: ... - def setMipLevel(self, level: int) -> None: ... - def setTexture(self, texture: 'QAbstractTexture') -> None: ... - def setAttachmentPoint(self, attachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... - def face(self) -> 'QAbstractTexture.CubeMapFace': ... - def layer(self) -> int: ... - def mipLevel(self) -> int: ... - def texture(self) -> 'QAbstractTexture': ... - def attachmentPoint(self) -> 'QRenderTargetOutput.AttachmentPoint': ... - - class QRenderTargetSelector('QFrameGraphNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def targetChanged(self, target: 'QRenderTarget') -> None: ... - def setTarget(self, target: 'QRenderTarget') -> None: ... - def target(self) -> 'QRenderTarget': ... - def outputs(self) -> typing.List[QRenderTargetOutput.AttachmentPoint]: ... - - class QSceneLoader(Qt3DCore.QComponent): - - class ComponentType(int): - UnknownComponent = ... # type: QSceneLoader.ComponentType - GeometryRendererComponent = ... # type: QSceneLoader.ComponentType - TransformComponent = ... # type: QSceneLoader.ComponentType - MaterialComponent = ... # type: QSceneLoader.ComponentType - LightComponent = ... # type: QSceneLoader.ComponentType - CameraLensComponent = ... # type: QSceneLoader.ComponentType - - class Status(int): - None_ = ... # type: QSceneLoader.Status - Loading = ... # type: QSceneLoader.Status - Ready = ... # type: QSceneLoader.Status - Error = ... # type: QSceneLoader.Status - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def component(self, entityName: str, componentType: 'QSceneLoader.ComponentType') -> Qt3DCore.QComponent: ... - def entityNames(self) -> typing.List[str]: ... - def entity(self, entityName: str) -> Qt3DCore.QEntity: ... - def statusChanged(self, status: 'QSceneLoader.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... - def setSource(self, arg: QtCore.QUrl) -> None: ... - def status(self) -> 'QSceneLoader.Status': ... - def source(self) -> QtCore.QUrl: ... - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - - class QScissorTest('QRenderState'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def heightChanged(self, height: int) -> None: ... - def widthChanged(self, width: int) -> None: ... - def bottomChanged(self, bottom: int) -> None: ... - def leftChanged(self, left: int) -> None: ... - def setHeight(self, height: int) -> None: ... - def setWidth(self, width: int) -> None: ... - def setBottom(self, bottom: int) -> None: ... - def setLeft(self, left: int) -> None: ... - def height(self) -> int: ... - def width(self) -> int: ... - def bottom(self) -> int: ... - def left(self) -> int: ... - - class QScreenRayCaster('QAbstractRayCaster'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def positionChanged(self, position: QtCore.QPoint) -> None: ... - @typing.overload - def trigger(self) -> None: ... - @typing.overload - def trigger(self, position: QtCore.QPoint) -> None: ... - def setPosition(self, position: QtCore.QPoint) -> None: ... - def position(self) -> QtCore.QPoint: ... - - class QSeamlessCubemap('QRenderState'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - class QSetFence('QFrameGraphNode'): - - class HandleType(int): - NoHandle = ... # type: QSetFence.HandleType - OpenGLFenceId = ... # type: QSetFence.HandleType - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def handleChanged(self, handle: typing.Any) -> None: ... - def handleTypeChanged(self, handleType: 'QSetFence.HandleType') -> None: ... - def handle(self) -> typing.Any: ... - def handleType(self) -> 'QSetFence.HandleType': ... - - class PropertyReaderInterface(sip.simplewrapper): - - def readProperty(self, v: typing.Any) -> typing.Any: ... - - class QShaderData(Qt3DCore.QComponent): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def event(self, event: QtCore.QEvent) -> bool: ... - def propertyReader(self) -> 'PropertyReaderInterface': ... - - class QShaderImage(Qt3DCore.QNode): - - class ImageFormat(int): - NoFormat = ... # type: QShaderImage.ImageFormat - Automatic = ... # type: QShaderImage.ImageFormat - R8_UNorm = ... # type: QShaderImage.ImageFormat - RG8_UNorm = ... # type: QShaderImage.ImageFormat - RGBA8_UNorm = ... # type: QShaderImage.ImageFormat - R16_UNorm = ... # type: QShaderImage.ImageFormat - RG16_UNorm = ... # type: QShaderImage.ImageFormat - RGBA16_UNorm = ... # type: QShaderImage.ImageFormat - R8_SNorm = ... # type: QShaderImage.ImageFormat - RG8_SNorm = ... # type: QShaderImage.ImageFormat - RGBA8_SNorm = ... # type: QShaderImage.ImageFormat - R16_SNorm = ... # type: QShaderImage.ImageFormat - RG16_SNorm = ... # type: QShaderImage.ImageFormat - RGBA16_SNorm = ... # type: QShaderImage.ImageFormat - R8U = ... # type: QShaderImage.ImageFormat - RG8U = ... # type: QShaderImage.ImageFormat - RGBA8U = ... # type: QShaderImage.ImageFormat - R16U = ... # type: QShaderImage.ImageFormat - RG16U = ... # type: QShaderImage.ImageFormat - RGBA16U = ... # type: QShaderImage.ImageFormat - R32U = ... # type: QShaderImage.ImageFormat - RG32U = ... # type: QShaderImage.ImageFormat - RGBA32U = ... # type: QShaderImage.ImageFormat - R8I = ... # type: QShaderImage.ImageFormat - RG8I = ... # type: QShaderImage.ImageFormat - RGBA8I = ... # type: QShaderImage.ImageFormat - R16I = ... # type: QShaderImage.ImageFormat - RG16I = ... # type: QShaderImage.ImageFormat - RGBA16I = ... # type: QShaderImage.ImageFormat - R32I = ... # type: QShaderImage.ImageFormat - RG32I = ... # type: QShaderImage.ImageFormat - RGBA32I = ... # type: QShaderImage.ImageFormat - R16F = ... # type: QShaderImage.ImageFormat - RG16F = ... # type: QShaderImage.ImageFormat - RGBA16F = ... # type: QShaderImage.ImageFormat - R32F = ... # type: QShaderImage.ImageFormat - RG32F = ... # type: QShaderImage.ImageFormat - RGBA32F = ... # type: QShaderImage.ImageFormat - RG11B10F = ... # type: QShaderImage.ImageFormat - RGB10A2 = ... # type: QShaderImage.ImageFormat - RGB10A2U = ... # type: QShaderImage.ImageFormat - - class Access(int): - ReadOnly = ... # type: QShaderImage.Access - WriteOnly = ... # type: QShaderImage.Access - ReadWrite = ... # type: QShaderImage.Access - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def formatChanged(self, format: 'QShaderImage.ImageFormat') -> None: ... - def accessChanged(self, access: 'QShaderImage.Access') -> None: ... - def layerChanged(self, layer: int) -> None: ... - def mipLevelChanged(self, mipLevel: int) -> None: ... - def layeredChanged(self, layered: bool) -> None: ... - def textureChanged(self, texture: 'QAbstractTexture') -> None: ... - def setFormat(self, format: 'QShaderImage.ImageFormat') -> None: ... - def setAccess(self, access: 'QShaderImage.Access') -> None: ... - def setLayer(self, layer: int) -> None: ... - def setMipLevel(self, mipLevel: int) -> None: ... - def setLayered(self, layered: bool) -> None: ... - def setTexture(self, texture: 'QAbstractTexture') -> None: ... - def format(self) -> 'QShaderImage.ImageFormat': ... - def access(self) -> 'QShaderImage.Access': ... - def layer(self) -> int: ... - def mipLevel(self) -> int: ... - def layered(self) -> bool: ... - def texture(self) -> 'QAbstractTexture': ... - - class QShaderProgram(Qt3DCore.QNode): - - class Format(int): - GLSL = ... # type: QShaderProgram.Format - SPIRV = ... # type: QShaderProgram.Format - - class Status(int): - NotReady = ... # type: QShaderProgram.Status - Ready = ... # type: QShaderProgram.Status - Error = ... # type: QShaderProgram.Status - - class ShaderType(int): - Vertex = ... # type: QShaderProgram.ShaderType - Fragment = ... # type: QShaderProgram.ShaderType - TessellationControl = ... # type: QShaderProgram.ShaderType - TessellationEvaluation = ... # type: QShaderProgram.ShaderType - Geometry = ... # type: QShaderProgram.ShaderType - Compute = ... # type: QShaderProgram.ShaderType - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def formatChanged(self, format: 'QShaderProgram.Format') -> None: ... - def format(self) -> 'QShaderProgram.Format': ... - def setFormat(self, format: 'QShaderProgram.Format') -> None: ... - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QShaderProgram.Status') -> None: ... - def logChanged(self, log: str) -> None: ... - def status(self) -> 'QShaderProgram.Status': ... - def log(self) -> str: ... - def computeShaderCodeChanged(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def fragmentShaderCodeChanged(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def geometryShaderCodeChanged(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationEvaluationShaderCodeChanged(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationControlShaderCodeChanged(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def vertexShaderCodeChanged(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def setComputeShaderCode(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def setFragmentShaderCode(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def setGeometryShaderCode(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def setTessellationEvaluationShaderCode(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def setTessellationControlShaderCode(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def setVertexShaderCode(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - @staticmethod - def loadSource(sourceUrl: QtCore.QUrl) -> QtCore.QByteArray: ... - def shaderCode(self, type: 'QShaderProgram.ShaderType') -> QtCore.QByteArray: ... - def setShaderCode(self, type: 'QShaderProgram.ShaderType', shaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def computeShaderCode(self) -> QtCore.QByteArray: ... - def fragmentShaderCode(self) -> QtCore.QByteArray: ... - def geometryShaderCode(self) -> QtCore.QByteArray: ... - def tessellationEvaluationShaderCode(self) -> QtCore.QByteArray: ... - def tessellationControlShaderCode(self) -> QtCore.QByteArray: ... - def vertexShaderCode(self) -> QtCore.QByteArray: ... - - class QShaderProgramBuilder(Qt3DCore.QNode): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def computeShaderCodeChanged(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def fragmentShaderCodeChanged(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def geometryShaderCodeChanged(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationEvaluationShaderCodeChanged(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def tessellationControlShaderCodeChanged(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def vertexShaderCodeChanged(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... - def computeShaderCode(self) -> QtCore.QByteArray: ... - def fragmentShaderCode(self) -> QtCore.QByteArray: ... - def geometryShaderCode(self) -> QtCore.QByteArray: ... - def tessellationEvaluationShaderCode(self) -> QtCore.QByteArray: ... - def tessellationControlShaderCode(self) -> QtCore.QByteArray: ... - def vertexShaderCode(self) -> QtCore.QByteArray: ... - def computeShaderGraphChanged(self, computeShaderGraph: QtCore.QUrl) -> None: ... - def fragmentShaderGraphChanged(self, fragmentShaderGraph: QtCore.QUrl) -> None: ... - def geometryShaderGraphChanged(self, geometryShaderGraph: QtCore.QUrl) -> None: ... - def tessellationEvaluationShaderGraphChanged(self, tessellationEvaluationShaderGraph: QtCore.QUrl) -> None: ... - def tessellationControlShaderGraphChanged(self, tessellationControlShaderGraph: QtCore.QUrl) -> None: ... - def vertexShaderGraphChanged(self, vertexShaderGraph: QtCore.QUrl) -> None: ... - def enabledLayersChanged(self, layers: typing.Iterable[str]) -> None: ... - def shaderProgramChanged(self, shaderProgram: 'QShaderProgram') -> None: ... - def setComputeShaderGraph(self, computeShaderGraph: QtCore.QUrl) -> None: ... - def setFragmentShaderGraph(self, fragmentShaderGraph: QtCore.QUrl) -> None: ... - def setGeometryShaderGraph(self, geometryShaderGraph: QtCore.QUrl) -> None: ... - def setTessellationEvaluationShaderGraph(self, tessellationEvaluationShaderGraph: QtCore.QUrl) -> None: ... - def setTessellationControlShaderGraph(self, tessellationControlShaderGraph: QtCore.QUrl) -> None: ... - def setVertexShaderGraph(self, vertexShaderGraph: QtCore.QUrl) -> None: ... - def setEnabledLayers(self, layers: typing.Iterable[str]) -> None: ... - def setShaderProgram(self, program: 'QShaderProgram') -> None: ... - def computeShaderGraph(self) -> QtCore.QUrl: ... - def fragmentShaderGraph(self) -> QtCore.QUrl: ... - def geometryShaderGraph(self) -> QtCore.QUrl: ... - def tessellationEvaluationShaderGraph(self) -> QtCore.QUrl: ... - def tessellationControlShaderGraph(self) -> QtCore.QUrl: ... - def vertexShaderGraph(self) -> QtCore.QUrl: ... - def enabledLayers(self) -> typing.List[str]: ... - def shaderProgram(self) -> 'QShaderProgram': ... - - class QSortPolicy('QFrameGraphNode'): - - class SortType(int): - StateChangeCost = ... # type: QSortPolicy.SortType - BackToFront = ... # type: QSortPolicy.SortType - Material = ... # type: QSortPolicy.SortType - FrontToBack = ... # type: QSortPolicy.SortType - Texture = ... # type: QSortPolicy.SortType - Uniform = ... # type: QSortPolicy.SortType - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... +class QMesh('QGeometryRenderer'): - @typing.overload - def sortTypesChanged(self, sortTypes: typing.Iterable[QSortPolicy.SortType]) -> None: ... - @typing.overload - def sortTypesChanged(self, sortTypes: typing.Iterable[int]) -> None: ... - @typing.overload - def setSortTypes(self, sortTypes: typing.Iterable[QSortPolicy.SortType]) -> None: ... - @typing.overload - def setSortTypes(self, sortTypesInt: typing.Iterable[int]) -> None: ... - def sortTypesInt(self) -> typing.List[int]: ... - def sortTypes(self) -> typing.List[QSortPolicy.SortType]: ... - - class QSpotLight('QAbstractLight'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def cutOffAngleChanged(self, cutOffAngle: float) -> None: ... - def localDirectionChanged(self, localDirection: QtGui.QVector3D) -> None: ... - def quadraticAttenuationChanged(self, quadraticAttenuation: float) -> None: ... - def linearAttenuationChanged(self, linearAttenuation: float) -> None: ... - def constantAttenuationChanged(self, constantAttenuation: float) -> None: ... - def setCutOffAngle(self, cutOffAngle: float) -> None: ... - def setLocalDirection(self, localDirection: QtGui.QVector3D) -> None: ... - def setQuadraticAttenuation(self, value: float) -> None: ... - def setLinearAttenuation(self, value: float) -> None: ... - def setConstantAttenuation(self, value: float) -> None: ... - def quadraticAttenuation(self) -> float: ... - def linearAttenuation(self) -> float: ... - def constantAttenuation(self) -> float: ... - def cutOffAngle(self) -> float: ... - def localDirection(self) -> QtGui.QVector3D: ... - - class QStencilMask('QRenderState'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def backOutputMaskChanged(self, backOutputMask: int) -> None: ... - def frontOutputMaskChanged(self, frontOutputMask: int) -> None: ... - def setBackOutputMask(self, backOutputMask: int) -> None: ... - def setFrontOutputMask(self, frontOutputMask: int) -> None: ... - def backOutputMask(self) -> int: ... - def frontOutputMask(self) -> int: ... - - class QStencilOperation('QRenderState'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def back(self) -> 'QStencilOperationArguments': ... - def front(self) -> 'QStencilOperationArguments': ... - - class QStencilOperationArguments(QtCore.QObject): - - class Operation(int): - Zero = ... # type: QStencilOperationArguments.Operation - Keep = ... # type: QStencilOperationArguments.Operation - Replace = ... # type: QStencilOperationArguments.Operation - Increment = ... # type: QStencilOperationArguments.Operation - Decrement = ... # type: QStencilOperationArguments.Operation - IncrementWrap = ... # type: QStencilOperationArguments.Operation - DecrementWrap = ... # type: QStencilOperationArguments.Operation - Invert = ... # type: QStencilOperationArguments.Operation - - class FaceMode(int): - Front = ... # type: QStencilOperationArguments.FaceMode - Back = ... # type: QStencilOperationArguments.FaceMode - FrontAndBack = ... # type: QStencilOperationArguments.FaceMode - - def faceModeChanged(self, faceMode: 'QStencilOperationArguments.FaceMode') -> None: ... - def allTestsPassOperationChanged(self, stencilDepthPass: 'QStencilOperationArguments.Operation') -> None: ... - def depthTestFailureOperationChanged(self, depthFail: 'QStencilOperationArguments.Operation') -> None: ... - def stencilTestFailureOperationChanged(self, stencilFail: 'QStencilOperationArguments.Operation') -> None: ... - def setAllTestsPassOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... - def setDepthTestFailureOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... - def setStencilTestFailureOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... - def allTestsPassOperation(self) -> 'QStencilOperationArguments.Operation': ... - def depthTestFailureOperation(self) -> 'QStencilOperationArguments.Operation': ... - def stencilTestFailureOperation(self) -> 'QStencilOperationArguments.Operation': ... - def faceMode(self) -> 'QStencilOperationArguments.FaceMode': ... + class Status(int): + None_ = ... # type: QMesh.Status + Loading = ... # type: QMesh.Status + Ready = ... # type: QMesh.Status + Error = ... # type: QMesh.Status - class QStencilTest('QRenderState'): + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def statusChanged(self, status: 'QMesh.Status') -> None: ... + def status(self) -> 'QMesh.Status': ... + def meshNameChanged(self, meshName: str) -> None: ... + def sourceChanged(self, source: QtCore.QUrl) -> None: ... + def setMeshName(self, meshName: str) -> None: ... + def setSource(self, source: QtCore.QUrl) -> None: ... + def meshName(self) -> str: ... + def source(self) -> QtCore.QUrl: ... - def back(self) -> 'QStencilTestArguments': ... - def front(self) -> 'QStencilTestArguments': ... - class QStencilTestArguments(QtCore.QObject): +class QMultiSampleAntiAliasing('QRenderState'): - class StencilFunction(int): - Never = ... # type: QStencilTestArguments.StencilFunction - Always = ... # type: QStencilTestArguments.StencilFunction - Less = ... # type: QStencilTestArguments.StencilFunction - LessOrEqual = ... # type: QStencilTestArguments.StencilFunction - Equal = ... # type: QStencilTestArguments.StencilFunction - GreaterOrEqual = ... # type: QStencilTestArguments.StencilFunction - Greater = ... # type: QStencilTestArguments.StencilFunction - NotEqual = ... # type: QStencilTestArguments.StencilFunction + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class StencilFaceMode(int): - Front = ... # type: QStencilTestArguments.StencilFaceMode - Back = ... # type: QStencilTestArguments.StencilFaceMode - FrontAndBack = ... # type: QStencilTestArguments.StencilFaceMode - def faceModeChanged(self, faceMode: 'QStencilTestArguments.StencilFaceMode') -> None: ... - def referenceValueChanged(self, referenceValue: int) -> None: ... - def stencilFunctionChanged(self, stencilFunction: 'QStencilTestArguments.StencilFunction') -> None: ... - def comparisonMaskChanged(self, comparisonMask: int) -> None: ... - def setStencilFunction(self, stencilFunction: 'QStencilTestArguments.StencilFunction') -> None: ... - def setReferenceValue(self, referenceValue: int) -> None: ... - def setComparisonMask(self, comparisonMask: int) -> None: ... - def faceMode(self) -> 'QStencilTestArguments.StencilFaceMode': ... - def stencilFunction(self) -> 'QStencilTestArguments.StencilFunction': ... - def referenceValue(self) -> int: ... - def comparisonMask(self) -> int: ... +class QNoDepthMask('QRenderState'): - class QSubtreeEnabler('QFrameGraphNode'): + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class Enablement(int): - Persistent = ... # type: QSubtreeEnabler.Enablement - SingleShot = ... # type: QSubtreeEnabler.Enablement - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... +class QNoDraw('QFrameGraphNode'): - def enablementChanged(self, enablement: 'QSubtreeEnabler.Enablement') -> None: ... - def requestUpdate(self) -> None: ... - def setEnablement(self, enablement: 'QSubtreeEnabler.Enablement') -> None: ... - def enablement(self) -> 'QSubtreeEnabler.Enablement': ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QTechnique(Qt3DCore.QNode): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... +class QNoPicking('QFrameGraphNode'): - def graphicsApiFilter(self) -> 'QGraphicsApiFilter': ... - def renderPasses(self) -> typing.List['QRenderPass']: ... - def removeRenderPass(self, pass_: 'QRenderPass') -> None: ... - def addRenderPass(self, pass_: 'QRenderPass') -> None: ... - def parameters(self) -> typing.List['QParameter']: ... - def removeParameter(self, p: 'QParameter') -> None: ... - def addParameter(self, p: 'QParameter') -> None: ... - def filterKeys(self) -> typing.List['QFilterKey']: ... - def removeFilterKey(self, filterKey: 'QFilterKey') -> None: ... - def addFilterKey(self, filterKey: 'QFilterKey') -> None: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QTechniqueFilter('QFrameGraphNode'): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... +class QObjectPicker(Qt3DCore.QComponent): - def parameters(self) -> typing.List['QParameter']: ... - def removeParameter(self, p: 'QParameter') -> None: ... - def addParameter(self, p: 'QParameter') -> None: ... - def removeMatch(self, filterKey: 'QFilterKey') -> None: ... - def addMatch(self, filterKey: 'QFilterKey') -> None: ... - def matchAll(self) -> typing.List['QFilterKey']: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QTexture1D('QAbstractTexture'): + def priorityChanged(self, priority: int) -> None: ... + def setPriority(self, priority: int) -> None: ... + def priority(self) -> int: ... + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def containsMouseChanged(self, containsMouse: bool) -> None: ... + def pressedChanged(self, pressed: bool) -> None: ... + def dragEnabledChanged(self, dragEnabled: bool) -> None: ... + def hoverEnabledChanged(self, hoverEnabled: bool) -> None: ... + def exited(self) -> None: ... + def entered(self) -> None: ... + def moved(self, pick: 'QPickEvent') -> None: ... + def clicked(self, pick: 'QPickEvent') -> None: ... + def released(self, pick: 'QPickEvent') -> None: ... + def pressed(self, pick: 'QPickEvent') -> None: ... + def setDragEnabled(self, dragEnabled: bool) -> None: ... + def setHoverEnabled(self, hoverEnabled: bool) -> None: ... + def isPressed(self) -> bool: ... + def containsMouse(self) -> bool: ... + def isDragEnabled(self) -> bool: ... + def isHoverEnabled(self) -> bool: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QTexture1DArray('QAbstractTexture'): +class QPaintedTextureImage('QAbstractTextureImage'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def paint(self, painter: QtGui.QPainter) -> None: ... + def sizeChanged(self, size: QtCore.QSize) -> None: ... + def heightChanged(self, w: int) -> None: ... + def widthChanged(self, w: int) -> None: ... + def setSize(self, size: QtCore.QSize) -> None: ... + def setHeight(self, h: int) -> None: ... + def setWidth(self, w: int) -> None: ... + def update(self, rect: QtCore.QRect = ...) -> None: ... + def size(self) -> QtCore.QSize: ... + def height(self) -> int: ... + def width(self) -> int: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QTexture2D('QAbstractTexture'): +class QParameter(Qt3DCore.QNode): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self, name: str, value: typing.Any, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self, name: str, texture: 'QAbstractTexture', parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QTexture2DArray('QAbstractTexture'): + def nameChanged(self, name: str) -> None: ... + def valueChanged(self, value: typing.Any) -> None: ... + def setValue(self, dv: typing.Any) -> None: ... + def setName(self, name: str) -> None: ... + def value(self) -> typing.Any: ... + def name(self) -> str: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QTexture3D('QAbstractTexture'): +class QPickEvent(QtCore.QObject): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + class Modifiers(int): + NoModifier = ... # type: QPickEvent.Modifiers + ShiftModifier = ... # type: QPickEvent.Modifiers + ControlModifier = ... # type: QPickEvent.Modifiers + AltModifier = ... # type: QPickEvent.Modifiers + MetaModifier = ... # type: QPickEvent.Modifiers + KeypadModifier = ... # type: QPickEvent.Modifiers - class QTextureCubeMap('QAbstractTexture'): + class Buttons(int): + LeftButton = ... # type: QPickEvent.Buttons + RightButton = ... # type: QPickEvent.Buttons + MiddleButton = ... # type: QPickEvent.Buttons + BackButton = ... # type: QPickEvent.Buttons + NoButton = ... # type: QPickEvent.Buttons - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float) -> None: ... + @typing.overload + def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float, button: 'QPickEvent.Buttons', buttons: int, modifiers: int) -> None: ... - class QTextureCubeMapArray('QAbstractTexture'): + def entity(self) -> Qt3DCore.QEntity: ... + def viewport(self) -> 'QViewport': ... + def modifiers(self) -> int: ... + def buttons(self) -> int: ... + def button(self) -> 'QPickEvent.Buttons': ... + def acceptedChanged(self, accepted: bool) -> None: ... + def setAccepted(self, accepted: bool) -> None: ... + def localIntersection(self) -> QtGui.QVector3D: ... + def worldIntersection(self) -> QtGui.QVector3D: ... + def distance(self) -> float: ... + def position(self) -> QtCore.QPointF: ... + def isAccepted(self) -> bool: ... + + +class QPickingSettings(Qt3DCore.QNode): + + class FaceOrientationPickingMode(int): + FrontFace = ... # type: QPickingSettings.FaceOrientationPickingMode + BackFace = ... # type: QPickingSettings.FaceOrientationPickingMode + FrontAndBackFace = ... # type: QPickingSettings.FaceOrientationPickingMode + + class PickResultMode(int): + NearestPick = ... # type: QPickingSettings.PickResultMode + AllPicks = ... # type: QPickingSettings.PickResultMode + NearestPriorityPick = ... # type: QPickingSettings.PickResultMode + + class PickMethod(int): + BoundingVolumePicking = ... # type: QPickingSettings.PickMethod + TrianglePicking = ... # type: QPickingSettings.PickMethod + LinePicking = ... # type: QPickingSettings.PickMethod + PointPicking = ... # type: QPickingSettings.PickMethod + PrimitivePicking = ... # type: QPickingSettings.PickMethod + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def worldSpaceToleranceChanged(self, worldSpaceTolerance: float) -> None: ... + def setWorldSpaceTolerance(self, worldSpaceTolerance: float) -> None: ... + def worldSpaceTolerance(self) -> float: ... + def faceOrientationPickingModeChanged(self, faceOrientationPickingMode: 'QPickingSettings.FaceOrientationPickingMode') -> None: ... + def setFaceOrientationPickingMode(self, faceOrientationPickingMode: 'QPickingSettings.FaceOrientationPickingMode') -> None: ... + def faceOrientationPickingMode(self) -> 'QPickingSettings.FaceOrientationPickingMode': ... + def pickResultModeChanged(self, pickResult: 'QPickingSettings.PickResultMode') -> None: ... + def pickMethodChanged(self, pickMethod: 'QPickingSettings.PickMethod') -> None: ... + def setPickResultMode(self, pickResultMode: 'QPickingSettings.PickResultMode') -> None: ... + def setPickMethod(self, pickMethod: 'QPickingSettings.PickMethod') -> None: ... + def pickResultMode(self) -> 'QPickingSettings.PickResultMode': ... + def pickMethod(self) -> 'QPickingSettings.PickMethod': ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QTexture2DMultisample('QAbstractTexture'): +class QPickLineEvent('QPickEvent'): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float, edgeIndex: int, vertex1Index: int, vertex2Index: int, button: 'QPickEvent.Buttons', buttons: int, modifiers: int) -> None: ... - class QTexture2DMultisampleArray('QAbstractTexture'): + def vertex2Index(self) -> int: ... + def vertex1Index(self) -> int: ... + def edgeIndex(self) -> int: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QTextureRectangle('QAbstractTexture'): +class QPickPointEvent('QPickEvent'): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float, pointIndex: int, button: 'QPickEvent.Buttons', buttons: int, modifiers: int) -> None: ... - class QTextureBuffer('QAbstractTexture'): + def pointIndex(self) -> int: ... - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - class QTextureLoader('QAbstractTexture'): +class QPickTriangleEvent('QPickEvent'): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float, triangleIndex: int, vertex1Index: int, vertex2Index: int, vertex3Index: int) -> None: ... + @typing.overload + def __init__(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], worldIntersection: QtGui.QVector3D, localIntersection: QtGui.QVector3D, distance: float, triangleIndex: int, vertex1Index: int, vertex2Index: int, vertex3Index: int, button: 'QPickEvent.Buttons', buttons: int, modifiers: int, uvw: QtGui.QVector3D) -> None: ... + + def uvw(self) -> QtGui.QVector3D: ... + def vertex3Index(self) -> int: ... + def vertex2Index(self) -> int: ... + def vertex1Index(self) -> int: ... + def triangleIndex(self) -> int: ... - def mirroredChanged(self, mirrored: bool) -> None: ... - def setMirrored(self, mirrored: bool) -> None: ... - def isMirrored(self) -> bool: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... - def setSource(self, source: QtCore.QUrl) -> None: ... - def source(self) -> QtCore.QUrl: ... - class QSharedGLTexture('QAbstractTexture'): +class QPointLight('QAbstractLight'): - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - def textureIdChanged(self, textureId: int) -> None: ... - def setTextureId(self, id: int) -> None: ... - def textureId(self) -> int: ... + def quadraticAttenuationChanged(self, quadraticAttenuation: float) -> None: ... + def linearAttenuationChanged(self, linearAttenuation: float) -> None: ... + def constantAttenuationChanged(self, constantAttenuation: float) -> None: ... + def setQuadraticAttenuation(self, value: float) -> None: ... + def setLinearAttenuation(self, value: float) -> None: ... + def setConstantAttenuation(self, value: float) -> None: ... + def quadraticAttenuation(self) -> float: ... + def linearAttenuation(self) -> float: ... + def constantAttenuation(self) -> float: ... - class QTextureData(sip.simplewrapper): - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, a0: 'QTextureData') -> None: ... - - def addImageData(self, imageData: 'QTextureImageData') -> None: ... - def imageData(self) -> typing.List[QTextureImageData]: ... - def setComparisonMode(self, comparisonMode: 'QAbstractTexture.ComparisonMode') -> None: ... - def comparisonMode(self) -> 'QAbstractTexture.ComparisonMode': ... - def setComparisonFunction(self, comparisonFunction: 'QAbstractTexture.ComparisonFunction') -> None: ... - def comparisonFunction(self) -> 'QAbstractTexture.ComparisonFunction': ... - def setWrapModeZ(self, wrapModeZ: 'QTextureWrapMode.WrapMode') -> None: ... - def wrapModeZ(self) -> 'QTextureWrapMode.WrapMode': ... - def setWrapModeY(self, wrapModeY: 'QTextureWrapMode.WrapMode') -> None: ... - def wrapModeY(self) -> 'QTextureWrapMode.WrapMode': ... - def setWrapModeX(self, wrapModeX: 'QTextureWrapMode.WrapMode') -> None: ... - def wrapModeX(self) -> 'QTextureWrapMode.WrapMode': ... - def setMagnificationFilter(self, filter: 'QAbstractTexture.Filter') -> None: ... - def magnificationFilter(self) -> 'QAbstractTexture.Filter': ... - def setMinificationFilter(self, filter: 'QAbstractTexture.Filter') -> None: ... - def minificationFilter(self) -> 'QAbstractTexture.Filter': ... - def setMaximumAnisotropy(self, maximumAnisotropy: float) -> None: ... - def maximumAnisotropy(self) -> float: ... - def setAutoMipMapGenerationEnabled(self, isAutoMipMapGenerationEnabled: bool) -> None: ... - def isAutoMipMapGenerationEnabled(self) -> bool: ... - def setLayers(self, layers: int) -> None: ... - def layers(self) -> int: ... - def setDepth(self, depth: int) -> None: ... - def depth(self) -> int: ... - def setHeight(self, height: int) -> None: ... - def height(self) -> int: ... - def setWidth(self, width: int) -> None: ... - def width(self) -> int: ... - def setFormat(self, a0: 'QAbstractTexture.TextureFormat') -> None: ... - def format(self) -> 'QAbstractTexture.TextureFormat': ... - def setTarget(self, target: 'QAbstractTexture.Target') -> None: ... - def target(self) -> 'QAbstractTexture.Target': ... - - class QTextureDataUpdate(sip.simplewrapper): +class QPointSize('QRenderState'): - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, other: 'QTextureDataUpdate') -> None: ... - - def setData(self, data: 'QTextureImageData') -> None: ... - def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... - def setMipLevel(self, mipLevel: int) -> None: ... - def setLayer(self, layer: int) -> None: ... - def setZ(self, z: int) -> None: ... - def setY(self, y: int) -> None: ... - def setX(self, x: int) -> None: ... - def data(self) -> 'QTextureImageData': ... - def face(self) -> 'QAbstractTexture.CubeMapFace': ... - def mipLevel(self) -> int: ... - def layer(self) -> int: ... - def z(self) -> int: ... - def y(self) -> int: ... - def x(self) -> int: ... - def swap(self, other: 'QTextureDataUpdate') -> None: ... - - class QTextureGenerator('QAbstractFunctor'): - - def __call__(self) -> 'QTextureData': ... - - class QTextureImage('QAbstractTextureImage'): - - class Status(int): - None_ = ... # type: QTextureImage.Status - Loading = ... # type: QTextureImage.Status - Ready = ... # type: QTextureImage.Status - Error = ... # type: QTextureImage.Status - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def mirroredChanged(self, mirrored: bool) -> None: ... - def setMirrored(self, mirrored: bool) -> None: ... - def isMirrored(self) -> bool: ... - def setStatus(self, status: 'QTextureImage.Status') -> None: ... - def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... - def statusChanged(self, status: 'QTextureImage.Status') -> None: ... - def sourceChanged(self, source: QtCore.QUrl) -> None: ... - def setSource(self, source: QtCore.QUrl) -> None: ... - def status(self) -> 'QTextureImage.Status': ... - def source(self) -> QtCore.QUrl: ... - - class QTextureImageData(sip.simplewrapper): + class SizeMode(int): + Fixed = ... # type: QPointSize.SizeMode + Programmable = ... # type: QPointSize.SizeMode - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, a0: 'QTextureImageData') -> None: ... - - def data(self, layer: int = ..., face: int = ..., mipmapLevel: int = ...) -> QtCore.QByteArray: ... - def setData(self, data: typing.Union[QtCore.QByteArray, bytes, bytearray], blockSize: int, isCompressed: bool = ...) -> None: ... - def setImage(self, a0: QtGui.QImage) -> None: ... - def setPixelType(self, pixelType: QtGui.QOpenGLTexture.PixelType) -> None: ... - def setPixelFormat(self, pixelFormat: QtGui.QOpenGLTexture.PixelFormat) -> None: ... - def setFormat(self, format: QtGui.QOpenGLTexture.TextureFormat) -> None: ... - def setTarget(self, target: QtGui.QOpenGLTexture.Target) -> None: ... - def pixelType(self) -> QtGui.QOpenGLTexture.PixelType: ... - def pixelFormat(self) -> QtGui.QOpenGLTexture.PixelFormat: ... - def format(self) -> QtGui.QOpenGLTexture.TextureFormat: ... - def target(self) -> QtGui.QOpenGLTexture.Target: ... - def setFaces(self, faces: int) -> None: ... - def setMipLevels(self, mipLevels: int) -> None: ... - def setLayers(self, layers: int) -> None: ... - def setDepth(self, depth: int) -> None: ... - def setHeight(self, height: int) -> None: ... - def setWidth(self, width: int) -> None: ... - def faces(self) -> int: ... - def mipLevels(self) -> int: ... - def layers(self) -> int: ... - def depth(self) -> int: ... - def height(self) -> int: ... - def width(self) -> int: ... - def isCompressed(self) -> bool: ... - def cleanup(self) -> None: ... - - class QTextureImageDataGenerator('QAbstractFunctor'): - - def __call__(self) -> 'QTextureImageData': ... - - class QTextureWrapMode(QtCore.QObject): - - class WrapMode(int): - Repeat = ... # type: QTextureWrapMode.WrapMode - MirroredRepeat = ... # type: QTextureWrapMode.WrapMode - ClampToEdge = ... # type: QTextureWrapMode.WrapMode - ClampToBorder = ... # type: QTextureWrapMode.WrapMode + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - @typing.overload - def __init__(self, wrapMode: 'QTextureWrapMode.WrapMode' = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, x: 'QTextureWrapMode.WrapMode', y: 'QTextureWrapMode.WrapMode', z: 'QTextureWrapMode.WrapMode', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def zChanged(self, z: 'QTextureWrapMode.WrapMode') -> None: ... - def yChanged(self, y: 'QTextureWrapMode.WrapMode') -> None: ... - def xChanged(self, x: 'QTextureWrapMode.WrapMode') -> None: ... - def setZ(self, z: 'QTextureWrapMode.WrapMode') -> None: ... - def setY(self, y: 'QTextureWrapMode.WrapMode') -> None: ... - def setX(self, x: 'QTextureWrapMode.WrapMode') -> None: ... - def z(self) -> 'QTextureWrapMode.WrapMode': ... - def y(self) -> 'QTextureWrapMode.WrapMode': ... - def x(self) -> 'QTextureWrapMode.WrapMode': ... - - class QViewport('QFrameGraphNode'): - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def gammaChanged(self, gamma: float) -> None: ... - def setGamma(self, gamma: float) -> None: ... - def gamma(self) -> float: ... - def normalizedRectChanged(self, normalizedRect: QtCore.QRectF) -> None: ... - def setNormalizedRect(self, normalizedRect: QtCore.QRectF) -> None: ... - def normalizedRect(self) -> QtCore.QRectF: ... - - class QWaitFence('QFrameGraphNode'): - - class HandleType(int): - NoHandle = ... # type: QWaitFence.HandleType - OpenGLFenceId = ... # type: QWaitFence.HandleType - - def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... - - def handleChanged(self, handle: typing.Any) -> None: ... - def handleTypeChanged(self, handleType: 'QWaitFence.HandleType') -> None: ... - def timeoutChanged(self, timeoutChanged: int) -> None: ... - def waitOnCPUChanged(self, waitOnCPU: bool) -> None: ... - def setTimeout(self, timeout: int) -> None: ... - def timeout(self) -> int: ... - def setWaitOnCPU(self, waitOnCPU: bool) -> None: ... - def waitOnCPU(self) -> bool: ... - def handle(self) -> typing.Any: ... - def handleType(self) -> 'QWaitFence.HandleType': ... - def setHandle(self, handle: typing.Any) -> None: ... - def setHandleType(self, type: 'QWaitFence.HandleType') -> None: ... + def valueChanged(self, value: float) -> None: ... + def sizeModeChanged(self, sizeMode: 'QPointSize.SizeMode') -> None: ... + def setValue(self, value: float) -> None: ... + def setSizeMode(self, sizeMode: 'QPointSize.SizeMode') -> None: ... + def value(self) -> float: ... + def sizeMode(self) -> 'QPointSize.SizeMode': ... + + +class QPolygonOffset('QRenderState'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def depthStepsChanged(self, depthSteps: float) -> None: ... + def scaleFactorChanged(self, scaleFactor: float) -> None: ... + def setDepthSteps(self, depthSteps: float) -> None: ... + def setScaleFactor(self, scaleFactor: float) -> None: ... + def depthSteps(self) -> float: ... + def scaleFactor(self) -> float: ... + + +class QProximityFilter('QFrameGraphNode'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def distanceThresholdChanged(self, distanceThreshold: float) -> None: ... + def entityChanged(self, entity: Qt3DCore.QEntity) -> None: ... + def setDistanceThreshold(self, distanceThreshold: float) -> None: ... + def setEntity(self, entity: Qt3DCore.QEntity) -> None: ... + def distanceThreshold(self) -> float: ... + def entity(self) -> Qt3DCore.QEntity: ... + + +class QRasterMode('QRenderState'): + + class FaceMode(int): + Front = ... # type: QRasterMode.FaceMode + Back = ... # type: QRasterMode.FaceMode + FrontAndBack = ... # type: QRasterMode.FaceMode + + class RasterMode(int): + Points = ... # type: QRasterMode.RasterMode + Lines = ... # type: QRasterMode.RasterMode + Fill = ... # type: QRasterMode.RasterMode + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def faceModeChanged(self, faceMode: 'QRasterMode.FaceMode') -> None: ... + def rasterModeChanged(self, rasterMode: 'QRasterMode.RasterMode') -> None: ... + def setFaceMode(self, faceMode: 'QRasterMode.FaceMode') -> None: ... + def setRasterMode(self, rasterMode: 'QRasterMode.RasterMode') -> None: ... + def faceMode(self) -> 'QRasterMode.FaceMode': ... + def rasterMode(self) -> 'QRasterMode.RasterMode': ... + + +class QRayCaster('QAbstractRayCaster'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def lengthChanged(self, length: float) -> None: ... + def directionChanged(self, direction: QtGui.QVector3D) -> None: ... + def originChanged(self, origin: QtGui.QVector3D) -> None: ... + @typing.overload + def trigger(self) -> None: ... + @typing.overload + def trigger(self, origin: QtGui.QVector3D, direction: QtGui.QVector3D, length: float) -> None: ... + def setLength(self, length: float) -> None: ... + def setDirection(self, direction: QtGui.QVector3D) -> None: ... + def setOrigin(self, origin: QtGui.QVector3D) -> None: ... + def length(self) -> float: ... + def direction(self) -> QtGui.QVector3D: ... + def origin(self) -> QtGui.QVector3D: ... + + +class QRayCasterHit(sip.simplewrapper): + + class HitType(int): + TriangleHit = ... # type: QRayCasterHit.HitType + LineHit = ... # type: QRayCasterHit.HitType + PointHit = ... # type: QRayCasterHit.HitType + EntityHit = ... # type: QRayCasterHit.HitType + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, type: 'QRayCasterHit.HitType', id: Qt3DCore.QNodeId, distance: float, localIntersect: QtGui.QVector3D, worldIntersect: QtGui.QVector3D, primitiveIndex: int, v1: int, v2: int, v3: int) -> None: ... + @typing.overload + def __init__(self, other: 'QRayCasterHit') -> None: ... + + def vertex3Index(self) -> int: ... + def vertex2Index(self) -> int: ... + def vertex1Index(self) -> int: ... + def primitiveIndex(self) -> int: ... + def worldIntersection(self) -> QtGui.QVector3D: ... + def localIntersection(self) -> QtGui.QVector3D: ... + def distance(self) -> float: ... + def entity(self) -> Qt3DCore.QEntity: ... + def entityId(self) -> Qt3DCore.QNodeId: ... + def type(self) -> 'QRayCasterHit.HitType': ... + + +class Render(PyQt5.sip.simplewrapper): ... + + +class QRenderAspect(Qt3DCore.QAbstractAspect): + + class RenderType(int): + Synchronous = ... # type: QRenderAspect.RenderType + Threaded = ... # type: QRenderAspect.RenderType + + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, type: 'QRenderAspect.RenderType', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + +class QRenderCapabilities(QtCore.QObject): + + class Profile(int): + NoProfile = ... # type: QRenderCapabilities.Profile + CoreProfile = ... # type: QRenderCapabilities.Profile + CompatibilityProfile = ... # type: QRenderCapabilities.Profile + + class API(int): + OpenGL = ... # type: QRenderCapabilities.API + OpenGLES = ... # type: QRenderCapabilities.API + Vulkan = ... # type: QRenderCapabilities.API + DirectX = ... # type: QRenderCapabilities.API + RHI = ... # type: QRenderCapabilities.API + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def maxComputeSharedMemorySize(self) -> int: ... + def maxComputeInvocations(self) -> int: ... + def maxWorkGroupSizeZ(self) -> int: ... + def maxWorkGroupSizeY(self) -> int: ... + def maxWorkGroupSizeX(self) -> int: ... + def maxWorkGroupCountZ(self) -> int: ... + def maxWorkGroupCountY(self) -> int: ... + def maxWorkGroupCountX(self) -> int: ... + def supportsCompute(self) -> bool: ... + def maxImageUnits(self) -> int: ... + def supportsImageStore(self) -> bool: ... + def maxSSBOBindings(self) -> int: ... + def maxSSBOSize(self) -> int: ... + def supportsSSBO(self) -> bool: ... + def maxUBOBindings(self) -> int: ... + def maxUBOSize(self) -> int: ... + def supportsUBO(self) -> bool: ... + def maxTextureLayers(self) -> int: ... + def maxTextureUnits(self) -> int: ... + def maxTextureSize(self) -> int: ... + def maxSamples(self) -> int: ... + def glslVersion(self) -> str: ... + def driverVersion(self) -> str: ... + def renderer(self) -> str: ... + def vendor(self) -> str: ... + def extensions(self) -> typing.List[str]: ... + def minorVersion(self) -> int: ... + def majorVersion(self) -> int: ... + def profile(self) -> 'QRenderCapabilities.Profile': ... + def api(self) -> 'QRenderCapabilities.API': ... + def isValid(self) -> bool: ... + + +class QRenderCaptureReply(QtCore.QObject): + + def completed(self) -> None: ... + def saveImage(self, fileName: str) -> bool: ... + def completeChanged(self, isComplete: bool) -> None: ... + def saveToFile(self, fileName: str) -> None: ... + def isComplete(self) -> bool: ... + def captureId(self) -> int: ... + def image(self) -> QtGui.QImage: ... + + +class QRenderCapture('QFrameGraphNode'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + @typing.overload + def requestCapture(self, captureId: int) -> 'QRenderCaptureReply': ... + @typing.overload + def requestCapture(self) -> 'QRenderCaptureReply': ... + @typing.overload + def requestCapture(self, rect: QtCore.QRect) -> 'QRenderCaptureReply': ... + + +class QRenderPass(Qt3DCore.QNode): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def shaderProgramChanged(self, shaderProgram: 'QShaderProgram') -> None: ... + def setShaderProgram(self, shaderProgram: 'QShaderProgram') -> None: ... + def parameters(self) -> typing.List['QParameter']: ... + def removeParameter(self, p: 'QParameter') -> None: ... + def addParameter(self, p: 'QParameter') -> None: ... + def renderStates(self) -> typing.List['QRenderState']: ... + def removeRenderState(self, state: 'QRenderState') -> None: ... + def addRenderState(self, state: 'QRenderState') -> None: ... + def filterKeys(self) -> typing.List['QFilterKey']: ... + def removeFilterKey(self, filterKey: 'QFilterKey') -> None: ... + def addFilterKey(self, filterKey: 'QFilterKey') -> None: ... + def shaderProgram(self) -> 'QShaderProgram': ... + + +class QRenderPassFilter('QFrameGraphNode'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def parameters(self) -> typing.List['QParameter']: ... + def removeParameter(self, parameter: 'QParameter') -> None: ... + def addParameter(self, parameter: 'QParameter') -> None: ... + def removeMatch(self, filterKey: 'QFilterKey') -> None: ... + def addMatch(self, filterKey: 'QFilterKey') -> None: ... + def matchAny(self) -> typing.List['QFilterKey']: ... + + +class QRenderSettings(Qt3DCore.QComponent): + + class RenderPolicy(int): + OnDemand = ... # type: QRenderSettings.RenderPolicy + Always = ... # type: QRenderSettings.RenderPolicy + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def renderPolicyChanged(self, renderPolicy: 'QRenderSettings.RenderPolicy') -> None: ... + def activeFrameGraphChanged(self, activeFrameGraph: 'QFrameGraphNode') -> None: ... + def setRenderPolicy(self, renderPolicy: 'QRenderSettings.RenderPolicy') -> None: ... + def setActiveFrameGraph(self, activeFrameGraph: 'QFrameGraphNode') -> None: ... + def renderCapabilities(self) -> 'QRenderCapabilities': ... + def renderPolicy(self) -> 'QRenderSettings.RenderPolicy': ... + def activeFrameGraph(self) -> 'QFrameGraphNode': ... + def pickingSettings(self) -> 'QPickingSettings': ... + + +class QRenderStateSet('QFrameGraphNode'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def renderStates(self) -> typing.List['QRenderState']: ... + def removeRenderState(self, state: 'QRenderState') -> None: ... + def addRenderState(self, state: 'QRenderState') -> None: ... + + +class QRenderSurfaceSelector('QFrameGraphNode'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def surfacePixelRatioChanged(self, ratio: float) -> None: ... + def externalRenderTargetSizeChanged(self, size: QtCore.QSize) -> None: ... + def surfaceChanged(self, surface: QtCore.QObject) -> None: ... + def setSurfacePixelRatio(self, ratio: float) -> None: ... + def setSurface(self, surfaceObject: QtCore.QObject) -> None: ... + def setExternalRenderTargetSize(self, size: QtCore.QSize) -> None: ... + def surfacePixelRatio(self) -> float: ... + def externalRenderTargetSize(self) -> QtCore.QSize: ... + def surface(self) -> QtCore.QObject: ... + + +class QRenderTarget(Qt3DCore.QComponent): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def outputs(self) -> typing.List['QRenderTargetOutput']: ... + def removeOutput(self, output: 'QRenderTargetOutput') -> None: ... + def addOutput(self, output: 'QRenderTargetOutput') -> None: ... + + +class QRenderTargetOutput(Qt3DCore.QNode): + + class AttachmentPoint(int): + Color0 = ... # type: QRenderTargetOutput.AttachmentPoint + Color1 = ... # type: QRenderTargetOutput.AttachmentPoint + Color2 = ... # type: QRenderTargetOutput.AttachmentPoint + Color3 = ... # type: QRenderTargetOutput.AttachmentPoint + Color4 = ... # type: QRenderTargetOutput.AttachmentPoint + Color5 = ... # type: QRenderTargetOutput.AttachmentPoint + Color6 = ... # type: QRenderTargetOutput.AttachmentPoint + Color7 = ... # type: QRenderTargetOutput.AttachmentPoint + Color8 = ... # type: QRenderTargetOutput.AttachmentPoint + Color9 = ... # type: QRenderTargetOutput.AttachmentPoint + Color10 = ... # type: QRenderTargetOutput.AttachmentPoint + Color11 = ... # type: QRenderTargetOutput.AttachmentPoint + Color12 = ... # type: QRenderTargetOutput.AttachmentPoint + Color13 = ... # type: QRenderTargetOutput.AttachmentPoint + Color14 = ... # type: QRenderTargetOutput.AttachmentPoint + Color15 = ... # type: QRenderTargetOutput.AttachmentPoint + Depth = ... # type: QRenderTargetOutput.AttachmentPoint + Stencil = ... # type: QRenderTargetOutput.AttachmentPoint + DepthStencil = ... # type: QRenderTargetOutput.AttachmentPoint + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def faceChanged(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... + def layerChanged(self, layer: int) -> None: ... + def mipLevelChanged(self, mipLevel: int) -> None: ... + def textureChanged(self, texture: 'QAbstractTexture') -> None: ... + def attachmentPointChanged(self, attachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... + def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... + def setLayer(self, layer: int) -> None: ... + def setMipLevel(self, level: int) -> None: ... + def setTexture(self, texture: 'QAbstractTexture') -> None: ... + def setAttachmentPoint(self, attachmentPoint: 'QRenderTargetOutput.AttachmentPoint') -> None: ... + def face(self) -> 'QAbstractTexture.CubeMapFace': ... + def layer(self) -> int: ... + def mipLevel(self) -> int: ... + def texture(self) -> 'QAbstractTexture': ... + def attachmentPoint(self) -> 'QRenderTargetOutput.AttachmentPoint': ... + + +class QRenderTargetSelector('QFrameGraphNode'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def targetChanged(self, target: 'QRenderTarget') -> None: ... + def setTarget(self, target: 'QRenderTarget') -> None: ... + def target(self) -> 'QRenderTarget': ... + def outputs(self) -> typing.List[QRenderTargetOutput.AttachmentPoint]: ... + + +class QSceneLoader(Qt3DCore.QComponent): + + class ComponentType(int): + UnknownComponent = ... # type: QSceneLoader.ComponentType + GeometryRendererComponent = ... # type: QSceneLoader.ComponentType + TransformComponent = ... # type: QSceneLoader.ComponentType + MaterialComponent = ... # type: QSceneLoader.ComponentType + LightComponent = ... # type: QSceneLoader.ComponentType + CameraLensComponent = ... # type: QSceneLoader.ComponentType + + class Status(int): + None_ = ... # type: QSceneLoader.Status + Loading = ... # type: QSceneLoader.Status + Ready = ... # type: QSceneLoader.Status + Error = ... # type: QSceneLoader.Status + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def component(self, entityName: str, componentType: 'QSceneLoader.ComponentType') -> Qt3DCore.QComponent: ... + def entityNames(self) -> typing.List[str]: ... + def entity(self, entityName: str) -> Qt3DCore.QEntity: ... + def statusChanged(self, status: 'QSceneLoader.Status') -> None: ... + def sourceChanged(self, source: QtCore.QUrl) -> None: ... + def setSource(self, arg: QtCore.QUrl) -> None: ... + def status(self) -> 'QSceneLoader.Status': ... + def source(self) -> QtCore.QUrl: ... + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + + +class QScissorTest('QRenderState'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def heightChanged(self, height: int) -> None: ... + def widthChanged(self, width: int) -> None: ... + def bottomChanged(self, bottom: int) -> None: ... + def leftChanged(self, left: int) -> None: ... + def setHeight(self, height: int) -> None: ... + def setWidth(self, width: int) -> None: ... + def setBottom(self, bottom: int) -> None: ... + def setLeft(self, left: int) -> None: ... + def height(self) -> int: ... + def width(self) -> int: ... + def bottom(self) -> int: ... + def left(self) -> int: ... + + +class QScreenRayCaster('QAbstractRayCaster'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def positionChanged(self, position: QtCore.QPoint) -> None: ... + @typing.overload + def trigger(self) -> None: ... + @typing.overload + def trigger(self, position: QtCore.QPoint) -> None: ... + def setPosition(self, position: QtCore.QPoint) -> None: ... + def position(self) -> QtCore.QPoint: ... + + +class QSeamlessCubemap('QRenderState'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QSetFence('QFrameGraphNode'): + + class HandleType(int): + NoHandle = ... # type: QSetFence.HandleType + OpenGLFenceId = ... # type: QSetFence.HandleType + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def handleChanged(self, handle: typing.Any) -> None: ... + def handleTypeChanged(self, handleType: 'QSetFence.HandleType') -> None: ... + def handle(self) -> typing.Any: ... + def handleType(self) -> 'QSetFence.HandleType': ... + + +class PropertyReaderInterface(sip.simplewrapper): + + def readProperty(self, v: typing.Any) -> typing.Any: ... + + +class QShaderData(Qt3DCore.QComponent): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def event(self, event: QtCore.QEvent) -> bool: ... + def propertyReader(self) -> 'PropertyReaderInterface': ... + + +class QShaderImage(Qt3DCore.QNode): + + class ImageFormat(int): + NoFormat = ... # type: QShaderImage.ImageFormat + Automatic = ... # type: QShaderImage.ImageFormat + R8_UNorm = ... # type: QShaderImage.ImageFormat + RG8_UNorm = ... # type: QShaderImage.ImageFormat + RGBA8_UNorm = ... # type: QShaderImage.ImageFormat + R16_UNorm = ... # type: QShaderImage.ImageFormat + RG16_UNorm = ... # type: QShaderImage.ImageFormat + RGBA16_UNorm = ... # type: QShaderImage.ImageFormat + R8_SNorm = ... # type: QShaderImage.ImageFormat + RG8_SNorm = ... # type: QShaderImage.ImageFormat + RGBA8_SNorm = ... # type: QShaderImage.ImageFormat + R16_SNorm = ... # type: QShaderImage.ImageFormat + RG16_SNorm = ... # type: QShaderImage.ImageFormat + RGBA16_SNorm = ... # type: QShaderImage.ImageFormat + R8U = ... # type: QShaderImage.ImageFormat + RG8U = ... # type: QShaderImage.ImageFormat + RGBA8U = ... # type: QShaderImage.ImageFormat + R16U = ... # type: QShaderImage.ImageFormat + RG16U = ... # type: QShaderImage.ImageFormat + RGBA16U = ... # type: QShaderImage.ImageFormat + R32U = ... # type: QShaderImage.ImageFormat + RG32U = ... # type: QShaderImage.ImageFormat + RGBA32U = ... # type: QShaderImage.ImageFormat + R8I = ... # type: QShaderImage.ImageFormat + RG8I = ... # type: QShaderImage.ImageFormat + RGBA8I = ... # type: QShaderImage.ImageFormat + R16I = ... # type: QShaderImage.ImageFormat + RG16I = ... # type: QShaderImage.ImageFormat + RGBA16I = ... # type: QShaderImage.ImageFormat + R32I = ... # type: QShaderImage.ImageFormat + RG32I = ... # type: QShaderImage.ImageFormat + RGBA32I = ... # type: QShaderImage.ImageFormat + R16F = ... # type: QShaderImage.ImageFormat + RG16F = ... # type: QShaderImage.ImageFormat + RGBA16F = ... # type: QShaderImage.ImageFormat + R32F = ... # type: QShaderImage.ImageFormat + RG32F = ... # type: QShaderImage.ImageFormat + RGBA32F = ... # type: QShaderImage.ImageFormat + RG11B10F = ... # type: QShaderImage.ImageFormat + RGB10A2 = ... # type: QShaderImage.ImageFormat + RGB10A2U = ... # type: QShaderImage.ImageFormat + + class Access(int): + ReadOnly = ... # type: QShaderImage.Access + WriteOnly = ... # type: QShaderImage.Access + ReadWrite = ... # type: QShaderImage.Access + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def formatChanged(self, format: 'QShaderImage.ImageFormat') -> None: ... + def accessChanged(self, access: 'QShaderImage.Access') -> None: ... + def layerChanged(self, layer: int) -> None: ... + def mipLevelChanged(self, mipLevel: int) -> None: ... + def layeredChanged(self, layered: bool) -> None: ... + def textureChanged(self, texture: 'QAbstractTexture') -> None: ... + def setFormat(self, format: 'QShaderImage.ImageFormat') -> None: ... + def setAccess(self, access: 'QShaderImage.Access') -> None: ... + def setLayer(self, layer: int) -> None: ... + def setMipLevel(self, mipLevel: int) -> None: ... + def setLayered(self, layered: bool) -> None: ... + def setTexture(self, texture: 'QAbstractTexture') -> None: ... + def format(self) -> 'QShaderImage.ImageFormat': ... + def access(self) -> 'QShaderImage.Access': ... + def layer(self) -> int: ... + def mipLevel(self) -> int: ... + def layered(self) -> bool: ... + def texture(self) -> 'QAbstractTexture': ... + + +class QShaderProgram(Qt3DCore.QNode): + + class Format(int): + GLSL = ... # type: QShaderProgram.Format + SPIRV = ... # type: QShaderProgram.Format + + class Status(int): + NotReady = ... # type: QShaderProgram.Status + Ready = ... # type: QShaderProgram.Status + Error = ... # type: QShaderProgram.Status + + class ShaderType(int): + Vertex = ... # type: QShaderProgram.ShaderType + Fragment = ... # type: QShaderProgram.ShaderType + TessellationControl = ... # type: QShaderProgram.ShaderType + TessellationEvaluation = ... # type: QShaderProgram.ShaderType + Geometry = ... # type: QShaderProgram.ShaderType + Compute = ... # type: QShaderProgram.ShaderType + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def formatChanged(self, format: 'QShaderProgram.Format') -> None: ... + def format(self) -> 'QShaderProgram.Format': ... + def setFormat(self, format: 'QShaderProgram.Format') -> None: ... + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def statusChanged(self, status: 'QShaderProgram.Status') -> None: ... + def logChanged(self, log: str) -> None: ... + def status(self) -> 'QShaderProgram.Status': ... + def log(self) -> str: ... + def computeShaderCodeChanged(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def fragmentShaderCodeChanged(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def geometryShaderCodeChanged(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def tessellationEvaluationShaderCodeChanged(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def tessellationControlShaderCodeChanged(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def vertexShaderCodeChanged(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def setComputeShaderCode(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def setFragmentShaderCode(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def setGeometryShaderCode(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def setTessellationEvaluationShaderCode(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def setTessellationControlShaderCode(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def setVertexShaderCode(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + @staticmethod + def loadSource(sourceUrl: QtCore.QUrl) -> QtCore.QByteArray: ... + def shaderCode(self, type: 'QShaderProgram.ShaderType') -> QtCore.QByteArray: ... + def setShaderCode(self, type: 'QShaderProgram.ShaderType', shaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def computeShaderCode(self) -> QtCore.QByteArray: ... + def fragmentShaderCode(self) -> QtCore.QByteArray: ... + def geometryShaderCode(self) -> QtCore.QByteArray: ... + def tessellationEvaluationShaderCode(self) -> QtCore.QByteArray: ... + def tessellationControlShaderCode(self) -> QtCore.QByteArray: ... + def vertexShaderCode(self) -> QtCore.QByteArray: ... + + +class QShaderProgramBuilder(Qt3DCore.QNode): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def computeShaderCodeChanged(self, computeShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def fragmentShaderCodeChanged(self, fragmentShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def geometryShaderCodeChanged(self, geometryShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def tessellationEvaluationShaderCodeChanged(self, tessellationEvaluationShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def tessellationControlShaderCodeChanged(self, tessellationControlShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def vertexShaderCodeChanged(self, vertexShaderCode: typing.Union[QtCore.QByteArray, bytes, bytearray]) -> None: ... + def computeShaderCode(self) -> QtCore.QByteArray: ... + def fragmentShaderCode(self) -> QtCore.QByteArray: ... + def geometryShaderCode(self) -> QtCore.QByteArray: ... + def tessellationEvaluationShaderCode(self) -> QtCore.QByteArray: ... + def tessellationControlShaderCode(self) -> QtCore.QByteArray: ... + def vertexShaderCode(self) -> QtCore.QByteArray: ... + def computeShaderGraphChanged(self, computeShaderGraph: QtCore.QUrl) -> None: ... + def fragmentShaderGraphChanged(self, fragmentShaderGraph: QtCore.QUrl) -> None: ... + def geometryShaderGraphChanged(self, geometryShaderGraph: QtCore.QUrl) -> None: ... + def tessellationEvaluationShaderGraphChanged(self, tessellationEvaluationShaderGraph: QtCore.QUrl) -> None: ... + def tessellationControlShaderGraphChanged(self, tessellationControlShaderGraph: QtCore.QUrl) -> None: ... + def vertexShaderGraphChanged(self, vertexShaderGraph: QtCore.QUrl) -> None: ... + def enabledLayersChanged(self, layers: typing.Iterable[str]) -> None: ... + def shaderProgramChanged(self, shaderProgram: 'QShaderProgram') -> None: ... + def setComputeShaderGraph(self, computeShaderGraph: QtCore.QUrl) -> None: ... + def setFragmentShaderGraph(self, fragmentShaderGraph: QtCore.QUrl) -> None: ... + def setGeometryShaderGraph(self, geometryShaderGraph: QtCore.QUrl) -> None: ... + def setTessellationEvaluationShaderGraph(self, tessellationEvaluationShaderGraph: QtCore.QUrl) -> None: ... + def setTessellationControlShaderGraph(self, tessellationControlShaderGraph: QtCore.QUrl) -> None: ... + def setVertexShaderGraph(self, vertexShaderGraph: QtCore.QUrl) -> None: ... + def setEnabledLayers(self, layers: typing.Iterable[str]) -> None: ... + def setShaderProgram(self, program: 'QShaderProgram') -> None: ... + def computeShaderGraph(self) -> QtCore.QUrl: ... + def fragmentShaderGraph(self) -> QtCore.QUrl: ... + def geometryShaderGraph(self) -> QtCore.QUrl: ... + def tessellationEvaluationShaderGraph(self) -> QtCore.QUrl: ... + def tessellationControlShaderGraph(self) -> QtCore.QUrl: ... + def vertexShaderGraph(self) -> QtCore.QUrl: ... + def enabledLayers(self) -> typing.List[str]: ... + def shaderProgram(self) -> 'QShaderProgram': ... + + +class QSortPolicy('QFrameGraphNode'): + + class SortType(int): + StateChangeCost = ... # type: QSortPolicy.SortType + BackToFront = ... # type: QSortPolicy.SortType + Material = ... # type: QSortPolicy.SortType + FrontToBack = ... # type: QSortPolicy.SortType + Texture = ... # type: QSortPolicy.SortType + Uniform = ... # type: QSortPolicy.SortType + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + @typing.overload + def sortTypesChanged(self, sortTypes: typing.Iterable[QSortPolicy.SortType]) -> None: ... + @typing.overload + def sortTypesChanged(self, sortTypes: typing.Iterable[int]) -> None: ... + @typing.overload + def setSortTypes(self, sortTypes: typing.Iterable[QSortPolicy.SortType]) -> None: ... + @typing.overload + def setSortTypes(self, sortTypesInt: typing.Iterable[int]) -> None: ... + def sortTypesInt(self) -> typing.List[int]: ... + def sortTypes(self) -> typing.List[QSortPolicy.SortType]: ... + + +class QSpotLight('QAbstractLight'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def cutOffAngleChanged(self, cutOffAngle: float) -> None: ... + def localDirectionChanged(self, localDirection: QtGui.QVector3D) -> None: ... + def quadraticAttenuationChanged(self, quadraticAttenuation: float) -> None: ... + def linearAttenuationChanged(self, linearAttenuation: float) -> None: ... + def constantAttenuationChanged(self, constantAttenuation: float) -> None: ... + def setCutOffAngle(self, cutOffAngle: float) -> None: ... + def setLocalDirection(self, localDirection: QtGui.QVector3D) -> None: ... + def setQuadraticAttenuation(self, value: float) -> None: ... + def setLinearAttenuation(self, value: float) -> None: ... + def setConstantAttenuation(self, value: float) -> None: ... + def quadraticAttenuation(self) -> float: ... + def linearAttenuation(self) -> float: ... + def constantAttenuation(self) -> float: ... + def cutOffAngle(self) -> float: ... + def localDirection(self) -> QtGui.QVector3D: ... + + +class QStencilMask('QRenderState'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def backOutputMaskChanged(self, backOutputMask: int) -> None: ... + def frontOutputMaskChanged(self, frontOutputMask: int) -> None: ... + def setBackOutputMask(self, backOutputMask: int) -> None: ... + def setFrontOutputMask(self, frontOutputMask: int) -> None: ... + def backOutputMask(self) -> int: ... + def frontOutputMask(self) -> int: ... + + +class QStencilOperation('QRenderState'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def back(self) -> 'QStencilOperationArguments': ... + def front(self) -> 'QStencilOperationArguments': ... + + +class QStencilOperationArguments(QtCore.QObject): + + class Operation(int): + Zero = ... # type: QStencilOperationArguments.Operation + Keep = ... # type: QStencilOperationArguments.Operation + Replace = ... # type: QStencilOperationArguments.Operation + Increment = ... # type: QStencilOperationArguments.Operation + Decrement = ... # type: QStencilOperationArguments.Operation + IncrementWrap = ... # type: QStencilOperationArguments.Operation + DecrementWrap = ... # type: QStencilOperationArguments.Operation + Invert = ... # type: QStencilOperationArguments.Operation + + class FaceMode(int): + Front = ... # type: QStencilOperationArguments.FaceMode + Back = ... # type: QStencilOperationArguments.FaceMode + FrontAndBack = ... # type: QStencilOperationArguments.FaceMode + + def faceModeChanged(self, faceMode: 'QStencilOperationArguments.FaceMode') -> None: ... + def allTestsPassOperationChanged(self, stencilDepthPass: 'QStencilOperationArguments.Operation') -> None: ... + def depthTestFailureOperationChanged(self, depthFail: 'QStencilOperationArguments.Operation') -> None: ... + def stencilTestFailureOperationChanged(self, stencilFail: 'QStencilOperationArguments.Operation') -> None: ... + def setAllTestsPassOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... + def setDepthTestFailureOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... + def setStencilTestFailureOperation(self, operation: 'QStencilOperationArguments.Operation') -> None: ... + def allTestsPassOperation(self) -> 'QStencilOperationArguments.Operation': ... + def depthTestFailureOperation(self) -> 'QStencilOperationArguments.Operation': ... + def stencilTestFailureOperation(self) -> 'QStencilOperationArguments.Operation': ... + def faceMode(self) -> 'QStencilOperationArguments.FaceMode': ... + + +class QStencilTest('QRenderState'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def back(self) -> 'QStencilTestArguments': ... + def front(self) -> 'QStencilTestArguments': ... + + +class QStencilTestArguments(QtCore.QObject): + + class StencilFunction(int): + Never = ... # type: QStencilTestArguments.StencilFunction + Always = ... # type: QStencilTestArguments.StencilFunction + Less = ... # type: QStencilTestArguments.StencilFunction + LessOrEqual = ... # type: QStencilTestArguments.StencilFunction + Equal = ... # type: QStencilTestArguments.StencilFunction + GreaterOrEqual = ... # type: QStencilTestArguments.StencilFunction + Greater = ... # type: QStencilTestArguments.StencilFunction + NotEqual = ... # type: QStencilTestArguments.StencilFunction + + class StencilFaceMode(int): + Front = ... # type: QStencilTestArguments.StencilFaceMode + Back = ... # type: QStencilTestArguments.StencilFaceMode + FrontAndBack = ... # type: QStencilTestArguments.StencilFaceMode + + def faceModeChanged(self, faceMode: 'QStencilTestArguments.StencilFaceMode') -> None: ... + def referenceValueChanged(self, referenceValue: int) -> None: ... + def stencilFunctionChanged(self, stencilFunction: 'QStencilTestArguments.StencilFunction') -> None: ... + def comparisonMaskChanged(self, comparisonMask: int) -> None: ... + def setStencilFunction(self, stencilFunction: 'QStencilTestArguments.StencilFunction') -> None: ... + def setReferenceValue(self, referenceValue: int) -> None: ... + def setComparisonMask(self, comparisonMask: int) -> None: ... + def faceMode(self) -> 'QStencilTestArguments.StencilFaceMode': ... + def stencilFunction(self) -> 'QStencilTestArguments.StencilFunction': ... + def referenceValue(self) -> int: ... + def comparisonMask(self) -> int: ... + + +class QSubtreeEnabler('QFrameGraphNode'): + + class Enablement(int): + Persistent = ... # type: QSubtreeEnabler.Enablement + SingleShot = ... # type: QSubtreeEnabler.Enablement + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def enablementChanged(self, enablement: 'QSubtreeEnabler.Enablement') -> None: ... + def requestUpdate(self) -> None: ... + def setEnablement(self, enablement: 'QSubtreeEnabler.Enablement') -> None: ... + def enablement(self) -> 'QSubtreeEnabler.Enablement': ... + + +class QTechnique(Qt3DCore.QNode): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def graphicsApiFilter(self) -> 'QGraphicsApiFilter': ... + def renderPasses(self) -> typing.List['QRenderPass']: ... + def removeRenderPass(self, pass_: 'QRenderPass') -> None: ... + def addRenderPass(self, pass_: 'QRenderPass') -> None: ... + def parameters(self) -> typing.List['QParameter']: ... + def removeParameter(self, p: 'QParameter') -> None: ... + def addParameter(self, p: 'QParameter') -> None: ... + def filterKeys(self) -> typing.List['QFilterKey']: ... + def removeFilterKey(self, filterKey: 'QFilterKey') -> None: ... + def addFilterKey(self, filterKey: 'QFilterKey') -> None: ... + + +class QTechniqueFilter('QFrameGraphNode'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def parameters(self) -> typing.List['QParameter']: ... + def removeParameter(self, p: 'QParameter') -> None: ... + def addParameter(self, p: 'QParameter') -> None: ... + def removeMatch(self, filterKey: 'QFilterKey') -> None: ... + def addMatch(self, filterKey: 'QFilterKey') -> None: ... + def matchAll(self) -> typing.List['QFilterKey']: ... + + +class QTexture1D('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QTexture1DArray('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QTexture2D('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QTexture2DArray('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QTexture3D('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QTextureCubeMap('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QTextureCubeMapArray('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QTexture2DMultisample('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QTexture2DMultisampleArray('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QTextureRectangle('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QTextureBuffer('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + +class QTextureLoader('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def mirroredChanged(self, mirrored: bool) -> None: ... + def setMirrored(self, mirrored: bool) -> None: ... + def isMirrored(self) -> bool: ... + def sourceChanged(self, source: QtCore.QUrl) -> None: ... + def setSource(self, source: QtCore.QUrl) -> None: ... + def source(self) -> QtCore.QUrl: ... + + +class QSharedGLTexture('QAbstractTexture'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def textureIdChanged(self, textureId: int) -> None: ... + def setTextureId(self, id: int) -> None: ... + def textureId(self) -> int: ... + + +class QTextureData(sip.simplewrapper): + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, a0: 'QTextureData') -> None: ... + + def addImageData(self, imageData: 'QTextureImageData') -> None: ... + def imageData(self) -> typing.List[QTextureImageData]: ... + def setComparisonMode(self, comparisonMode: 'QAbstractTexture.ComparisonMode') -> None: ... + def comparisonMode(self) -> 'QAbstractTexture.ComparisonMode': ... + def setComparisonFunction(self, comparisonFunction: 'QAbstractTexture.ComparisonFunction') -> None: ... + def comparisonFunction(self) -> 'QAbstractTexture.ComparisonFunction': ... + def setWrapModeZ(self, wrapModeZ: 'QTextureWrapMode.WrapMode') -> None: ... + def wrapModeZ(self) -> 'QTextureWrapMode.WrapMode': ... + def setWrapModeY(self, wrapModeY: 'QTextureWrapMode.WrapMode') -> None: ... + def wrapModeY(self) -> 'QTextureWrapMode.WrapMode': ... + def setWrapModeX(self, wrapModeX: 'QTextureWrapMode.WrapMode') -> None: ... + def wrapModeX(self) -> 'QTextureWrapMode.WrapMode': ... + def setMagnificationFilter(self, filter: 'QAbstractTexture.Filter') -> None: ... + def magnificationFilter(self) -> 'QAbstractTexture.Filter': ... + def setMinificationFilter(self, filter: 'QAbstractTexture.Filter') -> None: ... + def minificationFilter(self) -> 'QAbstractTexture.Filter': ... + def setMaximumAnisotropy(self, maximumAnisotropy: float) -> None: ... + def maximumAnisotropy(self) -> float: ... + def setAutoMipMapGenerationEnabled(self, isAutoMipMapGenerationEnabled: bool) -> None: ... + def isAutoMipMapGenerationEnabled(self) -> bool: ... + def setLayers(self, layers: int) -> None: ... + def layers(self) -> int: ... + def setDepth(self, depth: int) -> None: ... + def depth(self) -> int: ... + def setHeight(self, height: int) -> None: ... + def height(self) -> int: ... + def setWidth(self, width: int) -> None: ... + def width(self) -> int: ... + def setFormat(self, a0: 'QAbstractTexture.TextureFormat') -> None: ... + def format(self) -> 'QAbstractTexture.TextureFormat': ... + def setTarget(self, target: 'QAbstractTexture.Target') -> None: ... + def target(self) -> 'QAbstractTexture.Target': ... + + +class QTextureDataUpdate(sip.simplewrapper): + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, other: 'QTextureDataUpdate') -> None: ... + + def setData(self, data: 'QTextureImageData') -> None: ... + def setFace(self, face: 'QAbstractTexture.CubeMapFace') -> None: ... + def setMipLevel(self, mipLevel: int) -> None: ... + def setLayer(self, layer: int) -> None: ... + def setZ(self, z: int) -> None: ... + def setY(self, y: int) -> None: ... + def setX(self, x: int) -> None: ... + def data(self) -> 'QTextureImageData': ... + def face(self) -> 'QAbstractTexture.CubeMapFace': ... + def mipLevel(self) -> int: ... + def layer(self) -> int: ... + def z(self) -> int: ... + def y(self) -> int: ... + def x(self) -> int: ... + def swap(self, other: 'QTextureDataUpdate') -> None: ... + + +class QTextureGenerator('QAbstractFunctor'): + + def __call__(self) -> 'QTextureData': ... + + +class QTextureImage('QAbstractTextureImage'): + + class Status(int): + None_ = ... # type: QTextureImage.Status + Loading = ... # type: QTextureImage.Status + Ready = ... # type: QTextureImage.Status + Error = ... # type: QTextureImage.Status + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def mirroredChanged(self, mirrored: bool) -> None: ... + def setMirrored(self, mirrored: bool) -> None: ... + def isMirrored(self) -> bool: ... + def setStatus(self, status: 'QTextureImage.Status') -> None: ... + def sceneChangeEvent(self, change: Qt3DCore.QSceneChange) -> None: ... + def statusChanged(self, status: 'QTextureImage.Status') -> None: ... + def sourceChanged(self, source: QtCore.QUrl) -> None: ... + def setSource(self, source: QtCore.QUrl) -> None: ... + def status(self) -> 'QTextureImage.Status': ... + def source(self) -> QtCore.QUrl: ... + + +class QTextureImageData(sip.simplewrapper): + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, a0: 'QTextureImageData') -> None: ... + + def data(self, layer: int = ..., face: int = ..., mipmapLevel: int = ...) -> QtCore.QByteArray: ... + def setData(self, data: typing.Union[QtCore.QByteArray, bytes, bytearray], blockSize: int, isCompressed: bool = ...) -> None: ... + def setImage(self, a0: QtGui.QImage) -> None: ... + def setPixelType(self, pixelType: QtGui.QOpenGLTexture.PixelType) -> None: ... + def setPixelFormat(self, pixelFormat: QtGui.QOpenGLTexture.PixelFormat) -> None: ... + def setFormat(self, format: QtGui.QOpenGLTexture.TextureFormat) -> None: ... + def setTarget(self, target: QtGui.QOpenGLTexture.Target) -> None: ... + def pixelType(self) -> QtGui.QOpenGLTexture.PixelType: ... + def pixelFormat(self) -> QtGui.QOpenGLTexture.PixelFormat: ... + def format(self) -> QtGui.QOpenGLTexture.TextureFormat: ... + def target(self) -> QtGui.QOpenGLTexture.Target: ... + def setFaces(self, faces: int) -> None: ... + def setMipLevels(self, mipLevels: int) -> None: ... + def setLayers(self, layers: int) -> None: ... + def setDepth(self, depth: int) -> None: ... + def setHeight(self, height: int) -> None: ... + def setWidth(self, width: int) -> None: ... + def faces(self) -> int: ... + def mipLevels(self) -> int: ... + def layers(self) -> int: ... + def depth(self) -> int: ... + def height(self) -> int: ... + def width(self) -> int: ... + def isCompressed(self) -> bool: ... + def cleanup(self) -> None: ... + + +class QTextureImageDataGenerator('QAbstractFunctor'): + + def __call__(self) -> 'QTextureImageData': ... + + +class QTextureWrapMode(QtCore.QObject): + + class WrapMode(int): + Repeat = ... # type: QTextureWrapMode.WrapMode + MirroredRepeat = ... # type: QTextureWrapMode.WrapMode + ClampToEdge = ... # type: QTextureWrapMode.WrapMode + ClampToBorder = ... # type: QTextureWrapMode.WrapMode + + @typing.overload + def __init__(self, wrapMode: 'QTextureWrapMode.WrapMode' = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, x: 'QTextureWrapMode.WrapMode', y: 'QTextureWrapMode.WrapMode', z: 'QTextureWrapMode.WrapMode', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def zChanged(self, z: 'QTextureWrapMode.WrapMode') -> None: ... + def yChanged(self, y: 'QTextureWrapMode.WrapMode') -> None: ... + def xChanged(self, x: 'QTextureWrapMode.WrapMode') -> None: ... + def setZ(self, z: 'QTextureWrapMode.WrapMode') -> None: ... + def setY(self, y: 'QTextureWrapMode.WrapMode') -> None: ... + def setX(self, x: 'QTextureWrapMode.WrapMode') -> None: ... + def z(self) -> 'QTextureWrapMode.WrapMode': ... + def y(self) -> 'QTextureWrapMode.WrapMode': ... + def x(self) -> 'QTextureWrapMode.WrapMode': ... + + +class QViewport('QFrameGraphNode'): + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def gammaChanged(self, gamma: float) -> None: ... + def setGamma(self, gamma: float) -> None: ... + def gamma(self) -> float: ... + def normalizedRectChanged(self, normalizedRect: QtCore.QRectF) -> None: ... + def setNormalizedRect(self, normalizedRect: QtCore.QRectF) -> None: ... + def normalizedRect(self) -> QtCore.QRectF: ... + + +class QWaitFence('QFrameGraphNode'): + + class HandleType(int): + NoHandle = ... # type: QWaitFence.HandleType + OpenGLFenceId = ... # type: QWaitFence.HandleType + + def __init__(self, parent: typing.Optional[Qt3DCore.QNode] = ...) -> None: ... + + def handleChanged(self, handle: typing.Any) -> None: ... + def handleTypeChanged(self, handleType: 'QWaitFence.HandleType') -> None: ... + def timeoutChanged(self, timeoutChanged: int) -> None: ... + def waitOnCPUChanged(self, waitOnCPU: bool) -> None: ... + def setTimeout(self, timeout: int) -> None: ... + def timeout(self) -> int: ... + def setWaitOnCPU(self, waitOnCPU: bool) -> None: ... + def waitOnCPU(self) -> bool: ... + def handle(self) -> typing.Any: ... + def handleType(self) -> 'QWaitFence.HandleType': ... + def setHandle(self, handle: typing.Any) -> None: ... + def setHandleType(self, type: 'QWaitFence.HandleType') -> None: ... diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index 7a59acc3..e9e00ba1 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtBluetooth module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtChart.pyi b/PyQt5-stubs/QtChart.pyi index 788a739b..6a3985cb 100644 --- a/PyQt5-stubs/QtChart.pyi +++ b/PyQt5-stubs/QtChart.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtChart module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -41,1414 +41,1459 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], typing.Sequence[float], PyQt5.sip.Buffer, int, None] -class QtCharts(PyQt5.sip.simplewrapper): - - class QAbstractAxis(QtCore.QObject): - - class AxisType(int): - AxisTypeNoAxis = ... # type: QAbstractAxis.AxisType - AxisTypeValue = ... # type: QAbstractAxis.AxisType - AxisTypeBarCategory = ... # type: QAbstractAxis.AxisType - AxisTypeCategory = ... # type: QAbstractAxis.AxisType - AxisTypeDateTime = ... # type: QAbstractAxis.AxisType - AxisTypeLogValue = ... # type: QAbstractAxis.AxisType - - class AxisTypes(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, f: typing.Union['QAbstractAxis.AxisTypes', 'QAbstractAxis.AxisType']) -> None: ... - @typing.overload - def __init__(self, a0: 'QAbstractAxis.AxisTypes') -> None: ... - - def __hash__(self) -> int: ... - def __bool__(self) -> int: ... - def __invert__(self) -> 'QAbstractAxis.AxisTypes': ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... - - def labelsEditableChanged(self, editable: bool) -> None: ... - def labelsEditable(self) -> bool: ... - def setLabelsEditable(self, editable: bool = ...) -> None: ... - def reverseChanged(self, reverse: bool) -> None: ... - def minorGridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def gridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def minorGridLinePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def minorGridVisibleChanged(self, visible: bool) -> None: ... - def isReverse(self) -> bool: ... - def setReverse(self, reverse: bool = ...) -> None: ... - def minorGridLineColor(self) -> QtGui.QColor: ... - def setMinorGridLineColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def gridLineColor(self) -> QtGui.QColor: ... - def setGridLineColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def minorGridLinePen(self) -> QtGui.QPen: ... - def setMinorGridLinePen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def setMinorGridLineVisible(self, visible: bool = ...) -> None: ... - def isMinorGridLineVisible(self) -> bool: ... - def shadesBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesPenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def titleFontChanged(self, font: QtGui.QFont) -> None: ... - def titleVisibleChanged(self, visible: bool) -> None: ... - def titleBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def titleTextChanged(self, title: str) -> None: ... - def gridLinePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def labelsAngleChanged(self, angle: int) -> None: ... - def labelsFontChanged(self, pen: QtGui.QFont) -> None: ... - def labelsBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def linePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def alignment(self) -> QtCore.Qt.Alignment: ... - def titleText(self) -> str: ... - def setTitleText(self, title: str) -> None: ... - def titleFont(self) -> QtGui.QFont: ... - def setTitleFont(self, font: QtGui.QFont) -> None: ... - def titleBrush(self) -> QtGui.QBrush: ... - def setTitleBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def setTitleVisible(self, visible: bool = ...) -> None: ... - def isTitleVisible(self) -> bool: ... - def shadesBorderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesVisibleChanged(self, visible: bool) -> None: ... - def labelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def gridVisibleChanged(self, visible: bool) -> None: ... - def labelsVisibleChanged(self, visible: bool) -> None: ... - def lineVisibleChanged(self, visible: bool) -> None: ... - def visibleChanged(self, visible: bool) -> None: ... - def orientation(self) -> QtCore.Qt.Orientation: ... - def hide(self) -> None: ... - def show(self) -> None: ... - def setRange(self, min: typing.Any, max: typing.Any) -> None: ... - def setMax(self, max: typing.Any) -> None: ... - def setMin(self, min: typing.Any) -> None: ... - def shadesBorderColor(self) -> QtGui.QColor: ... - def setShadesBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesColor(self) -> QtGui.QColor: ... - def setShadesColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesBrush(self) -> QtGui.QBrush: ... - def setShadesBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def shadesPen(self) -> QtGui.QPen: ... - def setShadesPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def setShadesVisible(self, visible: bool = ...) -> None: ... - def shadesVisible(self) -> bool: ... - def labelsColor(self) -> QtGui.QColor: ... - def setLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def labelsAngle(self) -> int: ... - def setLabelsAngle(self, angle: int) -> None: ... - def labelsFont(self) -> QtGui.QFont: ... - def setLabelsFont(self, font: QtGui.QFont) -> None: ... - def labelsBrush(self) -> QtGui.QBrush: ... - def setLabelsBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def setLabelsVisible(self, visible: bool = ...) -> None: ... - def labelsVisible(self) -> bool: ... - def gridLinePen(self) -> QtGui.QPen: ... - def setGridLinePen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def setGridLineVisible(self, visible: bool = ...) -> None: ... - def isGridLineVisible(self) -> bool: ... - def linePenColor(self) -> QtGui.QColor: ... - def setLinePenColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def linePen(self) -> QtGui.QPen: ... - def setLinePen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def setLineVisible(self, visible: bool = ...) -> None: ... - def isLineVisible(self) -> bool: ... - def setVisible(self, visible: bool = ...) -> None: ... - def isVisible(self) -> bool: ... - def type(self) -> 'QAbstractAxis.AxisType': ... - - class QAbstractSeries(QtCore.QObject): - - class SeriesType(int): - SeriesTypeLine = ... # type: QAbstractSeries.SeriesType - SeriesTypeArea = ... # type: QAbstractSeries.SeriesType - SeriesTypeBar = ... # type: QAbstractSeries.SeriesType - SeriesTypeStackedBar = ... # type: QAbstractSeries.SeriesType - SeriesTypePercentBar = ... # type: QAbstractSeries.SeriesType - SeriesTypePie = ... # type: QAbstractSeries.SeriesType - SeriesTypeScatter = ... # type: QAbstractSeries.SeriesType - SeriesTypeSpline = ... # type: QAbstractSeries.SeriesType - SeriesTypeHorizontalBar = ... # type: QAbstractSeries.SeriesType - SeriesTypeHorizontalStackedBar = ... # type: QAbstractSeries.SeriesType - SeriesTypeHorizontalPercentBar = ... # type: QAbstractSeries.SeriesType - SeriesTypeBoxPlot = ... # type: QAbstractSeries.SeriesType - SeriesTypeCandlestick = ... # type: QAbstractSeries.SeriesType - - def useOpenGLChanged(self) -> None: ... - def useOpenGL(self) -> bool: ... - def setUseOpenGL(self, enable: bool = ...) -> None: ... - def opacityChanged(self) -> None: ... - def attachedAxes(self) -> typing.List['QAbstractAxis']: ... - def detachAxis(self, axis: 'QAbstractAxis') -> bool: ... - def attachAxis(self, axis: 'QAbstractAxis') -> bool: ... - def setOpacity(self, opacity: float) -> None: ... - def opacity(self) -> float: ... - def visibleChanged(self) -> None: ... - def nameChanged(self) -> None: ... - def hide(self) -> None: ... - def show(self) -> None: ... - def chart(self) -> 'QChart': ... - def isVisible(self) -> bool: ... - def setVisible(self, visible: bool = ...) -> None: ... - def name(self) -> str: ... - def setName(self, name: str) -> None: ... - def type(self) -> 'QAbstractSeries.SeriesType': ... - - class QAbstractBarSeries('QAbstractSeries'): - - class LabelsPosition(int): - LabelsCenter = ... # type: QAbstractBarSeries.LabelsPosition - LabelsInsideEnd = ... # type: QAbstractBarSeries.LabelsPosition - LabelsInsideBase = ... # type: QAbstractBarSeries.LabelsPosition - LabelsOutsideEnd = ... # type: QAbstractBarSeries.LabelsPosition - - def labelsPrecisionChanged(self, precision: int) -> None: ... - def labelsPrecision(self) -> int: ... - def setLabelsPrecision(self, precision: int) -> None: ... - def labelsAngleChanged(self, angle: float) -> None: ... - def labelsAngle(self) -> float: ... - def setLabelsAngle(self, angle: float) -> None: ... - def doubleClicked(self, index: int, barset: 'QBarSet') -> None: ... - def released(self, index: int, barset: 'QBarSet') -> None: ... - def pressed(self, index: int, barset: 'QBarSet') -> None: ... - def labelsPositionChanged(self, position: 'QAbstractBarSeries.LabelsPosition') -> None: ... - def labelsFormatChanged(self, format: str) -> None: ... - def labelsPosition(self) -> 'QAbstractBarSeries.LabelsPosition': ... - def setLabelsPosition(self, position: 'QAbstractBarSeries.LabelsPosition') -> None: ... - def labelsFormat(self) -> str: ... - def setLabelsFormat(self, format: str) -> None: ... - def barsetsRemoved(self, sets: typing.Iterable['QBarSet']) -> None: ... - def barsetsAdded(self, sets: typing.Iterable['QBarSet']) -> None: ... - def labelsVisibleChanged(self) -> None: ... - def countChanged(self) -> None: ... - def hovered(self, status: bool, index: int, barset: 'QBarSet') -> None: ... - def clicked(self, index: int, barset: 'QBarSet') -> None: ... - def take(self, set: 'QBarSet') -> bool: ... - def isLabelsVisible(self) -> bool: ... - def setLabelsVisible(self, visible: bool = ...) -> None: ... - def clear(self) -> None: ... - def barSets(self) -> typing.List['QBarSet']: ... - def __len__(self) -> int: ... - def count(self) -> int: ... - def insert(self, index: int, set: 'QBarSet') -> bool: ... - def remove(self, set: 'QBarSet') -> bool: ... - @typing.overload - def append(self, set: 'QBarSet') -> bool: ... - @typing.overload - def append(self, sets: typing.Iterable['QBarSet']) -> bool: ... - def barWidth(self) -> float: ... - def setBarWidth(self, width: float) -> None: ... - - class QLegendMarker(QtCore.QObject): - - class LegendMarkerType(int): - LegendMarkerTypeArea = ... # type: QLegendMarker.LegendMarkerType - LegendMarkerTypeBar = ... # type: QLegendMarker.LegendMarkerType - LegendMarkerTypePie = ... # type: QLegendMarker.LegendMarkerType - LegendMarkerTypeXY = ... # type: QLegendMarker.LegendMarkerType - LegendMarkerTypeBoxPlot = ... # type: QLegendMarker.LegendMarkerType - LegendMarkerTypeCandlestick = ... # type: QLegendMarker.LegendMarkerType - - def shapeChanged(self) -> None: ... - def setShape(self, shape: 'QLegend.MarkerShape') -> None: ... - def shape(self) -> 'QLegend.MarkerShape': ... - def visibleChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def fontChanged(self) -> None: ... - def labelBrushChanged(self) -> None: ... - def labelChanged(self) -> None: ... - def hovered(self, status: bool) -> None: ... - def clicked(self) -> None: ... - def series(self) -> 'QAbstractSeries': ... - def setVisible(self, visible: bool) -> None: ... - def isVisible(self) -> bool: ... - def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def brush(self) -> QtGui.QBrush: ... - def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pen(self) -> QtGui.QPen: ... - def setFont(self, font: QtGui.QFont) -> None: ... - def font(self) -> QtGui.QFont: ... - def setLabelBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def labelBrush(self) -> QtGui.QBrush: ... - def setLabel(self, label: str) -> None: ... - def label(self) -> str: ... - def type(self) -> 'QLegendMarker.LegendMarkerType': ... - - class QAreaLegendMarker('QLegendMarker'): - - def __init__(self, series: 'QAreaSeries', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def series(self) -> 'QAreaSeries': ... - def type(self) -> 'QLegendMarker.LegendMarkerType': ... - - class QAreaSeries('QAbstractSeries'): - - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, upperSeries: 'QLineSeries', lowerSeries: typing.Optional['QLineSeries'] = ...) -> None: ... - - def pointLabelsClippingChanged(self, clipping: bool) -> None: ... - def pointLabelsClipping(self) -> bool: ... - def setPointLabelsClipping(self, enable: bool = ...) -> None: ... - def doubleClicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def released(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pressed(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pointLabelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointLabelsFontChanged(self, font: QtGui.QFont) -> None: ... - def pointLabelsVisibilityChanged(self, visible: bool) -> None: ... - def pointLabelsFormatChanged(self, format: str) -> None: ... - def pointLabelsColor(self) -> QtGui.QColor: ... - def setPointLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointLabelsFont(self) -> QtGui.QFont: ... - def setPointLabelsFont(self, font: QtGui.QFont) -> None: ... - def pointLabelsVisible(self) -> bool: ... - def setPointLabelsVisible(self, visible: bool = ...) -> None: ... - def pointLabelsFormat(self) -> str: ... - def setPointLabelsFormat(self, format: str) -> None: ... - def hovered(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint], state: bool) -> None: ... - def selected(self) -> None: ... - def clicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def borderColor(self) -> QtGui.QColor: ... - def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def color(self) -> QtGui.QColor: ... - def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointsVisible(self) -> bool: ... - def setPointsVisible(self, visible: bool = ...) -> None: ... - def brush(self) -> QtGui.QBrush: ... - def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pen(self) -> QtGui.QPen: ... - def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def lowerSeries(self) -> 'QLineSeries': ... - def setLowerSeries(self, series: 'QLineSeries') -> None: ... - def upperSeries(self) -> 'QLineSeries': ... - def setUpperSeries(self, series: 'QLineSeries') -> None: ... - def type(self) -> 'QAbstractSeries.SeriesType': ... - - class QBarCategoryAxis('QAbstractAxis'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def countChanged(self) -> None: ... - def rangeChanged(self, min: str, max: str) -> None: ... - def maxChanged(self, max: str) -> None: ... - def minChanged(self, min: str) -> None: ... - def categoriesChanged(self) -> None: ... - def setRange(self, minCategory: str, maxCategory: str) -> None: ... - def max(self) -> str: ... - def setMax(self, maxCategory: str) -> None: ... - def min(self) -> str: ... - def setMin(self, minCategory: str) -> None: ... - def at(self, index: int) -> str: ... - def __len__(self) -> int: ... - def count(self) -> int: ... - def categories(self) -> typing.List[str]: ... - def setCategories(self, categories: typing.Iterable[str]) -> None: ... - def clear(self) -> None: ... - def replace(self, oldCategory: str, newCategory: str) -> None: ... - def insert(self, index: int, category: str) -> None: ... - def remove(self, category: str) -> None: ... - @typing.overload - def append(self, categories: typing.Iterable[str]) -> None: ... - @typing.overload - def append(self, category: str) -> None: ... - def type(self) -> 'QAbstractAxis.AxisType': ... - - class QBarLegendMarker('QLegendMarker'): - - def __init__(self, series: 'QAbstractBarSeries', barset: 'QBarSet', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def barset(self) -> 'QBarSet': ... - def series(self) -> 'QAbstractBarSeries': ... - def type(self) -> 'QLegendMarker.LegendMarkerType': ... - - class QBarSeries('QAbstractBarSeries'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def type(self) -> 'QAbstractSeries.SeriesType': ... - - class QBarSet(QtCore.QObject): - - def __init__(self, name: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def doubleClicked(self, index: int) -> None: ... - def released(self, index: int) -> None: ... - def pressed(self, index: int) -> None: ... - def labelColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def hovered(self, status: bool, index: int) -> None: ... - def clicked(self, index: int) -> None: ... - def valueChanged(self, index: int) -> None: ... - def valuesRemoved(self, index: int, count: int) -> None: ... - def valuesAdded(self, index: int, count: int) -> None: ... - def labelFontChanged(self) -> None: ... - def labelBrushChanged(self) -> None: ... - def labelChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def labelColor(self) -> QtGui.QColor: ... - def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def borderColor(self) -> QtGui.QColor: ... - def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def color(self) -> QtGui.QColor: ... - def __getitem__(self, index: int) -> float: ... - def at(self, index: int) -> float: ... - def remove(self, index: int, count: int = ...) -> None: ... - def label(self) -> str: ... - def setLabel(self, label: str) -> None: ... - def labelFont(self) -> QtGui.QFont: ... - def setLabelFont(self, font: QtGui.QFont) -> None: ... - def labelBrush(self) -> QtGui.QBrush: ... - def setLabelBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def brush(self) -> QtGui.QBrush: ... - def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pen(self) -> QtGui.QPen: ... - def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def sum(self) -> float: ... - def __len__(self) -> int: ... - def count(self) -> int: ... - def replace(self, index: int, value: float) -> None: ... - def insert(self, index: int, value: float) -> None: ... - @typing.overload - def append(self, value: float) -> None: ... - @typing.overload - def append(self, values: typing.Iterable[float]) -> None: ... - - class QBoxPlotLegendMarker('QLegendMarker'): - - def __init__(self, series: 'QBoxPlotSeries', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def series(self) -> 'QBoxPlotSeries': ... - def type(self) -> 'QLegendMarker.LegendMarkerType': ... - - class QBoxPlotSeries('QAbstractSeries'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def doubleClicked(self, boxset: 'QBoxSet') -> None: ... - def released(self, boxset: 'QBoxSet') -> None: ... - def pressed(self, boxset: 'QBoxSet') -> None: ... - def boxsetsRemoved(self, sets: typing.Iterable['QBoxSet']) -> None: ... - def boxsetsAdded(self, sets: typing.Iterable['QBoxSet']) -> None: ... - def boxWidthChanged(self) -> None: ... - def boxOutlineVisibilityChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def countChanged(self) -> None: ... - def hovered(self, status: bool, boxset: 'QBoxSet') -> None: ... - def clicked(self, boxset: 'QBoxSet') -> None: ... - def pen(self) -> QtGui.QPen: ... - def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def brush(self) -> QtGui.QBrush: ... - def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def boxWidth(self) -> float: ... - def setBoxWidth(self, width: float) -> None: ... - def boxOutlineVisible(self) -> bool: ... - def setBoxOutlineVisible(self, visible: bool) -> None: ... - def type(self) -> 'QAbstractSeries.SeriesType': ... - def clear(self) -> None: ... - def boxSets(self) -> typing.List['QBoxSet']: ... - def __len__(self) -> int: ... - def count(self) -> int: ... - def insert(self, index: int, box: 'QBoxSet') -> bool: ... - def take(self, box: 'QBoxSet') -> bool: ... - def remove(self, box: 'QBoxSet') -> bool: ... - @typing.overload - def append(self, box: 'QBoxSet') -> bool: ... - @typing.overload - def append(self, boxes: typing.Iterable['QBoxSet']) -> bool: ... +class QAbstractAxis(QtCore.QObject): - class QBoxSet(QtCore.QObject): + class AxisType(int): + AxisTypeNoAxis = ... # type: QAbstractAxis.AxisType + AxisTypeValue = ... # type: QAbstractAxis.AxisType + AxisTypeBarCategory = ... # type: QAbstractAxis.AxisType + AxisTypeCategory = ... # type: QAbstractAxis.AxisType + AxisTypeDateTime = ... # type: QAbstractAxis.AxisType + AxisTypeLogValue = ... # type: QAbstractAxis.AxisType - class ValuePositions(int): - LowerExtreme = ... # type: QBoxSet.ValuePositions - LowerQuartile = ... # type: QBoxSet.ValuePositions - Median = ... # type: QBoxSet.ValuePositions - UpperQuartile = ... # type: QBoxSet.ValuePositions - UpperExtreme = ... # type: QBoxSet.ValuePositions + class AxisTypes(sip.simplewrapper): @typing.overload - def __init__(self, label: str = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, le: float, lq: float, m: float, uq: float, ue: float, label: str = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def doubleClicked(self) -> None: ... - def released(self) -> None: ... - def pressed(self) -> None: ... - def cleared(self) -> None: ... - def valueChanged(self, index: int) -> None: ... - def valuesChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def hovered(self, status: bool) -> None: ... - def clicked(self) -> None: ... - def brush(self) -> QtGui.QBrush: ... - def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pen(self) -> QtGui.QPen: ... - def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def __len__(self) -> int: ... - def count(self) -> int: ... - def __getitem__(self, index: int) -> float: ... - def at(self, index: int) -> float: ... - def setValue(self, index: int, value: float) -> None: ... - def label(self) -> str: ... - def setLabel(self, label: str) -> None: ... - def clear(self) -> None: ... - @typing.overload - def append(self, value: float) -> None: ... - @typing.overload - def append(self, values: typing.Iterable[float]) -> None: ... - - class QCandlestickLegendMarker('QLegendMarker'): - - def __init__(self, series: 'QCandlestickSeries', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def series(self) -> 'QCandlestickSeries': ... - def type(self) -> 'QLegendMarker.LegendMarkerType': ... - - class QCandlestickModelMapper(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def lastSetSection(self) -> int: ... - def setLastSetSection(self, lastSetSection: int) -> None: ... - def firstSetSection(self) -> int: ... - def setFirstSetSection(self, firstSetSection: int) -> None: ... - def close(self) -> int: ... - def setClose(self, close: int) -> None: ... - def low(self) -> int: ... - def setLow(self, low: int) -> None: ... - def high(self) -> int: ... - def setHigh(self, high: int) -> None: ... - def open(self) -> int: ... - def setOpen(self, open: int) -> None: ... - def timestamp(self) -> int: ... - def setTimestamp(self, timestamp: int) -> None: ... - def seriesReplaced(self) -> None: ... - def modelReplaced(self) -> None: ... - def orientation(self) -> QtCore.Qt.Orientation: ... - def series(self) -> 'QCandlestickSeries': ... - def setSeries(self, series: 'QCandlestickSeries') -> None: ... - def model(self) -> QtCore.QAbstractItemModel: ... - def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... - - class QCandlestickSeries('QAbstractSeries'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def penChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def decreasingColorChanged(self) -> None: ... - def increasingColorChanged(self) -> None: ... - def capsVisibilityChanged(self) -> None: ... - def capsWidthChanged(self) -> None: ... - def bodyOutlineVisibilityChanged(self) -> None: ... - def bodyWidthChanged(self) -> None: ... - def minimumColumnWidthChanged(self) -> None: ... - def maximumColumnWidthChanged(self) -> None: ... - def countChanged(self) -> None: ... - def candlestickSetsRemoved(self, sets: typing.Iterable['QCandlestickSet']) -> None: ... - def candlestickSetsAdded(self, sets: typing.Iterable['QCandlestickSet']) -> None: ... - def doubleClicked(self, set: 'QCandlestickSet') -> None: ... - def released(self, set: 'QCandlestickSet') -> None: ... - def pressed(self, set: 'QCandlestickSet') -> None: ... - def hovered(self, status: bool, set: 'QCandlestickSet') -> None: ... - def clicked(self, set: 'QCandlestickSet') -> None: ... - def pen(self) -> QtGui.QPen: ... - def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def brush(self) -> QtGui.QBrush: ... - def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def decreasingColor(self) -> QtGui.QColor: ... - def setDecreasingColor(self, decreasingColor: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def increasingColor(self) -> QtGui.QColor: ... - def setIncreasingColor(self, increasingColor: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def capsVisible(self) -> bool: ... - def setCapsVisible(self, capsVisible: bool) -> None: ... - def capsWidth(self) -> float: ... - def setCapsWidth(self, capsWidth: float) -> None: ... - def bodyOutlineVisible(self) -> bool: ... - def setBodyOutlineVisible(self, bodyOutlineVisible: bool) -> None: ... - def bodyWidth(self) -> float: ... - def setBodyWidth(self, bodyWidth: float) -> None: ... - def minimumColumnWidth(self) -> float: ... - def setMinimumColumnWidth(self, minimumColumnWidth: float) -> None: ... - def maximumColumnWidth(self) -> float: ... - def setMaximumColumnWidth(self, maximumColumnWidth: float) -> None: ... - def type(self) -> 'QAbstractSeries.SeriesType': ... - def __len__(self) -> int: ... - def count(self) -> int: ... - def sets(self) -> typing.List['QCandlestickSet']: ... - def clear(self) -> None: ... - def take(self, set: 'QCandlestickSet') -> bool: ... - def insert(self, index: int, set: 'QCandlestickSet') -> bool: ... - @typing.overload - def remove(self, set: 'QCandlestickSet') -> bool: ... - @typing.overload - def remove(self, sets: typing.Iterable['QCandlestickSet']) -> bool: ... + def __init__(self) -> None: ... @typing.overload - def append(self, set: 'QCandlestickSet') -> bool: ... + def __init__(self, f: typing.Union['QAbstractAxis.AxisTypes', 'QAbstractAxis.AxisType']) -> None: ... @typing.overload - def append(self, sets: typing.Iterable['QCandlestickSet']) -> bool: ... + def __init__(self, a0: 'QAbstractAxis.AxisTypes') -> None: ... + + def __hash__(self) -> int: ... + def __bool__(self) -> int: ... + def __invert__(self) -> 'QAbstractAxis.AxisTypes': ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + + def labelsEditableChanged(self, editable: bool) -> None: ... + def labelsEditable(self) -> bool: ... + def setLabelsEditable(self, editable: bool = ...) -> None: ... + def reverseChanged(self, reverse: bool) -> None: ... + def minorGridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def gridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def minorGridLinePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def minorGridVisibleChanged(self, visible: bool) -> None: ... + def isReverse(self) -> bool: ... + def setReverse(self, reverse: bool = ...) -> None: ... + def minorGridLineColor(self) -> QtGui.QColor: ... + def setMinorGridLineColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def gridLineColor(self) -> QtGui.QColor: ... + def setGridLineColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def minorGridLinePen(self) -> QtGui.QPen: ... + def setMinorGridLinePen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def setMinorGridLineVisible(self, visible: bool = ...) -> None: ... + def isMinorGridLineVisible(self) -> bool: ... + def shadesBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def shadesPenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def titleFontChanged(self, font: QtGui.QFont) -> None: ... + def titleVisibleChanged(self, visible: bool) -> None: ... + def titleBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def titleTextChanged(self, title: str) -> None: ... + def gridLinePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def labelsAngleChanged(self, angle: int) -> None: ... + def labelsFontChanged(self, pen: QtGui.QFont) -> None: ... + def labelsBrushChanged(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def linePenChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def alignment(self) -> QtCore.Qt.Alignment: ... + def titleText(self) -> str: ... + def setTitleText(self, title: str) -> None: ... + def titleFont(self) -> QtGui.QFont: ... + def setTitleFont(self, font: QtGui.QFont) -> None: ... + def titleBrush(self) -> QtGui.QBrush: ... + def setTitleBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def setTitleVisible(self, visible: bool = ...) -> None: ... + def isTitleVisible(self) -> bool: ... + def shadesBorderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def shadesColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def shadesVisibleChanged(self, visible: bool) -> None: ... + def labelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def gridVisibleChanged(self, visible: bool) -> None: ... + def labelsVisibleChanged(self, visible: bool) -> None: ... + def lineVisibleChanged(self, visible: bool) -> None: ... + def visibleChanged(self, visible: bool) -> None: ... + def orientation(self) -> QtCore.Qt.Orientation: ... + def hide(self) -> None: ... + def show(self) -> None: ... + def setRange(self, min: typing.Any, max: typing.Any) -> None: ... + def setMax(self, max: typing.Any) -> None: ... + def setMin(self, min: typing.Any) -> None: ... + def shadesBorderColor(self) -> QtGui.QColor: ... + def setShadesBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def shadesColor(self) -> QtGui.QColor: ... + def setShadesColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def shadesBrush(self) -> QtGui.QBrush: ... + def setShadesBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def shadesPen(self) -> QtGui.QPen: ... + def setShadesPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def setShadesVisible(self, visible: bool = ...) -> None: ... + def shadesVisible(self) -> bool: ... + def labelsColor(self) -> QtGui.QColor: ... + def setLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def labelsAngle(self) -> int: ... + def setLabelsAngle(self, angle: int) -> None: ... + def labelsFont(self) -> QtGui.QFont: ... + def setLabelsFont(self, font: QtGui.QFont) -> None: ... + def labelsBrush(self) -> QtGui.QBrush: ... + def setLabelsBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def setLabelsVisible(self, visible: bool = ...) -> None: ... + def labelsVisible(self) -> bool: ... + def gridLinePen(self) -> QtGui.QPen: ... + def setGridLinePen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def setGridLineVisible(self, visible: bool = ...) -> None: ... + def isGridLineVisible(self) -> bool: ... + def linePenColor(self) -> QtGui.QColor: ... + def setLinePenColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def linePen(self) -> QtGui.QPen: ... + def setLinePen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def setLineVisible(self, visible: bool = ...) -> None: ... + def isLineVisible(self) -> bool: ... + def setVisible(self, visible: bool = ...) -> None: ... + def isVisible(self) -> bool: ... + def type(self) -> 'QAbstractAxis.AxisType': ... + + +class QAbstractSeries(QtCore.QObject): + + class SeriesType(int): + SeriesTypeLine = ... # type: QAbstractSeries.SeriesType + SeriesTypeArea = ... # type: QAbstractSeries.SeriesType + SeriesTypeBar = ... # type: QAbstractSeries.SeriesType + SeriesTypeStackedBar = ... # type: QAbstractSeries.SeriesType + SeriesTypePercentBar = ... # type: QAbstractSeries.SeriesType + SeriesTypePie = ... # type: QAbstractSeries.SeriesType + SeriesTypeScatter = ... # type: QAbstractSeries.SeriesType + SeriesTypeSpline = ... # type: QAbstractSeries.SeriesType + SeriesTypeHorizontalBar = ... # type: QAbstractSeries.SeriesType + SeriesTypeHorizontalStackedBar = ... # type: QAbstractSeries.SeriesType + SeriesTypeHorizontalPercentBar = ... # type: QAbstractSeries.SeriesType + SeriesTypeBoxPlot = ... # type: QAbstractSeries.SeriesType + SeriesTypeCandlestick = ... # type: QAbstractSeries.SeriesType + + def useOpenGLChanged(self) -> None: ... + def useOpenGL(self) -> bool: ... + def setUseOpenGL(self, enable: bool = ...) -> None: ... + def opacityChanged(self) -> None: ... + def attachedAxes(self) -> typing.List['QAbstractAxis']: ... + def detachAxis(self, axis: 'QAbstractAxis') -> bool: ... + def attachAxis(self, axis: 'QAbstractAxis') -> bool: ... + def setOpacity(self, opacity: float) -> None: ... + def opacity(self) -> float: ... + def visibleChanged(self) -> None: ... + def nameChanged(self) -> None: ... + def hide(self) -> None: ... + def show(self) -> None: ... + def chart(self) -> 'QChart': ... + def isVisible(self) -> bool: ... + def setVisible(self, visible: bool = ...) -> None: ... + def name(self) -> str: ... + def setName(self, name: str) -> None: ... + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QAbstractBarSeries('QAbstractSeries'): + + class LabelsPosition(int): + LabelsCenter = ... # type: QAbstractBarSeries.LabelsPosition + LabelsInsideEnd = ... # type: QAbstractBarSeries.LabelsPosition + LabelsInsideBase = ... # type: QAbstractBarSeries.LabelsPosition + LabelsOutsideEnd = ... # type: QAbstractBarSeries.LabelsPosition + + def labelsPrecisionChanged(self, precision: int) -> None: ... + def labelsPrecision(self) -> int: ... + def setLabelsPrecision(self, precision: int) -> None: ... + def labelsAngleChanged(self, angle: float) -> None: ... + def labelsAngle(self) -> float: ... + def setLabelsAngle(self, angle: float) -> None: ... + def doubleClicked(self, index: int, barset: 'QBarSet') -> None: ... + def released(self, index: int, barset: 'QBarSet') -> None: ... + def pressed(self, index: int, barset: 'QBarSet') -> None: ... + def labelsPositionChanged(self, position: 'QAbstractBarSeries.LabelsPosition') -> None: ... + def labelsFormatChanged(self, format: str) -> None: ... + def labelsPosition(self) -> 'QAbstractBarSeries.LabelsPosition': ... + def setLabelsPosition(self, position: 'QAbstractBarSeries.LabelsPosition') -> None: ... + def labelsFormat(self) -> str: ... + def setLabelsFormat(self, format: str) -> None: ... + def barsetsRemoved(self, sets: typing.Iterable['QBarSet']) -> None: ... + def barsetsAdded(self, sets: typing.Iterable['QBarSet']) -> None: ... + def labelsVisibleChanged(self) -> None: ... + def countChanged(self) -> None: ... + def hovered(self, status: bool, index: int, barset: 'QBarSet') -> None: ... + def clicked(self, index: int, barset: 'QBarSet') -> None: ... + def take(self, set: 'QBarSet') -> bool: ... + def isLabelsVisible(self) -> bool: ... + def setLabelsVisible(self, visible: bool = ...) -> None: ... + def clear(self) -> None: ... + def barSets(self) -> typing.List['QBarSet']: ... + def __len__(self) -> int: ... + def count(self) -> int: ... + def insert(self, index: int, set: 'QBarSet') -> bool: ... + def remove(self, set: 'QBarSet') -> bool: ... + @typing.overload + def append(self, set: 'QBarSet') -> bool: ... + @typing.overload + def append(self, sets: typing.Iterable['QBarSet']) -> bool: ... + def barWidth(self) -> float: ... + def setBarWidth(self, width: float) -> None: ... + + +class QLegendMarker(QtCore.QObject): + + class LegendMarkerType(int): + LegendMarkerTypeArea = ... # type: QLegendMarker.LegendMarkerType + LegendMarkerTypeBar = ... # type: QLegendMarker.LegendMarkerType + LegendMarkerTypePie = ... # type: QLegendMarker.LegendMarkerType + LegendMarkerTypeXY = ... # type: QLegendMarker.LegendMarkerType + LegendMarkerTypeBoxPlot = ... # type: QLegendMarker.LegendMarkerType + LegendMarkerTypeCandlestick = ... # type: QLegendMarker.LegendMarkerType + + def shapeChanged(self) -> None: ... + def setShape(self, shape: 'QLegend.MarkerShape') -> None: ... + def shape(self) -> 'QLegend.MarkerShape': ... + def visibleChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def penChanged(self) -> None: ... + def fontChanged(self) -> None: ... + def labelBrushChanged(self) -> None: ... + def labelChanged(self) -> None: ... + def hovered(self, status: bool) -> None: ... + def clicked(self) -> None: ... + def series(self) -> 'QAbstractSeries': ... + def setVisible(self, visible: bool) -> None: ... + def isVisible(self) -> bool: ... + def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def brush(self) -> QtGui.QBrush: ... + def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pen(self) -> QtGui.QPen: ... + def setFont(self, font: QtGui.QFont) -> None: ... + def font(self) -> QtGui.QFont: ... + def setLabelBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def labelBrush(self) -> QtGui.QBrush: ... + def setLabel(self, label: str) -> None: ... + def label(self) -> str: ... + def type(self) -> 'QLegendMarker.LegendMarkerType': ... + + +class QAreaLegendMarker('QLegendMarker'): + + def __init__(self, series: 'QAreaSeries', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def series(self) -> 'QAreaSeries': ... + def type(self) -> 'QLegendMarker.LegendMarkerType': ... + + +class QAreaSeries('QAbstractSeries'): + + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, upperSeries: 'QLineSeries', lowerSeries: typing.Optional['QLineSeries'] = ...) -> None: ... + + def pointLabelsClippingChanged(self, clipping: bool) -> None: ... + def pointLabelsClipping(self) -> bool: ... + def setPointLabelsClipping(self, enable: bool = ...) -> None: ... + def doubleClicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def released(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def pressed(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def pointLabelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pointLabelsFontChanged(self, font: QtGui.QFont) -> None: ... + def pointLabelsVisibilityChanged(self, visible: bool) -> None: ... + def pointLabelsFormatChanged(self, format: str) -> None: ... + def pointLabelsColor(self) -> QtGui.QColor: ... + def setPointLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pointLabelsFont(self) -> QtGui.QFont: ... + def setPointLabelsFont(self, font: QtGui.QFont) -> None: ... + def pointLabelsVisible(self) -> bool: ... + def setPointLabelsVisible(self, visible: bool = ...) -> None: ... + def pointLabelsFormat(self) -> str: ... + def setPointLabelsFormat(self, format: str) -> None: ... + def hovered(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint], state: bool) -> None: ... + def selected(self) -> None: ... + def clicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def borderColor(self) -> QtGui.QColor: ... + def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def color(self) -> QtGui.QColor: ... + def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pointsVisible(self) -> bool: ... + def setPointsVisible(self, visible: bool = ...) -> None: ... + def brush(self) -> QtGui.QBrush: ... + def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pen(self) -> QtGui.QPen: ... + def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def lowerSeries(self) -> 'QLineSeries': ... + def setLowerSeries(self, series: 'QLineSeries') -> None: ... + def upperSeries(self) -> 'QLineSeries': ... + def setUpperSeries(self, series: 'QLineSeries') -> None: ... + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QBarCategoryAxis('QAbstractAxis'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def countChanged(self) -> None: ... + def rangeChanged(self, min: str, max: str) -> None: ... + def maxChanged(self, max: str) -> None: ... + def minChanged(self, min: str) -> None: ... + def categoriesChanged(self) -> None: ... + def setRange(self, minCategory: str, maxCategory: str) -> None: ... + def max(self) -> str: ... + def setMax(self, maxCategory: str) -> None: ... + def min(self) -> str: ... + def setMin(self, minCategory: str) -> None: ... + def at(self, index: int) -> str: ... + def __len__(self) -> int: ... + def count(self) -> int: ... + def categories(self) -> typing.List[str]: ... + def setCategories(self, categories: typing.Iterable[str]) -> None: ... + def clear(self) -> None: ... + def replace(self, oldCategory: str, newCategory: str) -> None: ... + def insert(self, index: int, category: str) -> None: ... + def remove(self, category: str) -> None: ... + @typing.overload + def append(self, categories: typing.Iterable[str]) -> None: ... + @typing.overload + def append(self, category: str) -> None: ... + def type(self) -> 'QAbstractAxis.AxisType': ... + + +class QBarLegendMarker('QLegendMarker'): + + def __init__(self, series: 'QAbstractBarSeries', barset: 'QBarSet', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def barset(self) -> 'QBarSet': ... + def series(self) -> 'QAbstractBarSeries': ... + def type(self) -> 'QLegendMarker.LegendMarkerType': ... + + +class QBarSeries('QAbstractBarSeries'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QBarSet(QtCore.QObject): + + def __init__(self, name: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def doubleClicked(self, index: int) -> None: ... + def released(self, index: int) -> None: ... + def pressed(self, index: int) -> None: ... + def labelColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def hovered(self, status: bool, index: int) -> None: ... + def clicked(self, index: int) -> None: ... + def valueChanged(self, index: int) -> None: ... + def valuesRemoved(self, index: int, count: int) -> None: ... + def valuesAdded(self, index: int, count: int) -> None: ... + def labelFontChanged(self) -> None: ... + def labelBrushChanged(self) -> None: ... + def labelChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def penChanged(self) -> None: ... + def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def labelColor(self) -> QtGui.QColor: ... + def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def borderColor(self) -> QtGui.QColor: ... + def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def color(self) -> QtGui.QColor: ... + def __getitem__(self, index: int) -> float: ... + def at(self, index: int) -> float: ... + def remove(self, index: int, count: int = ...) -> None: ... + def label(self) -> str: ... + def setLabel(self, label: str) -> None: ... + def labelFont(self) -> QtGui.QFont: ... + def setLabelFont(self, font: QtGui.QFont) -> None: ... + def labelBrush(self) -> QtGui.QBrush: ... + def setLabelBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def brush(self) -> QtGui.QBrush: ... + def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pen(self) -> QtGui.QPen: ... + def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def sum(self) -> float: ... + def __len__(self) -> int: ... + def count(self) -> int: ... + def replace(self, index: int, value: float) -> None: ... + def insert(self, index: int, value: float) -> None: ... + @typing.overload + def append(self, value: float) -> None: ... + @typing.overload + def append(self, values: typing.Iterable[float]) -> None: ... + + +class QBoxPlotLegendMarker('QLegendMarker'): + + def __init__(self, series: 'QBoxPlotSeries', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def series(self) -> 'QBoxPlotSeries': ... + def type(self) -> 'QLegendMarker.LegendMarkerType': ... + + +class QBoxPlotSeries('QAbstractSeries'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def doubleClicked(self, boxset: 'QBoxSet') -> None: ... + def released(self, boxset: 'QBoxSet') -> None: ... + def pressed(self, boxset: 'QBoxSet') -> None: ... + def boxsetsRemoved(self, sets: typing.Iterable['QBoxSet']) -> None: ... + def boxsetsAdded(self, sets: typing.Iterable['QBoxSet']) -> None: ... + def boxWidthChanged(self) -> None: ... + def boxOutlineVisibilityChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def penChanged(self) -> None: ... + def countChanged(self) -> None: ... + def hovered(self, status: bool, boxset: 'QBoxSet') -> None: ... + def clicked(self, boxset: 'QBoxSet') -> None: ... + def pen(self) -> QtGui.QPen: ... + def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def brush(self) -> QtGui.QBrush: ... + def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def boxWidth(self) -> float: ... + def setBoxWidth(self, width: float) -> None: ... + def boxOutlineVisible(self) -> bool: ... + def setBoxOutlineVisible(self, visible: bool) -> None: ... + def type(self) -> 'QAbstractSeries.SeriesType': ... + def clear(self) -> None: ... + def boxSets(self) -> typing.List['QBoxSet']: ... + def __len__(self) -> int: ... + def count(self) -> int: ... + def insert(self, index: int, box: 'QBoxSet') -> bool: ... + def take(self, box: 'QBoxSet') -> bool: ... + def remove(self, box: 'QBoxSet') -> bool: ... + @typing.overload + def append(self, box: 'QBoxSet') -> bool: ... + @typing.overload + def append(self, boxes: typing.Iterable['QBoxSet']) -> bool: ... + + +class QBoxSet(QtCore.QObject): + + class ValuePositions(int): + LowerExtreme = ... # type: QBoxSet.ValuePositions + LowerQuartile = ... # type: QBoxSet.ValuePositions + Median = ... # type: QBoxSet.ValuePositions + UpperQuartile = ... # type: QBoxSet.ValuePositions + UpperExtreme = ... # type: QBoxSet.ValuePositions + + @typing.overload + def __init__(self, label: str = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, le: float, lq: float, m: float, uq: float, ue: float, label: str = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def doubleClicked(self) -> None: ... + def released(self) -> None: ... + def pressed(self) -> None: ... + def cleared(self) -> None: ... + def valueChanged(self, index: int) -> None: ... + def valuesChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def penChanged(self) -> None: ... + def hovered(self, status: bool) -> None: ... + def clicked(self) -> None: ... + def brush(self) -> QtGui.QBrush: ... + def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pen(self) -> QtGui.QPen: ... + def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def __len__(self) -> int: ... + def count(self) -> int: ... + def __getitem__(self, index: int) -> float: ... + def at(self, index: int) -> float: ... + def setValue(self, index: int, value: float) -> None: ... + def label(self) -> str: ... + def setLabel(self, label: str) -> None: ... + def clear(self) -> None: ... + @typing.overload + def append(self, value: float) -> None: ... + @typing.overload + def append(self, values: typing.Iterable[float]) -> None: ... + + +class QCandlestickLegendMarker('QLegendMarker'): + + def __init__(self, series: 'QCandlestickSeries', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def series(self) -> 'QCandlestickSeries': ... + def type(self) -> 'QLegendMarker.LegendMarkerType': ... + + +class QCandlestickModelMapper(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def lastSetSection(self) -> int: ... + def setLastSetSection(self, lastSetSection: int) -> None: ... + def firstSetSection(self) -> int: ... + def setFirstSetSection(self, firstSetSection: int) -> None: ... + def close(self) -> int: ... + def setClose(self, close: int) -> None: ... + def low(self) -> int: ... + def setLow(self, low: int) -> None: ... + def high(self) -> int: ... + def setHigh(self, high: int) -> None: ... + def open(self) -> int: ... + def setOpen(self, open: int) -> None: ... + def timestamp(self) -> int: ... + def setTimestamp(self, timestamp: int) -> None: ... + def seriesReplaced(self) -> None: ... + def modelReplaced(self) -> None: ... + def orientation(self) -> QtCore.Qt.Orientation: ... + def series(self) -> 'QCandlestickSeries': ... + def setSeries(self, series: 'QCandlestickSeries') -> None: ... + def model(self) -> QtCore.QAbstractItemModel: ... + def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... + + +class QCandlestickSeries('QAbstractSeries'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def penChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def decreasingColorChanged(self) -> None: ... + def increasingColorChanged(self) -> None: ... + def capsVisibilityChanged(self) -> None: ... + def capsWidthChanged(self) -> None: ... + def bodyOutlineVisibilityChanged(self) -> None: ... + def bodyWidthChanged(self) -> None: ... + def minimumColumnWidthChanged(self) -> None: ... + def maximumColumnWidthChanged(self) -> None: ... + def countChanged(self) -> None: ... + def candlestickSetsRemoved(self, sets: typing.Iterable['QCandlestickSet']) -> None: ... + def candlestickSetsAdded(self, sets: typing.Iterable['QCandlestickSet']) -> None: ... + def doubleClicked(self, set: 'QCandlestickSet') -> None: ... + def released(self, set: 'QCandlestickSet') -> None: ... + def pressed(self, set: 'QCandlestickSet') -> None: ... + def hovered(self, status: bool, set: 'QCandlestickSet') -> None: ... + def clicked(self, set: 'QCandlestickSet') -> None: ... + def pen(self) -> QtGui.QPen: ... + def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def brush(self) -> QtGui.QBrush: ... + def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def decreasingColor(self) -> QtGui.QColor: ... + def setDecreasingColor(self, decreasingColor: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def increasingColor(self) -> QtGui.QColor: ... + def setIncreasingColor(self, increasingColor: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def capsVisible(self) -> bool: ... + def setCapsVisible(self, capsVisible: bool) -> None: ... + def capsWidth(self) -> float: ... + def setCapsWidth(self, capsWidth: float) -> None: ... + def bodyOutlineVisible(self) -> bool: ... + def setBodyOutlineVisible(self, bodyOutlineVisible: bool) -> None: ... + def bodyWidth(self) -> float: ... + def setBodyWidth(self, bodyWidth: float) -> None: ... + def minimumColumnWidth(self) -> float: ... + def setMinimumColumnWidth(self, minimumColumnWidth: float) -> None: ... + def maximumColumnWidth(self) -> float: ... + def setMaximumColumnWidth(self, maximumColumnWidth: float) -> None: ... + def type(self) -> 'QAbstractSeries.SeriesType': ... + def __len__(self) -> int: ... + def count(self) -> int: ... + def sets(self) -> typing.List['QCandlestickSet']: ... + def clear(self) -> None: ... + def take(self, set: 'QCandlestickSet') -> bool: ... + def insert(self, index: int, set: 'QCandlestickSet') -> bool: ... + @typing.overload + def remove(self, set: 'QCandlestickSet') -> bool: ... + @typing.overload + def remove(self, sets: typing.Iterable['QCandlestickSet']) -> bool: ... + @typing.overload + def append(self, set: 'QCandlestickSet') -> bool: ... + @typing.overload + def append(self, sets: typing.Iterable['QCandlestickSet']) -> bool: ... + + +class QCandlestickSet(QtCore.QObject): + + @typing.overload + def __init__(self, timestamp: float = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, open: float, high: float, low: float, close: float, timestamp: float = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def penChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def closeChanged(self) -> None: ... + def lowChanged(self) -> None: ... + def highChanged(self) -> None: ... + def openChanged(self) -> None: ... + def timestampChanged(self) -> None: ... + def doubleClicked(self) -> None: ... + def released(self) -> None: ... + def pressed(self) -> None: ... + def hovered(self, status: bool) -> None: ... + def clicked(self) -> None: ... + def pen(self) -> QtGui.QPen: ... + def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def brush(self) -> QtGui.QBrush: ... + def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def close(self) -> float: ... + def setClose(self, close: float) -> None: ... + def low(self) -> float: ... + def setLow(self, low: float) -> None: ... + def high(self) -> float: ... + def setHigh(self, high: float) -> None: ... + def open(self) -> float: ... + def setOpen(self, open: float) -> None: ... + def timestamp(self) -> float: ... + def setTimestamp(self, timestamp: float) -> None: ... + + +class QValueAxis('QAbstractAxis'): + + class TickType(int): + TicksDynamic = ... # type: QValueAxis.TickType + TicksFixed = ... # type: QValueAxis.TickType + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def tickTypeChanged(self, type: 'QValueAxis.TickType') -> None: ... + def tickAnchorChanged(self, anchor: float) -> None: ... + def tickIntervalChanged(self, interval: float) -> None: ... + def tickType(self) -> 'QValueAxis.TickType': ... + def setTickType(self, type: 'QValueAxis.TickType') -> None: ... + def tickInterval(self) -> float: ... + def setTickInterval(self, insterval: float) -> None: ... + def tickAnchor(self) -> float: ... + def setTickAnchor(self, anchor: float) -> None: ... + def minorTickCountChanged(self, tickCount: int) -> None: ... + def minorTickCount(self) -> int: ... + def setMinorTickCount(self, count: int) -> None: ... + def labelFormatChanged(self, format: str) -> None: ... + def tickCountChanged(self, tickCount: int) -> None: ... + def rangeChanged(self, min: float, max: float) -> None: ... + def maxChanged(self, max: float) -> None: ... + def minChanged(self, min: float) -> None: ... + def applyNiceNumbers(self) -> None: ... + def labelFormat(self) -> str: ... + def setLabelFormat(self, format: str) -> None: ... + def tickCount(self) -> int: ... + def setTickCount(self, count: int) -> None: ... + def setRange(self, min: float, max: float) -> None: ... + def max(self) -> float: ... + def setMax(self, max: float) -> None: ... + def min(self) -> float: ... + def setMin(self, min: float) -> None: ... + def type(self) -> 'QAbstractAxis.AxisType': ... + + +class QCategoryAxis('QValueAxis'): + + class AxisLabelsPosition(int): + AxisLabelsPositionCenter = ... # type: QCategoryAxis.AxisLabelsPosition + AxisLabelsPositionOnValue = ... # type: QCategoryAxis.AxisLabelsPosition + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def labelsPositionChanged(self, position: 'QCategoryAxis.AxisLabelsPosition') -> None: ... + def setLabelsPosition(self, position: 'QCategoryAxis.AxisLabelsPosition') -> None: ... + def labelsPosition(self) -> 'QCategoryAxis.AxisLabelsPosition': ... + def categoriesChanged(self) -> None: ... + def __len__(self) -> int: ... + def count(self) -> int: ... + def categoriesLabels(self) -> typing.List[str]: ... + def endValue(self, categoryLabel: str) -> float: ... + def setStartValue(self, min: float) -> None: ... + def startValue(self, categoryLabel: str = ...) -> float: ... + def replaceLabel(self, oldLabel: str, newLabel: str) -> None: ... + def remove(self, label: str) -> None: ... + def append(self, label: str, categoryEndValue: float) -> None: ... + def type(self) -> 'QAbstractAxis.AxisType': ... + + +class QChart(QtWidgets.QGraphicsWidget): + + class ChartType(int): + ChartTypeUndefined = ... # type: QChart.ChartType + ChartTypeCartesian = ... # type: QChart.ChartType + ChartTypePolar = ... # type: QChart.ChartType + + class AnimationOption(int): + NoAnimation = ... # type: QChart.AnimationOption + GridAxisAnimations = ... # type: QChart.AnimationOption + SeriesAnimations = ... # type: QChart.AnimationOption + AllAnimations = ... # type: QChart.AnimationOption + + class ChartTheme(int): + ChartThemeLight = ... # type: QChart.ChartTheme + ChartThemeBlueCerulean = ... # type: QChart.ChartTheme + ChartThemeDark = ... # type: QChart.ChartTheme + ChartThemeBrownSand = ... # type: QChart.ChartTheme + ChartThemeBlueNcs = ... # type: QChart.ChartTheme + ChartThemeHighContrast = ... # type: QChart.ChartTheme + ChartThemeBlueIcy = ... # type: QChart.ChartTheme + ChartThemeQt = ... # type: QChart.ChartTheme + + class AnimationOptions(sip.simplewrapper): - class QCandlestickSet(QtCore.QObject): - - @typing.overload - def __init__(self, timestamp: float = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload - def __init__(self, open: float, high: float, low: float, close: float, timestamp: float = ..., parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def penChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def closeChanged(self) -> None: ... - def lowChanged(self) -> None: ... - def highChanged(self) -> None: ... - def openChanged(self) -> None: ... - def timestampChanged(self) -> None: ... - def doubleClicked(self) -> None: ... - def released(self) -> None: ... - def pressed(self) -> None: ... - def hovered(self, status: bool) -> None: ... - def clicked(self) -> None: ... - def pen(self) -> QtGui.QPen: ... - def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def brush(self) -> QtGui.QBrush: ... - def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def close(self) -> float: ... - def setClose(self, close: float) -> None: ... - def low(self) -> float: ... - def setLow(self, low: float) -> None: ... - def high(self) -> float: ... - def setHigh(self, high: float) -> None: ... - def open(self) -> float: ... - def setOpen(self, open: float) -> None: ... - def timestamp(self) -> float: ... - def setTimestamp(self, timestamp: float) -> None: ... - - class QValueAxis('QAbstractAxis'): - - class TickType(int): - TicksDynamic = ... # type: QValueAxis.TickType - TicksFixed = ... # type: QValueAxis.TickType - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def tickTypeChanged(self, type: 'QValueAxis.TickType') -> None: ... - def tickAnchorChanged(self, anchor: float) -> None: ... - def tickIntervalChanged(self, interval: float) -> None: ... - def tickType(self) -> 'QValueAxis.TickType': ... - def setTickType(self, type: 'QValueAxis.TickType') -> None: ... - def tickInterval(self) -> float: ... - def setTickInterval(self, insterval: float) -> None: ... - def tickAnchor(self) -> float: ... - def setTickAnchor(self, anchor: float) -> None: ... - def minorTickCountChanged(self, tickCount: int) -> None: ... - def minorTickCount(self) -> int: ... - def setMinorTickCount(self, count: int) -> None: ... - def labelFormatChanged(self, format: str) -> None: ... - def tickCountChanged(self, tickCount: int) -> None: ... - def rangeChanged(self, min: float, max: float) -> None: ... - def maxChanged(self, max: float) -> None: ... - def minChanged(self, min: float) -> None: ... - def applyNiceNumbers(self) -> None: ... - def labelFormat(self) -> str: ... - def setLabelFormat(self, format: str) -> None: ... - def tickCount(self) -> int: ... - def setTickCount(self, count: int) -> None: ... - def setRange(self, min: float, max: float) -> None: ... - def max(self) -> float: ... - def setMax(self, max: float) -> None: ... - def min(self) -> float: ... - def setMin(self, min: float) -> None: ... - def type(self) -> 'QAbstractAxis.AxisType': ... - - class QCategoryAxis('QValueAxis'): - - class AxisLabelsPosition(int): - AxisLabelsPositionCenter = ... # type: QCategoryAxis.AxisLabelsPosition - AxisLabelsPositionOnValue = ... # type: QCategoryAxis.AxisLabelsPosition - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def labelsPositionChanged(self, position: 'QCategoryAxis.AxisLabelsPosition') -> None: ... - def setLabelsPosition(self, position: 'QCategoryAxis.AxisLabelsPosition') -> None: ... - def labelsPosition(self) -> 'QCategoryAxis.AxisLabelsPosition': ... - def categoriesChanged(self) -> None: ... - def __len__(self) -> int: ... - def count(self) -> int: ... - def categoriesLabels(self) -> typing.List[str]: ... - def endValue(self, categoryLabel: str) -> float: ... - def setStartValue(self, min: float) -> None: ... - def startValue(self, categoryLabel: str = ...) -> float: ... - def replaceLabel(self, oldLabel: str, newLabel: str) -> None: ... - def remove(self, label: str) -> None: ... - def append(self, label: str, categoryEndValue: float) -> None: ... - def type(self) -> 'QAbstractAxis.AxisType': ... - - class QChart(QtWidgets.QGraphicsWidget): - - class ChartType(int): - ChartTypeUndefined = ... # type: QChart.ChartType - ChartTypeCartesian = ... # type: QChart.ChartType - ChartTypePolar = ... # type: QChart.ChartType - - class AnimationOption(int): - NoAnimation = ... # type: QChart.AnimationOption - GridAxisAnimations = ... # type: QChart.AnimationOption - SeriesAnimations = ... # type: QChart.AnimationOption - AllAnimations = ... # type: QChart.AnimationOption - - class ChartTheme(int): - ChartThemeLight = ... # type: QChart.ChartTheme - ChartThemeBlueCerulean = ... # type: QChart.ChartTheme - ChartThemeDark = ... # type: QChart.ChartTheme - ChartThemeBrownSand = ... # type: QChart.ChartTheme - ChartThemeBlueNcs = ... # type: QChart.ChartTheme - ChartThemeHighContrast = ... # type: QChart.ChartTheme - ChartThemeBlueIcy = ... # type: QChart.ChartTheme - ChartThemeQt = ... # type: QChart.ChartTheme - - class AnimationOptions(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, f: typing.Union['QChart.AnimationOptions', 'QChart.AnimationOption']) -> None: ... - @typing.overload - def __init__(self, a0: 'QChart.AnimationOptions') -> None: ... - - def __hash__(self) -> int: ... - def __bool__(self) -> int: ... - def __invert__(self) -> 'QChart.AnimationOptions': ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... - - def __init__(self, parent: typing.Optional[QtWidgets.QGraphicsItem] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... - - def animationEasingCurve(self) -> QtCore.QEasingCurve: ... - def setAnimationEasingCurve(self, curve: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... - def animationDuration(self) -> int: ... - def setAnimationDuration(self, msecs: int) -> None: ... - def plotAreaChanged(self, plotArea: QtCore.QRectF) -> None: ... - def locale(self) -> QtCore.QLocale: ... - def setLocale(self, locale: QtCore.QLocale) -> None: ... - def localizeNumbers(self) -> bool: ... - def setLocalizeNumbers(self, localize: bool) -> None: ... - def chartType(self) -> 'QChart.ChartType': ... - def isPlotAreaBackgroundVisible(self) -> bool: ... - def setPlotAreaBackgroundVisible(self, visible: bool = ...) -> None: ... - def plotAreaBackgroundPen(self) -> QtGui.QPen: ... - def setPlotAreaBackgroundPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def plotAreaBackgroundBrush(self) -> QtGui.QBrush: ... - def setPlotAreaBackgroundBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def setPlotArea(self, rect: QtCore.QRectF) -> None: ... - def isZoomed(self) -> bool: ... - def zoomReset(self) -> None: ... - def backgroundRoundness(self) -> float: ... - def setBackgroundRoundness(self, diameter: float) -> None: ... - def mapToPosition(self, value: typing.Union[QtCore.QPointF, QtCore.QPoint], series: typing.Optional['QAbstractSeries'] = ...) -> QtCore.QPointF: ... - def mapToValue(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], series: typing.Optional['QAbstractSeries'] = ...) -> QtCore.QPointF: ... - def margins(self) -> QtCore.QMargins: ... - def setMargins(self, margins: QtCore.QMargins) -> None: ... - def axes(self, orientation: typing.Union[QtCore.Qt.Orientations, QtCore.Qt.Orientation] = ..., series: typing.Optional['QAbstractSeries'] = ...) -> typing.List['QAbstractAxis']: ... - def removeAxis(self, axis: 'QAbstractAxis') -> None: ... - def addAxis(self, axis: 'QAbstractAxis', alignment: typing.Union[QtCore.Qt.Alignment, QtCore.Qt.AlignmentFlag]) -> None: ... - def plotArea(self) -> QtCore.QRectF: ... - def scroll(self, dx: float, dy: float) -> None: ... - def isDropShadowEnabled(self) -> bool: ... - def setDropShadowEnabled(self, enabled: bool = ...) -> None: ... - def createDefaultAxes(self) -> None: ... - def axisY(self, series: typing.Optional['QAbstractSeries'] = ...) -> 'QAbstractAxis': ... - def axisX(self, series: typing.Optional['QAbstractSeries'] = ...) -> 'QAbstractAxis': ... - def setAxisY(self, axis: 'QAbstractAxis', series: typing.Optional['QAbstractSeries'] = ...) -> None: ... - def setAxisX(self, axis: 'QAbstractAxis', series: typing.Optional['QAbstractSeries'] = ...) -> None: ... - def legend(self) -> 'QLegend': ... - def zoom(self, factor: float) -> None: ... - def zoomOut(self) -> None: ... + def __init__(self) -> None: ... @typing.overload - def zoomIn(self) -> None: ... + def __init__(self, f: typing.Union['QChart.AnimationOptions', 'QChart.AnimationOption']) -> None: ... @typing.overload - def zoomIn(self, rect: QtCore.QRectF) -> None: ... - def animationOptions(self) -> 'QChart.AnimationOptions': ... - def setAnimationOptions(self, options: typing.Union['QChart.AnimationOptions', 'QChart.AnimationOption']) -> None: ... - def isBackgroundVisible(self) -> bool: ... - def setBackgroundVisible(self, visible: bool = ...) -> None: ... - def backgroundPen(self) -> QtGui.QPen: ... - def setBackgroundPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def backgroundBrush(self) -> QtGui.QBrush: ... - def setBackgroundBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def titleBrush(self) -> QtGui.QBrush: ... - def setTitleBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def titleFont(self) -> QtGui.QFont: ... - def setTitleFont(self, font: QtGui.QFont) -> None: ... - def title(self) -> str: ... - def setTitle(self, title: str) -> None: ... - def theme(self) -> 'QChart.ChartTheme': ... - def setTheme(self, theme: 'QChart.ChartTheme') -> None: ... - def series(self) -> typing.List['QAbstractSeries']: ... - def removeAllSeries(self) -> None: ... - def removeSeries(self, series: 'QAbstractSeries') -> None: ... - def addSeries(self, series: 'QAbstractSeries') -> None: ... - - class QChartView(QtWidgets.QGraphicsView): - - class RubberBand(int): - NoRubberBand = ... # type: QChartView.RubberBand - VerticalRubberBand = ... # type: QChartView.RubberBand - HorizontalRubberBand = ... # type: QChartView.RubberBand - RectangleRubberBand = ... # type: QChartView.RubberBand - - class RubberBands(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, f: typing.Union['QChartView.RubberBands', 'QChartView.RubberBand']) -> None: ... - @typing.overload - def __init__(self, a0: 'QChartView.RubberBands') -> None: ... - - def __hash__(self) -> int: ... - def __bool__(self) -> int: ... - def __invert__(self) -> 'QChartView.RubberBands': ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... + def __init__(self, a0: 'QChart.AnimationOptions') -> None: ... + + def __hash__(self) -> int: ... + def __bool__(self) -> int: ... + def __invert__(self) -> 'QChart.AnimationOptions': ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + + def __init__(self, parent: typing.Optional[QtWidgets.QGraphicsItem] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... + + def animationEasingCurve(self) -> QtCore.QEasingCurve: ... + def setAnimationEasingCurve(self, curve: typing.Union[QtCore.QEasingCurve, QtCore.QEasingCurve.Type]) -> None: ... + def animationDuration(self) -> int: ... + def setAnimationDuration(self, msecs: int) -> None: ... + def plotAreaChanged(self, plotArea: QtCore.QRectF) -> None: ... + def locale(self) -> QtCore.QLocale: ... + def setLocale(self, locale: QtCore.QLocale) -> None: ... + def localizeNumbers(self) -> bool: ... + def setLocalizeNumbers(self, localize: bool) -> None: ... + def chartType(self) -> 'QChart.ChartType': ... + def isPlotAreaBackgroundVisible(self) -> bool: ... + def setPlotAreaBackgroundVisible(self, visible: bool = ...) -> None: ... + def plotAreaBackgroundPen(self) -> QtGui.QPen: ... + def setPlotAreaBackgroundPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def plotAreaBackgroundBrush(self) -> QtGui.QBrush: ... + def setPlotAreaBackgroundBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def setPlotArea(self, rect: QtCore.QRectF) -> None: ... + def isZoomed(self) -> bool: ... + def zoomReset(self) -> None: ... + def backgroundRoundness(self) -> float: ... + def setBackgroundRoundness(self, diameter: float) -> None: ... + def mapToPosition(self, value: typing.Union[QtCore.QPointF, QtCore.QPoint], series: typing.Optional['QAbstractSeries'] = ...) -> QtCore.QPointF: ... + def mapToValue(self, position: typing.Union[QtCore.QPointF, QtCore.QPoint], series: typing.Optional['QAbstractSeries'] = ...) -> QtCore.QPointF: ... + def margins(self) -> QtCore.QMargins: ... + def setMargins(self, margins: QtCore.QMargins) -> None: ... + def axes(self, orientation: typing.Union[QtCore.Qt.Orientations, QtCore.Qt.Orientation] = ..., series: typing.Optional['QAbstractSeries'] = ...) -> typing.List['QAbstractAxis']: ... + def removeAxis(self, axis: 'QAbstractAxis') -> None: ... + def addAxis(self, axis: 'QAbstractAxis', alignment: typing.Union[QtCore.Qt.Alignment, QtCore.Qt.AlignmentFlag]) -> None: ... + def plotArea(self) -> QtCore.QRectF: ... + def scroll(self, dx: float, dy: float) -> None: ... + def isDropShadowEnabled(self) -> bool: ... + def setDropShadowEnabled(self, enabled: bool = ...) -> None: ... + def createDefaultAxes(self) -> None: ... + def axisY(self, series: typing.Optional['QAbstractSeries'] = ...) -> 'QAbstractAxis': ... + def axisX(self, series: typing.Optional['QAbstractSeries'] = ...) -> 'QAbstractAxis': ... + def setAxisY(self, axis: 'QAbstractAxis', series: typing.Optional['QAbstractSeries'] = ...) -> None: ... + def setAxisX(self, axis: 'QAbstractAxis', series: typing.Optional['QAbstractSeries'] = ...) -> None: ... + def legend(self) -> 'QLegend': ... + def zoom(self, factor: float) -> None: ... + def zoomOut(self) -> None: ... + @typing.overload + def zoomIn(self) -> None: ... + @typing.overload + def zoomIn(self, rect: QtCore.QRectF) -> None: ... + def animationOptions(self) -> 'QChart.AnimationOptions': ... + def setAnimationOptions(self, options: typing.Union['QChart.AnimationOptions', 'QChart.AnimationOption']) -> None: ... + def isBackgroundVisible(self) -> bool: ... + def setBackgroundVisible(self, visible: bool = ...) -> None: ... + def backgroundPen(self) -> QtGui.QPen: ... + def setBackgroundPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def backgroundBrush(self) -> QtGui.QBrush: ... + def setBackgroundBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def titleBrush(self) -> QtGui.QBrush: ... + def setTitleBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def titleFont(self) -> QtGui.QFont: ... + def setTitleFont(self, font: QtGui.QFont) -> None: ... + def title(self) -> str: ... + def setTitle(self, title: str) -> None: ... + def theme(self) -> 'QChart.ChartTheme': ... + def setTheme(self, theme: 'QChart.ChartTheme') -> None: ... + def series(self) -> typing.List['QAbstractSeries']: ... + def removeAllSeries(self) -> None: ... + def removeSeries(self, series: 'QAbstractSeries') -> None: ... + def addSeries(self, series: 'QAbstractSeries') -> None: ... + + +class QChartView(QtWidgets.QGraphicsView): + + class RubberBand(int): + NoRubberBand = ... # type: QChartView.RubberBand + VerticalRubberBand = ... # type: QChartView.RubberBand + HorizontalRubberBand = ... # type: QChartView.RubberBand + RectangleRubberBand = ... # type: QChartView.RubberBand + + class RubberBands(sip.simplewrapper): @typing.overload - def __init__(self, parent: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... - @typing.overload - def __init__(self, chart: 'QChart', parent: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... - - def wheelEvent(self, event: QtGui.QWheelEvent) -> None: ... - def mouseReleaseEvent(self, event: QtGui.QMouseEvent) -> None: ... - def mouseMoveEvent(self, event: QtGui.QMouseEvent) -> None: ... - def mousePressEvent(self, event: QtGui.QMouseEvent) -> None: ... - def resizeEvent(self, event: QtGui.QResizeEvent) -> None: ... - def chart(self) -> 'QChart': ... - def setChart(self, chart: 'QChart') -> None: ... - def rubberBand(self) -> 'QChartView.RubberBands': ... - def setRubberBand(self, rubberBands: typing.Union['QChartView.RubberBands', 'QChartView.RubberBand']) -> None: ... - - class QDateTimeAxis('QAbstractAxis'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def tickCountChanged(self, tick: int) -> None: ... - def formatChanged(self, format: str) -> None: ... - def rangeChanged(self, min: typing.Union[QtCore.QDateTime, datetime.datetime], max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def maxChanged(self, max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def minChanged(self, min: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def tickCount(self) -> int: ... - def setTickCount(self, count: int) -> None: ... - def format(self) -> str: ... - def setFormat(self, format: str) -> None: ... - def setRange(self, min: typing.Union[QtCore.QDateTime, datetime.datetime], max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def max(self) -> QtCore.QDateTime: ... - def setMax(self, max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def min(self) -> QtCore.QDateTime: ... - def setMin(self, min: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... - def type(self) -> 'QAbstractAxis.AxisType': ... - - class QHBarModelMapper(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def lastBarSetRowChanged(self) -> None: ... - def firstBarSetRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... - def setColumnCount(self, columnCount: int) -> None: ... - def columnCount(self) -> int: ... - def setFirstColumn(self, firstColumn: int) -> None: ... - def firstColumn(self) -> int: ... - def setSeries(self, series: 'QAbstractBarSeries') -> None: ... - def series(self) -> 'QAbstractBarSeries': ... - def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... - def model(self) -> QtCore.QAbstractItemModel: ... - def setLastBarSetRow(self, lastBarSetRow: int) -> None: ... - def lastBarSetRow(self) -> int: ... - def setFirstBarSetRow(self, firstBarSetRow: int) -> None: ... - def firstBarSetRow(self) -> int: ... - - class QHBoxPlotModelMapper(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def lastBoxSetRowChanged(self) -> None: ... - def firstBoxSetRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... - def setColumnCount(self, rowCount: int) -> None: ... - def columnCount(self) -> int: ... - def setFirstColumn(self, firstColumn: int) -> None: ... - def firstColumn(self) -> int: ... - def setLastBoxSetRow(self, lastBoxSetRow: int) -> None: ... - def lastBoxSetRow(self) -> int: ... - def setFirstBoxSetRow(self, firstBoxSetRow: int) -> None: ... - def firstBoxSetRow(self) -> int: ... - def setSeries(self, series: 'QBoxPlotSeries') -> None: ... - def series(self) -> 'QBoxPlotSeries': ... - def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... - def model(self) -> QtCore.QAbstractItemModel: ... - - class QHCandlestickModelMapper('QCandlestickModelMapper'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def lastSetRowChanged(self) -> None: ... - def firstSetRowChanged(self) -> None: ... - def closeColumnChanged(self) -> None: ... - def lowColumnChanged(self) -> None: ... - def highColumnChanged(self) -> None: ... - def openColumnChanged(self) -> None: ... - def timestampColumnChanged(self) -> None: ... - def lastSetRow(self) -> int: ... - def setLastSetRow(self, lastSetRow: int) -> None: ... - def firstSetRow(self) -> int: ... - def setFirstSetRow(self, firstSetRow: int) -> None: ... - def closeColumn(self) -> int: ... - def setCloseColumn(self, closeColumn: int) -> None: ... - def lowColumn(self) -> int: ... - def setLowColumn(self, lowColumn: int) -> None: ... - def highColumn(self) -> int: ... - def setHighColumn(self, highColumn: int) -> None: ... - def openColumn(self) -> int: ... - def setOpenColumn(self, openColumn: int) -> None: ... - def timestampColumn(self) -> int: ... - def setTimestampColumn(self, timestampColumn: int) -> None: ... - def orientation(self) -> QtCore.Qt.Orientation: ... - - class QHorizontalBarSeries('QAbstractBarSeries'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def type(self) -> 'QAbstractSeries.SeriesType': ... - - class QHorizontalPercentBarSeries('QAbstractBarSeries'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def type(self) -> 'QAbstractSeries.SeriesType': ... - - class QHorizontalStackedBarSeries('QAbstractBarSeries'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def type(self) -> 'QAbstractSeries.SeriesType': ... - - class QHPieModelMapper(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def labelsRowChanged(self) -> None: ... - def valuesRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... - def setColumnCount(self, columnCount: int) -> None: ... - def columnCount(self) -> int: ... - def setFirstColumn(self, firstColumn: int) -> None: ... - def firstColumn(self) -> int: ... - def setSeries(self, series: 'QPieSeries') -> None: ... - def series(self) -> 'QPieSeries': ... - def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... - def model(self) -> QtCore.QAbstractItemModel: ... - def setLabelsRow(self, labelsRow: int) -> None: ... - def labelsRow(self) -> int: ... - def setValuesRow(self, valuesRow: int) -> None: ... - def valuesRow(self) -> int: ... - - class QHXYModelMapper(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def columnCountChanged(self) -> None: ... - def firstColumnChanged(self) -> None: ... - def yRowChanged(self) -> None: ... - def xRowChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... - def setColumnCount(self, columnCount: int) -> None: ... - def columnCount(self) -> int: ... - def setFirstColumn(self, firstColumn: int) -> None: ... - def firstColumn(self) -> int: ... - def setSeries(self, series: 'QXYSeries') -> None: ... - def series(self) -> 'QXYSeries': ... - def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... - def model(self) -> QtCore.QAbstractItemModel: ... - def setYRow(self, yRow: int) -> None: ... - def yRow(self) -> int: ... - def setXRow(self, xRow: int) -> None: ... - def xRow(self) -> int: ... - - class QLegend(QtWidgets.QGraphicsWidget): - - class MarkerShape(int): - MarkerShapeDefault = ... # type: QLegend.MarkerShape - MarkerShapeRectangle = ... # type: QLegend.MarkerShape - MarkerShapeCircle = ... # type: QLegend.MarkerShape - MarkerShapeFromSeries = ... # type: QLegend.MarkerShape - - def markerShapeChanged(self, shape: 'QLegend.MarkerShape') -> None: ... - def setMarkerShape(self, shape: 'QLegend.MarkerShape') -> None: ... - def markerShape(self) -> 'QLegend.MarkerShape': ... - def showToolTipsChanged(self, showToolTips: bool) -> None: ... - def setShowToolTips(self, show: bool) -> None: ... - def showToolTips(self) -> bool: ... - def reverseMarkersChanged(self, reverseMarkers: bool) -> None: ... - def setReverseMarkers(self, reverseMarkers: bool = ...) -> None: ... - def reverseMarkers(self) -> bool: ... - def showEvent(self, event: QtGui.QShowEvent) -> None: ... - def hideEvent(self, event: QtGui.QHideEvent) -> None: ... - def labelColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def backgroundVisibleChanged(self, visible: bool) -> None: ... - def markers(self, series: typing.Optional['QAbstractSeries'] = ...) -> typing.List['QLegendMarker']: ... - def labelColor(self) -> QtGui.QColor: ... - def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def labelBrush(self) -> QtGui.QBrush: ... - def setLabelBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def font(self) -> QtGui.QFont: ... - def setFont(self, font: QtGui.QFont) -> None: ... - def borderColor(self) -> QtGui.QColor: ... - def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def color(self) -> QtGui.QColor: ... - def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def isBackgroundVisible(self) -> bool: ... - def setBackgroundVisible(self, visible: bool = ...) -> None: ... - def isAttachedToChart(self) -> bool: ... - def attachToChart(self) -> None: ... - def detachFromChart(self) -> None: ... - def alignment(self) -> QtCore.Qt.Alignment: ... - def setAlignment(self, alignment: typing.Union[QtCore.Qt.Alignment, QtCore.Qt.AlignmentFlag]) -> None: ... - def pen(self) -> QtGui.QPen: ... - def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def brush(self) -> QtGui.QBrush: ... - def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def paint(self, painter: QtGui.QPainter, option: QtWidgets.QStyleOptionGraphicsItem, widget: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... - - class QXYSeries('QAbstractSeries'): - - def penChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointsRemoved(self, index: int, count: int) -> None: ... - def pointLabelsClippingChanged(self, clipping: bool) -> None: ... - def pointLabelsClipping(self) -> bool: ... - def setPointLabelsClipping(self, enable: bool = ...) -> None: ... - def pointsVector(self) -> typing.List[QtCore.QPointF]: ... - def removePoints(self, index: int, count: int) -> None: ... - def doubleClicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def released(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pressed(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def pointLabelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointLabelsFontChanged(self, font: QtGui.QFont) -> None: ... - def pointLabelsVisibilityChanged(self, visible: bool) -> None: ... - def pointLabelsFormatChanged(self, format: str) -> None: ... - def pointLabelsColor(self) -> QtGui.QColor: ... - def setPointLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pointLabelsFont(self) -> QtGui.QFont: ... - def setPointLabelsFont(self, font: QtGui.QFont) -> None: ... - def pointLabelsVisible(self) -> bool: ... - def setPointLabelsVisible(self, visible: bool = ...) -> None: ... - def pointLabelsFormat(self) -> str: ... - def setPointLabelsFormat(self, format: str) -> None: ... - def hovered(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint], state: bool) -> None: ... - def pointsReplaced(self) -> None: ... - def pointAdded(self, index: int) -> None: ... - def pointRemoved(self, index: int) -> None: ... - def pointReplaced(self, index: int) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def clicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - def at(self, index: int) -> QtCore.QPointF: ... - def pointsVisible(self) -> bool: ... - def setPointsVisible(self, visible: bool = ...) -> None: ... - def color(self) -> QtGui.QColor: ... - def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def brush(self) -> QtGui.QBrush: ... - def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def pen(self) -> QtGui.QPen: ... - def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def __len__(self) -> int: ... - def count(self) -> int: ... - def clear(self) -> None: ... - def insert(self, index: int, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - @typing.overload - def remove(self, x: float, y: float) -> None: ... - @typing.overload - def remove(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - @typing.overload - def remove(self, index: int) -> None: ... - @typing.overload - def replace(self, oldX: float, oldY: float, newX: float, newY: float) -> None: ... - @typing.overload - def replace(self, oldPoint: typing.Union[QtCore.QPointF, QtCore.QPoint], newPoint: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def __init__(self) -> None: ... @typing.overload - def replace(self, points: typing.Iterable[typing.Union[QtCore.QPointF, QtCore.QPoint]]) -> None: ... + def __init__(self, f: typing.Union['QChartView.RubberBands', 'QChartView.RubberBand']) -> None: ... @typing.overload - def replace(self, index: int, newX: float, newY: float) -> None: ... - @typing.overload - def replace(self, index: int, newPoint: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - @typing.overload - def append(self, x: float, y: float) -> None: ... - @typing.overload - def append(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... - @typing.overload - def append(self, points: typing.Iterable[typing.Union[QtCore.QPointF, QtCore.QPoint]]) -> None: ... - - class QLineSeries('QXYSeries'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def type(self) -> 'QAbstractSeries.SeriesType': ... - - class QLogValueAxis('QAbstractAxis'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def minorTickCountChanged(self, minorTickCount: int) -> None: ... - def tickCountChanged(self, tickCount: int) -> None: ... - def minorTickCount(self) -> int: ... - def setMinorTickCount(self, minorTickCount: int) -> None: ... - def tickCount(self) -> int: ... - def baseChanged(self, base: float) -> None: ... - def labelFormatChanged(self, format: str) -> None: ... - def rangeChanged(self, min: float, max: float) -> None: ... - def maxChanged(self, max: float) -> None: ... - def minChanged(self, min: float) -> None: ... - def base(self) -> float: ... - def setBase(self, base: float) -> None: ... - def labelFormat(self) -> str: ... - def setLabelFormat(self, format: str) -> None: ... - def setRange(self, min: float, max: float) -> None: ... - def max(self) -> float: ... - def setMax(self, max: float) -> None: ... - def min(self) -> float: ... - def setMin(self, min: float) -> None: ... - def type(self) -> 'QAbstractAxis.AxisType': ... - - class QPercentBarSeries('QAbstractBarSeries'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def type(self) -> 'QAbstractSeries.SeriesType': ... - - class QPieLegendMarker('QLegendMarker'): - - def __init__(self, series: 'QPieSeries', slice: 'QPieSlice', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def slice(self) -> 'QPieSlice': ... - def series(self) -> 'QPieSeries': ... - def type(self) -> 'QLegendMarker.LegendMarkerType': ... - - class QPieSeries('QAbstractSeries'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def doubleClicked(self, slice: 'QPieSlice') -> None: ... - def released(self, slice: 'QPieSlice') -> None: ... - def pressed(self, slice: 'QPieSlice') -> None: ... - def setLabelsPosition(self, position: 'QPieSlice.LabelPosition') -> None: ... - def holeSize(self) -> float: ... - def setHoleSize(self, holeSize: float) -> None: ... - def take(self, slice: 'QPieSlice') -> bool: ... - def sumChanged(self) -> None: ... - def countChanged(self) -> None: ... - def hovered(self, slice: 'QPieSlice', state: bool) -> None: ... - def clicked(self, slice: 'QPieSlice') -> None: ... - def removed(self, slices: typing.Iterable['QPieSlice']) -> None: ... - def added(self, slices: typing.Iterable['QPieSlice']) -> None: ... - def setLabelsVisible(self, visible: bool = ...) -> None: ... - def pieEndAngle(self) -> float: ... - def setPieEndAngle(self, endAngle: float) -> None: ... - def pieStartAngle(self) -> float: ... - def setPieStartAngle(self, startAngle: float) -> None: ... - def pieSize(self) -> float: ... - def setPieSize(self, relativeSize: float) -> None: ... - def verticalPosition(self) -> float: ... - def setVerticalPosition(self, relativePosition: float) -> None: ... - def horizontalPosition(self) -> float: ... - def setHorizontalPosition(self, relativePosition: float) -> None: ... - def sum(self) -> float: ... - def isEmpty(self) -> bool: ... - def __len__(self) -> int: ... - def count(self) -> int: ... - def slices(self) -> typing.List['QPieSlice']: ... - def clear(self) -> None: ... - def remove(self, slice: 'QPieSlice') -> bool: ... - def insert(self, index: int, slice: 'QPieSlice') -> bool: ... + def __init__(self, a0: 'QChartView.RubberBands') -> None: ... + + def __hash__(self) -> int: ... + def __bool__(self) -> int: ... + def __invert__(self) -> 'QChartView.RubberBands': ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + + @typing.overload + def __init__(self, parent: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... + @typing.overload + def __init__(self, chart: 'QChart', parent: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... + + def wheelEvent(self, event: QtGui.QWheelEvent) -> None: ... + def mouseReleaseEvent(self, event: QtGui.QMouseEvent) -> None: ... + def mouseMoveEvent(self, event: QtGui.QMouseEvent) -> None: ... + def mousePressEvent(self, event: QtGui.QMouseEvent) -> None: ... + def resizeEvent(self, event: QtGui.QResizeEvent) -> None: ... + def chart(self) -> 'QChart': ... + def setChart(self, chart: 'QChart') -> None: ... + def rubberBand(self) -> 'QChartView.RubberBands': ... + def setRubberBand(self, rubberBands: typing.Union['QChartView.RubberBands', 'QChartView.RubberBand']) -> None: ... + + +class QDateTimeAxis('QAbstractAxis'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def tickCountChanged(self, tick: int) -> None: ... + def formatChanged(self, format: str) -> None: ... + def rangeChanged(self, min: typing.Union[QtCore.QDateTime, datetime.datetime], max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... + def maxChanged(self, max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... + def minChanged(self, min: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... + def tickCount(self) -> int: ... + def setTickCount(self, count: int) -> None: ... + def format(self) -> str: ... + def setFormat(self, format: str) -> None: ... + def setRange(self, min: typing.Union[QtCore.QDateTime, datetime.datetime], max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... + def max(self) -> QtCore.QDateTime: ... + def setMax(self, max: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... + def min(self) -> QtCore.QDateTime: ... + def setMin(self, min: typing.Union[QtCore.QDateTime, datetime.datetime]) -> None: ... + def type(self) -> 'QAbstractAxis.AxisType': ... + + +class QHBarModelMapper(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def columnCountChanged(self) -> None: ... + def firstColumnChanged(self) -> None: ... + def lastBarSetRowChanged(self) -> None: ... + def firstBarSetRowChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... + def setColumnCount(self, columnCount: int) -> None: ... + def columnCount(self) -> int: ... + def setFirstColumn(self, firstColumn: int) -> None: ... + def firstColumn(self) -> int: ... + def setSeries(self, series: 'QAbstractBarSeries') -> None: ... + def series(self) -> 'QAbstractBarSeries': ... + def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... + def model(self) -> QtCore.QAbstractItemModel: ... + def setLastBarSetRow(self, lastBarSetRow: int) -> None: ... + def lastBarSetRow(self) -> int: ... + def setFirstBarSetRow(self, firstBarSetRow: int) -> None: ... + def firstBarSetRow(self) -> int: ... + + +class QHBoxPlotModelMapper(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def columnCountChanged(self) -> None: ... + def firstColumnChanged(self) -> None: ... + def lastBoxSetRowChanged(self) -> None: ... + def firstBoxSetRowChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... + def setColumnCount(self, rowCount: int) -> None: ... + def columnCount(self) -> int: ... + def setFirstColumn(self, firstColumn: int) -> None: ... + def firstColumn(self) -> int: ... + def setLastBoxSetRow(self, lastBoxSetRow: int) -> None: ... + def lastBoxSetRow(self) -> int: ... + def setFirstBoxSetRow(self, firstBoxSetRow: int) -> None: ... + def firstBoxSetRow(self) -> int: ... + def setSeries(self, series: 'QBoxPlotSeries') -> None: ... + def series(self) -> 'QBoxPlotSeries': ... + def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... + def model(self) -> QtCore.QAbstractItemModel: ... + + +class QHCandlestickModelMapper('QCandlestickModelMapper'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def lastSetRowChanged(self) -> None: ... + def firstSetRowChanged(self) -> None: ... + def closeColumnChanged(self) -> None: ... + def lowColumnChanged(self) -> None: ... + def highColumnChanged(self) -> None: ... + def openColumnChanged(self) -> None: ... + def timestampColumnChanged(self) -> None: ... + def lastSetRow(self) -> int: ... + def setLastSetRow(self, lastSetRow: int) -> None: ... + def firstSetRow(self) -> int: ... + def setFirstSetRow(self, firstSetRow: int) -> None: ... + def closeColumn(self) -> int: ... + def setCloseColumn(self, closeColumn: int) -> None: ... + def lowColumn(self) -> int: ... + def setLowColumn(self, lowColumn: int) -> None: ... + def highColumn(self) -> int: ... + def setHighColumn(self, highColumn: int) -> None: ... + def openColumn(self) -> int: ... + def setOpenColumn(self, openColumn: int) -> None: ... + def timestampColumn(self) -> int: ... + def setTimestampColumn(self, timestampColumn: int) -> None: ... + def orientation(self) -> QtCore.Qt.Orientation: ... + + +class QHorizontalBarSeries('QAbstractBarSeries'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QHorizontalPercentBarSeries('QAbstractBarSeries'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QHorizontalStackedBarSeries('QAbstractBarSeries'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QHPieModelMapper(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def columnCountChanged(self) -> None: ... + def firstColumnChanged(self) -> None: ... + def labelsRowChanged(self) -> None: ... + def valuesRowChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... + def setColumnCount(self, columnCount: int) -> None: ... + def columnCount(self) -> int: ... + def setFirstColumn(self, firstColumn: int) -> None: ... + def firstColumn(self) -> int: ... + def setSeries(self, series: 'QPieSeries') -> None: ... + def series(self) -> 'QPieSeries': ... + def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... + def model(self) -> QtCore.QAbstractItemModel: ... + def setLabelsRow(self, labelsRow: int) -> None: ... + def labelsRow(self) -> int: ... + def setValuesRow(self, valuesRow: int) -> None: ... + def valuesRow(self) -> int: ... + + +class QHXYModelMapper(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def columnCountChanged(self) -> None: ... + def firstColumnChanged(self) -> None: ... + def yRowChanged(self) -> None: ... + def xRowChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... + def setColumnCount(self, columnCount: int) -> None: ... + def columnCount(self) -> int: ... + def setFirstColumn(self, firstColumn: int) -> None: ... + def firstColumn(self) -> int: ... + def setSeries(self, series: 'QXYSeries') -> None: ... + def series(self) -> 'QXYSeries': ... + def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... + def model(self) -> QtCore.QAbstractItemModel: ... + def setYRow(self, yRow: int) -> None: ... + def yRow(self) -> int: ... + def setXRow(self, xRow: int) -> None: ... + def xRow(self) -> int: ... + + +class QLegend(QtWidgets.QGraphicsWidget): + + class MarkerShape(int): + MarkerShapeDefault = ... # type: QLegend.MarkerShape + MarkerShapeRectangle = ... # type: QLegend.MarkerShape + MarkerShapeCircle = ... # type: QLegend.MarkerShape + MarkerShapeFromSeries = ... # type: QLegend.MarkerShape + + def markerShapeChanged(self, shape: 'QLegend.MarkerShape') -> None: ... + def setMarkerShape(self, shape: 'QLegend.MarkerShape') -> None: ... + def markerShape(self) -> 'QLegend.MarkerShape': ... + def showToolTipsChanged(self, showToolTips: bool) -> None: ... + def setShowToolTips(self, show: bool) -> None: ... + def showToolTips(self) -> bool: ... + def reverseMarkersChanged(self, reverseMarkers: bool) -> None: ... + def setReverseMarkers(self, reverseMarkers: bool = ...) -> None: ... + def reverseMarkers(self) -> bool: ... + def showEvent(self, event: QtGui.QShowEvent) -> None: ... + def hideEvent(self, event: QtGui.QHideEvent) -> None: ... + def labelColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... + def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def backgroundVisibleChanged(self, visible: bool) -> None: ... + def markers(self, series: typing.Optional['QAbstractSeries'] = ...) -> typing.List['QLegendMarker']: ... + def labelColor(self) -> QtGui.QColor: ... + def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def labelBrush(self) -> QtGui.QBrush: ... + def setLabelBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def font(self) -> QtGui.QFont: ... + def setFont(self, font: QtGui.QFont) -> None: ... + def borderColor(self) -> QtGui.QColor: ... + def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def color(self) -> QtGui.QColor: ... + def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def isBackgroundVisible(self) -> bool: ... + def setBackgroundVisible(self, visible: bool = ...) -> None: ... + def isAttachedToChart(self) -> bool: ... + def attachToChart(self) -> None: ... + def detachFromChart(self) -> None: ... + def alignment(self) -> QtCore.Qt.Alignment: ... + def setAlignment(self, alignment: typing.Union[QtCore.Qt.Alignment, QtCore.Qt.AlignmentFlag]) -> None: ... + def pen(self) -> QtGui.QPen: ... + def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def brush(self) -> QtGui.QBrush: ... + def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def paint(self, painter: QtGui.QPainter, option: QtWidgets.QStyleOptionGraphicsItem, widget: typing.Optional[QtWidgets.QWidget] = ...) -> None: ... + + +class QXYSeries('QAbstractSeries'): + + def penChanged(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pointsRemoved(self, index: int, count: int) -> None: ... + def pointLabelsClippingChanged(self, clipping: bool) -> None: ... + def pointLabelsClipping(self) -> bool: ... + def setPointLabelsClipping(self, enable: bool = ...) -> None: ... + def pointsVector(self) -> typing.List[QtCore.QPointF]: ... + def removePoints(self, index: int, count: int) -> None: ... + def doubleClicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def released(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def pressed(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def pointLabelsColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pointLabelsFontChanged(self, font: QtGui.QFont) -> None: ... + def pointLabelsVisibilityChanged(self, visible: bool) -> None: ... + def pointLabelsFormatChanged(self, format: str) -> None: ... + def pointLabelsColor(self) -> QtGui.QColor: ... + def setPointLabelsColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pointLabelsFont(self) -> QtGui.QFont: ... + def setPointLabelsFont(self, font: QtGui.QFont) -> None: ... + def pointLabelsVisible(self) -> bool: ... + def setPointLabelsVisible(self, visible: bool = ...) -> None: ... + def pointLabelsFormat(self) -> str: ... + def setPointLabelsFormat(self, format: str) -> None: ... + def hovered(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint], state: bool) -> None: ... + def pointsReplaced(self) -> None: ... + def pointAdded(self, index: int) -> None: ... + def pointRemoved(self, index: int) -> None: ... + def pointReplaced(self, index: int) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def clicked(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + def at(self, index: int) -> QtCore.QPointF: ... + def pointsVisible(self) -> bool: ... + def setPointsVisible(self, visible: bool = ...) -> None: ... + def color(self) -> QtGui.QColor: ... + def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def brush(self) -> QtGui.QBrush: ... + def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def pen(self) -> QtGui.QPen: ... + def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def __len__(self) -> int: ... + def count(self) -> int: ... + def clear(self) -> None: ... + def insert(self, index: int, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + @typing.overload + def remove(self, x: float, y: float) -> None: ... + @typing.overload + def remove(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + @typing.overload + def remove(self, index: int) -> None: ... + @typing.overload + def replace(self, oldX: float, oldY: float, newX: float, newY: float) -> None: ... + @typing.overload + def replace(self, oldPoint: typing.Union[QtCore.QPointF, QtCore.QPoint], newPoint: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + @typing.overload + def replace(self, points: typing.Iterable[typing.Union[QtCore.QPointF, QtCore.QPoint]]) -> None: ... + @typing.overload + def replace(self, index: int, newX: float, newY: float) -> None: ... + @typing.overload + def replace(self, index: int, newPoint: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + @typing.overload + def append(self, x: float, y: float) -> None: ... + @typing.overload + def append(self, point: typing.Union[QtCore.QPointF, QtCore.QPoint]) -> None: ... + @typing.overload + def append(self, points: typing.Iterable[typing.Union[QtCore.QPointF, QtCore.QPoint]]) -> None: ... + + +class QLineSeries('QXYSeries'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QLogValueAxis('QAbstractAxis'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def minorTickCountChanged(self, minorTickCount: int) -> None: ... + def tickCountChanged(self, tickCount: int) -> None: ... + def minorTickCount(self) -> int: ... + def setMinorTickCount(self, minorTickCount: int) -> None: ... + def tickCount(self) -> int: ... + def baseChanged(self, base: float) -> None: ... + def labelFormatChanged(self, format: str) -> None: ... + def rangeChanged(self, min: float, max: float) -> None: ... + def maxChanged(self, max: float) -> None: ... + def minChanged(self, min: float) -> None: ... + def base(self) -> float: ... + def setBase(self, base: float) -> None: ... + def labelFormat(self) -> str: ... + def setLabelFormat(self, format: str) -> None: ... + def setRange(self, min: float, max: float) -> None: ... + def max(self) -> float: ... + def setMax(self, max: float) -> None: ... + def min(self) -> float: ... + def setMin(self, min: float) -> None: ... + def type(self) -> 'QAbstractAxis.AxisType': ... + + +class QPercentBarSeries('QAbstractBarSeries'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QPieLegendMarker('QLegendMarker'): + + def __init__(self, series: 'QPieSeries', slice: 'QPieSlice', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def slice(self) -> 'QPieSlice': ... + def series(self) -> 'QPieSeries': ... + def type(self) -> 'QLegendMarker.LegendMarkerType': ... + + +class QPieSeries('QAbstractSeries'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def doubleClicked(self, slice: 'QPieSlice') -> None: ... + def released(self, slice: 'QPieSlice') -> None: ... + def pressed(self, slice: 'QPieSlice') -> None: ... + def setLabelsPosition(self, position: 'QPieSlice.LabelPosition') -> None: ... + def holeSize(self) -> float: ... + def setHoleSize(self, holeSize: float) -> None: ... + def take(self, slice: 'QPieSlice') -> bool: ... + def sumChanged(self) -> None: ... + def countChanged(self) -> None: ... + def hovered(self, slice: 'QPieSlice', state: bool) -> None: ... + def clicked(self, slice: 'QPieSlice') -> None: ... + def removed(self, slices: typing.Iterable['QPieSlice']) -> None: ... + def added(self, slices: typing.Iterable['QPieSlice']) -> None: ... + def setLabelsVisible(self, visible: bool = ...) -> None: ... + def pieEndAngle(self) -> float: ... + def setPieEndAngle(self, endAngle: float) -> None: ... + def pieStartAngle(self) -> float: ... + def setPieStartAngle(self, startAngle: float) -> None: ... + def pieSize(self) -> float: ... + def setPieSize(self, relativeSize: float) -> None: ... + def verticalPosition(self) -> float: ... + def setVerticalPosition(self, relativePosition: float) -> None: ... + def horizontalPosition(self) -> float: ... + def setHorizontalPosition(self, relativePosition: float) -> None: ... + def sum(self) -> float: ... + def isEmpty(self) -> bool: ... + def __len__(self) -> int: ... + def count(self) -> int: ... + def slices(self) -> typing.List['QPieSlice']: ... + def clear(self) -> None: ... + def remove(self, slice: 'QPieSlice') -> bool: ... + def insert(self, index: int, slice: 'QPieSlice') -> bool: ... + @typing.overload + def append(self, slice: 'QPieSlice') -> bool: ... + @typing.overload + def append(self, slices: typing.Iterable['QPieSlice']) -> bool: ... + @typing.overload + def append(self, label: str, value: float) -> 'QPieSlice': ... + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QPieSlice(QtCore.QObject): + + class LabelPosition(int): + LabelOutside = ... # type: QPieSlice.LabelPosition + LabelInsideHorizontal = ... # type: QPieSlice.LabelPosition + LabelInsideTangential = ... # type: QPieSlice.LabelPosition + LabelInsideNormal = ... # type: QPieSlice.LabelPosition + + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, label: str, value: float, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def doubleClicked(self) -> None: ... + def released(self) -> None: ... + def pressed(self) -> None: ... + def hovered(self, state: bool) -> None: ... + def clicked(self) -> None: ... + def labelColorChanged(self) -> None: ... + def borderWidthChanged(self) -> None: ... + def borderColorChanged(self) -> None: ... + def colorChanged(self) -> None: ... + def angleSpanChanged(self) -> None: ... + def startAngleChanged(self) -> None: ... + def percentageChanged(self) -> None: ... + def labelFontChanged(self) -> None: ... + def labelBrushChanged(self) -> None: ... + def brushChanged(self) -> None: ... + def penChanged(self) -> None: ... + def labelVisibleChanged(self) -> None: ... + def valueChanged(self) -> None: ... + def labelChanged(self) -> None: ... + def setLabelPosition(self, position: 'QPieSlice.LabelPosition') -> None: ... + def labelPosition(self) -> 'QPieSlice.LabelPosition': ... + def series(self) -> 'QPieSeries': ... + def angleSpan(self) -> float: ... + def startAngle(self) -> float: ... + def percentage(self) -> float: ... + def explodeDistanceFactor(self) -> float: ... + def setExplodeDistanceFactor(self, factor: float) -> None: ... + def labelArmLengthFactor(self) -> float: ... + def setLabelArmLengthFactor(self, factor: float) -> None: ... + def labelFont(self) -> QtGui.QFont: ... + def setLabelFont(self, font: QtGui.QFont) -> None: ... + def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def labelColor(self) -> QtGui.QColor: ... + def labelBrush(self) -> QtGui.QBrush: ... + def setLabelBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def color(self) -> QtGui.QColor: ... + def brush(self) -> QtGui.QBrush: ... + def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def setBorderWidth(self, width: int) -> None: ... + def borderWidth(self) -> int: ... + def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def borderColor(self) -> QtGui.QColor: ... + def pen(self) -> QtGui.QPen: ... + def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def isExploded(self) -> bool: ... + def setExploded(self, exploded: bool = ...) -> None: ... + def isLabelVisible(self) -> bool: ... + def setLabelVisible(self, visible: bool = ...) -> None: ... + def value(self) -> float: ... + def setValue(self, value: float) -> None: ... + def label(self) -> str: ... + def setLabel(self, label: str) -> None: ... + + +class QPolarChart('QChart'): + + class PolarOrientation(int): + PolarOrientationRadial = ... # type: QPolarChart.PolarOrientation + PolarOrientationAngular = ... # type: QPolarChart.PolarOrientation + + class PolarOrientations(sip.simplewrapper): + @typing.overload - def append(self, slice: 'QPieSlice') -> bool: ... + def __init__(self) -> None: ... @typing.overload - def append(self, slices: typing.Iterable['QPieSlice']) -> bool: ... + def __init__(self, f: typing.Union['QPolarChart.PolarOrientations', 'QPolarChart.PolarOrientation']) -> None: ... @typing.overload - def append(self, label: str, value: float) -> 'QPieSlice': ... - def type(self) -> 'QAbstractSeries.SeriesType': ... + def __init__(self, a0: 'QPolarChart.PolarOrientations') -> None: ... + + def __hash__(self) -> int: ... + def __bool__(self) -> int: ... + def __invert__(self) -> 'QPolarChart.PolarOrientations': ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... - class QPieSlice(QtCore.QObject): + def __init__(self, parent: typing.Optional[QtWidgets.QGraphicsItem] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... - class LabelPosition(int): - LabelOutside = ... # type: QPieSlice.LabelPosition - LabelInsideHorizontal = ... # type: QPieSlice.LabelPosition - LabelInsideTangential = ... # type: QPieSlice.LabelPosition - LabelInsideNormal = ... # type: QPieSlice.LabelPosition + @staticmethod + def axisPolarOrientation(axis: 'QAbstractAxis') -> 'QPolarChart.PolarOrientation': ... + def axes(self, polarOrientation: 'QPolarChart.PolarOrientations' = ..., series: typing.Optional['QAbstractSeries'] = ...) -> typing.List['QAbstractAxis']: ... + def addAxis(self, axis: 'QAbstractAxis', polarOrientation: 'QPolarChart.PolarOrientation') -> None: ... - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, label: str, value: float, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def doubleClicked(self) -> None: ... - def released(self) -> None: ... - def pressed(self) -> None: ... - def hovered(self, state: bool) -> None: ... - def clicked(self) -> None: ... - def labelColorChanged(self) -> None: ... - def borderWidthChanged(self) -> None: ... - def borderColorChanged(self) -> None: ... - def colorChanged(self) -> None: ... - def angleSpanChanged(self) -> None: ... - def startAngleChanged(self) -> None: ... - def percentageChanged(self) -> None: ... - def labelFontChanged(self) -> None: ... - def labelBrushChanged(self) -> None: ... - def brushChanged(self) -> None: ... - def penChanged(self) -> None: ... - def labelVisibleChanged(self) -> None: ... - def valueChanged(self) -> None: ... - def labelChanged(self) -> None: ... - def setLabelPosition(self, position: 'QPieSlice.LabelPosition') -> None: ... - def labelPosition(self) -> 'QPieSlice.LabelPosition': ... - def series(self) -> 'QPieSeries': ... - def angleSpan(self) -> float: ... - def startAngle(self) -> float: ... - def percentage(self) -> float: ... - def explodeDistanceFactor(self) -> float: ... - def setExplodeDistanceFactor(self, factor: float) -> None: ... - def labelArmLengthFactor(self) -> float: ... - def setLabelArmLengthFactor(self, factor: float) -> None: ... - def labelFont(self) -> QtGui.QFont: ... - def setLabelFont(self, font: QtGui.QFont) -> None: ... - def setLabelColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def labelColor(self) -> QtGui.QColor: ... - def labelBrush(self) -> QtGui.QBrush: ... - def setLabelBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def color(self) -> QtGui.QColor: ... - def brush(self) -> QtGui.QBrush: ... - def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def setBorderWidth(self, width: int) -> None: ... - def borderWidth(self) -> int: ... - def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def borderColor(self) -> QtGui.QColor: ... - def pen(self) -> QtGui.QPen: ... - def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def isExploded(self) -> bool: ... - def setExploded(self, exploded: bool = ...) -> None: ... - def isLabelVisible(self) -> bool: ... - def setLabelVisible(self, visible: bool = ...) -> None: ... - def value(self) -> float: ... - def setValue(self, value: float) -> None: ... - def label(self) -> str: ... - def setLabel(self, label: str) -> None: ... - - class QPolarChart('QChart'): - - class PolarOrientation(int): - PolarOrientationRadial = ... # type: QPolarChart.PolarOrientation - PolarOrientationAngular = ... # type: QPolarChart.PolarOrientation - - class PolarOrientations(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, f: typing.Union['QPolarChart.PolarOrientations', 'QPolarChart.PolarOrientation']) -> None: ... - @typing.overload - def __init__(self, a0: 'QPolarChart.PolarOrientations') -> None: ... - - def __hash__(self) -> int: ... - def __bool__(self) -> int: ... - def __invert__(self) -> 'QPolarChart.PolarOrientations': ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... - - def __init__(self, parent: typing.Optional[QtWidgets.QGraphicsItem] = ..., flags: typing.Union[QtCore.Qt.WindowFlags, QtCore.Qt.WindowType] = ...) -> None: ... - - @staticmethod - def axisPolarOrientation(axis: 'QAbstractAxis') -> 'QPolarChart.PolarOrientation': ... - def axes(self, polarOrientation: 'QPolarChart.PolarOrientations' = ..., series: typing.Optional['QAbstractSeries'] = ...) -> typing.List['QAbstractAxis']: ... - def addAxis(self, axis: 'QAbstractAxis', polarOrientation: 'QPolarChart.PolarOrientation') -> None: ... - - class QScatterSeries('QXYSeries'): - - class MarkerShape(int): - MarkerShapeCircle = ... # type: QScatterSeries.MarkerShape - MarkerShapeRectangle = ... # type: QScatterSeries.MarkerShape - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def markerSizeChanged(self, size: float) -> None: ... - def markerShapeChanged(self, shape: 'QScatterSeries.MarkerShape') -> None: ... - def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def borderColor(self) -> QtGui.QColor: ... - def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def color(self) -> QtGui.QColor: ... - def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def brush(self) -> QtGui.QBrush: ... - def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... - def setMarkerSize(self, size: float) -> None: ... - def markerSize(self) -> float: ... - def setMarkerShape(self, shape: 'QScatterSeries.MarkerShape') -> None: ... - def markerShape(self) -> 'QScatterSeries.MarkerShape': ... - def type(self) -> 'QAbstractSeries.SeriesType': ... - - class QSplineSeries('QLineSeries'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def type(self) -> 'QAbstractSeries.SeriesType': ... - - class QStackedBarSeries('QAbstractBarSeries'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def type(self) -> 'QAbstractSeries.SeriesType': ... - - class QVBarModelMapper(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def lastBarSetColumnChanged(self) -> None: ... - def firstBarSetColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... - def setRowCount(self, rowCount: int) -> None: ... - def rowCount(self) -> int: ... - def setFirstRow(self, firstRow: int) -> None: ... - def firstRow(self) -> int: ... - def setSeries(self, series: 'QAbstractBarSeries') -> None: ... - def series(self) -> 'QAbstractBarSeries': ... - def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... - def model(self) -> QtCore.QAbstractItemModel: ... - def setLastBarSetColumn(self, lastBarSetColumn: int) -> None: ... - def lastBarSetColumn(self) -> int: ... - def setFirstBarSetColumn(self, firstBarSetColumn: int) -> None: ... - def firstBarSetColumn(self) -> int: ... - - class QVBoxPlotModelMapper(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def lastBoxSetColumnChanged(self) -> None: ... - def firstBoxSetColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... - def setRowCount(self, rowCount: int) -> None: ... - def rowCount(self) -> int: ... - def setFirstRow(self, firstRow: int) -> None: ... - def firstRow(self) -> int: ... - def setLastBoxSetColumn(self, lastBoxSetColumn: int) -> None: ... - def lastBoxSetColumn(self) -> int: ... - def setFirstBoxSetColumn(self, firstBoxSetColumn: int) -> None: ... - def firstBoxSetColumn(self) -> int: ... - def setSeries(self, series: 'QBoxPlotSeries') -> None: ... - def series(self) -> 'QBoxPlotSeries': ... - def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... - def model(self) -> QtCore.QAbstractItemModel: ... - - class QVCandlestickModelMapper('QCandlestickModelMapper'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def lastSetColumnChanged(self) -> None: ... - def firstSetColumnChanged(self) -> None: ... - def closeRowChanged(self) -> None: ... - def lowRowChanged(self) -> None: ... - def highRowChanged(self) -> None: ... - def openRowChanged(self) -> None: ... - def timestampRowChanged(self) -> None: ... - def lastSetColumn(self) -> int: ... - def setLastSetColumn(self, lastSetColumn: int) -> None: ... - def firstSetColumn(self) -> int: ... - def setFirstSetColumn(self, firstSetColumn: int) -> None: ... - def closeRow(self) -> int: ... - def setCloseRow(self, closeRow: int) -> None: ... - def lowRow(self) -> int: ... - def setLowRow(self, lowRow: int) -> None: ... - def highRow(self) -> int: ... - def setHighRow(self, highRow: int) -> None: ... - def openRow(self) -> int: ... - def setOpenRow(self, openRow: int) -> None: ... - def timestampRow(self) -> int: ... - def setTimestampRow(self, timestampRow: int) -> None: ... - def orientation(self) -> QtCore.Qt.Orientation: ... - - class QVPieModelMapper(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def labelsColumnChanged(self) -> None: ... - def valuesColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... - def setRowCount(self, rowCount: int) -> None: ... - def rowCount(self) -> int: ... - def setFirstRow(self, firstRow: int) -> None: ... - def firstRow(self) -> int: ... - def setSeries(self, series: 'QPieSeries') -> None: ... - def series(self) -> 'QPieSeries': ... - def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... - def model(self) -> QtCore.QAbstractItemModel: ... - def setLabelsColumn(self, labelsColumn: int) -> None: ... - def labelsColumn(self) -> int: ... - def setValuesColumn(self, valuesColumn: int) -> None: ... - def valuesColumn(self) -> int: ... - - class QVXYModelMapper(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def rowCountChanged(self) -> None: ... - def firstRowChanged(self) -> None: ... - def yColumnChanged(self) -> None: ... - def xColumnChanged(self) -> None: ... - def modelReplaced(self) -> None: ... - def seriesReplaced(self) -> None: ... - def setRowCount(self, rowCount: int) -> None: ... - def rowCount(self) -> int: ... - def setFirstRow(self, firstRow: int) -> None: ... - def firstRow(self) -> int: ... - def setSeries(self, series: 'QXYSeries') -> None: ... - def series(self) -> 'QXYSeries': ... - def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... - def model(self) -> QtCore.QAbstractItemModel: ... - def setYColumn(self, yColumn: int) -> None: ... - def yColumn(self) -> int: ... - def setXColumn(self, xColumn: int) -> None: ... - def xColumn(self) -> int: ... - - class QXYLegendMarker('QLegendMarker'): - - def __init__(self, series: 'QXYSeries', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def series(self) -> 'QXYSeries': ... - def type(self) -> 'QLegendMarker.LegendMarkerType': ... + +class QScatterSeries('QXYSeries'): + + class MarkerShape(int): + MarkerShapeCircle = ... # type: QScatterSeries.MarkerShape + MarkerShapeRectangle = ... # type: QScatterSeries.MarkerShape + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def markerSizeChanged(self, size: float) -> None: ... + def markerShapeChanged(self, shape: 'QScatterSeries.MarkerShape') -> None: ... + def borderColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def colorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def borderColor(self) -> QtGui.QColor: ... + def setBorderColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def color(self) -> QtGui.QColor: ... + def setColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def setBrush(self, brush: typing.Union[QtGui.QBrush, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def brush(self) -> QtGui.QBrush: ... + def setPen(self, pen: typing.Union[QtGui.QPen, QtGui.QColor, QtCore.Qt.GlobalColor, QtGui.QGradient]) -> None: ... + def setMarkerSize(self, size: float) -> None: ... + def markerSize(self) -> float: ... + def setMarkerShape(self, shape: 'QScatterSeries.MarkerShape') -> None: ... + def markerShape(self) -> 'QScatterSeries.MarkerShape': ... + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QSplineSeries('QLineSeries'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QStackedBarSeries('QAbstractBarSeries'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def type(self) -> 'QAbstractSeries.SeriesType': ... + + +class QVBarModelMapper(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def rowCountChanged(self) -> None: ... + def firstRowChanged(self) -> None: ... + def lastBarSetColumnChanged(self) -> None: ... + def firstBarSetColumnChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... + def setRowCount(self, rowCount: int) -> None: ... + def rowCount(self) -> int: ... + def setFirstRow(self, firstRow: int) -> None: ... + def firstRow(self) -> int: ... + def setSeries(self, series: 'QAbstractBarSeries') -> None: ... + def series(self) -> 'QAbstractBarSeries': ... + def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... + def model(self) -> QtCore.QAbstractItemModel: ... + def setLastBarSetColumn(self, lastBarSetColumn: int) -> None: ... + def lastBarSetColumn(self) -> int: ... + def setFirstBarSetColumn(self, firstBarSetColumn: int) -> None: ... + def firstBarSetColumn(self) -> int: ... + + +class QVBoxPlotModelMapper(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def rowCountChanged(self) -> None: ... + def firstRowChanged(self) -> None: ... + def lastBoxSetColumnChanged(self) -> None: ... + def firstBoxSetColumnChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... + def setRowCount(self, rowCount: int) -> None: ... + def rowCount(self) -> int: ... + def setFirstRow(self, firstRow: int) -> None: ... + def firstRow(self) -> int: ... + def setLastBoxSetColumn(self, lastBoxSetColumn: int) -> None: ... + def lastBoxSetColumn(self) -> int: ... + def setFirstBoxSetColumn(self, firstBoxSetColumn: int) -> None: ... + def firstBoxSetColumn(self) -> int: ... + def setSeries(self, series: 'QBoxPlotSeries') -> None: ... + def series(self) -> 'QBoxPlotSeries': ... + def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... + def model(self) -> QtCore.QAbstractItemModel: ... + + +class QVCandlestickModelMapper('QCandlestickModelMapper'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def lastSetColumnChanged(self) -> None: ... + def firstSetColumnChanged(self) -> None: ... + def closeRowChanged(self) -> None: ... + def lowRowChanged(self) -> None: ... + def highRowChanged(self) -> None: ... + def openRowChanged(self) -> None: ... + def timestampRowChanged(self) -> None: ... + def lastSetColumn(self) -> int: ... + def setLastSetColumn(self, lastSetColumn: int) -> None: ... + def firstSetColumn(self) -> int: ... + def setFirstSetColumn(self, firstSetColumn: int) -> None: ... + def closeRow(self) -> int: ... + def setCloseRow(self, closeRow: int) -> None: ... + def lowRow(self) -> int: ... + def setLowRow(self, lowRow: int) -> None: ... + def highRow(self) -> int: ... + def setHighRow(self, highRow: int) -> None: ... + def openRow(self) -> int: ... + def setOpenRow(self, openRow: int) -> None: ... + def timestampRow(self) -> int: ... + def setTimestampRow(self, timestampRow: int) -> None: ... + def orientation(self) -> QtCore.Qt.Orientation: ... + + +class QVPieModelMapper(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def rowCountChanged(self) -> None: ... + def firstRowChanged(self) -> None: ... + def labelsColumnChanged(self) -> None: ... + def valuesColumnChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... + def setRowCount(self, rowCount: int) -> None: ... + def rowCount(self) -> int: ... + def setFirstRow(self, firstRow: int) -> None: ... + def firstRow(self) -> int: ... + def setSeries(self, series: 'QPieSeries') -> None: ... + def series(self) -> 'QPieSeries': ... + def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... + def model(self) -> QtCore.QAbstractItemModel: ... + def setLabelsColumn(self, labelsColumn: int) -> None: ... + def labelsColumn(self) -> int: ... + def setValuesColumn(self, valuesColumn: int) -> None: ... + def valuesColumn(self) -> int: ... + + +class QVXYModelMapper(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def rowCountChanged(self) -> None: ... + def firstRowChanged(self) -> None: ... + def yColumnChanged(self) -> None: ... + def xColumnChanged(self) -> None: ... + def modelReplaced(self) -> None: ... + def seriesReplaced(self) -> None: ... + def setRowCount(self, rowCount: int) -> None: ... + def rowCount(self) -> int: ... + def setFirstRow(self, firstRow: int) -> None: ... + def firstRow(self) -> int: ... + def setSeries(self, series: 'QXYSeries') -> None: ... + def series(self) -> 'QXYSeries': ... + def setModel(self, model: QtCore.QAbstractItemModel) -> None: ... + def model(self) -> QtCore.QAbstractItemModel: ... + def setYColumn(self, yColumn: int) -> None: ... + def yColumn(self) -> int: ... + def setXColumn(self, xColumn: int) -> None: ... + def xColumn(self) -> int: ... + + +class QXYLegendMarker('QLegendMarker'): + + def __init__(self, series: 'QXYSeries', legend: 'QLegend', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def series(self) -> 'QXYSeries': ... + def type(self) -> 'QLegendMarker.LegendMarkerType': ... PYQT_CHART_VERSION = ... # type: int diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 41c4e6c5..6ad49a1e 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtCore module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtDBus.pyi b/PyQt5-stubs/QtDBus.pyi index 1fdebcbf..dbed5cbe 100644 --- a/PyQt5-stubs/QtDBus.pyi +++ b/PyQt5-stubs/QtDBus.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtDBus module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtDataVisualization.pyi b/PyQt5-stubs/QtDataVisualization.pyi index 39bbf634..860acca4 100644 --- a/PyQt5-stubs/QtDataVisualization.pyi +++ b/PyQt5-stubs/QtDataVisualization.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtDataVisualization module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -40,1363 +40,1396 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], typing.Sequence[float], PyQt5.sip.Buffer, int, None] -class QtDataVisualization(PyQt5.sip.simplewrapper): - - class QAbstract3DGraph(QtGui.QWindow): - - class OptimizationHint(int): - OptimizationDefault = ... # type: QAbstract3DGraph.OptimizationHint - OptimizationStatic = ... # type: QAbstract3DGraph.OptimizationHint - - class ElementType(int): - ElementNone = ... # type: QAbstract3DGraph.ElementType - ElementSeries = ... # type: QAbstract3DGraph.ElementType - ElementAxisXLabel = ... # type: QAbstract3DGraph.ElementType - ElementAxisYLabel = ... # type: QAbstract3DGraph.ElementType - ElementAxisZLabel = ... # type: QAbstract3DGraph.ElementType - ElementCustomItem = ... # type: QAbstract3DGraph.ElementType - - class ShadowQuality(int): - ShadowQualityNone = ... # type: QAbstract3DGraph.ShadowQuality - ShadowQualityLow = ... # type: QAbstract3DGraph.ShadowQuality - ShadowQualityMedium = ... # type: QAbstract3DGraph.ShadowQuality - ShadowQualityHigh = ... # type: QAbstract3DGraph.ShadowQuality - ShadowQualitySoftLow = ... # type: QAbstract3DGraph.ShadowQuality - ShadowQualitySoftMedium = ... # type: QAbstract3DGraph.ShadowQuality - ShadowQualitySoftHigh = ... # type: QAbstract3DGraph.ShadowQuality - - class SelectionFlag(int): - SelectionNone = ... # type: QAbstract3DGraph.SelectionFlag - SelectionItem = ... # type: QAbstract3DGraph.SelectionFlag - SelectionRow = ... # type: QAbstract3DGraph.SelectionFlag - SelectionItemAndRow = ... # type: QAbstract3DGraph.SelectionFlag - SelectionColumn = ... # type: QAbstract3DGraph.SelectionFlag - SelectionItemAndColumn = ... # type: QAbstract3DGraph.SelectionFlag - SelectionRowAndColumn = ... # type: QAbstract3DGraph.SelectionFlag - SelectionItemRowAndColumn = ... # type: QAbstract3DGraph.SelectionFlag - SelectionSlice = ... # type: QAbstract3DGraph.SelectionFlag - SelectionMultiSeries = ... # type: QAbstract3DGraph.SelectionFlag - - class SelectionFlags(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, f: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag']) -> None: ... - @typing.overload - def __init__(self, a0: 'QAbstract3DGraph.SelectionFlags') -> None: ... - - def __hash__(self) -> int: ... - def __bool__(self) -> int: ... - def __invert__(self) -> 'QAbstract3DGraph.SelectionFlags': ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... - - class OptimizationHints(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, f: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... - @typing.overload - def __init__(self, a0: 'QAbstract3DGraph.OptimizationHints') -> None: ... - - def __hash__(self) -> int: ... - def __bool__(self) -> int: ... - def __invert__(self) -> 'QAbstract3DGraph.OptimizationHints': ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... - - def hasContext(self) -> bool: ... - def marginChanged(self, margin: float) -> None: ... - def queriedGraphPositionChanged(self, data: QtGui.QVector3D) -> None: ... - def localeChanged(self, locale: QtCore.QLocale) -> None: ... - def reflectivityChanged(self, reflectivity: float) -> None: ... - def reflectionChanged(self, enabled: bool) -> None: ... - def horizontalAspectRatioChanged(self, ratio: float) -> None: ... - def radialLabelOffsetChanged(self, offset: float) -> None: ... - def polarChanged(self, enabled: bool) -> None: ... - def margin(self) -> float: ... - def setMargin(self, margin: float) -> None: ... - def queriedGraphPosition(self) -> QtGui.QVector3D: ... - def locale(self) -> QtCore.QLocale: ... - def setLocale(self, locale: QtCore.QLocale) -> None: ... - def reflectivity(self) -> float: ... - def setReflectivity(self, reflectivity: float) -> None: ... - def isReflection(self) -> bool: ... - def setReflection(self, enable: bool) -> None: ... - def horizontalAspectRatio(self) -> float: ... - def setHorizontalAspectRatio(self, ratio: float) -> None: ... - def radialLabelOffset(self) -> float: ... - def setRadialLabelOffset(self, offset: float) -> None: ... - def isPolar(self) -> bool: ... - def setPolar(self, enable: bool) -> None: ... - def customItems(self) -> typing.List['QCustom3DItem']: ... - def optimizationHintsChanged(self, hints: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... - def aspectRatioChanged(self, ratio: float) -> None: ... - def orthoProjectionChanged(self, enabled: bool) -> None: ... - def currentFpsChanged(self, fps: float) -> None: ... - def measureFpsChanged(self, enabled: bool) -> None: ... - def selectedElementChanged(self, type: 'QAbstract3DGraph.ElementType') -> None: ... - def optimizationHints(self) -> 'QAbstract3DGraph.OptimizationHints': ... - def setOptimizationHints(self, hints: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... - def aspectRatio(self) -> float: ... - def setAspectRatio(self, ratio: float) -> None: ... - def selectedElement(self) -> 'QAbstract3DGraph.ElementType': ... - def isOrthoProjection(self) -> bool: ... - def setOrthoProjection(self, enable: bool) -> None: ... - def currentFps(self) -> float: ... - def measureFps(self) -> bool: ... - def setMeasureFps(self, enable: bool) -> None: ... - def renderToImage(self, msaaSamples: int = ..., imageSize: QtCore.QSize = ...) -> QtGui.QImage: ... - def selectedCustomItem(self) -> 'QCustom3DItem': ... - def selectedCustomItemIndex(self) -> int: ... - def selectedAxis(self) -> 'QAbstract3DAxis': ... - def selectedLabelIndex(self) -> int: ... - def releaseCustomItem(self, item: 'QCustom3DItem') -> None: ... - def removeCustomItemAt(self, position: QtGui.QVector3D) -> None: ... - def removeCustomItem(self, item: 'QCustom3DItem') -> None: ... - def removeCustomItems(self) -> None: ... - def addCustomItem(self, item: 'QCustom3DItem') -> int: ... - def wheelEvent(self, event: QtGui.QWheelEvent) -> None: ... - def mouseMoveEvent(self, event: QtGui.QMouseEvent) -> None: ... - def mouseReleaseEvent(self, event: QtGui.QMouseEvent) -> None: ... - def mousePressEvent(self, event: QtGui.QMouseEvent) -> None: ... - def touchEvent(self, event: QtGui.QTouchEvent) -> None: ... - def mouseDoubleClickEvent(self, event: QtGui.QMouseEvent) -> None: ... - def exposeEvent(self, event: QtGui.QExposeEvent) -> None: ... - def resizeEvent(self, event: QtGui.QResizeEvent) -> None: ... - def event(self, event: QtCore.QEvent) -> bool: ... - def shadowQualityChanged(self, quality: 'QAbstract3DGraph.ShadowQuality') -> None: ... - def selectionModeChanged(self, mode: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag']) -> None: ... - def activeThemeChanged(self, theme: 'Q3DTheme') -> None: ... - def activeInputHandlerChanged(self, inputHandler: 'QAbstract3DInputHandler') -> None: ... - def shadowsSupported(self) -> bool: ... - def activeInputHandler(self) -> 'QAbstract3DInputHandler': ... - def clearSelection(self) -> None: ... - def scene(self) -> 'Q3DScene': ... - def shadowQuality(self) -> 'QAbstract3DGraph.ShadowQuality': ... - def setShadowQuality(self, quality: 'QAbstract3DGraph.ShadowQuality') -> None: ... - def selectionMode(self) -> 'QAbstract3DGraph.SelectionFlags': ... - def setSelectionMode(self, mode: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag']) -> None: ... - def themes(self) -> typing.List['Q3DTheme']: ... - def activeTheme(self) -> 'Q3DTheme': ... - def setActiveTheme(self, theme: 'Q3DTheme') -> None: ... - def releaseTheme(self, theme: 'Q3DTheme') -> None: ... - def addTheme(self, theme: 'Q3DTheme') -> None: ... - def inputHandlers(self) -> typing.List['QAbstract3DInputHandler']: ... - def setActiveInputHandler(self, inputHandler: 'QAbstract3DInputHandler') -> None: ... - def releaseInputHandler(self, inputHandler: 'QAbstract3DInputHandler') -> None: ... - def addInputHandler(self, inputHandler: 'QAbstract3DInputHandler') -> None: ... - - class Q3DBars('QAbstract3DGraph'): - - def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - - def floorLevelChanged(self, level: float) -> None: ... - def floorLevel(self) -> float: ... - def setFloorLevel(self, level: float) -> None: ... - def selectedSeriesChanged(self, series: 'QBar3DSeries') -> None: ... - def primarySeriesChanged(self, series: 'QBar3DSeries') -> None: ... - def valueAxisChanged(self, axis: 'QValue3DAxis') -> None: ... - def columnAxisChanged(self, axis: 'QCategory3DAxis') -> None: ... - def rowAxisChanged(self, axis: 'QCategory3DAxis') -> None: ... - def barSpacingRelativeChanged(self, relative: bool) -> None: ... - def barSpacingChanged(self, spacing: QtCore.QSizeF) -> None: ... - def barThicknessChanged(self, thicknessRatio: float) -> None: ... - def multiSeriesUniformChanged(self, uniform: bool) -> None: ... - def selectedSeries(self) -> 'QBar3DSeries': ... - def axes(self) -> typing.List['QAbstract3DAxis']: ... - def releaseAxis(self, axis: 'QAbstract3DAxis') -> None: ... - def addAxis(self, axis: 'QAbstract3DAxis') -> None: ... - def valueAxis(self) -> 'QValue3DAxis': ... - def setValueAxis(self, axis: 'QValue3DAxis') -> None: ... - def columnAxis(self) -> 'QCategory3DAxis': ... - def setColumnAxis(self, axis: 'QCategory3DAxis') -> None: ... - def rowAxis(self) -> 'QCategory3DAxis': ... - def setRowAxis(self, axis: 'QCategory3DAxis') -> None: ... - def isBarSpacingRelative(self) -> bool: ... - def setBarSpacingRelative(self, relative: bool) -> None: ... - def barSpacing(self) -> QtCore.QSizeF: ... - def setBarSpacing(self, spacing: QtCore.QSizeF) -> None: ... - def barThickness(self) -> float: ... - def setBarThickness(self, thicknessRatio: float) -> None: ... - def isMultiSeriesUniform(self) -> bool: ... - def setMultiSeriesUniform(self, uniform: bool) -> None: ... - def seriesList(self) -> typing.List['QBar3DSeries']: ... - def insertSeries(self, index: int, series: 'QBar3DSeries') -> None: ... - def removeSeries(self, series: 'QBar3DSeries') -> None: ... - def addSeries(self, series: 'QBar3DSeries') -> None: ... - def primarySeries(self) -> 'QBar3DSeries': ... - def setPrimarySeries(self, series: 'QBar3DSeries') -> None: ... - - class Q3DObject(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def isDirty(self) -> bool: ... - def setDirty(self, dirty: bool) -> None: ... - def positionChanged(self, position: QtGui.QVector3D) -> None: ... - def setPosition(self, position: QtGui.QVector3D) -> None: ... - def position(self) -> QtGui.QVector3D: ... - def parentScene(self) -> 'Q3DScene': ... - def copyValuesFrom(self, source: 'Q3DObject') -> None: ... - - class Q3DCamera('Q3DObject'): - - class CameraPreset(int): - CameraPresetNone = ... # type: Q3DCamera.CameraPreset - CameraPresetFrontLow = ... # type: Q3DCamera.CameraPreset - CameraPresetFront = ... # type: Q3DCamera.CameraPreset - CameraPresetFrontHigh = ... # type: Q3DCamera.CameraPreset - CameraPresetLeftLow = ... # type: Q3DCamera.CameraPreset - CameraPresetLeft = ... # type: Q3DCamera.CameraPreset - CameraPresetLeftHigh = ... # type: Q3DCamera.CameraPreset - CameraPresetRightLow = ... # type: Q3DCamera.CameraPreset - CameraPresetRight = ... # type: Q3DCamera.CameraPreset - CameraPresetRightHigh = ... # type: Q3DCamera.CameraPreset - CameraPresetBehindLow = ... # type: Q3DCamera.CameraPreset - CameraPresetBehind = ... # type: Q3DCamera.CameraPreset - CameraPresetBehindHigh = ... # type: Q3DCamera.CameraPreset - CameraPresetIsometricLeft = ... # type: Q3DCamera.CameraPreset - CameraPresetIsometricLeftHigh = ... # type: Q3DCamera.CameraPreset - CameraPresetIsometricRight = ... # type: Q3DCamera.CameraPreset - CameraPresetIsometricRightHigh = ... # type: Q3DCamera.CameraPreset - CameraPresetDirectlyAbove = ... # type: Q3DCamera.CameraPreset - CameraPresetDirectlyAboveCW45 = ... # type: Q3DCamera.CameraPreset - CameraPresetDirectlyAboveCCW45 = ... # type: Q3DCamera.CameraPreset - CameraPresetFrontBelow = ... # type: Q3DCamera.CameraPreset - CameraPresetLeftBelow = ... # type: Q3DCamera.CameraPreset - CameraPresetRightBelow = ... # type: Q3DCamera.CameraPreset - CameraPresetBehindBelow = ... # type: Q3DCamera.CameraPreset - CameraPresetDirectlyBelow = ... # type: Q3DCamera.CameraPreset - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def targetChanged(self, target: QtGui.QVector3D) -> None: ... - def maxZoomLevelChanged(self, zoomLevel: float) -> None: ... - def minZoomLevelChanged(self, zoomLevel: float) -> None: ... - def setTarget(self, target: QtGui.QVector3D) -> None: ... - def target(self) -> QtGui.QVector3D: ... - def setMaxZoomLevel(self, zoomLevel: float) -> None: ... - def maxZoomLevel(self) -> float: ... - def setMinZoomLevel(self, zoomLevel: float) -> None: ... - def minZoomLevel(self) -> float: ... - def wrapYRotationChanged(self, isEnabled: bool) -> None: ... - def wrapXRotationChanged(self, isEnabled: bool) -> None: ... - def cameraPresetChanged(self, preset: 'Q3DCamera.CameraPreset') -> None: ... - def zoomLevelChanged(self, zoomLevel: float) -> None: ... - def yRotationChanged(self, rotation: float) -> None: ... - def xRotationChanged(self, rotation: float) -> None: ... - def setZoomLevel(self, zoomLevel: float) -> None: ... - def zoomLevel(self) -> float: ... - def setCameraPosition(self, horizontal: float, vertical: float, zoom: float = ...) -> None: ... - def setCameraPreset(self, preset: 'Q3DCamera.CameraPreset') -> None: ... - def cameraPreset(self) -> 'Q3DCamera.CameraPreset': ... - def copyValuesFrom(self, source: 'Q3DObject') -> None: ... - def setWrapYRotation(self, isEnabled: bool) -> None: ... - def wrapYRotation(self) -> bool: ... - def setWrapXRotation(self, isEnabled: bool) -> None: ... - def wrapXRotation(self) -> bool: ... - def setYRotation(self, rotation: float) -> None: ... - def yRotation(self) -> float: ... - def setXRotation(self, rotation: float) -> None: ... - def xRotation(self) -> float: ... - - class QAbstract3DInputHandler(QtCore.QObject): - - class InputView(int): - InputViewNone = ... # type: QAbstract3DInputHandler.InputView - InputViewOnPrimary = ... # type: QAbstract3DInputHandler.InputView - InputViewOnSecondary = ... # type: QAbstract3DInputHandler.InputView - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def previousInputPos(self) -> QtCore.QPoint: ... - def setPreviousInputPos(self, position: QtCore.QPoint) -> None: ... - def prevDistance(self) -> int: ... - def setPrevDistance(self, distance: int) -> None: ... - def sceneChanged(self, scene: 'Q3DScene') -> None: ... - def inputViewChanged(self, view: 'QAbstract3DInputHandler.InputView') -> None: ... - def positionChanged(self, position: QtCore.QPoint) -> None: ... - def setScene(self, scene: 'Q3DScene') -> None: ... - def scene(self) -> 'Q3DScene': ... - def setInputPosition(self, position: QtCore.QPoint) -> None: ... - def inputPosition(self) -> QtCore.QPoint: ... - def setInputView(self, inputView: 'QAbstract3DInputHandler.InputView') -> None: ... - def inputView(self) -> 'QAbstract3DInputHandler.InputView': ... - def wheelEvent(self, event: QtGui.QWheelEvent) -> None: ... - def mouseMoveEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... - def mouseReleaseEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... - def mousePressEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... - def touchEvent(self, event: QtGui.QTouchEvent) -> None: ... - def mouseDoubleClickEvent(self, event: QtGui.QMouseEvent) -> None: ... - - class Q3DInputHandler('QAbstract3DInputHandler'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def zoomAtTargetEnabledChanged(self, enable: bool) -> None: ... - def selectionEnabledChanged(self, enable: bool) -> None: ... - def zoomEnabledChanged(self, enable: bool) -> None: ... - def rotationEnabledChanged(self, enable: bool) -> None: ... - def isZoomAtTargetEnabled(self) -> bool: ... - def setZoomAtTargetEnabled(self, enable: bool) -> None: ... - def isSelectionEnabled(self) -> bool: ... - def setSelectionEnabled(self, enable: bool) -> None: ... - def isZoomEnabled(self) -> bool: ... - def setZoomEnabled(self, enable: bool) -> None: ... - def isRotationEnabled(self) -> bool: ... - def setRotationEnabled(self, enable: bool) -> None: ... - def wheelEvent(self, event: QtGui.QWheelEvent) -> None: ... - def mouseMoveEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... - def mouseReleaseEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... - def mousePressEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... - - class Q3DLight('Q3DObject'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def autoPositionChanged(self, autoPosition: bool) -> None: ... - def isAutoPosition(self) -> bool: ... - def setAutoPosition(self, enabled: bool) -> None: ... - - class Q3DScatter('QAbstract3DGraph'): - - def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - - def selectedSeriesChanged(self, series: 'QScatter3DSeries') -> None: ... - def axisZChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisYChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisXChanged(self, axis: 'QValue3DAxis') -> None: ... - def selectedSeries(self) -> 'QScatter3DSeries': ... - def axes(self) -> typing.List['QValue3DAxis']: ... - def releaseAxis(self, axis: 'QValue3DAxis') -> None: ... - def addAxis(self, axis: 'QValue3DAxis') -> None: ... - def axisZ(self) -> 'QValue3DAxis': ... - def setAxisZ(self, axis: 'QValue3DAxis') -> None: ... - def axisY(self) -> 'QValue3DAxis': ... - def setAxisY(self, axis: 'QValue3DAxis') -> None: ... - def axisX(self) -> 'QValue3DAxis': ... - def setAxisX(self, axis: 'QValue3DAxis') -> None: ... - def seriesList(self) -> typing.List['QScatter3DSeries']: ... - def removeSeries(self, series: 'QScatter3DSeries') -> None: ... - def addSeries(self, series: 'QScatter3DSeries') -> None: ... - - class Q3DScene(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def graphPositionQueryChanged(self, position: QtCore.QPoint) -> None: ... - def graphPositionQuery(self) -> QtCore.QPoint: ... - def setGraphPositionQuery(self, point: QtCore.QPoint) -> None: ... - def selectionQueryPositionChanged(self, position: QtCore.QPoint) -> None: ... - def devicePixelRatioChanged(self, pixelRatio: float) -> None: ... - def activeLightChanged(self, light: 'Q3DLight') -> None: ... - def activeCameraChanged(self, camera: 'Q3DCamera') -> None: ... - def slicingActiveChanged(self, isSlicingActive: bool) -> None: ... - def secondarySubviewOnTopChanged(self, isSecondaryOnTop: bool) -> None: ... - def secondarySubViewportChanged(self, subViewport: QtCore.QRect) -> None: ... - def primarySubViewportChanged(self, subViewport: QtCore.QRect) -> None: ... - def viewportChanged(self, viewport: QtCore.QRect) -> None: ... - def setDevicePixelRatio(self, pixelRatio: float) -> None: ... - def devicePixelRatio(self) -> float: ... - def setActiveLight(self, light: 'Q3DLight') -> None: ... - def activeLight(self) -> 'Q3DLight': ... - def setActiveCamera(self, camera: 'Q3DCamera') -> None: ... - def activeCamera(self) -> 'Q3DCamera': ... - def isSecondarySubviewOnTop(self) -> bool: ... - def setSecondarySubviewOnTop(self, isSecondaryOnTop: bool) -> None: ... - def isSlicingActive(self) -> bool: ... - def setSlicingActive(self, isSlicing: bool) -> None: ... - @staticmethod - def invalidSelectionPoint() -> QtCore.QPoint: ... - def selectionQueryPosition(self) -> QtCore.QPoint: ... - def setSelectionQueryPosition(self, point: QtCore.QPoint) -> None: ... - def isPointInSecondarySubView(self, point: QtCore.QPoint) -> bool: ... - def setSecondarySubViewport(self, secondarySubViewport: QtCore.QRect) -> None: ... - def secondarySubViewport(self) -> QtCore.QRect: ... - def isPointInPrimarySubView(self, point: QtCore.QPoint) -> bool: ... - def setPrimarySubViewport(self, primarySubViewport: QtCore.QRect) -> None: ... - def primarySubViewport(self) -> QtCore.QRect: ... - def viewport(self) -> QtCore.QRect: ... - - class Q3DSurface('QAbstract3DGraph'): - - def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... - - def flipHorizontalGridChanged(self, flip: bool) -> None: ... - def flipHorizontalGrid(self) -> bool: ... - def setFlipHorizontalGrid(self, flip: bool) -> None: ... - def selectedSeriesChanged(self, series: 'QSurface3DSeries') -> None: ... - def axisZChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisYChanged(self, axis: 'QValue3DAxis') -> None: ... - def axisXChanged(self, axis: 'QValue3DAxis') -> None: ... - def selectedSeries(self) -> 'QSurface3DSeries': ... - def axes(self) -> typing.List['QValue3DAxis']: ... - def releaseAxis(self, axis: 'QValue3DAxis') -> None: ... - def addAxis(self, axis: 'QValue3DAxis') -> None: ... - def axisZ(self) -> 'QValue3DAxis': ... - def setAxisZ(self, axis: 'QValue3DAxis') -> None: ... - def axisY(self) -> 'QValue3DAxis': ... - def setAxisY(self, axis: 'QValue3DAxis') -> None: ... - def axisX(self) -> 'QValue3DAxis': ... - def setAxisX(self, axis: 'QValue3DAxis') -> None: ... - def seriesList(self) -> typing.List['QSurface3DSeries']: ... - def removeSeries(self, series: 'QSurface3DSeries') -> None: ... - def addSeries(self, series: 'QSurface3DSeries') -> None: ... - - class Q3DTheme(QtCore.QObject): - - class Theme(int): - ThemeQt = ... # type: Q3DTheme.Theme - ThemePrimaryColors = ... # type: Q3DTheme.Theme - ThemeDigia = ... # type: Q3DTheme.Theme - ThemeStoneMoss = ... # type: Q3DTheme.Theme - ThemeArmyBlue = ... # type: Q3DTheme.Theme - ThemeRetro = ... # type: Q3DTheme.Theme - ThemeEbony = ... # type: Q3DTheme.Theme - ThemeIsabelle = ... # type: Q3DTheme.Theme - ThemeUserDefined = ... # type: Q3DTheme.Theme - - class ColorStyle(int): - ColorStyleUniform = ... # type: Q3DTheme.ColorStyle - ColorStyleObjectGradient = ... # type: Q3DTheme.ColorStyle - ColorStyleRangeGradient = ... # type: Q3DTheme.ColorStyle - - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, themeType: 'Q3DTheme.Theme', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def colorStyleChanged(self, style: 'Q3DTheme.ColorStyle') -> None: ... - def labelBackgroundEnabledChanged(self, enabled: bool) -> None: ... - def gridEnabledChanged(self, enabled: bool) -> None: ... - def backgroundEnabledChanged(self, enabled: bool) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def labelBorderEnabledChanged(self, enabled: bool) -> None: ... - def highlightLightStrengthChanged(self, strength: float) -> None: ... - def ambientLightStrengthChanged(self, strength: float) -> None: ... - def lightStrengthChanged(self, strength: float) -> None: ... - def multiHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def singleHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def baseGradientsChanged(self, gradients: typing.Iterable[QtGui.QLinearGradient]) -> None: ... - def lightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def multiHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def singleHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def gridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def labelBackgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def labelTextColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def windowColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def backgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def baseColorsChanged(self, colors: typing.Iterable[typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]]) -> None: ... - def typeChanged(self, themeType: 'Q3DTheme.Theme') -> None: ... - def colorStyle(self) -> 'Q3DTheme.ColorStyle': ... - def setColorStyle(self, style: 'Q3DTheme.ColorStyle') -> None: ... - def isLabelBackgroundEnabled(self) -> bool: ... - def setLabelBackgroundEnabled(self, enabled: bool) -> None: ... - def isGridEnabled(self) -> bool: ... - def setGridEnabled(self, enabled: bool) -> None: ... - def isBackgroundEnabled(self) -> bool: ... - def setBackgroundEnabled(self, enabled: bool) -> None: ... - def font(self) -> QtGui.QFont: ... - def setFont(self, font: QtGui.QFont) -> None: ... - def isLabelBorderEnabled(self) -> bool: ... - def setLabelBorderEnabled(self, enabled: bool) -> None: ... - def highlightLightStrength(self) -> float: ... - def setHighlightLightStrength(self, strength: float) -> None: ... - def ambientLightStrength(self) -> float: ... - def setAmbientLightStrength(self, strength: float) -> None: ... - def lightStrength(self) -> float: ... - def setLightStrength(self, strength: float) -> None: ... - def multiHighlightGradient(self) -> QtGui.QLinearGradient: ... - def setMultiHighlightGradient(self, gradient: QtGui.QLinearGradient) -> None: ... - def singleHighlightGradient(self) -> QtGui.QLinearGradient: ... - def setSingleHighlightGradient(self, gradient: QtGui.QLinearGradient) -> None: ... - def baseGradients(self) -> typing.List[QtGui.QLinearGradient]: ... - def setBaseGradients(self, gradients: typing.Iterable[QtGui.QLinearGradient]) -> None: ... - def lightColor(self) -> QtGui.QColor: ... - def setLightColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def multiHighlightColor(self) -> QtGui.QColor: ... - def setMultiHighlightColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def singleHighlightColor(self) -> QtGui.QColor: ... - def setSingleHighlightColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def gridLineColor(self) -> QtGui.QColor: ... - def setGridLineColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def labelBackgroundColor(self) -> QtGui.QColor: ... - def setLabelBackgroundColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def labelTextColor(self) -> QtGui.QColor: ... - def setLabelTextColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def windowColor(self) -> QtGui.QColor: ... - def setWindowColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def backgroundColor(self) -> QtGui.QColor: ... - def setBackgroundColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def baseColors(self) -> typing.List[QtGui.QColor]: ... - def setBaseColors(self, colors: typing.Iterable[typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]]) -> None: ... - def type(self) -> 'Q3DTheme.Theme': ... - def setType(self, themeType: 'Q3DTheme.Theme') -> None: ... - - class QAbstract3DAxis(QtCore.QObject): - - class AxisType(int): - AxisTypeNone = ... # type: QAbstract3DAxis.AxisType - AxisTypeCategory = ... # type: QAbstract3DAxis.AxisType - AxisTypeValue = ... # type: QAbstract3DAxis.AxisType - - class AxisOrientation(int): - AxisOrientationNone = ... # type: QAbstract3DAxis.AxisOrientation - AxisOrientationX = ... # type: QAbstract3DAxis.AxisOrientation - AxisOrientationY = ... # type: QAbstract3DAxis.AxisOrientation - AxisOrientationZ = ... # type: QAbstract3DAxis.AxisOrientation - - def titleFixedChanged(self, fixed: bool) -> None: ... - def titleVisibilityChanged(self, visible: bool) -> None: ... - def labelAutoRotationChanged(self, angle: float) -> None: ... - def isTitleFixed(self) -> bool: ... - def setTitleFixed(self, fixed: bool) -> None: ... - def isTitleVisible(self) -> bool: ... - def setTitleVisible(self, visible: bool) -> None: ... - def labelAutoRotation(self) -> float: ... - def setLabelAutoRotation(self, angle: float) -> None: ... - def autoAdjustRangeChanged(self, autoAdjust: bool) -> None: ... - def rangeChanged(self, min: float, max: float) -> None: ... - def maxChanged(self, value: float) -> None: ... - def minChanged(self, value: float) -> None: ... - def orientationChanged(self, orientation: 'QAbstract3DAxis.AxisOrientation') -> None: ... - def labelsChanged(self) -> None: ... - def titleChanged(self, newTitle: str) -> None: ... - def setTitle(self, title: str) -> None: ... - def setRange(self, min: float, max: float) -> None: ... - def isAutoAdjustRange(self) -> bool: ... - def setAutoAdjustRange(self, autoAdjust: bool) -> None: ... - def max(self) -> float: ... - def setMax(self, max: float) -> None: ... - def min(self) -> float: ... - def setMin(self, min: float) -> None: ... - def type(self) -> 'QAbstract3DAxis.AxisType': ... - def orientation(self) -> 'QAbstract3DAxis.AxisOrientation': ... - def labels(self) -> typing.List[str]: ... - def setLabels(self, labels: typing.Iterable[str]) -> None: ... - def title(self) -> str: ... - - class QAbstract3DSeries(QtCore.QObject): - - class Mesh(int): - MeshUserDefined = ... # type: QAbstract3DSeries.Mesh - MeshBar = ... # type: QAbstract3DSeries.Mesh - MeshCube = ... # type: QAbstract3DSeries.Mesh - MeshPyramid = ... # type: QAbstract3DSeries.Mesh - MeshCone = ... # type: QAbstract3DSeries.Mesh - MeshCylinder = ... # type: QAbstract3DSeries.Mesh - MeshBevelBar = ... # type: QAbstract3DSeries.Mesh - MeshBevelCube = ... # type: QAbstract3DSeries.Mesh - MeshSphere = ... # type: QAbstract3DSeries.Mesh - MeshMinimal = ... # type: QAbstract3DSeries.Mesh - MeshArrow = ... # type: QAbstract3DSeries.Mesh - MeshPoint = ... # type: QAbstract3DSeries.Mesh - - class SeriesType(int): - SeriesTypeNone = ... # type: QAbstract3DSeries.SeriesType - SeriesTypeBar = ... # type: QAbstract3DSeries.SeriesType - SeriesTypeScatter = ... # type: QAbstract3DSeries.SeriesType - SeriesTypeSurface = ... # type: QAbstract3DSeries.SeriesType - - def itemLabelVisibilityChanged(self, visible: bool) -> None: ... - def itemLabelChanged(self, label: str) -> None: ... - def isItemLabelVisible(self) -> bool: ... - def setItemLabelVisible(self, visible: bool) -> None: ... - def itemLabel(self) -> str: ... - def nameChanged(self, name: str) -> None: ... - def multiHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def multiHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def singleHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def singleHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def baseGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... - def baseColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def colorStyleChanged(self, style: 'Q3DTheme.ColorStyle') -> None: ... - def userDefinedMeshChanged(self, fileName: str) -> None: ... - def meshRotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def meshSmoothChanged(self, enabled: bool) -> None: ... - def meshChanged(self, mesh: 'QAbstract3DSeries.Mesh') -> None: ... - def visibilityChanged(self, visible: bool) -> None: ... - def itemLabelFormatChanged(self, format: str) -> None: ... - def setMeshAxisAndAngle(self, axis: QtGui.QVector3D, angle: float) -> None: ... - def name(self) -> str: ... - def setName(self, name: str) -> None: ... - def multiHighlightGradient(self) -> QtGui.QLinearGradient: ... - def setMultiHighlightGradient(self, gradient: QtGui.QLinearGradient) -> None: ... - def multiHighlightColor(self) -> QtGui.QColor: ... - def setMultiHighlightColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def singleHighlightGradient(self) -> QtGui.QLinearGradient: ... - def setSingleHighlightGradient(self, gradient: QtGui.QLinearGradient) -> None: ... - def singleHighlightColor(self) -> QtGui.QColor: ... - def setSingleHighlightColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def baseGradient(self) -> QtGui.QLinearGradient: ... - def setBaseGradient(self, gradient: QtGui.QLinearGradient) -> None: ... - def baseColor(self) -> QtGui.QColor: ... - def setBaseColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def colorStyle(self) -> 'Q3DTheme.ColorStyle': ... - def setColorStyle(self, style: 'Q3DTheme.ColorStyle') -> None: ... - def userDefinedMesh(self) -> str: ... - def setUserDefinedMesh(self, fileName: str) -> None: ... - def meshRotation(self) -> QtGui.QQuaternion: ... - def setMeshRotation(self, rotation: QtGui.QQuaternion) -> None: ... - def isMeshSmooth(self) -> bool: ... - def setMeshSmooth(self, enable: bool) -> None: ... - def mesh(self) -> 'QAbstract3DSeries.Mesh': ... - def setMesh(self, mesh: 'QAbstract3DSeries.Mesh') -> None: ... - def isVisible(self) -> bool: ... - def setVisible(self, visible: bool) -> None: ... - def itemLabelFormat(self) -> str: ... - def setItemLabelFormat(self, format: str) -> None: ... - def type(self) -> 'QAbstract3DSeries.SeriesType': ... - - class QAbstractDataProxy(QtCore.QObject): - - class DataType(int): - DataTypeNone = ... # type: QAbstractDataProxy.DataType - DataTypeBar = ... # type: QAbstractDataProxy.DataType - DataTypeScatter = ... # type: QAbstractDataProxy.DataType - DataTypeSurface = ... # type: QAbstractDataProxy.DataType - - def type(self) -> 'QAbstractDataProxy.DataType': ... - - class QBar3DSeries('QAbstract3DSeries'): - - @typing.overload - def __init__(self, dataProxy: 'QBarDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def meshAngleChanged(self, angle: float) -> None: ... - def selectedBarChanged(self, position: QtCore.QPoint) -> None: ... - def dataProxyChanged(self, proxy: 'QBarDataProxy') -> None: ... - def meshAngle(self) -> float: ... - def setMeshAngle(self, angle: float) -> None: ... - @staticmethod - def invalidSelectionPosition() -> QtCore.QPoint: ... - def selectedBar(self) -> QtCore.QPoint: ... - def setSelectedBar(self, position: QtCore.QPoint) -> None: ... - def dataProxy(self) -> 'QBarDataProxy': ... - def setDataProxy(self, proxy: 'QBarDataProxy') -> None: ... - - class QBarDataItem(sip.simplewrapper): +class QAbstract3DGraph(QtGui.QWindow): + + class OptimizationHint(int): + OptimizationDefault = ... # type: QAbstract3DGraph.OptimizationHint + OptimizationStatic = ... # type: QAbstract3DGraph.OptimizationHint + + class ElementType(int): + ElementNone = ... # type: QAbstract3DGraph.ElementType + ElementSeries = ... # type: QAbstract3DGraph.ElementType + ElementAxisXLabel = ... # type: QAbstract3DGraph.ElementType + ElementAxisYLabel = ... # type: QAbstract3DGraph.ElementType + ElementAxisZLabel = ... # type: QAbstract3DGraph.ElementType + ElementCustomItem = ... # type: QAbstract3DGraph.ElementType + + class ShadowQuality(int): + ShadowQualityNone = ... # type: QAbstract3DGraph.ShadowQuality + ShadowQualityLow = ... # type: QAbstract3DGraph.ShadowQuality + ShadowQualityMedium = ... # type: QAbstract3DGraph.ShadowQuality + ShadowQualityHigh = ... # type: QAbstract3DGraph.ShadowQuality + ShadowQualitySoftLow = ... # type: QAbstract3DGraph.ShadowQuality + ShadowQualitySoftMedium = ... # type: QAbstract3DGraph.ShadowQuality + ShadowQualitySoftHigh = ... # type: QAbstract3DGraph.ShadowQuality + + class SelectionFlag(int): + SelectionNone = ... # type: QAbstract3DGraph.SelectionFlag + SelectionItem = ... # type: QAbstract3DGraph.SelectionFlag + SelectionRow = ... # type: QAbstract3DGraph.SelectionFlag + SelectionItemAndRow = ... # type: QAbstract3DGraph.SelectionFlag + SelectionColumn = ... # type: QAbstract3DGraph.SelectionFlag + SelectionItemAndColumn = ... # type: QAbstract3DGraph.SelectionFlag + SelectionRowAndColumn = ... # type: QAbstract3DGraph.SelectionFlag + SelectionItemRowAndColumn = ... # type: QAbstract3DGraph.SelectionFlag + SelectionSlice = ... # type: QAbstract3DGraph.SelectionFlag + SelectionMultiSeries = ... # type: QAbstract3DGraph.SelectionFlag + + class SelectionFlags(sip.simplewrapper): @typing.overload def __init__(self) -> None: ... @typing.overload - def __init__(self, value: float) -> None: ... - @typing.overload - def __init__(self, value: float, angle: float) -> None: ... - @typing.overload - def __init__(self, other: 'QBarDataItem') -> None: ... - - def rotation(self) -> float: ... - def setRotation(self, angle: float) -> None: ... - def value(self) -> float: ... - def setValue(self, value: float) -> None: ... - - class QBarDataProxy('QAbstractDataProxy'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def seriesChanged(self, series: 'QBar3DSeries') -> None: ... - def columnLabelsChanged(self) -> None: ... - def rowLabelsChanged(self) -> None: ... - def rowCountChanged(self, count: int) -> None: ... - def itemChanged(self, rowIndex: int, columnIndex: int) -> None: ... - def rowsInserted(self, startIndex: int, count: int) -> None: ... - def rowsRemoved(self, startIndex: int, count: int) -> None: ... - def rowsChanged(self, startIndex: int, count: int) -> None: ... - def rowsAdded(self, startIndex: int, count: int) -> None: ... - def arrayReset(self) -> None: ... - def series(self) -> 'QBar3DSeries': ... - def removeRows(self, rowIndex: int, removeCount: int, removeLabels: bool = ...) -> None: ... - @typing.overload - def insertRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QBarDataItem']]) -> None: ... - @typing.overload - def insertRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QBarDataItem']], labels: typing.Iterable[str]) -> None: ... - @typing.overload - def insertRow(self, rowIndex: int, row: typing.Iterable['QBarDataItem']) -> None: ... - @typing.overload - def insertRow(self, rowIndex: int, row: typing.Iterable['QBarDataItem'], label: str) -> None: ... - @typing.overload - def addRows(self, rows: typing.Iterable[typing.Iterable['QBarDataItem']]) -> int: ... - @typing.overload - def addRows(self, rows: typing.Iterable[typing.Iterable['QBarDataItem']], labels: typing.Iterable[str]) -> int: ... - @typing.overload - def addRow(self, row: typing.Iterable['QBarDataItem']) -> int: ... - @typing.overload - def addRow(self, row: typing.Iterable['QBarDataItem'], label: str) -> int: ... - @typing.overload - def setItem(self, rowIndex: int, columnIndex: int, item: 'QBarDataItem') -> None: ... - @typing.overload - def setItem(self, position: QtCore.QPoint, item: 'QBarDataItem') -> None: ... - @typing.overload - def setRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QBarDataItem']]) -> None: ... - @typing.overload - def setRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QBarDataItem']], labels: typing.Iterable[str]) -> None: ... - @typing.overload - def setRow(self, rowIndex: int, row: typing.Iterable['QBarDataItem']) -> None: ... - @typing.overload - def setRow(self, rowIndex: int, row: typing.Iterable['QBarDataItem'], label: str) -> None: ... - @typing.overload - def resetArray(self) -> None: ... - @typing.overload - def resetArray(self, newArray: typing.Iterable[typing.Iterable['QBarDataItem']]) -> None: ... - @typing.overload - def resetArray(self, newArray: typing.Iterable[typing.Iterable['QBarDataItem']], rowLabels: typing.Iterable[str], columnLabels: typing.Iterable[str]) -> None: ... - @typing.overload - def itemAt(self, rowIndex: int, columnIndex: int) -> 'QBarDataItem': ... - @typing.overload - def itemAt(self, position: QtCore.QPoint) -> 'QBarDataItem': ... - def rowAt(self, rowIndex: int) -> typing.List['QBarDataItem']: ... - def array(self) -> typing.List[typing.List['QBarDataItem']]: ... - def setColumnLabels(self, labels: typing.Iterable[str]) -> None: ... - def columnLabels(self) -> typing.List[str]: ... - def setRowLabels(self, labels: typing.Iterable[str]) -> None: ... - def rowLabels(self) -> typing.List[str]: ... - def rowCount(self) -> int: ... - - class QCategory3DAxis('QAbstract3DAxis'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def labelsChanged(self) -> None: ... - def labels(self) -> typing.List[str]: ... - def setLabels(self, labels: typing.Iterable[str]) -> None: ... - - class QCustom3DItem(QtCore.QObject): - - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, meshFile: str, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, texture: QtGui.QImage, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def scalingAbsoluteChanged(self, scalingAbsolute: bool) -> None: ... - def isScalingAbsolute(self) -> bool: ... - def setScalingAbsolute(self, scalingAbsolute: bool) -> None: ... - def shadowCastingChanged(self, shadowCasting: bool) -> None: ... - def visibleChanged(self, visible: bool) -> None: ... - def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... - def scalingChanged(self, scaling: QtGui.QVector3D) -> None: ... - def positionAbsoluteChanged(self, positionAbsolute: bool) -> None: ... - def positionChanged(self, position: QtGui.QVector3D) -> None: ... - def textureFileChanged(self, textureFile: str) -> None: ... - def meshFileChanged(self, meshFile: str) -> None: ... - def setTextureImage(self, textureImage: QtGui.QImage) -> None: ... - def setRotationAxisAndAngle(self, axis: QtGui.QVector3D, angle: float) -> None: ... - def isShadowCasting(self) -> bool: ... - def setShadowCasting(self, enabled: bool) -> None: ... - def isVisible(self) -> bool: ... - def setVisible(self, visible: bool) -> None: ... - def rotation(self) -> QtGui.QQuaternion: ... - def setRotation(self, rotation: QtGui.QQuaternion) -> None: ... - def scaling(self) -> QtGui.QVector3D: ... - def setScaling(self, scaling: QtGui.QVector3D) -> None: ... - def isPositionAbsolute(self) -> bool: ... - def setPositionAbsolute(self, positionAbsolute: bool) -> None: ... - def position(self) -> QtGui.QVector3D: ... - def setPosition(self, position: QtGui.QVector3D) -> None: ... - def textureFile(self) -> str: ... - def setTextureFile(self, textureFile: str) -> None: ... - def meshFile(self) -> str: ... - def setMeshFile(self, meshFile: str) -> None: ... - - class QCustom3DLabel('QCustom3DItem'): - - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, text: str, font: QtGui.QFont, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def facingCameraChanged(self, enabled: bool) -> None: ... - def backgroundEnabledChanged(self, enabled: bool) -> None: ... - def borderEnabledChanged(self, enabled: bool) -> None: ... - def backgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def textColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def fontChanged(self, font: QtGui.QFont) -> None: ... - def textChanged(self, text: str) -> None: ... - def isFacingCamera(self) -> bool: ... - def setFacingCamera(self, enabled: bool) -> None: ... - def isBackgroundEnabled(self) -> bool: ... - def setBackgroundEnabled(self, enabled: bool) -> None: ... - def isBorderEnabled(self) -> bool: ... - def setBorderEnabled(self, enabled: bool) -> None: ... - def backgroundColor(self) -> QtGui.QColor: ... - def setBackgroundColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def textColor(self) -> QtGui.QColor: ... - def setTextColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def font(self) -> QtGui.QFont: ... - def setFont(self, font: QtGui.QFont) -> None: ... - def text(self) -> str: ... - def setText(self, text: str) -> None: ... - - class QCustom3DVolume('QCustom3DItem'): - - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + def __init__(self, f: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag']) -> None: ... @typing.overload - def __init__(self, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, textureWidth: int, textureHeight: int, textureDepth: int, textureData: sip.array, textureFormat: QtGui.QImage.Format, colorTable: typing.Iterable[int], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def sliceFrameThicknessesChanged(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameGapsChanged(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameWidthsChanged(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def drawSliceFramesChanged(self, enabled: bool) -> None: ... - def drawSlicesChanged(self, enabled: bool) -> None: ... - def useHighDefShaderChanged(self, enabled: bool) -> None: ... - def preserveOpacityChanged(self, enabled: bool) -> None: ... - def alphaMultiplierChanged(self, mult: float) -> None: ... - def textureFormatChanged(self, format: QtGui.QImage.Format) -> None: ... - def textureDataChanged(self, data: sip.array) -> None: ... - def colorTableChanged(self) -> None: ... - def sliceIndexZChanged(self, value: int) -> None: ... - def sliceIndexYChanged(self, value: int) -> None: ... - def sliceIndexXChanged(self, value: int) -> None: ... - def textureDepthChanged(self, value: int) -> None: ... - def textureHeightChanged(self, value: int) -> None: ... - def textureWidthChanged(self, value: int) -> None: ... - def renderSlice(self, axis: QtCore.Qt.Axis, index: int) -> QtGui.QImage: ... - def sliceFrameThicknesses(self) -> QtGui.QVector3D: ... - def setSliceFrameThicknesses(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameGaps(self) -> QtGui.QVector3D: ... - def setSliceFrameGaps(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameWidths(self) -> QtGui.QVector3D: ... - def setSliceFrameWidths(self, values: QtGui.QVector3D) -> None: ... - def sliceFrameColor(self) -> QtGui.QColor: ... - def setSliceFrameColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... - def drawSliceFrames(self) -> bool: ... - def setDrawSliceFrames(self, enable: bool) -> None: ... - def drawSlices(self) -> bool: ... - def setDrawSlices(self, enable: bool) -> None: ... - def useHighDefShader(self) -> bool: ... - def setUseHighDefShader(self, enable: bool) -> None: ... - def preserveOpacity(self) -> bool: ... - def setPreserveOpacity(self, enable: bool) -> None: ... - def alphaMultiplier(self) -> float: ... - def setAlphaMultiplier(self, mult: float) -> None: ... - def textureFormat(self) -> QtGui.QImage.Format: ... - def setTextureFormat(self, format: QtGui.QImage.Format) -> None: ... - @typing.overload - def setSubTextureData(self, axis: QtCore.Qt.Axis, index: int, data: PyQt5.sip.voidptr) -> None: ... - @typing.overload - def setSubTextureData(self, axis: QtCore.Qt.Axis, index: int, image: QtGui.QImage) -> None: ... - def textureData(self) -> sip.array: ... - def createTextureData(self, images: typing.Iterable[QtGui.QImage]) -> sip.array: ... - def setTextureData(self, data: sip.array) -> None: ... - def colorTable(self) -> typing.List[int]: ... - def setColorTable(self, colors: typing.Iterable[int]) -> None: ... - def setSliceIndices(self, x: int, y: int, z: int) -> None: ... - def sliceIndexZ(self) -> int: ... - def setSliceIndexZ(self, value: int) -> None: ... - def sliceIndexY(self) -> int: ... - def setSliceIndexY(self, value: int) -> None: ... - def sliceIndexX(self) -> int: ... - def setSliceIndexX(self, value: int) -> None: ... - def textureDataWidth(self) -> int: ... - def setTextureDimensions(self, width: int, height: int, depth: int) -> None: ... - def textureDepth(self) -> int: ... - def setTextureDepth(self, value: int) -> None: ... - def textureHeight(self) -> int: ... - def setTextureHeight(self, value: int) -> None: ... - def textureWidth(self) -> int: ... - def setTextureWidth(self, value: int) -> None: ... - - class QSurfaceDataProxy('QAbstractDataProxy'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def seriesChanged(self, series: 'QSurface3DSeries') -> None: ... - def columnCountChanged(self, count: int) -> None: ... - def rowCountChanged(self, count: int) -> None: ... - def itemChanged(self, rowIndex: int, columnIndex: int) -> None: ... - def rowsInserted(self, startIndex: int, count: int) -> None: ... - def rowsRemoved(self, startIndex: int, count: int) -> None: ... - def rowsChanged(self, startIndex: int, count: int) -> None: ... - def rowsAdded(self, startIndex: int, count: int) -> None: ... - def arrayReset(self) -> None: ... - @typing.overload - def itemAt(self, rowIndex: int, columnIndex: int) -> 'QSurfaceDataItem': ... - @typing.overload - def itemAt(self, position: QtCore.QPoint) -> 'QSurfaceDataItem': ... - def series(self) -> 'QSurface3DSeries': ... - def removeRows(self, rowIndex: int, removeCount: int) -> None: ... - def insertRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QSurfaceDataItem']]) -> None: ... - def insertRow(self, rowIndex: int, row: typing.Iterable['QSurfaceDataItem']) -> None: ... - def addRows(self, rows: typing.Iterable[typing.Iterable['QSurfaceDataItem']]) -> int: ... - def addRow(self, row: typing.Iterable['QSurfaceDataItem']) -> int: ... - @typing.overload - def setItem(self, rowIndex: int, columnIndex: int, item: 'QSurfaceDataItem') -> None: ... - @typing.overload - def setItem(self, position: QtCore.QPoint, item: 'QSurfaceDataItem') -> None: ... - def setRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QSurfaceDataItem']]) -> None: ... - def setRow(self, rowIndex: int, row: typing.Iterable['QSurfaceDataItem']) -> None: ... - def resetArray(self, newArray: typing.Iterable[typing.Iterable['QSurfaceDataItem']]) -> None: ... - def array(self) -> typing.List[typing.List['QSurfaceDataItem']]: ... - def columnCount(self) -> int: ... - def rowCount(self) -> int: ... - - class QHeightMapSurfaceDataProxy('QSurfaceDataProxy'): + def __init__(self, a0: 'QAbstract3DGraph.SelectionFlags') -> None: ... - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, image: QtGui.QImage, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, filename: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def maxZValueChanged(self, value: float) -> None: ... - def minZValueChanged(self, value: float) -> None: ... - def maxXValueChanged(self, value: float) -> None: ... - def minXValueChanged(self, value: float) -> None: ... - def heightMapFileChanged(self, filename: str) -> None: ... - def heightMapChanged(self, image: QtGui.QImage) -> None: ... - def maxZValue(self) -> float: ... - def setMaxZValue(self, max: float) -> None: ... - def minZValue(self) -> float: ... - def setMinZValue(self, min: float) -> None: ... - def maxXValue(self) -> float: ... - def setMaxXValue(self, max: float) -> None: ... - def minXValue(self) -> float: ... - def setMinXValue(self, min: float) -> None: ... - def setValueRanges(self, minX: float, maxX: float, minZ: float, maxZ: float) -> None: ... - def heightMapFile(self) -> str: ... - def setHeightMapFile(self, filename: str) -> None: ... - def heightMap(self) -> QtGui.QImage: ... - def setHeightMap(self, image: QtGui.QImage) -> None: ... - - class QItemModelBarDataProxy('QBarDataProxy'): - - class MultiMatchBehavior(int): - MMBFirst = ... # type: QItemModelBarDataProxy.MultiMatchBehavior - MMBLast = ... # type: QItemModelBarDataProxy.MultiMatchBehavior - MMBAverage = ... # type: QItemModelBarDataProxy.MultiMatchBehavior - MMBCumulative = ... # type: QItemModelBarDataProxy.MultiMatchBehavior + def __hash__(self) -> int: ... + def __bool__(self) -> int: ... + def __invert__(self) -> 'QAbstract3DGraph.SelectionFlags': ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, valueRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, valueRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, valueRole: str, rotationRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, valueRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, valueRole: str, rotationRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def multiMatchBehaviorChanged(self, behavior: 'QItemModelBarDataProxy.MultiMatchBehavior') -> None: ... - def rotationRoleReplaceChanged(self, replace: str) -> None: ... - def valueRoleReplaceChanged(self, replace: str) -> None: ... - def columnRoleReplaceChanged(self, replace: str) -> None: ... - def rowRoleReplaceChanged(self, replace: str) -> None: ... - def rotationRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def valueRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def columnRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def rowRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def multiMatchBehavior(self) -> 'QItemModelBarDataProxy.MultiMatchBehavior': ... - def setMultiMatchBehavior(self, behavior: 'QItemModelBarDataProxy.MultiMatchBehavior') -> None: ... - def rotationRoleReplace(self) -> str: ... - def setRotationRoleReplace(self, replace: str) -> None: ... - def valueRoleReplace(self) -> str: ... - def setValueRoleReplace(self, replace: str) -> None: ... - def columnRoleReplace(self) -> str: ... - def setColumnRoleReplace(self, replace: str) -> None: ... - def rowRoleReplace(self) -> str: ... - def setRowRoleReplace(self, replace: str) -> None: ... - def rotationRolePattern(self) -> QtCore.QRegExp: ... - def setRotationRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def valueRolePattern(self) -> QtCore.QRegExp: ... - def setValueRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def columnRolePattern(self) -> QtCore.QRegExp: ... - def setColumnRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def rowRolePattern(self) -> QtCore.QRegExp: ... - def setRowRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def autoColumnCategoriesChanged(self, enable: bool) -> None: ... - def autoRowCategoriesChanged(self, enable: bool) -> None: ... - def useModelCategoriesChanged(self, enable: bool) -> None: ... - def columnCategoriesChanged(self) -> None: ... - def rowCategoriesChanged(self) -> None: ... - def rotationRoleChanged(self, role: str) -> None: ... - def valueRoleChanged(self, role: str) -> None: ... - def columnRoleChanged(self, role: str) -> None: ... - def rowRoleChanged(self, role: str) -> None: ... - def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... - def remap(self, rowRole: str, columnRole: str, valueRole: str, rotationRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str]) -> None: ... - def rotationRole(self) -> str: ... - def setRotationRole(self, role: str) -> None: ... - def columnCategoryIndex(self, category: str) -> int: ... - def rowCategoryIndex(self, category: str) -> int: ... - def autoColumnCategories(self) -> bool: ... - def setAutoColumnCategories(self, enable: bool) -> None: ... - def autoRowCategories(self) -> bool: ... - def setAutoRowCategories(self, enable: bool) -> None: ... - def useModelCategories(self) -> bool: ... - def setUseModelCategories(self, enable: bool) -> None: ... - def columnCategories(self) -> typing.List[str]: ... - def setColumnCategories(self, categories: typing.Iterable[str]) -> None: ... - def rowCategories(self) -> typing.List[str]: ... - def setRowCategories(self, categories: typing.Iterable[str]) -> None: ... - def valueRole(self) -> str: ... - def setValueRole(self, role: str) -> None: ... - def columnRole(self) -> str: ... - def setColumnRole(self, role: str) -> None: ... - def rowRole(self) -> str: ... - def setRowRole(self, role: str) -> None: ... - def itemModel(self) -> QtCore.QAbstractItemModel: ... - def setItemModel(self, itemModel: QtCore.QAbstractItemModel) -> None: ... - - class QScatterDataProxy('QAbstractDataProxy'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def seriesChanged(self, series: 'QScatter3DSeries') -> None: ... - def itemCountChanged(self, count: int) -> None: ... - def itemsInserted(self, startIndex: int, count: int) -> None: ... - def itemsRemoved(self, startIndex: int, count: int) -> None: ... - def itemsChanged(self, startIndex: int, count: int) -> None: ... - def itemsAdded(self, startIndex: int, count: int) -> None: ... - def arrayReset(self) -> None: ... - def series(self) -> 'QScatter3DSeries': ... - def removeItems(self, index: int, removeCount: int) -> None: ... - def insertItems(self, index: int, items: typing.Iterable['QScatterDataItem']) -> None: ... - def insertItem(self, index: int, item: 'QScatterDataItem') -> None: ... - def addItems(self, items: typing.Iterable['QScatterDataItem']) -> int: ... - def addItem(self, item: 'QScatterDataItem') -> int: ... - def setItems(self, index: int, items: typing.Iterable['QScatterDataItem']) -> None: ... - def setItem(self, index: int, item: 'QScatterDataItem') -> None: ... - def resetArray(self, newArray: typing.Iterable['QScatterDataItem']) -> None: ... - def itemAt(self, index: int) -> 'QScatterDataItem': ... - def array(self) -> typing.List['QScatterDataItem']: ... - def itemCount(self) -> int: ... - - class QItemModelScatterDataProxy('QScatterDataProxy'): - - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, xPosRole: str, yPosRole: str, zPosRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, xPosRole: str, yPosRole: str, zPosRole: str, rotationRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def zPosRoleReplaceChanged(self, replace: str) -> None: ... - def yPosRoleReplaceChanged(self, replace: str) -> None: ... - def xPosRoleReplaceChanged(self, replace: str) -> None: ... - def rotationRoleReplaceChanged(self, replace: str) -> None: ... - def rotationRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def zPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def yPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def xPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def rotationRoleReplace(self) -> str: ... - def setRotationRoleReplace(self, replace: str) -> None: ... - def zPosRoleReplace(self) -> str: ... - def setZPosRoleReplace(self, replace: str) -> None: ... - def yPosRoleReplace(self) -> str: ... - def setYPosRoleReplace(self, replace: str) -> None: ... - def xPosRoleReplace(self) -> str: ... - def setXPosRoleReplace(self, replace: str) -> None: ... - def rotationRolePattern(self) -> QtCore.QRegExp: ... - def setRotationRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def zPosRolePattern(self) -> QtCore.QRegExp: ... - def setZPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def yPosRolePattern(self) -> QtCore.QRegExp: ... - def setYPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def xPosRolePattern(self) -> QtCore.QRegExp: ... - def setXPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def rotationRoleChanged(self, role: str) -> None: ... - def zPosRoleChanged(self, role: str) -> None: ... - def yPosRoleChanged(self, role: str) -> None: ... - def xPosRoleChanged(self, role: str) -> None: ... - def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... - def remap(self, xPosRole: str, yPosRole: str, zPosRole: str, rotationRole: str) -> None: ... - def rotationRole(self) -> str: ... - def setRotationRole(self, role: str) -> None: ... - def zPosRole(self) -> str: ... - def setZPosRole(self, role: str) -> None: ... - def yPosRole(self) -> str: ... - def setYPosRole(self, role: str) -> None: ... - def xPosRole(self) -> str: ... - def setXPosRole(self, role: str) -> None: ... - def itemModel(self) -> QtCore.QAbstractItemModel: ... - def setItemModel(self, itemModel: QtCore.QAbstractItemModel) -> None: ... - - class QItemModelSurfaceDataProxy('QSurfaceDataProxy'): - - class MultiMatchBehavior(int): - MMBFirst = ... # type: QItemModelSurfaceDataProxy.MultiMatchBehavior - MMBLast = ... # type: QItemModelSurfaceDataProxy.MultiMatchBehavior - MMBAverage = ... # type: QItemModelSurfaceDataProxy.MultiMatchBehavior - MMBCumulativeY = ... # type: QItemModelSurfaceDataProxy.MultiMatchBehavior - - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, yPosRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, yPosRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, yPosRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, xPosRole: str, yPosRole: str, zPosRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, xPosRole: str, yPosRole: str, zPosRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def multiMatchBehaviorChanged(self, behavior: 'QItemModelSurfaceDataProxy.MultiMatchBehavior') -> None: ... - def zPosRoleReplaceChanged(self, replace: str) -> None: ... - def yPosRoleReplaceChanged(self, replace: str) -> None: ... - def xPosRoleReplaceChanged(self, replace: str) -> None: ... - def columnRoleReplaceChanged(self, replace: str) -> None: ... - def rowRoleReplaceChanged(self, replace: str) -> None: ... - def zPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def yPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def xPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def columnRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def rowRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... - def multiMatchBehavior(self) -> 'QItemModelSurfaceDataProxy.MultiMatchBehavior': ... - def setMultiMatchBehavior(self, behavior: 'QItemModelSurfaceDataProxy.MultiMatchBehavior') -> None: ... - def zPosRoleReplace(self) -> str: ... - def setZPosRoleReplace(self, replace: str) -> None: ... - def yPosRoleReplace(self) -> str: ... - def setYPosRoleReplace(self, replace: str) -> None: ... - def xPosRoleReplace(self) -> str: ... - def setXPosRoleReplace(self, replace: str) -> None: ... - def columnRoleReplace(self) -> str: ... - def setColumnRoleReplace(self, replace: str) -> None: ... - def rowRoleReplace(self) -> str: ... - def setRowRoleReplace(self, replace: str) -> None: ... - def zPosRolePattern(self) -> QtCore.QRegExp: ... - def setZPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def yPosRolePattern(self) -> QtCore.QRegExp: ... - def setYPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def xPosRolePattern(self) -> QtCore.QRegExp: ... - def setXPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def columnRolePattern(self) -> QtCore.QRegExp: ... - def setColumnRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def rowRolePattern(self) -> QtCore.QRegExp: ... - def setRowRolePattern(self, pattern: QtCore.QRegExp) -> None: ... - def autoColumnCategoriesChanged(self, enable: bool) -> None: ... - def autoRowCategoriesChanged(self, enable: bool) -> None: ... - def useModelCategoriesChanged(self, enable: bool) -> None: ... - def columnCategoriesChanged(self) -> None: ... - def rowCategoriesChanged(self) -> None: ... - def zPosRoleChanged(self, role: str) -> None: ... - def yPosRoleChanged(self, role: str) -> None: ... - def xPosRoleChanged(self, role: str) -> None: ... - def columnRoleChanged(self, role: str) -> None: ... - def rowRoleChanged(self, role: str) -> None: ... - def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... - def remap(self, rowRole: str, columnRole: str, xPosRole: str, yPosRole: str, zPosRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str]) -> None: ... - def zPosRole(self) -> str: ... - def setZPosRole(self, role: str) -> None: ... - def yPosRole(self) -> str: ... - def setYPosRole(self, role: str) -> None: ... - def xPosRole(self) -> str: ... - def setXPosRole(self, role: str) -> None: ... - def columnCategoryIndex(self, category: str) -> int: ... - def rowCategoryIndex(self, category: str) -> int: ... - def autoColumnCategories(self) -> bool: ... - def setAutoColumnCategories(self, enable: bool) -> None: ... - def autoRowCategories(self) -> bool: ... - def setAutoRowCategories(self, enable: bool) -> None: ... - def useModelCategories(self) -> bool: ... - def setUseModelCategories(self, enable: bool) -> None: ... - def columnCategories(self) -> typing.List[str]: ... - def setColumnCategories(self, categories: typing.Iterable[str]) -> None: ... - def rowCategories(self) -> typing.List[str]: ... - def setRowCategories(self, categories: typing.Iterable[str]) -> None: ... - def columnRole(self) -> str: ... - def setColumnRole(self, role: str) -> None: ... - def rowRole(self) -> str: ... - def setRowRole(self, role: str) -> None: ... - def itemModel(self) -> QtCore.QAbstractItemModel: ... - def setItemModel(self, itemModel: QtCore.QAbstractItemModel) -> None: ... - - class QValue3DAxisFormatter(QtCore.QObject): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def locale(self) -> QtCore.QLocale: ... - def setLocale(self, locale: QtCore.QLocale) -> None: ... - def labelStrings(self) -> typing.List[str]: ... - def labelPositions(self) -> typing.List[float]: ... - def subGridPositions(self) -> typing.List[float]: ... - def gridPositions(self) -> typing.List[float]: ... - def axis(self) -> 'QValue3DAxis': ... - def markDirty(self, labelsChange: bool = ...) -> None: ... - def populateCopy(self, copy: 'QValue3DAxisFormatter') -> None: ... - def valueAt(self, position: float) -> float: ... - def positionAt(self, value: float) -> float: ... - def stringForValue(self, value: float, format: str) -> str: ... - def recalculate(self) -> None: ... - def createNewInstance(self) -> 'QValue3DAxisFormatter': ... - def allowZero(self) -> bool: ... - def setAllowZero(self, allow: bool) -> None: ... - def allowNegatives(self) -> bool: ... - def setAllowNegatives(self, allow: bool) -> None: ... - - class QLogValue3DAxisFormatter('QValue3DAxisFormatter'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def populateCopy(self, copy: 'QValue3DAxisFormatter') -> None: ... - def valueAt(self, position: float) -> float: ... - def positionAt(self, value: float) -> float: ... - def recalculate(self) -> None: ... - def createNewInstance(self) -> 'QValue3DAxisFormatter': ... - def showEdgeLabelsChanged(self, enabled: bool) -> None: ... - def autoSubGridChanged(self, enabled: bool) -> None: ... - def baseChanged(self, base: float) -> None: ... - def showEdgeLabels(self) -> bool: ... - def setShowEdgeLabels(self, enabled: bool) -> None: ... - def autoSubGrid(self) -> bool: ... - def setAutoSubGrid(self, enabled: bool) -> None: ... - def base(self) -> float: ... - def setBase(self, base: float) -> None: ... - - class QScatter3DSeries('QAbstract3DSeries'): - - @typing.overload - def __init__(self, dataProxy: 'QScatterDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def itemSizeChanged(self, size: float) -> None: ... - def selectedItemChanged(self, index: int) -> None: ... - def dataProxyChanged(self, proxy: 'QScatterDataProxy') -> None: ... - def itemSize(self) -> float: ... - def setItemSize(self, size: float) -> None: ... - @staticmethod - def invalidSelectionIndex() -> int: ... - def selectedItem(self) -> int: ... - def setSelectedItem(self, index: int) -> None: ... - def dataProxy(self) -> 'QScatterDataProxy': ... - def setDataProxy(self, proxy: 'QScatterDataProxy') -> None: ... - - class QScatterDataItem(sip.simplewrapper): + class OptimizationHints(sip.simplewrapper): @typing.overload def __init__(self) -> None: ... @typing.overload - def __init__(self, position: QtGui.QVector3D) -> None: ... - @typing.overload - def __init__(self, position: QtGui.QVector3D, rotation: QtGui.QQuaternion) -> None: ... - @typing.overload - def __init__(self, other: 'QScatterDataItem') -> None: ... - - def z(self) -> float: ... - def y(self) -> float: ... - def x(self) -> float: ... - def setZ(self, value: float) -> None: ... - def setY(self, value: float) -> None: ... - def setX(self, value: float) -> None: ... - def rotation(self) -> QtGui.QQuaternion: ... - def setRotation(self, rotation: QtGui.QQuaternion) -> None: ... - def position(self) -> QtGui.QVector3D: ... - def setPosition(self, position: QtGui.QVector3D) -> None: ... - - class QSurface3DSeries('QAbstract3DSeries'): - - class DrawFlag(int): - DrawWireframe = ... # type: QSurface3DSeries.DrawFlag - DrawSurface = ... # type: QSurface3DSeries.DrawFlag - DrawSurfaceAndWireframe = ... # type: QSurface3DSeries.DrawFlag - - class DrawFlags(sip.simplewrapper): - - @typing.overload - def __init__(self) -> None: ... - @typing.overload - def __init__(self, f: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... - @typing.overload - def __init__(self, a0: 'QSurface3DSeries.DrawFlags') -> None: ... - - def __hash__(self) -> int: ... - def __bool__(self) -> int: ... - def __invert__(self) -> 'QSurface3DSeries.DrawFlags': ... - def __index__(self) -> int: ... - def __int__(self) -> int: ... - - @typing.overload - def __init__(self, dataProxy: 'QSurfaceDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def textureFileChanged(self, filename: str) -> None: ... - def textureChanged(self, image: QtGui.QImage) -> None: ... - def textureFile(self) -> str: ... - def setTextureFile(self, filename: str) -> None: ... - def texture(self) -> QtGui.QImage: ... - def setTexture(self, texture: QtGui.QImage) -> None: ... - def drawModeChanged(self, mode: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... - def flatShadingSupportedChanged(self, enable: bool) -> None: ... - def flatShadingEnabledChanged(self, enable: bool) -> None: ... - def selectedPointChanged(self, position: QtCore.QPoint) -> None: ... - def dataProxyChanged(self, proxy: 'QSurfaceDataProxy') -> None: ... - def isFlatShadingSupported(self) -> bool: ... - def drawMode(self) -> 'QSurface3DSeries.DrawFlags': ... - def setDrawMode(self, mode: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... - def isFlatShadingEnabled(self) -> bool: ... - def setFlatShadingEnabled(self, enabled: bool) -> None: ... - @staticmethod - def invalidSelectionPosition() -> QtCore.QPoint: ... - def selectedPoint(self) -> QtCore.QPoint: ... - def setSelectedPoint(self, position: QtCore.QPoint) -> None: ... - def dataProxy(self) -> 'QSurfaceDataProxy': ... - def setDataProxy(self, proxy: 'QSurfaceDataProxy') -> None: ... - - class QSurfaceDataItem(sip.simplewrapper): + def __init__(self, f: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... + @typing.overload + def __init__(self, a0: 'QAbstract3DGraph.OptimizationHints') -> None: ... + + def __hash__(self) -> int: ... + def __bool__(self) -> int: ... + def __invert__(self) -> 'QAbstract3DGraph.OptimizationHints': ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + + def hasContext(self) -> bool: ... + def marginChanged(self, margin: float) -> None: ... + def queriedGraphPositionChanged(self, data: QtGui.QVector3D) -> None: ... + def localeChanged(self, locale: QtCore.QLocale) -> None: ... + def reflectivityChanged(self, reflectivity: float) -> None: ... + def reflectionChanged(self, enabled: bool) -> None: ... + def horizontalAspectRatioChanged(self, ratio: float) -> None: ... + def radialLabelOffsetChanged(self, offset: float) -> None: ... + def polarChanged(self, enabled: bool) -> None: ... + def margin(self) -> float: ... + def setMargin(self, margin: float) -> None: ... + def queriedGraphPosition(self) -> QtGui.QVector3D: ... + def locale(self) -> QtCore.QLocale: ... + def setLocale(self, locale: QtCore.QLocale) -> None: ... + def reflectivity(self) -> float: ... + def setReflectivity(self, reflectivity: float) -> None: ... + def isReflection(self) -> bool: ... + def setReflection(self, enable: bool) -> None: ... + def horizontalAspectRatio(self) -> float: ... + def setHorizontalAspectRatio(self, ratio: float) -> None: ... + def radialLabelOffset(self) -> float: ... + def setRadialLabelOffset(self, offset: float) -> None: ... + def isPolar(self) -> bool: ... + def setPolar(self, enable: bool) -> None: ... + def customItems(self) -> typing.List['QCustom3DItem']: ... + def optimizationHintsChanged(self, hints: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... + def aspectRatioChanged(self, ratio: float) -> None: ... + def orthoProjectionChanged(self, enabled: bool) -> None: ... + def currentFpsChanged(self, fps: float) -> None: ... + def measureFpsChanged(self, enabled: bool) -> None: ... + def selectedElementChanged(self, type: 'QAbstract3DGraph.ElementType') -> None: ... + def optimizationHints(self) -> 'QAbstract3DGraph.OptimizationHints': ... + def setOptimizationHints(self, hints: typing.Union['QAbstract3DGraph.OptimizationHints', 'QAbstract3DGraph.OptimizationHint']) -> None: ... + def aspectRatio(self) -> float: ... + def setAspectRatio(self, ratio: float) -> None: ... + def selectedElement(self) -> 'QAbstract3DGraph.ElementType': ... + def isOrthoProjection(self) -> bool: ... + def setOrthoProjection(self, enable: bool) -> None: ... + def currentFps(self) -> float: ... + def measureFps(self) -> bool: ... + def setMeasureFps(self, enable: bool) -> None: ... + def renderToImage(self, msaaSamples: int = ..., imageSize: QtCore.QSize = ...) -> QtGui.QImage: ... + def selectedCustomItem(self) -> 'QCustom3DItem': ... + def selectedCustomItemIndex(self) -> int: ... + def selectedAxis(self) -> 'QAbstract3DAxis': ... + def selectedLabelIndex(self) -> int: ... + def releaseCustomItem(self, item: 'QCustom3DItem') -> None: ... + def removeCustomItemAt(self, position: QtGui.QVector3D) -> None: ... + def removeCustomItem(self, item: 'QCustom3DItem') -> None: ... + def removeCustomItems(self) -> None: ... + def addCustomItem(self, item: 'QCustom3DItem') -> int: ... + def wheelEvent(self, event: QtGui.QWheelEvent) -> None: ... + def mouseMoveEvent(self, event: QtGui.QMouseEvent) -> None: ... + def mouseReleaseEvent(self, event: QtGui.QMouseEvent) -> None: ... + def mousePressEvent(self, event: QtGui.QMouseEvent) -> None: ... + def touchEvent(self, event: QtGui.QTouchEvent) -> None: ... + def mouseDoubleClickEvent(self, event: QtGui.QMouseEvent) -> None: ... + def exposeEvent(self, event: QtGui.QExposeEvent) -> None: ... + def resizeEvent(self, event: QtGui.QResizeEvent) -> None: ... + def event(self, event: QtCore.QEvent) -> bool: ... + def shadowQualityChanged(self, quality: 'QAbstract3DGraph.ShadowQuality') -> None: ... + def selectionModeChanged(self, mode: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag']) -> None: ... + def activeThemeChanged(self, theme: 'Q3DTheme') -> None: ... + def activeInputHandlerChanged(self, inputHandler: 'QAbstract3DInputHandler') -> None: ... + def shadowsSupported(self) -> bool: ... + def activeInputHandler(self) -> 'QAbstract3DInputHandler': ... + def clearSelection(self) -> None: ... + def scene(self) -> 'Q3DScene': ... + def shadowQuality(self) -> 'QAbstract3DGraph.ShadowQuality': ... + def setShadowQuality(self, quality: 'QAbstract3DGraph.ShadowQuality') -> None: ... + def selectionMode(self) -> 'QAbstract3DGraph.SelectionFlags': ... + def setSelectionMode(self, mode: typing.Union['QAbstract3DGraph.SelectionFlags', 'QAbstract3DGraph.SelectionFlag']) -> None: ... + def themes(self) -> typing.List['Q3DTheme']: ... + def activeTheme(self) -> 'Q3DTheme': ... + def setActiveTheme(self, theme: 'Q3DTheme') -> None: ... + def releaseTheme(self, theme: 'Q3DTheme') -> None: ... + def addTheme(self, theme: 'Q3DTheme') -> None: ... + def inputHandlers(self) -> typing.List['QAbstract3DInputHandler']: ... + def setActiveInputHandler(self, inputHandler: 'QAbstract3DInputHandler') -> None: ... + def releaseInputHandler(self, inputHandler: 'QAbstract3DInputHandler') -> None: ... + def addInputHandler(self, inputHandler: 'QAbstract3DInputHandler') -> None: ... + + +class Q3DBars('QAbstract3DGraph'): + + def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... + + def floorLevelChanged(self, level: float) -> None: ... + def floorLevel(self) -> float: ... + def setFloorLevel(self, level: float) -> None: ... + def selectedSeriesChanged(self, series: 'QBar3DSeries') -> None: ... + def primarySeriesChanged(self, series: 'QBar3DSeries') -> None: ... + def valueAxisChanged(self, axis: 'QValue3DAxis') -> None: ... + def columnAxisChanged(self, axis: 'QCategory3DAxis') -> None: ... + def rowAxisChanged(self, axis: 'QCategory3DAxis') -> None: ... + def barSpacingRelativeChanged(self, relative: bool) -> None: ... + def barSpacingChanged(self, spacing: QtCore.QSizeF) -> None: ... + def barThicknessChanged(self, thicknessRatio: float) -> None: ... + def multiSeriesUniformChanged(self, uniform: bool) -> None: ... + def selectedSeries(self) -> 'QBar3DSeries': ... + def axes(self) -> typing.List['QAbstract3DAxis']: ... + def releaseAxis(self, axis: 'QAbstract3DAxis') -> None: ... + def addAxis(self, axis: 'QAbstract3DAxis') -> None: ... + def valueAxis(self) -> 'QValue3DAxis': ... + def setValueAxis(self, axis: 'QValue3DAxis') -> None: ... + def columnAxis(self) -> 'QCategory3DAxis': ... + def setColumnAxis(self, axis: 'QCategory3DAxis') -> None: ... + def rowAxis(self) -> 'QCategory3DAxis': ... + def setRowAxis(self, axis: 'QCategory3DAxis') -> None: ... + def isBarSpacingRelative(self) -> bool: ... + def setBarSpacingRelative(self, relative: bool) -> None: ... + def barSpacing(self) -> QtCore.QSizeF: ... + def setBarSpacing(self, spacing: QtCore.QSizeF) -> None: ... + def barThickness(self) -> float: ... + def setBarThickness(self, thicknessRatio: float) -> None: ... + def isMultiSeriesUniform(self) -> bool: ... + def setMultiSeriesUniform(self, uniform: bool) -> None: ... + def seriesList(self) -> typing.List['QBar3DSeries']: ... + def insertSeries(self, index: int, series: 'QBar3DSeries') -> None: ... + def removeSeries(self, series: 'QBar3DSeries') -> None: ... + def addSeries(self, series: 'QBar3DSeries') -> None: ... + def primarySeries(self) -> 'QBar3DSeries': ... + def setPrimarySeries(self, series: 'QBar3DSeries') -> None: ... + + +class Q3DObject(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def isDirty(self) -> bool: ... + def setDirty(self, dirty: bool) -> None: ... + def positionChanged(self, position: QtGui.QVector3D) -> None: ... + def setPosition(self, position: QtGui.QVector3D) -> None: ... + def position(self) -> QtGui.QVector3D: ... + def parentScene(self) -> 'Q3DScene': ... + def copyValuesFrom(self, source: 'Q3DObject') -> None: ... + + +class Q3DCamera('Q3DObject'): + + class CameraPreset(int): + CameraPresetNone = ... # type: Q3DCamera.CameraPreset + CameraPresetFrontLow = ... # type: Q3DCamera.CameraPreset + CameraPresetFront = ... # type: Q3DCamera.CameraPreset + CameraPresetFrontHigh = ... # type: Q3DCamera.CameraPreset + CameraPresetLeftLow = ... # type: Q3DCamera.CameraPreset + CameraPresetLeft = ... # type: Q3DCamera.CameraPreset + CameraPresetLeftHigh = ... # type: Q3DCamera.CameraPreset + CameraPresetRightLow = ... # type: Q3DCamera.CameraPreset + CameraPresetRight = ... # type: Q3DCamera.CameraPreset + CameraPresetRightHigh = ... # type: Q3DCamera.CameraPreset + CameraPresetBehindLow = ... # type: Q3DCamera.CameraPreset + CameraPresetBehind = ... # type: Q3DCamera.CameraPreset + CameraPresetBehindHigh = ... # type: Q3DCamera.CameraPreset + CameraPresetIsometricLeft = ... # type: Q3DCamera.CameraPreset + CameraPresetIsometricLeftHigh = ... # type: Q3DCamera.CameraPreset + CameraPresetIsometricRight = ... # type: Q3DCamera.CameraPreset + CameraPresetIsometricRightHigh = ... # type: Q3DCamera.CameraPreset + CameraPresetDirectlyAbove = ... # type: Q3DCamera.CameraPreset + CameraPresetDirectlyAboveCW45 = ... # type: Q3DCamera.CameraPreset + CameraPresetDirectlyAboveCCW45 = ... # type: Q3DCamera.CameraPreset + CameraPresetFrontBelow = ... # type: Q3DCamera.CameraPreset + CameraPresetLeftBelow = ... # type: Q3DCamera.CameraPreset + CameraPresetRightBelow = ... # type: Q3DCamera.CameraPreset + CameraPresetBehindBelow = ... # type: Q3DCamera.CameraPreset + CameraPresetDirectlyBelow = ... # type: Q3DCamera.CameraPreset + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def targetChanged(self, target: QtGui.QVector3D) -> None: ... + def maxZoomLevelChanged(self, zoomLevel: float) -> None: ... + def minZoomLevelChanged(self, zoomLevel: float) -> None: ... + def setTarget(self, target: QtGui.QVector3D) -> None: ... + def target(self) -> QtGui.QVector3D: ... + def setMaxZoomLevel(self, zoomLevel: float) -> None: ... + def maxZoomLevel(self) -> float: ... + def setMinZoomLevel(self, zoomLevel: float) -> None: ... + def minZoomLevel(self) -> float: ... + def wrapYRotationChanged(self, isEnabled: bool) -> None: ... + def wrapXRotationChanged(self, isEnabled: bool) -> None: ... + def cameraPresetChanged(self, preset: 'Q3DCamera.CameraPreset') -> None: ... + def zoomLevelChanged(self, zoomLevel: float) -> None: ... + def yRotationChanged(self, rotation: float) -> None: ... + def xRotationChanged(self, rotation: float) -> None: ... + def setZoomLevel(self, zoomLevel: float) -> None: ... + def zoomLevel(self) -> float: ... + def setCameraPosition(self, horizontal: float, vertical: float, zoom: float = ...) -> None: ... + def setCameraPreset(self, preset: 'Q3DCamera.CameraPreset') -> None: ... + def cameraPreset(self) -> 'Q3DCamera.CameraPreset': ... + def copyValuesFrom(self, source: 'Q3DObject') -> None: ... + def setWrapYRotation(self, isEnabled: bool) -> None: ... + def wrapYRotation(self) -> bool: ... + def setWrapXRotation(self, isEnabled: bool) -> None: ... + def wrapXRotation(self) -> bool: ... + def setYRotation(self, rotation: float) -> None: ... + def yRotation(self) -> float: ... + def setXRotation(self, rotation: float) -> None: ... + def xRotation(self) -> float: ... + + +class QAbstract3DInputHandler(QtCore.QObject): + + class InputView(int): + InputViewNone = ... # type: QAbstract3DInputHandler.InputView + InputViewOnPrimary = ... # type: QAbstract3DInputHandler.InputView + InputViewOnSecondary = ... # type: QAbstract3DInputHandler.InputView + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def previousInputPos(self) -> QtCore.QPoint: ... + def setPreviousInputPos(self, position: QtCore.QPoint) -> None: ... + def prevDistance(self) -> int: ... + def setPrevDistance(self, distance: int) -> None: ... + def sceneChanged(self, scene: 'Q3DScene') -> None: ... + def inputViewChanged(self, view: 'QAbstract3DInputHandler.InputView') -> None: ... + def positionChanged(self, position: QtCore.QPoint) -> None: ... + def setScene(self, scene: 'Q3DScene') -> None: ... + def scene(self) -> 'Q3DScene': ... + def setInputPosition(self, position: QtCore.QPoint) -> None: ... + def inputPosition(self) -> QtCore.QPoint: ... + def setInputView(self, inputView: 'QAbstract3DInputHandler.InputView') -> None: ... + def inputView(self) -> 'QAbstract3DInputHandler.InputView': ... + def wheelEvent(self, event: QtGui.QWheelEvent) -> None: ... + def mouseMoveEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... + def mouseReleaseEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... + def mousePressEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... + def touchEvent(self, event: QtGui.QTouchEvent) -> None: ... + def mouseDoubleClickEvent(self, event: QtGui.QMouseEvent) -> None: ... + + +class Q3DInputHandler('QAbstract3DInputHandler'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def zoomAtTargetEnabledChanged(self, enable: bool) -> None: ... + def selectionEnabledChanged(self, enable: bool) -> None: ... + def zoomEnabledChanged(self, enable: bool) -> None: ... + def rotationEnabledChanged(self, enable: bool) -> None: ... + def isZoomAtTargetEnabled(self) -> bool: ... + def setZoomAtTargetEnabled(self, enable: bool) -> None: ... + def isSelectionEnabled(self) -> bool: ... + def setSelectionEnabled(self, enable: bool) -> None: ... + def isZoomEnabled(self) -> bool: ... + def setZoomEnabled(self, enable: bool) -> None: ... + def isRotationEnabled(self) -> bool: ... + def setRotationEnabled(self, enable: bool) -> None: ... + def wheelEvent(self, event: QtGui.QWheelEvent) -> None: ... + def mouseMoveEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... + def mouseReleaseEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... + def mousePressEvent(self, event: QtGui.QMouseEvent, mousePos: QtCore.QPoint) -> None: ... + + +class Q3DLight('Q3DObject'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def autoPositionChanged(self, autoPosition: bool) -> None: ... + def isAutoPosition(self) -> bool: ... + def setAutoPosition(self, enabled: bool) -> None: ... + + +class Q3DScatter('QAbstract3DGraph'): + + def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... + + def selectedSeriesChanged(self, series: 'QScatter3DSeries') -> None: ... + def axisZChanged(self, axis: 'QValue3DAxis') -> None: ... + def axisYChanged(self, axis: 'QValue3DAxis') -> None: ... + def axisXChanged(self, axis: 'QValue3DAxis') -> None: ... + def selectedSeries(self) -> 'QScatter3DSeries': ... + def axes(self) -> typing.List['QValue3DAxis']: ... + def releaseAxis(self, axis: 'QValue3DAxis') -> None: ... + def addAxis(self, axis: 'QValue3DAxis') -> None: ... + def axisZ(self) -> 'QValue3DAxis': ... + def setAxisZ(self, axis: 'QValue3DAxis') -> None: ... + def axisY(self) -> 'QValue3DAxis': ... + def setAxisY(self, axis: 'QValue3DAxis') -> None: ... + def axisX(self) -> 'QValue3DAxis': ... + def setAxisX(self, axis: 'QValue3DAxis') -> None: ... + def seriesList(self) -> typing.List['QScatter3DSeries']: ... + def removeSeries(self, series: 'QScatter3DSeries') -> None: ... + def addSeries(self, series: 'QScatter3DSeries') -> None: ... + + +class Q3DScene(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def graphPositionQueryChanged(self, position: QtCore.QPoint) -> None: ... + def graphPositionQuery(self) -> QtCore.QPoint: ... + def setGraphPositionQuery(self, point: QtCore.QPoint) -> None: ... + def selectionQueryPositionChanged(self, position: QtCore.QPoint) -> None: ... + def devicePixelRatioChanged(self, pixelRatio: float) -> None: ... + def activeLightChanged(self, light: 'Q3DLight') -> None: ... + def activeCameraChanged(self, camera: 'Q3DCamera') -> None: ... + def slicingActiveChanged(self, isSlicingActive: bool) -> None: ... + def secondarySubviewOnTopChanged(self, isSecondaryOnTop: bool) -> None: ... + def secondarySubViewportChanged(self, subViewport: QtCore.QRect) -> None: ... + def primarySubViewportChanged(self, subViewport: QtCore.QRect) -> None: ... + def viewportChanged(self, viewport: QtCore.QRect) -> None: ... + def setDevicePixelRatio(self, pixelRatio: float) -> None: ... + def devicePixelRatio(self) -> float: ... + def setActiveLight(self, light: 'Q3DLight') -> None: ... + def activeLight(self) -> 'Q3DLight': ... + def setActiveCamera(self, camera: 'Q3DCamera') -> None: ... + def activeCamera(self) -> 'Q3DCamera': ... + def isSecondarySubviewOnTop(self) -> bool: ... + def setSecondarySubviewOnTop(self, isSecondaryOnTop: bool) -> None: ... + def isSlicingActive(self) -> bool: ... + def setSlicingActive(self, isSlicing: bool) -> None: ... + @staticmethod + def invalidSelectionPoint() -> QtCore.QPoint: ... + def selectionQueryPosition(self) -> QtCore.QPoint: ... + def setSelectionQueryPosition(self, point: QtCore.QPoint) -> None: ... + def isPointInSecondarySubView(self, point: QtCore.QPoint) -> bool: ... + def setSecondarySubViewport(self, secondarySubViewport: QtCore.QRect) -> None: ... + def secondarySubViewport(self) -> QtCore.QRect: ... + def isPointInPrimarySubView(self, point: QtCore.QPoint) -> bool: ... + def setPrimarySubViewport(self, primarySubViewport: QtCore.QRect) -> None: ... + def primarySubViewport(self) -> QtCore.QRect: ... + def viewport(self) -> QtCore.QRect: ... + + +class Q3DSurface('QAbstract3DGraph'): + + def __init__(self, format: typing.Optional[QtGui.QSurfaceFormat] = ..., parent: typing.Optional[QtGui.QWindow] = ...) -> None: ... + + def flipHorizontalGridChanged(self, flip: bool) -> None: ... + def flipHorizontalGrid(self) -> bool: ... + def setFlipHorizontalGrid(self, flip: bool) -> None: ... + def selectedSeriesChanged(self, series: 'QSurface3DSeries') -> None: ... + def axisZChanged(self, axis: 'QValue3DAxis') -> None: ... + def axisYChanged(self, axis: 'QValue3DAxis') -> None: ... + def axisXChanged(self, axis: 'QValue3DAxis') -> None: ... + def selectedSeries(self) -> 'QSurface3DSeries': ... + def axes(self) -> typing.List['QValue3DAxis']: ... + def releaseAxis(self, axis: 'QValue3DAxis') -> None: ... + def addAxis(self, axis: 'QValue3DAxis') -> None: ... + def axisZ(self) -> 'QValue3DAxis': ... + def setAxisZ(self, axis: 'QValue3DAxis') -> None: ... + def axisY(self) -> 'QValue3DAxis': ... + def setAxisY(self, axis: 'QValue3DAxis') -> None: ... + def axisX(self) -> 'QValue3DAxis': ... + def setAxisX(self, axis: 'QValue3DAxis') -> None: ... + def seriesList(self) -> typing.List['QSurface3DSeries']: ... + def removeSeries(self, series: 'QSurface3DSeries') -> None: ... + def addSeries(self, series: 'QSurface3DSeries') -> None: ... + + +class Q3DTheme(QtCore.QObject): + + class Theme(int): + ThemeQt = ... # type: Q3DTheme.Theme + ThemePrimaryColors = ... # type: Q3DTheme.Theme + ThemeDigia = ... # type: Q3DTheme.Theme + ThemeStoneMoss = ... # type: Q3DTheme.Theme + ThemeArmyBlue = ... # type: Q3DTheme.Theme + ThemeRetro = ... # type: Q3DTheme.Theme + ThemeEbony = ... # type: Q3DTheme.Theme + ThemeIsabelle = ... # type: Q3DTheme.Theme + ThemeUserDefined = ... # type: Q3DTheme.Theme + + class ColorStyle(int): + ColorStyleUniform = ... # type: Q3DTheme.ColorStyle + ColorStyleObjectGradient = ... # type: Q3DTheme.ColorStyle + ColorStyleRangeGradient = ... # type: Q3DTheme.ColorStyle + + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, themeType: 'Q3DTheme.Theme', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def colorStyleChanged(self, style: 'Q3DTheme.ColorStyle') -> None: ... + def labelBackgroundEnabledChanged(self, enabled: bool) -> None: ... + def gridEnabledChanged(self, enabled: bool) -> None: ... + def backgroundEnabledChanged(self, enabled: bool) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... + def labelBorderEnabledChanged(self, enabled: bool) -> None: ... + def highlightLightStrengthChanged(self, strength: float) -> None: ... + def ambientLightStrengthChanged(self, strength: float) -> None: ... + def lightStrengthChanged(self, strength: float) -> None: ... + def multiHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... + def singleHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... + def baseGradientsChanged(self, gradients: typing.Iterable[QtGui.QLinearGradient]) -> None: ... + def lightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def multiHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def singleHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def gridLineColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def labelBackgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def labelTextColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def windowColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def backgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def baseColorsChanged(self, colors: typing.Iterable[typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]]) -> None: ... + def typeChanged(self, themeType: 'Q3DTheme.Theme') -> None: ... + def colorStyle(self) -> 'Q3DTheme.ColorStyle': ... + def setColorStyle(self, style: 'Q3DTheme.ColorStyle') -> None: ... + def isLabelBackgroundEnabled(self) -> bool: ... + def setLabelBackgroundEnabled(self, enabled: bool) -> None: ... + def isGridEnabled(self) -> bool: ... + def setGridEnabled(self, enabled: bool) -> None: ... + def isBackgroundEnabled(self) -> bool: ... + def setBackgroundEnabled(self, enabled: bool) -> None: ... + def font(self) -> QtGui.QFont: ... + def setFont(self, font: QtGui.QFont) -> None: ... + def isLabelBorderEnabled(self) -> bool: ... + def setLabelBorderEnabled(self, enabled: bool) -> None: ... + def highlightLightStrength(self) -> float: ... + def setHighlightLightStrength(self, strength: float) -> None: ... + def ambientLightStrength(self) -> float: ... + def setAmbientLightStrength(self, strength: float) -> None: ... + def lightStrength(self) -> float: ... + def setLightStrength(self, strength: float) -> None: ... + def multiHighlightGradient(self) -> QtGui.QLinearGradient: ... + def setMultiHighlightGradient(self, gradient: QtGui.QLinearGradient) -> None: ... + def singleHighlightGradient(self) -> QtGui.QLinearGradient: ... + def setSingleHighlightGradient(self, gradient: QtGui.QLinearGradient) -> None: ... + def baseGradients(self) -> typing.List[QtGui.QLinearGradient]: ... + def setBaseGradients(self, gradients: typing.Iterable[QtGui.QLinearGradient]) -> None: ... + def lightColor(self) -> QtGui.QColor: ... + def setLightColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def multiHighlightColor(self) -> QtGui.QColor: ... + def setMultiHighlightColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def singleHighlightColor(self) -> QtGui.QColor: ... + def setSingleHighlightColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def gridLineColor(self) -> QtGui.QColor: ... + def setGridLineColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def labelBackgroundColor(self) -> QtGui.QColor: ... + def setLabelBackgroundColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def labelTextColor(self) -> QtGui.QColor: ... + def setLabelTextColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def windowColor(self) -> QtGui.QColor: ... + def setWindowColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def backgroundColor(self) -> QtGui.QColor: ... + def setBackgroundColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def baseColors(self) -> typing.List[QtGui.QColor]: ... + def setBaseColors(self, colors: typing.Iterable[typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]]) -> None: ... + def type(self) -> 'Q3DTheme.Theme': ... + def setType(self, themeType: 'Q3DTheme.Theme') -> None: ... + + +class QAbstract3DAxis(QtCore.QObject): + + class AxisType(int): + AxisTypeNone = ... # type: QAbstract3DAxis.AxisType + AxisTypeCategory = ... # type: QAbstract3DAxis.AxisType + AxisTypeValue = ... # type: QAbstract3DAxis.AxisType + + class AxisOrientation(int): + AxisOrientationNone = ... # type: QAbstract3DAxis.AxisOrientation + AxisOrientationX = ... # type: QAbstract3DAxis.AxisOrientation + AxisOrientationY = ... # type: QAbstract3DAxis.AxisOrientation + AxisOrientationZ = ... # type: QAbstract3DAxis.AxisOrientation + + def titleFixedChanged(self, fixed: bool) -> None: ... + def titleVisibilityChanged(self, visible: bool) -> None: ... + def labelAutoRotationChanged(self, angle: float) -> None: ... + def isTitleFixed(self) -> bool: ... + def setTitleFixed(self, fixed: bool) -> None: ... + def isTitleVisible(self) -> bool: ... + def setTitleVisible(self, visible: bool) -> None: ... + def labelAutoRotation(self) -> float: ... + def setLabelAutoRotation(self, angle: float) -> None: ... + def autoAdjustRangeChanged(self, autoAdjust: bool) -> None: ... + def rangeChanged(self, min: float, max: float) -> None: ... + def maxChanged(self, value: float) -> None: ... + def minChanged(self, value: float) -> None: ... + def orientationChanged(self, orientation: 'QAbstract3DAxis.AxisOrientation') -> None: ... + def labelsChanged(self) -> None: ... + def titleChanged(self, newTitle: str) -> None: ... + def setTitle(self, title: str) -> None: ... + def setRange(self, min: float, max: float) -> None: ... + def isAutoAdjustRange(self) -> bool: ... + def setAutoAdjustRange(self, autoAdjust: bool) -> None: ... + def max(self) -> float: ... + def setMax(self, max: float) -> None: ... + def min(self) -> float: ... + def setMin(self, min: float) -> None: ... + def type(self) -> 'QAbstract3DAxis.AxisType': ... + def orientation(self) -> 'QAbstract3DAxis.AxisOrientation': ... + def labels(self) -> typing.List[str]: ... + def setLabels(self, labels: typing.Iterable[str]) -> None: ... + def title(self) -> str: ... + + +class QAbstract3DSeries(QtCore.QObject): + + class Mesh(int): + MeshUserDefined = ... # type: QAbstract3DSeries.Mesh + MeshBar = ... # type: QAbstract3DSeries.Mesh + MeshCube = ... # type: QAbstract3DSeries.Mesh + MeshPyramid = ... # type: QAbstract3DSeries.Mesh + MeshCone = ... # type: QAbstract3DSeries.Mesh + MeshCylinder = ... # type: QAbstract3DSeries.Mesh + MeshBevelBar = ... # type: QAbstract3DSeries.Mesh + MeshBevelCube = ... # type: QAbstract3DSeries.Mesh + MeshSphere = ... # type: QAbstract3DSeries.Mesh + MeshMinimal = ... # type: QAbstract3DSeries.Mesh + MeshArrow = ... # type: QAbstract3DSeries.Mesh + MeshPoint = ... # type: QAbstract3DSeries.Mesh + + class SeriesType(int): + SeriesTypeNone = ... # type: QAbstract3DSeries.SeriesType + SeriesTypeBar = ... # type: QAbstract3DSeries.SeriesType + SeriesTypeScatter = ... # type: QAbstract3DSeries.SeriesType + SeriesTypeSurface = ... # type: QAbstract3DSeries.SeriesType + + def itemLabelVisibilityChanged(self, visible: bool) -> None: ... + def itemLabelChanged(self, label: str) -> None: ... + def isItemLabelVisible(self) -> bool: ... + def setItemLabelVisible(self, visible: bool) -> None: ... + def itemLabel(self) -> str: ... + def nameChanged(self, name: str) -> None: ... + def multiHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... + def multiHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def singleHighlightGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... + def singleHighlightColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def baseGradientChanged(self, gradient: QtGui.QLinearGradient) -> None: ... + def baseColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def colorStyleChanged(self, style: 'Q3DTheme.ColorStyle') -> None: ... + def userDefinedMeshChanged(self, fileName: str) -> None: ... + def meshRotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... + def meshSmoothChanged(self, enabled: bool) -> None: ... + def meshChanged(self, mesh: 'QAbstract3DSeries.Mesh') -> None: ... + def visibilityChanged(self, visible: bool) -> None: ... + def itemLabelFormatChanged(self, format: str) -> None: ... + def setMeshAxisAndAngle(self, axis: QtGui.QVector3D, angle: float) -> None: ... + def name(self) -> str: ... + def setName(self, name: str) -> None: ... + def multiHighlightGradient(self) -> QtGui.QLinearGradient: ... + def setMultiHighlightGradient(self, gradient: QtGui.QLinearGradient) -> None: ... + def multiHighlightColor(self) -> QtGui.QColor: ... + def setMultiHighlightColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def singleHighlightGradient(self) -> QtGui.QLinearGradient: ... + def setSingleHighlightGradient(self, gradient: QtGui.QLinearGradient) -> None: ... + def singleHighlightColor(self) -> QtGui.QColor: ... + def setSingleHighlightColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def baseGradient(self) -> QtGui.QLinearGradient: ... + def setBaseGradient(self, gradient: QtGui.QLinearGradient) -> None: ... + def baseColor(self) -> QtGui.QColor: ... + def setBaseColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def colorStyle(self) -> 'Q3DTheme.ColorStyle': ... + def setColorStyle(self, style: 'Q3DTheme.ColorStyle') -> None: ... + def userDefinedMesh(self) -> str: ... + def setUserDefinedMesh(self, fileName: str) -> None: ... + def meshRotation(self) -> QtGui.QQuaternion: ... + def setMeshRotation(self, rotation: QtGui.QQuaternion) -> None: ... + def isMeshSmooth(self) -> bool: ... + def setMeshSmooth(self, enable: bool) -> None: ... + def mesh(self) -> 'QAbstract3DSeries.Mesh': ... + def setMesh(self, mesh: 'QAbstract3DSeries.Mesh') -> None: ... + def isVisible(self) -> bool: ... + def setVisible(self, visible: bool) -> None: ... + def itemLabelFormat(self) -> str: ... + def setItemLabelFormat(self, format: str) -> None: ... + def type(self) -> 'QAbstract3DSeries.SeriesType': ... + + +class QAbstractDataProxy(QtCore.QObject): + + class DataType(int): + DataTypeNone = ... # type: QAbstractDataProxy.DataType + DataTypeBar = ... # type: QAbstractDataProxy.DataType + DataTypeScatter = ... # type: QAbstractDataProxy.DataType + DataTypeSurface = ... # type: QAbstractDataProxy.DataType + + def type(self) -> 'QAbstractDataProxy.DataType': ... + + +class QBar3DSeries('QAbstract3DSeries'): + + @typing.overload + def __init__(self, dataProxy: 'QBarDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def meshAngleChanged(self, angle: float) -> None: ... + def selectedBarChanged(self, position: QtCore.QPoint) -> None: ... + def dataProxyChanged(self, proxy: 'QBarDataProxy') -> None: ... + def meshAngle(self) -> float: ... + def setMeshAngle(self, angle: float) -> None: ... + @staticmethod + def invalidSelectionPosition() -> QtCore.QPoint: ... + def selectedBar(self) -> QtCore.QPoint: ... + def setSelectedBar(self, position: QtCore.QPoint) -> None: ... + def dataProxy(self) -> 'QBarDataProxy': ... + def setDataProxy(self, proxy: 'QBarDataProxy') -> None: ... + + +class QBarDataItem(sip.simplewrapper): + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, value: float) -> None: ... + @typing.overload + def __init__(self, value: float, angle: float) -> None: ... + @typing.overload + def __init__(self, other: 'QBarDataItem') -> None: ... + + def rotation(self) -> float: ... + def setRotation(self, angle: float) -> None: ... + def value(self) -> float: ... + def setValue(self, value: float) -> None: ... + + +class QBarDataProxy('QAbstractDataProxy'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def seriesChanged(self, series: 'QBar3DSeries') -> None: ... + def columnLabelsChanged(self) -> None: ... + def rowLabelsChanged(self) -> None: ... + def rowCountChanged(self, count: int) -> None: ... + def itemChanged(self, rowIndex: int, columnIndex: int) -> None: ... + def rowsInserted(self, startIndex: int, count: int) -> None: ... + def rowsRemoved(self, startIndex: int, count: int) -> None: ... + def rowsChanged(self, startIndex: int, count: int) -> None: ... + def rowsAdded(self, startIndex: int, count: int) -> None: ... + def arrayReset(self) -> None: ... + def series(self) -> 'QBar3DSeries': ... + def removeRows(self, rowIndex: int, removeCount: int, removeLabels: bool = ...) -> None: ... + @typing.overload + def insertRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QBarDataItem']]) -> None: ... + @typing.overload + def insertRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QBarDataItem']], labels: typing.Iterable[str]) -> None: ... + @typing.overload + def insertRow(self, rowIndex: int, row: typing.Iterable['QBarDataItem']) -> None: ... + @typing.overload + def insertRow(self, rowIndex: int, row: typing.Iterable['QBarDataItem'], label: str) -> None: ... + @typing.overload + def addRows(self, rows: typing.Iterable[typing.Iterable['QBarDataItem']]) -> int: ... + @typing.overload + def addRows(self, rows: typing.Iterable[typing.Iterable['QBarDataItem']], labels: typing.Iterable[str]) -> int: ... + @typing.overload + def addRow(self, row: typing.Iterable['QBarDataItem']) -> int: ... + @typing.overload + def addRow(self, row: typing.Iterable['QBarDataItem'], label: str) -> int: ... + @typing.overload + def setItem(self, rowIndex: int, columnIndex: int, item: 'QBarDataItem') -> None: ... + @typing.overload + def setItem(self, position: QtCore.QPoint, item: 'QBarDataItem') -> None: ... + @typing.overload + def setRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QBarDataItem']]) -> None: ... + @typing.overload + def setRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QBarDataItem']], labels: typing.Iterable[str]) -> None: ... + @typing.overload + def setRow(self, rowIndex: int, row: typing.Iterable['QBarDataItem']) -> None: ... + @typing.overload + def setRow(self, rowIndex: int, row: typing.Iterable['QBarDataItem'], label: str) -> None: ... + @typing.overload + def resetArray(self) -> None: ... + @typing.overload + def resetArray(self, newArray: typing.Iterable[typing.Iterable['QBarDataItem']]) -> None: ... + @typing.overload + def resetArray(self, newArray: typing.Iterable[typing.Iterable['QBarDataItem']], rowLabels: typing.Iterable[str], columnLabels: typing.Iterable[str]) -> None: ... + @typing.overload + def itemAt(self, rowIndex: int, columnIndex: int) -> 'QBarDataItem': ... + @typing.overload + def itemAt(self, position: QtCore.QPoint) -> 'QBarDataItem': ... + def rowAt(self, rowIndex: int) -> typing.List['QBarDataItem']: ... + def array(self) -> typing.List[typing.List['QBarDataItem']]: ... + def setColumnLabels(self, labels: typing.Iterable[str]) -> None: ... + def columnLabels(self) -> typing.List[str]: ... + def setRowLabels(self, labels: typing.Iterable[str]) -> None: ... + def rowLabels(self) -> typing.List[str]: ... + def rowCount(self) -> int: ... + + +class QCategory3DAxis('QAbstract3DAxis'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def labelsChanged(self) -> None: ... + def labels(self) -> typing.List[str]: ... + def setLabels(self, labels: typing.Iterable[str]) -> None: ... + + +class QCustom3DItem(QtCore.QObject): + + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, meshFile: str, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, texture: QtGui.QImage, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def scalingAbsoluteChanged(self, scalingAbsolute: bool) -> None: ... + def isScalingAbsolute(self) -> bool: ... + def setScalingAbsolute(self, scalingAbsolute: bool) -> None: ... + def shadowCastingChanged(self, shadowCasting: bool) -> None: ... + def visibleChanged(self, visible: bool) -> None: ... + def rotationChanged(self, rotation: QtGui.QQuaternion) -> None: ... + def scalingChanged(self, scaling: QtGui.QVector3D) -> None: ... + def positionAbsoluteChanged(self, positionAbsolute: bool) -> None: ... + def positionChanged(self, position: QtGui.QVector3D) -> None: ... + def textureFileChanged(self, textureFile: str) -> None: ... + def meshFileChanged(self, meshFile: str) -> None: ... + def setTextureImage(self, textureImage: QtGui.QImage) -> None: ... + def setRotationAxisAndAngle(self, axis: QtGui.QVector3D, angle: float) -> None: ... + def isShadowCasting(self) -> bool: ... + def setShadowCasting(self, enabled: bool) -> None: ... + def isVisible(self) -> bool: ... + def setVisible(self, visible: bool) -> None: ... + def rotation(self) -> QtGui.QQuaternion: ... + def setRotation(self, rotation: QtGui.QQuaternion) -> None: ... + def scaling(self) -> QtGui.QVector3D: ... + def setScaling(self, scaling: QtGui.QVector3D) -> None: ... + def isPositionAbsolute(self) -> bool: ... + def setPositionAbsolute(self, positionAbsolute: bool) -> None: ... + def position(self) -> QtGui.QVector3D: ... + def setPosition(self, position: QtGui.QVector3D) -> None: ... + def textureFile(self) -> str: ... + def setTextureFile(self, textureFile: str) -> None: ... + def meshFile(self) -> str: ... + def setMeshFile(self, meshFile: str) -> None: ... + + +class QCustom3DLabel('QCustom3DItem'): + + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, text: str, font: QtGui.QFont, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def facingCameraChanged(self, enabled: bool) -> None: ... + def backgroundEnabledChanged(self, enabled: bool) -> None: ... + def borderEnabledChanged(self, enabled: bool) -> None: ... + def backgroundColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def textColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def fontChanged(self, font: QtGui.QFont) -> None: ... + def textChanged(self, text: str) -> None: ... + def isFacingCamera(self) -> bool: ... + def setFacingCamera(self, enabled: bool) -> None: ... + def isBackgroundEnabled(self) -> bool: ... + def setBackgroundEnabled(self, enabled: bool) -> None: ... + def isBorderEnabled(self) -> bool: ... + def setBorderEnabled(self, enabled: bool) -> None: ... + def backgroundColor(self) -> QtGui.QColor: ... + def setBackgroundColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def textColor(self) -> QtGui.QColor: ... + def setTextColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def font(self) -> QtGui.QFont: ... + def setFont(self, font: QtGui.QFont) -> None: ... + def text(self) -> str: ... + def setText(self, text: str) -> None: ... + + +class QCustom3DVolume('QCustom3DItem'): + + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, position: QtGui.QVector3D, scaling: QtGui.QVector3D, rotation: QtGui.QQuaternion, textureWidth: int, textureHeight: int, textureDepth: int, textureData: sip.array, textureFormat: QtGui.QImage.Format, colorTable: typing.Iterable[int], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def sliceFrameThicknessesChanged(self, values: QtGui.QVector3D) -> None: ... + def sliceFrameGapsChanged(self, values: QtGui.QVector3D) -> None: ... + def sliceFrameWidthsChanged(self, values: QtGui.QVector3D) -> None: ... + def sliceFrameColorChanged(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def drawSliceFramesChanged(self, enabled: bool) -> None: ... + def drawSlicesChanged(self, enabled: bool) -> None: ... + def useHighDefShaderChanged(self, enabled: bool) -> None: ... + def preserveOpacityChanged(self, enabled: bool) -> None: ... + def alphaMultiplierChanged(self, mult: float) -> None: ... + def textureFormatChanged(self, format: QtGui.QImage.Format) -> None: ... + def textureDataChanged(self, data: sip.array) -> None: ... + def colorTableChanged(self) -> None: ... + def sliceIndexZChanged(self, value: int) -> None: ... + def sliceIndexYChanged(self, value: int) -> None: ... + def sliceIndexXChanged(self, value: int) -> None: ... + def textureDepthChanged(self, value: int) -> None: ... + def textureHeightChanged(self, value: int) -> None: ... + def textureWidthChanged(self, value: int) -> None: ... + def renderSlice(self, axis: QtCore.Qt.Axis, index: int) -> QtGui.QImage: ... + def sliceFrameThicknesses(self) -> QtGui.QVector3D: ... + def setSliceFrameThicknesses(self, values: QtGui.QVector3D) -> None: ... + def sliceFrameGaps(self) -> QtGui.QVector3D: ... + def setSliceFrameGaps(self, values: QtGui.QVector3D) -> None: ... + def sliceFrameWidths(self) -> QtGui.QVector3D: ... + def setSliceFrameWidths(self, values: QtGui.QVector3D) -> None: ... + def sliceFrameColor(self) -> QtGui.QColor: ... + def setSliceFrameColor(self, color: typing.Union[QtGui.QColor, QtCore.Qt.GlobalColor]) -> None: ... + def drawSliceFrames(self) -> bool: ... + def setDrawSliceFrames(self, enable: bool) -> None: ... + def drawSlices(self) -> bool: ... + def setDrawSlices(self, enable: bool) -> None: ... + def useHighDefShader(self) -> bool: ... + def setUseHighDefShader(self, enable: bool) -> None: ... + def preserveOpacity(self) -> bool: ... + def setPreserveOpacity(self, enable: bool) -> None: ... + def alphaMultiplier(self) -> float: ... + def setAlphaMultiplier(self, mult: float) -> None: ... + def textureFormat(self) -> QtGui.QImage.Format: ... + def setTextureFormat(self, format: QtGui.QImage.Format) -> None: ... + @typing.overload + def setSubTextureData(self, axis: QtCore.Qt.Axis, index: int, data: PyQt5.sip.voidptr) -> None: ... + @typing.overload + def setSubTextureData(self, axis: QtCore.Qt.Axis, index: int, image: QtGui.QImage) -> None: ... + def textureData(self) -> sip.array: ... + def createTextureData(self, images: typing.Iterable[QtGui.QImage]) -> sip.array: ... + def setTextureData(self, data: sip.array) -> None: ... + def colorTable(self) -> typing.List[int]: ... + def setColorTable(self, colors: typing.Iterable[int]) -> None: ... + def setSliceIndices(self, x: int, y: int, z: int) -> None: ... + def sliceIndexZ(self) -> int: ... + def setSliceIndexZ(self, value: int) -> None: ... + def sliceIndexY(self) -> int: ... + def setSliceIndexY(self, value: int) -> None: ... + def sliceIndexX(self) -> int: ... + def setSliceIndexX(self, value: int) -> None: ... + def textureDataWidth(self) -> int: ... + def setTextureDimensions(self, width: int, height: int, depth: int) -> None: ... + def textureDepth(self) -> int: ... + def setTextureDepth(self, value: int) -> None: ... + def textureHeight(self) -> int: ... + def setTextureHeight(self, value: int) -> None: ... + def textureWidth(self) -> int: ... + def setTextureWidth(self, value: int) -> None: ... + + +class QSurfaceDataProxy('QAbstractDataProxy'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def seriesChanged(self, series: 'QSurface3DSeries') -> None: ... + def columnCountChanged(self, count: int) -> None: ... + def rowCountChanged(self, count: int) -> None: ... + def itemChanged(self, rowIndex: int, columnIndex: int) -> None: ... + def rowsInserted(self, startIndex: int, count: int) -> None: ... + def rowsRemoved(self, startIndex: int, count: int) -> None: ... + def rowsChanged(self, startIndex: int, count: int) -> None: ... + def rowsAdded(self, startIndex: int, count: int) -> None: ... + def arrayReset(self) -> None: ... + @typing.overload + def itemAt(self, rowIndex: int, columnIndex: int) -> 'QSurfaceDataItem': ... + @typing.overload + def itemAt(self, position: QtCore.QPoint) -> 'QSurfaceDataItem': ... + def series(self) -> 'QSurface3DSeries': ... + def removeRows(self, rowIndex: int, removeCount: int) -> None: ... + def insertRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QSurfaceDataItem']]) -> None: ... + def insertRow(self, rowIndex: int, row: typing.Iterable['QSurfaceDataItem']) -> None: ... + def addRows(self, rows: typing.Iterable[typing.Iterable['QSurfaceDataItem']]) -> int: ... + def addRow(self, row: typing.Iterable['QSurfaceDataItem']) -> int: ... + @typing.overload + def setItem(self, rowIndex: int, columnIndex: int, item: 'QSurfaceDataItem') -> None: ... + @typing.overload + def setItem(self, position: QtCore.QPoint, item: 'QSurfaceDataItem') -> None: ... + def setRows(self, rowIndex: int, rows: typing.Iterable[typing.Iterable['QSurfaceDataItem']]) -> None: ... + def setRow(self, rowIndex: int, row: typing.Iterable['QSurfaceDataItem']) -> None: ... + def resetArray(self, newArray: typing.Iterable[typing.Iterable['QSurfaceDataItem']]) -> None: ... + def array(self) -> typing.List[typing.List['QSurfaceDataItem']]: ... + def columnCount(self) -> int: ... + def rowCount(self) -> int: ... + + +class QHeightMapSurfaceDataProxy('QSurfaceDataProxy'): + + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, image: QtGui.QImage, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, filename: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def maxZValueChanged(self, value: float) -> None: ... + def minZValueChanged(self, value: float) -> None: ... + def maxXValueChanged(self, value: float) -> None: ... + def minXValueChanged(self, value: float) -> None: ... + def heightMapFileChanged(self, filename: str) -> None: ... + def heightMapChanged(self, image: QtGui.QImage) -> None: ... + def maxZValue(self) -> float: ... + def setMaxZValue(self, max: float) -> None: ... + def minZValue(self) -> float: ... + def setMinZValue(self, min: float) -> None: ... + def maxXValue(self) -> float: ... + def setMaxXValue(self, max: float) -> None: ... + def minXValue(self) -> float: ... + def setMinXValue(self, min: float) -> None: ... + def setValueRanges(self, minX: float, maxX: float, minZ: float, maxZ: float) -> None: ... + def heightMapFile(self) -> str: ... + def setHeightMapFile(self, filename: str) -> None: ... + def heightMap(self) -> QtGui.QImage: ... + def setHeightMap(self, image: QtGui.QImage) -> None: ... + + +class QItemModelBarDataProxy('QBarDataProxy'): + + class MultiMatchBehavior(int): + MMBFirst = ... # type: QItemModelBarDataProxy.MultiMatchBehavior + MMBLast = ... # type: QItemModelBarDataProxy.MultiMatchBehavior + MMBAverage = ... # type: QItemModelBarDataProxy.MultiMatchBehavior + MMBCumulative = ... # type: QItemModelBarDataProxy.MultiMatchBehavior + + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, valueRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, valueRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, valueRole: str, rotationRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, valueRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, valueRole: str, rotationRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def multiMatchBehaviorChanged(self, behavior: 'QItemModelBarDataProxy.MultiMatchBehavior') -> None: ... + def rotationRoleReplaceChanged(self, replace: str) -> None: ... + def valueRoleReplaceChanged(self, replace: str) -> None: ... + def columnRoleReplaceChanged(self, replace: str) -> None: ... + def rowRoleReplaceChanged(self, replace: str) -> None: ... + def rotationRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def valueRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def columnRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def rowRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def multiMatchBehavior(self) -> 'QItemModelBarDataProxy.MultiMatchBehavior': ... + def setMultiMatchBehavior(self, behavior: 'QItemModelBarDataProxy.MultiMatchBehavior') -> None: ... + def rotationRoleReplace(self) -> str: ... + def setRotationRoleReplace(self, replace: str) -> None: ... + def valueRoleReplace(self) -> str: ... + def setValueRoleReplace(self, replace: str) -> None: ... + def columnRoleReplace(self) -> str: ... + def setColumnRoleReplace(self, replace: str) -> None: ... + def rowRoleReplace(self) -> str: ... + def setRowRoleReplace(self, replace: str) -> None: ... + def rotationRolePattern(self) -> QtCore.QRegExp: ... + def setRotationRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def valueRolePattern(self) -> QtCore.QRegExp: ... + def setValueRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def columnRolePattern(self) -> QtCore.QRegExp: ... + def setColumnRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def rowRolePattern(self) -> QtCore.QRegExp: ... + def setRowRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def autoColumnCategoriesChanged(self, enable: bool) -> None: ... + def autoRowCategoriesChanged(self, enable: bool) -> None: ... + def useModelCategoriesChanged(self, enable: bool) -> None: ... + def columnCategoriesChanged(self) -> None: ... + def rowCategoriesChanged(self) -> None: ... + def rotationRoleChanged(self, role: str) -> None: ... + def valueRoleChanged(self, role: str) -> None: ... + def columnRoleChanged(self, role: str) -> None: ... + def rowRoleChanged(self, role: str) -> None: ... + def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + def remap(self, rowRole: str, columnRole: str, valueRole: str, rotationRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str]) -> None: ... + def rotationRole(self) -> str: ... + def setRotationRole(self, role: str) -> None: ... + def columnCategoryIndex(self, category: str) -> int: ... + def rowCategoryIndex(self, category: str) -> int: ... + def autoColumnCategories(self) -> bool: ... + def setAutoColumnCategories(self, enable: bool) -> None: ... + def autoRowCategories(self) -> bool: ... + def setAutoRowCategories(self, enable: bool) -> None: ... + def useModelCategories(self) -> bool: ... + def setUseModelCategories(self, enable: bool) -> None: ... + def columnCategories(self) -> typing.List[str]: ... + def setColumnCategories(self, categories: typing.Iterable[str]) -> None: ... + def rowCategories(self) -> typing.List[str]: ... + def setRowCategories(self, categories: typing.Iterable[str]) -> None: ... + def valueRole(self) -> str: ... + def setValueRole(self, role: str) -> None: ... + def columnRole(self) -> str: ... + def setColumnRole(self, role: str) -> None: ... + def rowRole(self) -> str: ... + def setRowRole(self, role: str) -> None: ... + def itemModel(self) -> QtCore.QAbstractItemModel: ... + def setItemModel(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + + +class QScatterDataProxy('QAbstractDataProxy'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def seriesChanged(self, series: 'QScatter3DSeries') -> None: ... + def itemCountChanged(self, count: int) -> None: ... + def itemsInserted(self, startIndex: int, count: int) -> None: ... + def itemsRemoved(self, startIndex: int, count: int) -> None: ... + def itemsChanged(self, startIndex: int, count: int) -> None: ... + def itemsAdded(self, startIndex: int, count: int) -> None: ... + def arrayReset(self) -> None: ... + def series(self) -> 'QScatter3DSeries': ... + def removeItems(self, index: int, removeCount: int) -> None: ... + def insertItems(self, index: int, items: typing.Iterable['QScatterDataItem']) -> None: ... + def insertItem(self, index: int, item: 'QScatterDataItem') -> None: ... + def addItems(self, items: typing.Iterable['QScatterDataItem']) -> int: ... + def addItem(self, item: 'QScatterDataItem') -> int: ... + def setItems(self, index: int, items: typing.Iterable['QScatterDataItem']) -> None: ... + def setItem(self, index: int, item: 'QScatterDataItem') -> None: ... + def resetArray(self, newArray: typing.Iterable['QScatterDataItem']) -> None: ... + def itemAt(self, index: int) -> 'QScatterDataItem': ... + def array(self) -> typing.List['QScatterDataItem']: ... + def itemCount(self) -> int: ... + + +class QItemModelScatterDataProxy('QScatterDataProxy'): + + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, xPosRole: str, yPosRole: str, zPosRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, xPosRole: str, yPosRole: str, zPosRole: str, rotationRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def zPosRoleReplaceChanged(self, replace: str) -> None: ... + def yPosRoleReplaceChanged(self, replace: str) -> None: ... + def xPosRoleReplaceChanged(self, replace: str) -> None: ... + def rotationRoleReplaceChanged(self, replace: str) -> None: ... + def rotationRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def zPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def yPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def xPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def rotationRoleReplace(self) -> str: ... + def setRotationRoleReplace(self, replace: str) -> None: ... + def zPosRoleReplace(self) -> str: ... + def setZPosRoleReplace(self, replace: str) -> None: ... + def yPosRoleReplace(self) -> str: ... + def setYPosRoleReplace(self, replace: str) -> None: ... + def xPosRoleReplace(self) -> str: ... + def setXPosRoleReplace(self, replace: str) -> None: ... + def rotationRolePattern(self) -> QtCore.QRegExp: ... + def setRotationRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def zPosRolePattern(self) -> QtCore.QRegExp: ... + def setZPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def yPosRolePattern(self) -> QtCore.QRegExp: ... + def setYPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def xPosRolePattern(self) -> QtCore.QRegExp: ... + def setXPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def rotationRoleChanged(self, role: str) -> None: ... + def zPosRoleChanged(self, role: str) -> None: ... + def yPosRoleChanged(self, role: str) -> None: ... + def xPosRoleChanged(self, role: str) -> None: ... + def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + def remap(self, xPosRole: str, yPosRole: str, zPosRole: str, rotationRole: str) -> None: ... + def rotationRole(self) -> str: ... + def setRotationRole(self, role: str) -> None: ... + def zPosRole(self) -> str: ... + def setZPosRole(self, role: str) -> None: ... + def yPosRole(self) -> str: ... + def setYPosRole(self, role: str) -> None: ... + def xPosRole(self) -> str: ... + def setXPosRole(self, role: str) -> None: ... + def itemModel(self) -> QtCore.QAbstractItemModel: ... + def setItemModel(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + + +class QItemModelSurfaceDataProxy('QSurfaceDataProxy'): + + class MultiMatchBehavior(int): + MMBFirst = ... # type: QItemModelSurfaceDataProxy.MultiMatchBehavior + MMBLast = ... # type: QItemModelSurfaceDataProxy.MultiMatchBehavior + MMBAverage = ... # type: QItemModelSurfaceDataProxy.MultiMatchBehavior + MMBCumulativeY = ... # type: QItemModelSurfaceDataProxy.MultiMatchBehavior + + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, yPosRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, yPosRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, yPosRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, xPosRole: str, yPosRole: str, zPosRole: str, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, itemModel: QtCore.QAbstractItemModel, rowRole: str, columnRole: str, xPosRole: str, yPosRole: str, zPosRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def multiMatchBehaviorChanged(self, behavior: 'QItemModelSurfaceDataProxy.MultiMatchBehavior') -> None: ... + def zPosRoleReplaceChanged(self, replace: str) -> None: ... + def yPosRoleReplaceChanged(self, replace: str) -> None: ... + def xPosRoleReplaceChanged(self, replace: str) -> None: ... + def columnRoleReplaceChanged(self, replace: str) -> None: ... + def rowRoleReplaceChanged(self, replace: str) -> None: ... + def zPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def yPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def xPosRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def columnRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def rowRolePatternChanged(self, pattern: QtCore.QRegExp) -> None: ... + def multiMatchBehavior(self) -> 'QItemModelSurfaceDataProxy.MultiMatchBehavior': ... + def setMultiMatchBehavior(self, behavior: 'QItemModelSurfaceDataProxy.MultiMatchBehavior') -> None: ... + def zPosRoleReplace(self) -> str: ... + def setZPosRoleReplace(self, replace: str) -> None: ... + def yPosRoleReplace(self) -> str: ... + def setYPosRoleReplace(self, replace: str) -> None: ... + def xPosRoleReplace(self) -> str: ... + def setXPosRoleReplace(self, replace: str) -> None: ... + def columnRoleReplace(self) -> str: ... + def setColumnRoleReplace(self, replace: str) -> None: ... + def rowRoleReplace(self) -> str: ... + def setRowRoleReplace(self, replace: str) -> None: ... + def zPosRolePattern(self) -> QtCore.QRegExp: ... + def setZPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def yPosRolePattern(self) -> QtCore.QRegExp: ... + def setYPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def xPosRolePattern(self) -> QtCore.QRegExp: ... + def setXPosRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def columnRolePattern(self) -> QtCore.QRegExp: ... + def setColumnRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def rowRolePattern(self) -> QtCore.QRegExp: ... + def setRowRolePattern(self, pattern: QtCore.QRegExp) -> None: ... + def autoColumnCategoriesChanged(self, enable: bool) -> None: ... + def autoRowCategoriesChanged(self, enable: bool) -> None: ... + def useModelCategoriesChanged(self, enable: bool) -> None: ... + def columnCategoriesChanged(self) -> None: ... + def rowCategoriesChanged(self) -> None: ... + def zPosRoleChanged(self, role: str) -> None: ... + def yPosRoleChanged(self, role: str) -> None: ... + def xPosRoleChanged(self, role: str) -> None: ... + def columnRoleChanged(self, role: str) -> None: ... + def rowRoleChanged(self, role: str) -> None: ... + def itemModelChanged(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + def remap(self, rowRole: str, columnRole: str, xPosRole: str, yPosRole: str, zPosRole: str, rowCategories: typing.Iterable[str], columnCategories: typing.Iterable[str]) -> None: ... + def zPosRole(self) -> str: ... + def setZPosRole(self, role: str) -> None: ... + def yPosRole(self) -> str: ... + def setYPosRole(self, role: str) -> None: ... + def xPosRole(self) -> str: ... + def setXPosRole(self, role: str) -> None: ... + def columnCategoryIndex(self, category: str) -> int: ... + def rowCategoryIndex(self, category: str) -> int: ... + def autoColumnCategories(self) -> bool: ... + def setAutoColumnCategories(self, enable: bool) -> None: ... + def autoRowCategories(self) -> bool: ... + def setAutoRowCategories(self, enable: bool) -> None: ... + def useModelCategories(self) -> bool: ... + def setUseModelCategories(self, enable: bool) -> None: ... + def columnCategories(self) -> typing.List[str]: ... + def setColumnCategories(self, categories: typing.Iterable[str]) -> None: ... + def rowCategories(self) -> typing.List[str]: ... + def setRowCategories(self, categories: typing.Iterable[str]) -> None: ... + def columnRole(self) -> str: ... + def setColumnRole(self, role: str) -> None: ... + def rowRole(self) -> str: ... + def setRowRole(self, role: str) -> None: ... + def itemModel(self) -> QtCore.QAbstractItemModel: ... + def setItemModel(self, itemModel: QtCore.QAbstractItemModel) -> None: ... + + +class QValue3DAxisFormatter(QtCore.QObject): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def locale(self) -> QtCore.QLocale: ... + def setLocale(self, locale: QtCore.QLocale) -> None: ... + def labelStrings(self) -> typing.List[str]: ... + def labelPositions(self) -> typing.List[float]: ... + def subGridPositions(self) -> typing.List[float]: ... + def gridPositions(self) -> typing.List[float]: ... + def axis(self) -> 'QValue3DAxis': ... + def markDirty(self, labelsChange: bool = ...) -> None: ... + def populateCopy(self, copy: 'QValue3DAxisFormatter') -> None: ... + def valueAt(self, position: float) -> float: ... + def positionAt(self, value: float) -> float: ... + def stringForValue(self, value: float, format: str) -> str: ... + def recalculate(self) -> None: ... + def createNewInstance(self) -> 'QValue3DAxisFormatter': ... + def allowZero(self) -> bool: ... + def setAllowZero(self, allow: bool) -> None: ... + def allowNegatives(self) -> bool: ... + def setAllowNegatives(self, allow: bool) -> None: ... + + +class QLogValue3DAxisFormatter('QValue3DAxisFormatter'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def populateCopy(self, copy: 'QValue3DAxisFormatter') -> None: ... + def valueAt(self, position: float) -> float: ... + def positionAt(self, value: float) -> float: ... + def recalculate(self) -> None: ... + def createNewInstance(self) -> 'QValue3DAxisFormatter': ... + def showEdgeLabelsChanged(self, enabled: bool) -> None: ... + def autoSubGridChanged(self, enabled: bool) -> None: ... + def baseChanged(self, base: float) -> None: ... + def showEdgeLabels(self) -> bool: ... + def setShowEdgeLabels(self, enabled: bool) -> None: ... + def autoSubGrid(self) -> bool: ... + def setAutoSubGrid(self, enabled: bool) -> None: ... + def base(self) -> float: ... + def setBase(self, base: float) -> None: ... + + +class QScatter3DSeries('QAbstract3DSeries'): + + @typing.overload + def __init__(self, dataProxy: 'QScatterDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def itemSizeChanged(self, size: float) -> None: ... + def selectedItemChanged(self, index: int) -> None: ... + def dataProxyChanged(self, proxy: 'QScatterDataProxy') -> None: ... + def itemSize(self) -> float: ... + def setItemSize(self, size: float) -> None: ... + @staticmethod + def invalidSelectionIndex() -> int: ... + def selectedItem(self) -> int: ... + def setSelectedItem(self, index: int) -> None: ... + def dataProxy(self) -> 'QScatterDataProxy': ... + def setDataProxy(self, proxy: 'QScatterDataProxy') -> None: ... + + +class QScatterDataItem(sip.simplewrapper): + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, position: QtGui.QVector3D) -> None: ... + @typing.overload + def __init__(self, position: QtGui.QVector3D, rotation: QtGui.QQuaternion) -> None: ... + @typing.overload + def __init__(self, other: 'QScatterDataItem') -> None: ... + + def z(self) -> float: ... + def y(self) -> float: ... + def x(self) -> float: ... + def setZ(self, value: float) -> None: ... + def setY(self, value: float) -> None: ... + def setX(self, value: float) -> None: ... + def rotation(self) -> QtGui.QQuaternion: ... + def setRotation(self, rotation: QtGui.QQuaternion) -> None: ... + def position(self) -> QtGui.QVector3D: ... + def setPosition(self, position: QtGui.QVector3D) -> None: ... + + +class QSurface3DSeries('QAbstract3DSeries'): + + class DrawFlag(int): + DrawWireframe = ... # type: QSurface3DSeries.DrawFlag + DrawSurface = ... # type: QSurface3DSeries.DrawFlag + DrawSurfaceAndWireframe = ... # type: QSurface3DSeries.DrawFlag + + class DrawFlags(sip.simplewrapper): @typing.overload def __init__(self) -> None: ... @typing.overload - def __init__(self, position: QtGui.QVector3D) -> None: ... - @typing.overload - def __init__(self, other: 'QSurfaceDataItem') -> None: ... - - def z(self) -> float: ... - def y(self) -> float: ... - def x(self) -> float: ... - def setZ(self, value: float) -> None: ... - def setY(self, value: float) -> None: ... - def setX(self, value: float) -> None: ... - def position(self) -> QtGui.QVector3D: ... - def setPosition(self, position: QtGui.QVector3D) -> None: ... - - class QTouch3DInputHandler('Q3DInputHandler'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def touchEvent(self, event: QtGui.QTouchEvent) -> None: ... - - class QValue3DAxis('QAbstract3DAxis'): - - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... - - def reversedChanged(self, enable: bool) -> None: ... - def formatterChanged(self, formatter: 'QValue3DAxisFormatter') -> None: ... - def reversed(self) -> bool: ... - def setReversed(self, enable: bool) -> None: ... - def formatter(self) -> 'QValue3DAxisFormatter': ... - def setFormatter(self, formatter: 'QValue3DAxisFormatter') -> None: ... - def labelFormatChanged(self, format: str) -> None: ... - def subSegmentCountChanged(self, count: int) -> None: ... - def segmentCountChanged(self, count: int) -> None: ... - def labelFormat(self) -> str: ... - def setLabelFormat(self, format: str) -> None: ... - def subSegmentCount(self) -> int: ... - def setSubSegmentCount(self, count: int) -> None: ... - def segmentCount(self) -> int: ... - def setSegmentCount(self, count: int) -> None: ... - - def qDefaultSurfaceFormat(self, antialias: bool = ...) -> QtGui.QSurfaceFormat: ... + def __init__(self, f: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... + @typing.overload + def __init__(self, a0: 'QSurface3DSeries.DrawFlags') -> None: ... + + def __hash__(self) -> int: ... + def __bool__(self) -> int: ... + def __invert__(self) -> 'QSurface3DSeries.DrawFlags': ... + def __index__(self) -> int: ... + def __int__(self) -> int: ... + + @typing.overload + def __init__(self, dataProxy: 'QSurfaceDataProxy', parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def textureFileChanged(self, filename: str) -> None: ... + def textureChanged(self, image: QtGui.QImage) -> None: ... + def textureFile(self) -> str: ... + def setTextureFile(self, filename: str) -> None: ... + def texture(self) -> QtGui.QImage: ... + def setTexture(self, texture: QtGui.QImage) -> None: ... + def drawModeChanged(self, mode: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... + def flatShadingSupportedChanged(self, enable: bool) -> None: ... + def flatShadingEnabledChanged(self, enable: bool) -> None: ... + def selectedPointChanged(self, position: QtCore.QPoint) -> None: ... + def dataProxyChanged(self, proxy: 'QSurfaceDataProxy') -> None: ... + def isFlatShadingSupported(self) -> bool: ... + def drawMode(self) -> 'QSurface3DSeries.DrawFlags': ... + def setDrawMode(self, mode: typing.Union['QSurface3DSeries.DrawFlags', 'QSurface3DSeries.DrawFlag']) -> None: ... + def isFlatShadingEnabled(self) -> bool: ... + def setFlatShadingEnabled(self, enabled: bool) -> None: ... + @staticmethod + def invalidSelectionPosition() -> QtCore.QPoint: ... + def selectedPoint(self) -> QtCore.QPoint: ... + def setSelectedPoint(self, position: QtCore.QPoint) -> None: ... + def dataProxy(self) -> 'QSurfaceDataProxy': ... + def setDataProxy(self, proxy: 'QSurfaceDataProxy') -> None: ... + + +class QSurfaceDataItem(sip.simplewrapper): + + @typing.overload + def __init__(self) -> None: ... + @typing.overload + def __init__(self, position: QtGui.QVector3D) -> None: ... + @typing.overload + def __init__(self, other: 'QSurfaceDataItem') -> None: ... + + def z(self) -> float: ... + def y(self) -> float: ... + def x(self) -> float: ... + def setZ(self, value: float) -> None: ... + def setY(self, value: float) -> None: ... + def setX(self, value: float) -> None: ... + def position(self) -> QtGui.QVector3D: ... + def setPosition(self, position: QtGui.QVector3D) -> None: ... + + +class QTouch3DInputHandler('Q3DInputHandler'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def touchEvent(self, event: QtGui.QTouchEvent) -> None: ... + + +class QValue3DAxis('QAbstract3DAxis'): + + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + + def reversedChanged(self, enable: bool) -> None: ... + def formatterChanged(self, formatter: 'QValue3DAxisFormatter') -> None: ... + def reversed(self) -> bool: ... + def setReversed(self, enable: bool) -> None: ... + def formatter(self) -> 'QValue3DAxisFormatter': ... + def setFormatter(self, formatter: 'QValue3DAxisFormatter') -> None: ... + def labelFormatChanged(self, format: str) -> None: ... + def subSegmentCountChanged(self, count: int) -> None: ... + def segmentCountChanged(self, count: int) -> None: ... + def labelFormat(self) -> str: ... + def setLabelFormat(self, format: str) -> None: ... + def subSegmentCount(self) -> int: ... + def setSubSegmentCount(self, count: int) -> None: ... + def segmentCount(self) -> int: ... + def setSegmentCount(self, count: int) -> None: ... + + +def qDefaultSurfaceFormat(self, antialias: bool = ...) -> QtGui.QSurfaceFormat: ... PYQT_DATAVISUALIZATION_VERSION = ... # type: int diff --git a/PyQt5-stubs/QtDesigner.pyi b/PyQt5-stubs/QtDesigner.pyi index 90c5ad4d..8ff86ca0 100644 --- a/PyQt5-stubs/QtDesigner.pyi +++ b/PyQt5-stubs/QtDesigner.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtDesigner module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 153a988c..7bb5df17 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtGui module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -6010,7 +6010,10 @@ class QPdfWriter(QtCore.QObject, QPagedPaintDevice): def paintEngine(self) -> QPaintEngine: ... def setMargins(self, m: QPagedPaintDevice.Margins) -> None: ... def setPageSizeMM(self, size: QtCore.QSizeF) -> None: ... + @typing.overload def setPageSize(self, size: QPagedPaintDevice.PageSize) -> None: ... + @typing.overload + def setPageSize(self, pageSize: QPageSize) -> bool: ... def newPage(self) -> bool: ... def setCreator(self, creator: str) -> None: ... def creator(self) -> str: ... diff --git a/PyQt5-stubs/QtHelp.pyi b/PyQt5-stubs/QtHelp.pyi index 904e8a8b..57a7a1dc 100644 --- a/PyQt5-stubs/QtHelp.pyi +++ b/PyQt5-stubs/QtHelp.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtHelp module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index 9132ffd8..a35e57b0 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtLocation module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index e0fee9cd..a9b99520 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtMultimedia module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtMultimediaWidgets.pyi b/PyQt5-stubs/QtMultimediaWidgets.pyi index cf87f5c0..7c2fce32 100644 --- a/PyQt5-stubs/QtMultimediaWidgets.pyi +++ b/PyQt5-stubs/QtMultimediaWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtMultimediaWidgets module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index 929210cb..aa92cb46 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtNetwork module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtNetworkAuth.pyi b/PyQt5-stubs/QtNetworkAuth.pyi index 8411710e..fddb0f03 100644 --- a/PyQt5-stubs/QtNetworkAuth.pyi +++ b/PyQt5-stubs/QtNetworkAuth.pyi @@ -1,10 +1,10 @@ # The PEP 484 type hints stub file for the QtNetworkAuth module. # -# Generated by SIP 5.4.0 +# Generated by SIP 6.3.1 # -# Copyright (c) 2020 Riverbank Computing Limited +# Copyright (c) 2021 Riverbank Computing Limited # -# This file is part of PyQt5. +# This file is part of PyQtNetworkAuth. # # This file may be used under the terms of the GNU General Public License # version 3.0 as published by the Free Software Foundation and appearing in @@ -21,7 +21,8 @@ import typing -import sip + +import PyQt5.sip from PyQt5 import QtNetwork from PyQt5 import QtCore @@ -36,29 +37,29 @@ PYQT_SLOT = typing.Union[typing.Callable[..., None], QtCore.pyqtBoundSignal] class QAbstractOAuth(QtCore.QObject): - class ContentType(int): ... - WwwFormUrlEncoded = ... # type: 'QAbstractOAuth.ContentType' - Json = ... # type: 'QAbstractOAuth.ContentType' - - class Error(int): ... - NoError = ... # type: 'QAbstractOAuth.Error' - NetworkError = ... # type: 'QAbstractOAuth.Error' - ServerError = ... # type: 'QAbstractOAuth.Error' - OAuthTokenNotFoundError = ... # type: 'QAbstractOAuth.Error' - OAuthTokenSecretNotFoundError = ... # type: 'QAbstractOAuth.Error' - OAuthCallbackNotVerified = ... # type: 'QAbstractOAuth.Error' - - class Stage(int): ... - RequestingTemporaryCredentials = ... # type: 'QAbstractOAuth.Stage' - RequestingAuthorization = ... # type: 'QAbstractOAuth.Stage' - RequestingAccessToken = ... # type: 'QAbstractOAuth.Stage' - RefreshingAccessToken = ... # type: 'QAbstractOAuth.Stage' - - class Status(int): ... - NotAuthenticated = ... # type: 'QAbstractOAuth.Status' - TemporaryCredentialsReceived = ... # type: 'QAbstractOAuth.Status' - Granted = ... # type: 'QAbstractOAuth.Status' - RefreshingToken = ... # type: 'QAbstractOAuth.Status' + class ContentType(int): + WwwFormUrlEncoded = ... # type: QAbstractOAuth.ContentType + Json = ... # type: QAbstractOAuth.ContentType + + class Error(int): + NoError = ... # type: QAbstractOAuth.Error + NetworkError = ... # type: QAbstractOAuth.Error + ServerError = ... # type: QAbstractOAuth.Error + OAuthTokenNotFoundError = ... # type: QAbstractOAuth.Error + OAuthTokenSecretNotFoundError = ... # type: QAbstractOAuth.Error + OAuthCallbackNotVerified = ... # type: QAbstractOAuth.Error + + class Stage(int): + RequestingTemporaryCredentials = ... # type: QAbstractOAuth.Stage + RequestingAuthorization = ... # type: QAbstractOAuth.Stage + RequestingAccessToken = ... # type: QAbstractOAuth.Stage + RefreshingAccessToken = ... # type: QAbstractOAuth.Stage + + class Status(int): + NotAuthenticated = ... # type: QAbstractOAuth.Status + TemporaryCredentialsReceived = ... # type: QAbstractOAuth.Status + Granted = ... # type: QAbstractOAuth.Status + RefreshingToken = ... # type: QAbstractOAuth.Status @staticmethod def generateRandomString(length: int) -> QtCore.QByteArray: ... @@ -162,10 +163,10 @@ class QAbstractOAuthReplyHandler(QtCore.QObject): class QOAuth1(QAbstractOAuth): - class SignatureMethod(int): ... - Hmac_Sha1 = ... # type: 'QOAuth1.SignatureMethod' - Rsa_Sha1 = ... # type: 'QOAuth1.SignatureMethod' - PlainText = ... # type: 'QOAuth1.SignatureMethod' + class SignatureMethod(int): + Hmac_Sha1 = ... # type: QOAuth1.SignatureMethod + Rsa_Sha1 = ... # type: QOAuth1.SignatureMethod + PlainText = ... # type: QOAuth1.SignatureMethod @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @@ -220,14 +221,14 @@ class QOAuth1(QAbstractOAuth): class QOAuth1Signature(sip.simplewrapper): - class HttpRequestMethod(int): ... - Head = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Get = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Put = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Post = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Delete = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Custom = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Unknown = ... # type: 'QOAuth1Signature.HttpRequestMethod' + class HttpRequestMethod(int): + Head = ... # type: QOAuth1Signature.HttpRequestMethod + Get = ... # type: QOAuth1Signature.HttpRequestMethod + Put = ... # type: QOAuth1Signature.HttpRequestMethod + Post = ... # type: QOAuth1Signature.HttpRequestMethod + Delete = ... # type: QOAuth1Signature.HttpRequestMethod + Custom = ... # type: QOAuth1Signature.HttpRequestMethod + Unknown = ... # type: QOAuth1Signature.HttpRequestMethod @typing.overload def __init__(self, url: QtCore.QUrl = ..., method: 'QOAuth1Signature.HttpRequestMethod' = ..., parameters: typing.Dict[str, typing.Any] = ...) -> None: ... diff --git a/PyQt5-stubs/QtNfc.pyi b/PyQt5-stubs/QtNfc.pyi index f4cab86a..e26efeaf 100644 --- a/PyQt5-stubs/QtNfc.pyi +++ b/PyQt5-stubs/QtNfc.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtNfc module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtOpenGL.pyi b/PyQt5-stubs/QtOpenGL.pyi index d9ea2a18..c0535822 100644 --- a/PyQt5-stubs/QtOpenGL.pyi +++ b/PyQt5-stubs/QtOpenGL.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtOpenGL module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtPositioning.pyi b/PyQt5-stubs/QtPositioning.pyi index ff3fed6d..a0116fa6 100644 --- a/PyQt5-stubs/QtPositioning.pyi +++ b/PyQt5-stubs/QtPositioning.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtPositioning module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtPrintSupport.pyi b/PyQt5-stubs/QtPrintSupport.pyi index 76831d1f..748a473b 100644 --- a/PyQt5-stubs/QtPrintSupport.pyi +++ b/PyQt5-stubs/QtPrintSupport.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtPrintSupport module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtPurchasing.pyi b/PyQt5-stubs/QtPurchasing.pyi index 5bb9d611..e7d063d3 100644 --- a/PyQt5-stubs/QtPurchasing.pyi +++ b/PyQt5-stubs/QtPurchasing.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtPurchasing module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtQml.pyi b/PyQt5-stubs/QtQml.pyi index 6fb88182..e82b1c80 100644 --- a/PyQt5-stubs/QtQml.pyi +++ b/PyQt5-stubs/QtQml.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtQml module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 744d4ec5..d59360b1 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtQuick module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtQuickWidgets.pyi b/PyQt5-stubs/QtQuickWidgets.pyi index de642e55..ecbb55e6 100644 --- a/PyQt5-stubs/QtQuickWidgets.pyi +++ b/PyQt5-stubs/QtQuickWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtQuickWidgets module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtRemoteObjects.pyi b/PyQt5-stubs/QtRemoteObjects.pyi index a04756b4..c1af53c4 100644 --- a/PyQt5-stubs/QtRemoteObjects.pyi +++ b/PyQt5-stubs/QtRemoteObjects.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtRemoteObjects module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSensors.pyi b/PyQt5-stubs/QtSensors.pyi index caa5e0e9..b6d9a68e 100644 --- a/PyQt5-stubs/QtSensors.pyi +++ b/PyQt5-stubs/QtSensors.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSensors module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSerialPort.pyi b/PyQt5-stubs/QtSerialPort.pyi index 71526b09..4b430dc1 100644 --- a/PyQt5-stubs/QtSerialPort.pyi +++ b/PyQt5-stubs/QtSerialPort.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSerialPort module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSql.pyi b/PyQt5-stubs/QtSql.pyi index cf9e1eae..1cabe1dd 100644 --- a/PyQt5-stubs/QtSql.pyi +++ b/PyQt5-stubs/QtSql.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSql module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSvg.pyi b/PyQt5-stubs/QtSvg.pyi index a0a4c20e..ed7cfcc0 100644 --- a/PyQt5-stubs/QtSvg.pyi +++ b/PyQt5-stubs/QtSvg.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSvg module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtTest.pyi b/PyQt5-stubs/QtTest.pyi index 59873221..48a2c5f4 100644 --- a/PyQt5-stubs/QtTest.pyi +++ b/PyQt5-stubs/QtTest.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtTest module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebChannel.pyi b/PyQt5-stubs/QtWebChannel.pyi index ca33b388..b6aaa569 100644 --- a/PyQt5-stubs/QtWebChannel.pyi +++ b/PyQt5-stubs/QtWebChannel.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebChannel module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebEngine.pyi b/PyQt5-stubs/QtWebEngine.pyi index 49faeeae..98f81420 100644 --- a/PyQt5-stubs/QtWebEngine.pyi +++ b/PyQt5-stubs/QtWebEngine.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebEngine module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebEngineCore.pyi b/PyQt5-stubs/QtWebEngineCore.pyi index ae7e8279..e524d4c3 100644 --- a/PyQt5-stubs/QtWebEngineCore.pyi +++ b/PyQt5-stubs/QtWebEngineCore.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebEngineCore module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -42,9 +42,6 @@ PYQT_OPENGL_BOUND_ARRAY = typing.Union[typing.Sequence[int], typing.Sequence[float], PyQt5.sip.Buffer, int, None] -class QtWebEngineCore(PyQt5.sip.simplewrapper): ... - - class QWebEngineClientCertificateStore(sip.simplewrapper): def clear(self) -> None: ... diff --git a/PyQt5-stubs/QtWebEngineWidgets.pyi b/PyQt5-stubs/QtWebEngineWidgets.pyi index 6e3682aa..a0932dc4 100644 --- a/PyQt5-stubs/QtWebEngineWidgets.pyi +++ b/PyQt5-stubs/QtWebEngineWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebEngineWidgets module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebKit.pyi b/PyQt5-stubs/QtWebKit.pyi index 37150802..e5d6f4fe 100644 --- a/PyQt5-stubs/QtWebKit.pyi +++ b/PyQt5-stubs/QtWebKit.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebKit module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebKitWidgets.pyi b/PyQt5-stubs/QtWebKitWidgets.pyi index 07390efb..b787ec05 100644 --- a/PyQt5-stubs/QtWebKitWidgets.pyi +++ b/PyQt5-stubs/QtWebKitWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebKitWidgets module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebSockets.pyi b/PyQt5-stubs/QtWebSockets.pyi index bfcce4d0..cc21f242 100644 --- a/PyQt5-stubs/QtWebSockets.pyi +++ b/PyQt5-stubs/QtWebSockets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebSockets module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index a3a03249..0bd113e5 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWidgets module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -2503,12 +2503,12 @@ class QCompleter(QtCore.QObject): UnfilteredPopupCompletion = ... # type: QCompleter.CompletionMode InlineCompletion = ... # type: QCompleter.CompletionMode - @typing.overload - def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, model: QtCore.QAbstractItemModel, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @typing.overload def __init__(self, list: typing.Iterable[str], parent: typing.Optional[QtCore.QObject] = ...) -> None: ... + @typing.overload + def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... def filterMode(self) -> QtCore.Qt.MatchFlags: ... def setFilterMode(self, filterMode: typing.Union[QtCore.Qt.MatchFlags, QtCore.Qt.MatchFlag]) -> None: ... diff --git a/PyQt5-stubs/QtX11Extras.pyi b/PyQt5-stubs/QtX11Extras.pyi index 5450716e..8c71a9fa 100644 --- a/PyQt5-stubs/QtX11Extras.pyi +++ b/PyQt5-stubs/QtX11Extras.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtX11Extras module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtXml.pyi b/PyQt5-stubs/QtXml.pyi index ca6f875e..ac47a4fe 100644 --- a/PyQt5-stubs/QtXml.pyi +++ b/PyQt5-stubs/QtXml.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtXml module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtXmlPatterns.pyi b/PyQt5-stubs/QtXmlPatterns.pyi index dd2fc8af..3b499501 100644 --- a/PyQt5-stubs/QtXmlPatterns.pyi +++ b/PyQt5-stubs/QtXmlPatterns.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtXmlPatterns module. # -# Generated by SIP 6.0.3 +# Generated by SIP 6.3.1 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/__init__.pyi b/PyQt5-stubs/__init__.pyi index c2fa8bdc..087b1cec 100644 --- a/PyQt5-stubs/__init__.pyi +++ b/PyQt5-stubs/__init__.pyi @@ -1 +1 @@ -__version__ = "5.15.4.0" +__version__ = "5.15.5.0" From 39c4f4e25b9dbc9807188976cbf2a81b5885b6b8 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 29 Nov 2021 09:38:48 -0500 Subject: [PATCH 376/421] Correct PyQtNetworkAuth handling --- Dockerfile | 35 ++++++++++++++++ PyQt5-stubs/QtNetworkAuth.pyi | 79 ++++++++++++++++++----------------- 2 files changed, 75 insertions(+), 39 deletions(-) diff --git a/Dockerfile b/Dockerfile index 88859565..6f7e7592 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ ARG PYQT_CHART_VERSION="5.15.4" ARG PYQT_DATA_VISUALIZATION_VERSION="5.15.4" ARG PYQT_PURCHASING_VERSION="5.15.4" ARG PYQT_WEB_ENGINE_VERSION="5.15.4" +ARG PYQT_NETWORK_AUTH_VERSION="5.15.4" ARG MAKEFLAGS="" @@ -301,6 +302,39 @@ RUN sip-install \ WORKDIR /output/ RUN find /upstream/ -name \*.pyi -exec cp {} . \; +################################################################################ +# PyQtNetworkAuth +################################################################################ + +FROM build-dep AS pyqt-network-auth + +# Reuse arguments from previous build scope +ARG MAKEFLAGS +ARG PYQT_NETWORK_AUTH_VERSION + +# Download source tar +RUN wget --no-verbose \ + --output-document upstream.tar.gz \ + https://pypi.io/packages/source/p/pyqtnetworkauth/PyQtNetworkAuth-${PYQT_NETWORK_AUTH_VERSION}.tar.gz +RUN mkdir /upstream/ && \ + tar -xf \ + upstream.tar.gz \ + --directory /upstream/ \ + --strip-components 1 + +# Build PyQtNetworkAuth with stubs +# TODO: Find way to build only stubs +WORKDIR /upstream/ +RUN sip-install \ + --qmake /usr/bin/qmake-qt5 \ + --pep484-pyi \ + --build-dir ./build \ + --verbose + +# Copy all .pyi files to output dir +WORKDIR /output/ +RUN find /upstream/ -name \*.pyi -exec cp {} . \; + ################################################################################ # Output ################################################################################ @@ -316,6 +350,7 @@ COPY --from=pyqt-chart /output/* ./ COPY --from=pyqt-data-visualization /output/* ./ COPY --from=pyqt-purchasing /output/* ./ COPY --from=pyqt-web-engine /output/* ./ +COPY --from=pyqt-network-auth /output/* ./ # Required to run the image (which we need to do to get the files) CMD /bin/true diff --git a/PyQt5-stubs/QtNetworkAuth.pyi b/PyQt5-stubs/QtNetworkAuth.pyi index 8411710e..385ad85c 100644 --- a/PyQt5-stubs/QtNetworkAuth.pyi +++ b/PyQt5-stubs/QtNetworkAuth.pyi @@ -1,10 +1,10 @@ # The PEP 484 type hints stub file for the QtNetworkAuth module. # -# Generated by SIP 5.4.0 +# Generated by SIP 6.0.3 # -# Copyright (c) 2020 Riverbank Computing Limited +# Copyright (c) 2021 Riverbank Computing Limited # -# This file is part of PyQt5. +# This file is part of PyQtNetworkAuth. # # This file may be used under the terms of the GNU General Public License # version 3.0 as published by the Free Software Foundation and appearing in @@ -21,7 +21,8 @@ import typing -import sip + +import PyQt5.sip from PyQt5 import QtNetwork from PyQt5 import QtCore @@ -36,29 +37,29 @@ PYQT_SLOT = typing.Union[typing.Callable[..., None], QtCore.pyqtBoundSignal] class QAbstractOAuth(QtCore.QObject): - class ContentType(int): ... - WwwFormUrlEncoded = ... # type: 'QAbstractOAuth.ContentType' - Json = ... # type: 'QAbstractOAuth.ContentType' - - class Error(int): ... - NoError = ... # type: 'QAbstractOAuth.Error' - NetworkError = ... # type: 'QAbstractOAuth.Error' - ServerError = ... # type: 'QAbstractOAuth.Error' - OAuthTokenNotFoundError = ... # type: 'QAbstractOAuth.Error' - OAuthTokenSecretNotFoundError = ... # type: 'QAbstractOAuth.Error' - OAuthCallbackNotVerified = ... # type: 'QAbstractOAuth.Error' - - class Stage(int): ... - RequestingTemporaryCredentials = ... # type: 'QAbstractOAuth.Stage' - RequestingAuthorization = ... # type: 'QAbstractOAuth.Stage' - RequestingAccessToken = ... # type: 'QAbstractOAuth.Stage' - RefreshingAccessToken = ... # type: 'QAbstractOAuth.Stage' - - class Status(int): ... - NotAuthenticated = ... # type: 'QAbstractOAuth.Status' - TemporaryCredentialsReceived = ... # type: 'QAbstractOAuth.Status' - Granted = ... # type: 'QAbstractOAuth.Status' - RefreshingToken = ... # type: 'QAbstractOAuth.Status' + class ContentType(int): + WwwFormUrlEncoded = ... # type: QAbstractOAuth.ContentType + Json = ... # type: QAbstractOAuth.ContentType + + class Error(int): + NoError = ... # type: QAbstractOAuth.Error + NetworkError = ... # type: QAbstractOAuth.Error + ServerError = ... # type: QAbstractOAuth.Error + OAuthTokenNotFoundError = ... # type: QAbstractOAuth.Error + OAuthTokenSecretNotFoundError = ... # type: QAbstractOAuth.Error + OAuthCallbackNotVerified = ... # type: QAbstractOAuth.Error + + class Stage(int): + RequestingTemporaryCredentials = ... # type: QAbstractOAuth.Stage + RequestingAuthorization = ... # type: QAbstractOAuth.Stage + RequestingAccessToken = ... # type: QAbstractOAuth.Stage + RefreshingAccessToken = ... # type: QAbstractOAuth.Stage + + class Status(int): + NotAuthenticated = ... # type: QAbstractOAuth.Status + TemporaryCredentialsReceived = ... # type: QAbstractOAuth.Status + Granted = ... # type: QAbstractOAuth.Status + RefreshingToken = ... # type: QAbstractOAuth.Status @staticmethod def generateRandomString(length: int) -> QtCore.QByteArray: ... @@ -162,10 +163,10 @@ class QAbstractOAuthReplyHandler(QtCore.QObject): class QOAuth1(QAbstractOAuth): - class SignatureMethod(int): ... - Hmac_Sha1 = ... # type: 'QOAuth1.SignatureMethod' - Rsa_Sha1 = ... # type: 'QOAuth1.SignatureMethod' - PlainText = ... # type: 'QOAuth1.SignatureMethod' + class SignatureMethod(int): + Hmac_Sha1 = ... # type: QOAuth1.SignatureMethod + Rsa_Sha1 = ... # type: QOAuth1.SignatureMethod + PlainText = ... # type: QOAuth1.SignatureMethod @typing.overload def __init__(self, parent: typing.Optional[QtCore.QObject] = ...) -> None: ... @@ -220,14 +221,14 @@ class QOAuth1(QAbstractOAuth): class QOAuth1Signature(sip.simplewrapper): - class HttpRequestMethod(int): ... - Head = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Get = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Put = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Post = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Delete = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Custom = ... # type: 'QOAuth1Signature.HttpRequestMethod' - Unknown = ... # type: 'QOAuth1Signature.HttpRequestMethod' + class HttpRequestMethod(int): + Head = ... # type: QOAuth1Signature.HttpRequestMethod + Get = ... # type: QOAuth1Signature.HttpRequestMethod + Put = ... # type: QOAuth1Signature.HttpRequestMethod + Post = ... # type: QOAuth1Signature.HttpRequestMethod + Delete = ... # type: QOAuth1Signature.HttpRequestMethod + Custom = ... # type: QOAuth1Signature.HttpRequestMethod + Unknown = ... # type: QOAuth1Signature.HttpRequestMethod @typing.overload def __init__(self, url: QtCore.QUrl = ..., method: 'QOAuth1Signature.HttpRequestMethod' = ..., parameters: typing.Dict[str, typing.Any] = ...) -> None: ... From 05142de51683966e02691fcb60830b7cc9b15034 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 29 Nov 2021 11:20:45 -0500 Subject: [PATCH 377/421] remove unused ignore --- PyQt5-stubs/QtGui.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 03416d44..c2acfc7e 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -7360,7 +7360,7 @@ class QPdfWriter(QtCore.QObject, QPagedPaintDevice): def setMargins(self, m: QPagedPaintDevice.Margins) -> None: ... def setPageSizeMM(self, size: QtCore.QSizeF) -> None: ... @typing.overload - def setPageSize(self, size: QPagedPaintDevice.PageSize) -> None: ... # type: ignore[override] + def setPageSize(self, size: QPagedPaintDevice.PageSize) -> None: ... @typing.overload def setPageSize(self, pageSize: QPageSize) -> bool: ... def newPage(self) -> bool: ... From ba1a6282f93c378aa6b3df041e0198f903e80c9b Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 29 Nov 2021 11:27:24 -0500 Subject: [PATCH 378/421] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a586c39a..7e015483 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [unreleased] ### Added +* [#176](https://github.com/python-qt-tools/PyQt5-stubs/pull/176) update to PyQt5 5.15.5 +* [#175](https://github.com/python-qt-tools/PyQt5-stubs/pull/175) catch up PyQtNetworkAuth with the 5.15.4 release +* [#149](https://github.com/python-qt-tools/PyQt5-stubs/pull/149) update to PyQt5 5.15.4 * [#138](https://github.com/python-qt-tools/PyQt5-stubs/pull/138) update to PyQt5 5.15.3 * [#144](https://github.com/python-qt-tools/PyQt5-stubs/pull/144) add `QTreeWidgetItem.__lt__()` to allow sorting of items in a QTreeWidget * [#143](https://github.com/python-qt-tools/PyQt5-stubs/pull/143) make `bytes(QByteArray())` valid by incorrectly adding `.__bytes__()` until a proper solution is developed upstream From 0d6eebe38439a31985cf7bacdbd94df1466ec062 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 29 Nov 2021 12:50:42 -0500 Subject: [PATCH 379/421] 5.15.6 --- Dockerfile | 8 ++++---- PyQt5-stubs/Qt3DAnimation.pyi | 2 +- PyQt5-stubs/Qt3DCore.pyi | 2 +- PyQt5-stubs/Qt3DExtras.pyi | 2 +- PyQt5-stubs/Qt3DInput.pyi | 2 +- PyQt5-stubs/Qt3DLogic.pyi | 2 +- PyQt5-stubs/Qt3DRender.pyi | 2 +- PyQt5-stubs/QtBluetooth.pyi | 2 +- PyQt5-stubs/QtChart.pyi | 2 +- PyQt5-stubs/QtCore.pyi | 3 +-- PyQt5-stubs/QtDBus.pyi | 2 +- PyQt5-stubs/QtDataVisualization.pyi | 2 +- PyQt5-stubs/QtDesigner.pyi | 2 +- PyQt5-stubs/QtGui.pyi | 2 +- PyQt5-stubs/QtHelp.pyi | 2 +- PyQt5-stubs/QtLocation.pyi | 2 +- PyQt5-stubs/QtMultimedia.pyi | 2 +- PyQt5-stubs/QtMultimediaWidgets.pyi | 2 +- PyQt5-stubs/QtNetwork.pyi | 2 +- PyQt5-stubs/QtNetworkAuth.pyi | 2 +- PyQt5-stubs/QtNfc.pyi | 2 +- PyQt5-stubs/QtOpenGL.pyi | 2 +- PyQt5-stubs/QtPositioning.pyi | 2 +- PyQt5-stubs/QtPrintSupport.pyi | 2 +- PyQt5-stubs/QtPurchasing.pyi | 2 +- PyQt5-stubs/QtQml.pyi | 2 +- PyQt5-stubs/QtQuick.pyi | 2 +- PyQt5-stubs/QtQuickWidgets.pyi | 2 +- PyQt5-stubs/QtRemoteObjects.pyi | 2 +- PyQt5-stubs/QtSensors.pyi | 2 +- PyQt5-stubs/QtSerialPort.pyi | 2 +- PyQt5-stubs/QtSql.pyi | 2 +- PyQt5-stubs/QtSvg.pyi | 2 +- PyQt5-stubs/QtTest.pyi | 2 +- PyQt5-stubs/QtWebChannel.pyi | 2 +- PyQt5-stubs/QtWebEngine.pyi | 2 +- PyQt5-stubs/QtWebEngineCore.pyi | 2 +- PyQt5-stubs/QtWebEngineWidgets.pyi | 2 +- PyQt5-stubs/QtWebKit.pyi | 2 +- PyQt5-stubs/QtWebKitWidgets.pyi | 2 +- PyQt5-stubs/QtWebSockets.pyi | 2 +- PyQt5-stubs/QtWidgets.pyi | 2 +- PyQt5-stubs/QtX11Extras.pyi | 2 +- PyQt5-stubs/QtXml.pyi | 2 +- PyQt5-stubs/QtXmlPatterns.pyi | 2 +- PyQt5-stubs/__init__.pyi | 2 +- 46 files changed, 49 insertions(+), 50 deletions(-) diff --git a/Dockerfile b/Dockerfile index 72d80203..347da1ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,13 +2,13 @@ # https://hub.docker.com/_/archlinux?tab=tags&page=1&ordering=last_updated # BUILD_DATE is a path from: # https://archive.archlinux.org/repos/ -ARG ARCH_VERSION="base-20211017.0.36769" -ARG BUILD_DATE="2021/10/28" +ARG ARCH_VERSION="base-20211121.0.39613" +ARG BUILD_DATE="2021/11/29" -ARG SIP_VERSION="6.3.1" +ARG SIP_VERSION="6.4.0" # Also the major of PyQt5-sip ARG SIP_ABI_VERSION="12" -ARG PYQT_VERSION="5.15.5" +ARG PYQT_VERSION="5.15.6" ARG PYQT_3D_VERSION="5.15.5" ARG PYQT_CHART_VERSION="5.15.5" ARG PYQT_DATA_VISUALIZATION_VERSION="5.15.5" diff --git a/PyQt5-stubs/Qt3DAnimation.pyi b/PyQt5-stubs/Qt3DAnimation.pyi index 44c209f7..a9eb8250 100644 --- a/PyQt5-stubs/Qt3DAnimation.pyi +++ b/PyQt5-stubs/Qt3DAnimation.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DAnimation module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/Qt3DCore.pyi b/PyQt5-stubs/Qt3DCore.pyi index d4cc77d6..3b9718ee 100644 --- a/PyQt5-stubs/Qt3DCore.pyi +++ b/PyQt5-stubs/Qt3DCore.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DCore module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/Qt3DExtras.pyi b/PyQt5-stubs/Qt3DExtras.pyi index 485367ea..a2fea0ba 100644 --- a/PyQt5-stubs/Qt3DExtras.pyi +++ b/PyQt5-stubs/Qt3DExtras.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DExtras module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/Qt3DInput.pyi b/PyQt5-stubs/Qt3DInput.pyi index 153c70db..de5b99d8 100644 --- a/PyQt5-stubs/Qt3DInput.pyi +++ b/PyQt5-stubs/Qt3DInput.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DInput module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/Qt3DLogic.pyi b/PyQt5-stubs/Qt3DLogic.pyi index 1b712824..48b0c5f5 100644 --- a/PyQt5-stubs/Qt3DLogic.pyi +++ b/PyQt5-stubs/Qt3DLogic.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DLogic module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/Qt3DRender.pyi b/PyQt5-stubs/Qt3DRender.pyi index 93382b93..1a98616d 100644 --- a/PyQt5-stubs/Qt3DRender.pyi +++ b/PyQt5-stubs/Qt3DRender.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the Qt3DRender module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtBluetooth.pyi b/PyQt5-stubs/QtBluetooth.pyi index e9e00ba1..035d7f8c 100644 --- a/PyQt5-stubs/QtBluetooth.pyi +++ b/PyQt5-stubs/QtBluetooth.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtBluetooth module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtChart.pyi b/PyQt5-stubs/QtChart.pyi index 6a3985cb..17b55ef5 100644 --- a/PyQt5-stubs/QtChart.pyi +++ b/PyQt5-stubs/QtChart.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtChart module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 6ad49a1e..b9de1d78 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtCore module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # @@ -1833,7 +1833,6 @@ class QObject(PyQt5.sip.wrapper): def tr(self, sourceText: str, disambiguation: typing.Optional[str] = ..., n: int = ...) -> str: ... def eventFilter(self, a0: 'QObject', a1: 'QEvent') -> bool: ... def event(self, a0: 'QEvent') -> bool: ... - def __getattr__(self, name: str) -> typing.Any: ... def pyqtConfigure(self, a0: typing.Any) -> None: ... def metaObject(self) -> 'QMetaObject': ... diff --git a/PyQt5-stubs/QtDBus.pyi b/PyQt5-stubs/QtDBus.pyi index dbed5cbe..a154aab7 100644 --- a/PyQt5-stubs/QtDBus.pyi +++ b/PyQt5-stubs/QtDBus.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtDBus module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtDataVisualization.pyi b/PyQt5-stubs/QtDataVisualization.pyi index 860acca4..cd1346ea 100644 --- a/PyQt5-stubs/QtDataVisualization.pyi +++ b/PyQt5-stubs/QtDataVisualization.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtDataVisualization module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtDesigner.pyi b/PyQt5-stubs/QtDesigner.pyi index 8ff86ca0..b7183403 100644 --- a/PyQt5-stubs/QtDesigner.pyi +++ b/PyQt5-stubs/QtDesigner.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtDesigner module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtGui.pyi b/PyQt5-stubs/QtGui.pyi index 7bb5df17..bfd5cb11 100644 --- a/PyQt5-stubs/QtGui.pyi +++ b/PyQt5-stubs/QtGui.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtGui module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtHelp.pyi b/PyQt5-stubs/QtHelp.pyi index 57a7a1dc..fea1f383 100644 --- a/PyQt5-stubs/QtHelp.pyi +++ b/PyQt5-stubs/QtHelp.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtHelp module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtLocation.pyi b/PyQt5-stubs/QtLocation.pyi index a35e57b0..a27f6297 100644 --- a/PyQt5-stubs/QtLocation.pyi +++ b/PyQt5-stubs/QtLocation.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtLocation module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtMultimedia.pyi b/PyQt5-stubs/QtMultimedia.pyi index a9b99520..17e0cc6b 100644 --- a/PyQt5-stubs/QtMultimedia.pyi +++ b/PyQt5-stubs/QtMultimedia.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtMultimedia module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtMultimediaWidgets.pyi b/PyQt5-stubs/QtMultimediaWidgets.pyi index 7c2fce32..7f9fe266 100644 --- a/PyQt5-stubs/QtMultimediaWidgets.pyi +++ b/PyQt5-stubs/QtMultimediaWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtMultimediaWidgets module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtNetwork.pyi b/PyQt5-stubs/QtNetwork.pyi index aa92cb46..b5e42efc 100644 --- a/PyQt5-stubs/QtNetwork.pyi +++ b/PyQt5-stubs/QtNetwork.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtNetwork module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtNetworkAuth.pyi b/PyQt5-stubs/QtNetworkAuth.pyi index fddb0f03..5ab8589e 100644 --- a/PyQt5-stubs/QtNetworkAuth.pyi +++ b/PyQt5-stubs/QtNetworkAuth.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtNetworkAuth module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtNfc.pyi b/PyQt5-stubs/QtNfc.pyi index e26efeaf..8fdb2b22 100644 --- a/PyQt5-stubs/QtNfc.pyi +++ b/PyQt5-stubs/QtNfc.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtNfc module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtOpenGL.pyi b/PyQt5-stubs/QtOpenGL.pyi index c0535822..1ad48724 100644 --- a/PyQt5-stubs/QtOpenGL.pyi +++ b/PyQt5-stubs/QtOpenGL.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtOpenGL module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtPositioning.pyi b/PyQt5-stubs/QtPositioning.pyi index a0116fa6..291415a3 100644 --- a/PyQt5-stubs/QtPositioning.pyi +++ b/PyQt5-stubs/QtPositioning.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtPositioning module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtPrintSupport.pyi b/PyQt5-stubs/QtPrintSupport.pyi index 748a473b..b2815c38 100644 --- a/PyQt5-stubs/QtPrintSupport.pyi +++ b/PyQt5-stubs/QtPrintSupport.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtPrintSupport module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtPurchasing.pyi b/PyQt5-stubs/QtPurchasing.pyi index e7d063d3..20cb94dc 100644 --- a/PyQt5-stubs/QtPurchasing.pyi +++ b/PyQt5-stubs/QtPurchasing.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtPurchasing module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtQml.pyi b/PyQt5-stubs/QtQml.pyi index e82b1c80..cfa7a2cc 100644 --- a/PyQt5-stubs/QtQml.pyi +++ b/PyQt5-stubs/QtQml.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtQml module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index d59360b1..16d5a67f 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtQuick module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtQuickWidgets.pyi b/PyQt5-stubs/QtQuickWidgets.pyi index ecbb55e6..8ee15f95 100644 --- a/PyQt5-stubs/QtQuickWidgets.pyi +++ b/PyQt5-stubs/QtQuickWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtQuickWidgets module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtRemoteObjects.pyi b/PyQt5-stubs/QtRemoteObjects.pyi index c1af53c4..1ef7e48d 100644 --- a/PyQt5-stubs/QtRemoteObjects.pyi +++ b/PyQt5-stubs/QtRemoteObjects.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtRemoteObjects module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSensors.pyi b/PyQt5-stubs/QtSensors.pyi index b6d9a68e..281246a3 100644 --- a/PyQt5-stubs/QtSensors.pyi +++ b/PyQt5-stubs/QtSensors.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSensors module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSerialPort.pyi b/PyQt5-stubs/QtSerialPort.pyi index 4b430dc1..4819afd0 100644 --- a/PyQt5-stubs/QtSerialPort.pyi +++ b/PyQt5-stubs/QtSerialPort.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSerialPort module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSql.pyi b/PyQt5-stubs/QtSql.pyi index 1cabe1dd..2f0f2401 100644 --- a/PyQt5-stubs/QtSql.pyi +++ b/PyQt5-stubs/QtSql.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSql module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtSvg.pyi b/PyQt5-stubs/QtSvg.pyi index ed7cfcc0..06521856 100644 --- a/PyQt5-stubs/QtSvg.pyi +++ b/PyQt5-stubs/QtSvg.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtSvg module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtTest.pyi b/PyQt5-stubs/QtTest.pyi index 48a2c5f4..5512a874 100644 --- a/PyQt5-stubs/QtTest.pyi +++ b/PyQt5-stubs/QtTest.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtTest module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebChannel.pyi b/PyQt5-stubs/QtWebChannel.pyi index b6aaa569..885cca99 100644 --- a/PyQt5-stubs/QtWebChannel.pyi +++ b/PyQt5-stubs/QtWebChannel.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebChannel module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebEngine.pyi b/PyQt5-stubs/QtWebEngine.pyi index 98f81420..24b54747 100644 --- a/PyQt5-stubs/QtWebEngine.pyi +++ b/PyQt5-stubs/QtWebEngine.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebEngine module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebEngineCore.pyi b/PyQt5-stubs/QtWebEngineCore.pyi index e524d4c3..7efe555d 100644 --- a/PyQt5-stubs/QtWebEngineCore.pyi +++ b/PyQt5-stubs/QtWebEngineCore.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebEngineCore module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebEngineWidgets.pyi b/PyQt5-stubs/QtWebEngineWidgets.pyi index a0932dc4..24f45879 100644 --- a/PyQt5-stubs/QtWebEngineWidgets.pyi +++ b/PyQt5-stubs/QtWebEngineWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebEngineWidgets module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebKit.pyi b/PyQt5-stubs/QtWebKit.pyi index e5d6f4fe..39b74d10 100644 --- a/PyQt5-stubs/QtWebKit.pyi +++ b/PyQt5-stubs/QtWebKit.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebKit module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebKitWidgets.pyi b/PyQt5-stubs/QtWebKitWidgets.pyi index b787ec05..986b2ff0 100644 --- a/PyQt5-stubs/QtWebKitWidgets.pyi +++ b/PyQt5-stubs/QtWebKitWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebKitWidgets module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWebSockets.pyi b/PyQt5-stubs/QtWebSockets.pyi index cc21f242..86c2ed06 100644 --- a/PyQt5-stubs/QtWebSockets.pyi +++ b/PyQt5-stubs/QtWebSockets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWebSockets module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 0bd113e5..14bd9c29 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtWidgets module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtX11Extras.pyi b/PyQt5-stubs/QtX11Extras.pyi index 8c71a9fa..5c462a5d 100644 --- a/PyQt5-stubs/QtX11Extras.pyi +++ b/PyQt5-stubs/QtX11Extras.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtX11Extras module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtXml.pyi b/PyQt5-stubs/QtXml.pyi index ac47a4fe..08581099 100644 --- a/PyQt5-stubs/QtXml.pyi +++ b/PyQt5-stubs/QtXml.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtXml module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/QtXmlPatterns.pyi b/PyQt5-stubs/QtXmlPatterns.pyi index 3b499501..d24215af 100644 --- a/PyQt5-stubs/QtXmlPatterns.pyi +++ b/PyQt5-stubs/QtXmlPatterns.pyi @@ -1,6 +1,6 @@ # The PEP 484 type hints stub file for the QtXmlPatterns module. # -# Generated by SIP 6.3.1 +# Generated by SIP 6.4.0 # # Copyright (c) 2021 Riverbank Computing Limited # diff --git a/PyQt5-stubs/__init__.pyi b/PyQt5-stubs/__init__.pyi index 087b1cec..968f13c7 100644 --- a/PyQt5-stubs/__init__.pyi +++ b/PyQt5-stubs/__init__.pyi @@ -1 +1 @@ -__version__ = "5.15.5.0" +__version__ = "5.15.6.0" From 7b39ec336bffeebd861e6aedbfd2042c74b8ee62 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 29 Nov 2021 14:25:30 -0500 Subject: [PATCH 380/421] 5.15.6 --- CHANGELOG.md | 1 + tox.ini | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e015483..873bf6d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [unreleased] ### Added +* [#179](https://github.com/python-qt-tools/PyQt5-stubs/pull/179) update to PyQt5 5.15.6 * [#176](https://github.com/python-qt-tools/PyQt5-stubs/pull/176) update to PyQt5 5.15.5 * [#175](https://github.com/python-qt-tools/PyQt5-stubs/pull/175) catch up PyQtNetworkAuth with the 5.15.4 release * [#149](https://github.com/python-qt-tools/PyQt5-stubs/pull/149) update to PyQt5 5.15.4 diff --git a/tox.ini b/tox.ini index 047a2ac4..6ef4764f 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ deps = extras = dev commands = - pip install PyQt5==5.15.5 PyQt3D==5.15.5 PyQtChart==5.15.5 PyQtDataVisualization==5.15.5 PyQtNetworkAuth==5.15.5 PyQtPurchasing==5.15.5 PyQtWebEngine==5.15.5 + pip install PyQt5==5.15.6 PyQt3D==5.15.5 PyQtChart==5.15.5 PyQtDataVisualization==5.15.5 PyQtNetworkAuth==5.15.5 PyQtPurchasing==5.15.5 PyQtWebEngine==5.15.5 pip freeze --all mypy --show-error-codes -p PyQt5-stubs stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review PyQt5 From 9e6572cb493b8dbb639e27521ffb61121e5bfe69 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Tue, 30 Nov 2021 21:40:55 +0100 Subject: [PATCH 381/421] apply comments from the review --- .github/workflows/ci.yml | 43 +++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34177b50..e1a0cca1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,20 +1,23 @@ name: CI on: - workflow_dispatch: push: branches: - master - - run-ci-on-windows tags: - v* pull_request: branches: - "*" + schedule: + # Daily at 06:14. This is just an arbitrary time to stagger + # relative to other daily builds in any given organization. + - cron: '14 6 * * *' + jobs: test: name: ${{ matrix.os.name }} ${{ matrix.python.name }} - runs-on: ${{ matrix.os.runs-on }} + runs-on: ${{ matrix.os.runs-on }} strategy: fail-fast: false matrix: @@ -46,12 +49,34 @@ jobs: tox: py36 action: 3.6 - os: - name: Windows - runs-on: windows-latest + name: Windows + runs-on: windows-latest + python: + name: CPython 3.7 + tox: py37 + action: 3.7 + - os: + name: Windows + runs-on: windows-latest + python: + name: CPytron 3.8 + tox: py38 + action: 3.8 + - os: + name: Windows + runs-on: windows-latest python: - name: CPython 3.9 - tox: py39 - action: '3.9' + name: CPython 3.9 + tox: py39 + action: 3.9 +# Windows 10 not working yet, because there are no wheels yet for it. +# - os: +# name: Windows +# runs-on: windows-latest +# python: +# name: CPython 3.10 +# tox: py310 +# action: '3.10' steps: - uses: actions/checkout@v2 - name: Set up ${{ matrix.python.name }} @@ -61,7 +86,7 @@ jobs: architecture: x64 - uses: twisted/python-info-action@v1.0.1 - name: Install Linux Qt5 dependencies - if: matrix.os.name == 'Linux' + if: matrix.os.matrix == 'linux' run: | sudo apt-get update --yes sudo apt-get install --yes libgl1 From bccbf3f83f9201b001862b21df7610bfecea008b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 2 Dec 2021 20:45:00 +0100 Subject: [PATCH 382/421] Use matrix to run windows, and exclude windows 10 --- .github/workflows/ci.yml | 43 +++++++--------------------------------- 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1a0cca1..425e0726 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,8 @@ jobs: os: - name: Linux runs-on: ubuntu-latest + - name: Windows + runs-on: windows-latest python: - name: CPython 3.6 tox: py36 @@ -40,43 +42,12 @@ jobs: - name: CPython 3.10 tox: py310 action: '3.10' - include: - - os: - name: Windows - runs-on: windows-latest - python: - name: CPython 3.6 - tox: py36 - action: 3.6 - - os: - name: Windows - runs-on: windows-latest - python: - name: CPython 3.7 - tox: py37 - action: 3.7 - - os: - name: Windows - runs-on: windows-latest - python: - name: CPytron 3.8 - tox: py38 - action: 3.8 - - os: - name: Windows - runs-on: windows-latest - python: - name: CPython 3.9 - tox: py39 - action: 3.9 + exclude: # Windows 10 not working yet, because there are no wheels yet for it. -# - os: -# name: Windows -# runs-on: windows-latest -# python: -# name: CPython 3.10 -# tox: py310 -# action: '3.10' + - os: + name: Windows + python: + name: CPython 3.10 steps: - uses: actions/checkout@v2 - name: Set up ${{ matrix.python.name }} From 2c3268061c525230e5e6d4d100bdf6cd33f2935b Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 2 Dec 2021 20:56:06 +0100 Subject: [PATCH 383/421] Oops, trigger installation of dependent linux package --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 425e0726..d5cde168 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: architecture: x64 - uses: twisted/python-info-action@v1.0.1 - name: Install Linux Qt5 dependencies - if: matrix.os.matrix == 'linux' + if: matrix.os.name == 'Linux' run: | sudo apt-get update --yes sudo apt-get install --yes libgl1 From 0f98aad26c23ac82d716d8eca74eb30140a1e590 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 2 Dec 2021 21:01:45 +0100 Subject: [PATCH 384/421] Define OS for tox into environement list --- .github/workflows/ci.yml | 4 +++- tox.ini | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5cde168..7e329d9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,8 +24,10 @@ jobs: os: - name: Linux runs-on: ubuntu-latest + tox: linux - name: Windows runs-on: windows-latest + tox: windows python: - name: CPython 3.6 tox: py36 @@ -69,7 +71,7 @@ jobs: pip install tox - name: Test run: | - tox -v -e ${{ matrix.python.tox }} + tox -v -e ${{ matrix.python.tox }}-${{ matrix.os.tox }} all: name: All diff --git a/tox.ini b/tox.ini index 19d77e41..1e11e711 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,19 @@ [tox] -envlist = py3{6,7,8,9,10} +envlist = py3{6,7,8,9,10}-{windows,linux} [testenv] deps = pip>=20.0 -passenv = RUNNER_OS +setenv: + windows: OS_MARKER = windows + linux: OS_MARKER = linux extras = dev commands = pip install PyQt5==5.15.6 PyQt3D==5.15.5 PyQtChart==5.15.5 PyQtDataVisualization==5.15.5 PyQtNetworkAuth==5.15.5 PyQtPurchasing==5.15.5 PyQtWebEngine==5.15.5 pip freeze --all mypy --show-error-codes -p PyQt5-stubs - stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review --allowlist {toxinidir}/stubtest.allowlist.{env:RUNNER_OS:} PyQt5 + stubtest --allowlist {toxinidir}/stubtest.allowlist --allowlist {toxinidir}/stubtest.allowlist.to_review --allowlist {toxinidir}/stubtest.allowlist.{env:OS_MARKER} PyQt5 pytest --capture=no --verbose {posargs} [pytest] From 93878c3c6b26298b6b0cb654f32f37b54be1bd66 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Thu, 2 Dec 2021 21:04:16 +0100 Subject: [PATCH 385/421] rename for new tox names --- stubtest.allowlist.Linux => stubtest.allowlist.linux | 0 stubtest.allowlist.Windows => stubtest.allowlist.windows | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename stubtest.allowlist.Linux => stubtest.allowlist.linux (100%) rename stubtest.allowlist.Windows => stubtest.allowlist.windows (100%) diff --git a/stubtest.allowlist.Linux b/stubtest.allowlist.linux similarity index 100% rename from stubtest.allowlist.Linux rename to stubtest.allowlist.linux diff --git a/stubtest.allowlist.Windows b/stubtest.allowlist.windows similarity index 100% rename from stubtest.allowlist.Windows rename to stubtest.allowlist.windows From 1a25b0659d3c5ce20740066776b2027ded2809df Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sat, 4 Dec 2021 14:34:46 +0100 Subject: [PATCH 386/421] Update .github/workflows/ci.yml Co-authored-by: Kyle Altendorf --- .github/workflows/ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e329d9c..333361ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,12 +44,6 @@ jobs: - name: CPython 3.10 tox: py310 action: '3.10' - exclude: -# Windows 10 not working yet, because there are no wheels yet for it. - - os: - name: Windows - python: - name: CPython 3.10 steps: - uses: actions/checkout@v2 - name: Set up ${{ matrix.python.name }} From 4385b054768df6d5f910fe6b8b6a571fddd2c9e1 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 5 Dec 2021 09:28:18 -0500 Subject: [PATCH 387/421] update --- stubtest.allowlist.macos | 0 tox.ini | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 stubtest.allowlist.macos diff --git a/stubtest.allowlist.macos b/stubtest.allowlist.macos new file mode 100644 index 00000000..e69de29b diff --git a/tox.ini b/tox.ini index 1e11e711..726866b3 100644 --- a/tox.ini +++ b/tox.ini @@ -5,8 +5,9 @@ envlist = py3{6,7,8,9,10}-{windows,linux} deps = pip>=20.0 setenv: - windows: OS_MARKER = windows linux: OS_MARKER = linux + macos: OS_MARKER = macos + windows: OS_MARKER = windows extras = dev commands = From fed63af936bb1e4b356fdddf217226cde0ef52d4 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 5 Dec 2021 09:44:10 -0500 Subject: [PATCH 388/421] Make some Windows specific hints platform sensitive --- PyQt5-stubs/QtCore.pyi | 71 +++++++++++++++++++++------------------- stubtest.allowlist.linux | 3 -- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 4d1f4948..14367632 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -20,6 +20,7 @@ # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +import sys import typing from PyQt5 import sip @@ -12296,7 +12297,41 @@ class QSysInfo(sip.simplewrapper): WordSize = ... # type: QSysInfo.Sizes - class WinVersion(int): + if sys.platform == "win32": + class WinVersion(int): + WV_10_0 = ... # type: int + WV_2000 = ... # type: int + WV_2003 = ... # type: int + WV_32s = ... # type: int + WV_4_0 = ... # type: int + WV_5_0 = ... # type: int + WV_5_1 = ... # type: int + WV_5_2 = ... # type: int + WV_6_0 = ... # type: int + WV_6_1 = ... # type: int + WV_6_2 = ... # type: int + WV_6_3 = ... # type: int + WV_95 = ... # type: int + WV_98 = ... # type: int + WV_CE = ... # type: int + WV_CENET = ... # type: int + WV_CE_5 = ... # type: int + WV_CE_6 = ... # type: int + WV_CE_based = ... # type: int + WV_DOS_based = ... # type: int + WV_Me = ... # type: int + WV_NT = ... # type: int + WV_NT_based = ... # type: int + WV_VISTA = ... # type: int + WV_WINDOWS10 = ... # type: int + WV_WINDOWS7 = ... # type: int + WV_WINDOWS8 = ... # type: int + WV_WINDOWS8_1 = ... # type: int + WV_XP = ... # type: int + + @staticmethod + def windowsVersion() -> 'QSysInfo.WinVersion': ... + WV_10_0 = ... # type: int WV_2000 = ... # type: int WV_2003 = ... # type: int @@ -12327,35 +12362,7 @@ class QSysInfo(sip.simplewrapper): WV_WINDOWS8_1 = ... # type: int WV_XP = ... # type: int - WV_10_0 = ... # type: int - WV_2000 = ... # type: int - WV_2003 = ... # type: int - WV_32s = ... # type: int - WV_4_0 = ... # type: int - WV_5_0 = ... # type: int - WV_5_1 = ... # type: int - WV_5_2 = ... # type: int - WV_6_0 = ... # type: int - WV_6_1 = ... # type: int - WV_6_2 = ... # type: int - WV_6_3 = ... # type: int - WV_95 = ... # type: int - WV_98 = ... # type: int - WV_CE = ... # type: int - WV_CENET = ... # type: int - WV_CE_5 = ... # type: int - WV_CE_6 = ... # type: int - WV_CE_based = ... # type: int - WV_DOS_based = ... # type: int - WV_Me = ... # type: int - WV_NT = ... # type: int - WV_NT_based = ... # type: int - WV_VISTA = ... # type: int - WV_WINDOWS10 = ... # type: int - WV_WINDOWS7 = ... # type: int - WV_WINDOWS8 = ... # type: int - WV_WINDOWS8_1 = ... # type: int - WV_XP = ... # type: int + WindowsVersion = ... # type: QSysInfo.WinVersion @typing.overload def __init__(self) -> None: ... @@ -12380,10 +12387,6 @@ class QSysInfo(sip.simplewrapper): def buildCpuArchitecture() -> str: ... @staticmethod def buildAbi() -> str: ... - @staticmethod - def windowsVersion() -> 'QSysInfo.WinVersion': ... - - WindowsVersion = ... # type: QSysInfo.WinVersion PYQT_VERSION = ... # type: int diff --git a/stubtest.allowlist.linux b/stubtest.allowlist.linux index 1eadaceb..e69de29b 100644 --- a/stubtest.allowlist.linux +++ b/stubtest.allowlist.linux @@ -1,3 +0,0 @@ -# implementation present only on Windows -PyQt5.QtCore.QSysInfo.WinVersion -PyQt5.QtCore.QSysInfo.windowsVersion From a81290fb374777bb35e4ec1916b341df20b6a03d Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 5 Dec 2021 09:56:26 -0500 Subject: [PATCH 389/421] slight reorder for consistency --- PyQt5-stubs/QtCore.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 14367632..432e6dd6 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -12329,8 +12329,7 @@ class QSysInfo(sip.simplewrapper): WV_WINDOWS8_1 = ... # type: int WV_XP = ... # type: int - @staticmethod - def windowsVersion() -> 'QSysInfo.WinVersion': ... + WindowsVersion = ... # type: QSysInfo.WinVersion WV_10_0 = ... # type: int WV_2000 = ... # type: int @@ -12362,7 +12361,8 @@ class QSysInfo(sip.simplewrapper): WV_WINDOWS8_1 = ... # type: int WV_XP = ... # type: int - WindowsVersion = ... # type: QSysInfo.WinVersion + @staticmethod + def windowsVersion() -> 'QSysInfo.WinVersion': ... @typing.overload def __init__(self) -> None: ... From 5f2b179996a7c5d4ffb4e1a39c5612d2abeb09f4 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 5 Dec 2021 10:02:31 -0500 Subject: [PATCH 390/421] add mac version bits --- PyQt5-stubs/QtCore.pyi | 62 ++++++++++++++++++++++++++++++++++++++++ stubtest.allowlist.macos | 2 ++ 2 files changed, 64 insertions(+) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 4d1f4948..6566c00f 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -20,6 +20,7 @@ # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +import sys import typing from PyQt5 import sip @@ -12357,6 +12358,67 @@ class QSysInfo(sip.simplewrapper): WV_WINDOWS8_1 = ... # type: int WV_XP = ... # type: int + if sys.platform == "darwin": + class MacintoshVersion(int): + MV_10_0 = ... # type: int + MV_10_1 = ... # type: int + MV_10_10 = ... # type: int + MV_10_11 = ... # type: int + MV_10_12 = ... # type: int + MV_10_2 = ... # type: int + MV_10_3 = ... # type: int + MV_10_4 = ... # type: int + MV_10_5 = ... # type: int + MV_10_6 = ... # type: int + MV_10_7 = ... # type: int + MV_10_8 = ... # type: int + MV_10_9 = ... # type: int + MV_9 = ... # type: int + MV_CHEETAH = ... # type: int + MV_ELCAPITAN = ... # type: int + MV_IOS = ... # type: int + MV_IOS_10_0 = ... # type: int + MV_IOS_4_3 = ... # type: int + MV_IOS_5_0 = ... # type: int + MV_IOS_5_1 = ... # type: int + MV_IOS_6_0 = ... # type: int + MV_IOS_6_1 = ... # type: int + MV_IOS_7_0 = ... # type: int + MV_IOS_7_1 = ... # type: int + MV_IOS_8_0 = ... # type: int + MV_IOS_8_1 = ... # type: int + MV_IOS_8_2 = ... # type: int + MV_IOS_8_3 = ... # type: int + MV_IOS_8_4 = ... # type: int + MV_IOS_9_0 = ... # type: int + MV_IOS_9_1 = ... # type: int + MV_IOS_9_2 = ... # type: int + MV_IOS_9_3 = ... # type: int + MV_JAGUAR = ... # type: int + MV_LEOPARD = ... # type: int + MV_LION = ... # type: int + MV_MAVERICKS = ... # type: int + MV_MOUNTAINLION = ... # type: int + MV_PANTHER = ... # type: int + MV_PUMA = ... # type: int + MV_SIERRA = ... # type: int + MV_SNOWLEOPARD = ... # type: int + MV_TIGER = ... # type: int + MV_TVOS = ... # type: int + MV_TVOS_10_0 = ... # type: int + MV_TVOS_9_0 = ... # type: int + MV_TVOS_9_1 = ... # type: int + MV_TVOS_9_2 = ... # type: int + MV_Unknown = ... # type: int + MV_WATCHOS = ... # type: int + MV_WATCHOS_2_0 = ... # type: int + MV_WATCHOS_2_1 = ... # type: int + MV_WATCHOS_2_2 = ... # type: int + MV_WATCHOS_3_0 = ... # type: int + MV_YOSEMITE = ... # type: int + + MacintoshVersion = ... # type: QSysInfo.MacintoshVersion + @typing.overload def __init__(self) -> None: ... @typing.overload diff --git a/stubtest.allowlist.macos b/stubtest.allowlist.macos index e69de29b..f4d00efa 100644 --- a/stubtest.allowlist.macos +++ b/stubtest.allowlist.macos @@ -0,0 +1,2 @@ +# Linux only +PyQt5.QtX11Extras From aeee34e3704fb5ee5a9c3930b9bbc87c466c4bb1 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 5 Dec 2021 10:06:40 -0500 Subject: [PATCH 391/421] oops --- PyQt5-stubs/QtCore.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 6566c00f..d3f664b4 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -12417,7 +12417,7 @@ class QSysInfo(sip.simplewrapper): MV_WATCHOS_3_0 = ... # type: int MV_YOSEMITE = ... # type: int - MacintoshVersion = ... # type: QSysInfo.MacintoshVersion + macVersion = ... # type: QSysInfo.MacintoshVersion @typing.overload def __init__(self) -> None: ... From 30c9ddd0e7dc9881eccee7996930521dee994ac9 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 5 Dec 2021 10:12:04 -0500 Subject: [PATCH 392/421] some ignores for macos --- stubtest.allowlist.macos | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stubtest.allowlist.macos b/stubtest.allowlist.macos index f4d00efa..40df1961 100644 --- a/stubtest.allowlist.macos +++ b/stubtest.allowlist.macos @@ -1,2 +1,7 @@ # Linux only PyQt5.QtX11Extras + +# To review +PyQt5.QtGui.QDrag.cancel +PyQt5.QtWidgets.QMacCocoaViewContainer +PyQt5.QtWidgets.QMenu.setAsDockMenu From 9b47c5653f11736e3b9bba12d4c0e8848ddc511f Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 5 Dec 2021 10:23:22 -0500 Subject: [PATCH 393/421] macVersion is a function --- PyQt5-stubs/QtCore.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index d3f664b4..a0aa81f9 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -12417,7 +12417,8 @@ class QSysInfo(sip.simplewrapper): MV_WATCHOS_3_0 = ... # type: int MV_YOSEMITE = ... # type: int - macVersion = ... # type: QSysInfo.MacintoshVersion + @staticmethod + def macVersion() -> 'QSysInfo.MacintoshVersion': ... @typing.overload def __init__(self) -> None: ... From 352369f1a66b27ca7a415251678656b39640d71a Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Sun, 5 Dec 2021 10:24:28 -0500 Subject: [PATCH 394/421] and MacVersion --- PyQt5-stubs/QtCore.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index a0aa81f9..32db1fd4 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -12417,6 +12417,8 @@ class QSysInfo(sip.simplewrapper): MV_WATCHOS_3_0 = ... # type: int MV_YOSEMITE = ... # type: int + MacVersion = ... # type: QSysInfo.MacintoshVersion + @staticmethod def macVersion() -> 'QSysInfo.MacintoshVersion': ... From 5146d6880c9831b8f57a3573e78e18cf7c0f576d Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Dec 2021 21:49:23 +0100 Subject: [PATCH 395/421] Update tests/test_stubs.py Co-authored-by: Kyle Altendorf --- tests/test_stubs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index 84e033ac..eba4c108 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -7,7 +7,7 @@ def gen_tests(): - '''List of all tests files included in the directory tests''' + """List of all tests files included in the directory tests""" for filename in TESTS_DIR.glob('*.py'): if not str(filename.parts[-1]).startswith('test_'): yield filename From e048028427a1e0417e24d10773d344ec8e89e629 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Dec 2021 21:59:54 +0100 Subject: [PATCH 396/421] Use triple quotes for docstrings --- .../qflags/generate_qflags_stubs_and_tests.py | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/qflags/generate_qflags_stubs_and_tests.py b/tests/qflags/generate_qflags_stubs_and_tests.py index 8cea63d2..ff3a51e1 100644 --- a/tests/qflags/generate_qflags_stubs_and_tests.py +++ b/tests/qflags/generate_qflags_stubs_and_tests.py @@ -91,7 +91,7 @@ class QFlagLocationInfo: def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[str, Any]]: - '''Encode the QFlagClassLoationInfo into a format suitable for json export (a dict)''' + """Encode the QFlagClassLoationInfo into a format suitable for json export (a dict)""" if not isinstance(flag_loc_info, QFlagLocationInfo): # oups, we don't know how to encode that return flag_loc_info @@ -109,11 +109,11 @@ def json_encode_qflaglocationinfo(flag_loc_info: object) -> Union[object, Dict[s def identify_qflag_location(fname_grep_result: str, qt_modules: Dict[str, str], ) -> List[ QFlagLocationInfo ]: - '''Parses the grep results to extract each qflag, and then look into all Qt modules + """Parses the grep results to extract each qflag, and then look into all Qt modules to see where the flag is located. Return a list of QFlagLocationInfo indicating in which module the flag has been located. - ''' + """ # the file defining the qflag implementation, to be skipped when performing QDECLARE analysis QFLAG_SRC = 'src\\corelib\\global\\qflags.h' @@ -187,13 +187,13 @@ def identify_qflag_location(fname_grep_result: str, def group_qflags(qflag_location: List[QFlagLocationInfo] ) -> Dict[str, List[QFlagLocationInfo]]: - '''Group the QFlags into the following groups (inside a dictionnary): + """Group the QFlags into the following groups (inside a dictionnary): * flag_and_module_identified: this flag is present once in one module exactly. * flag_without_module: this flag is not present in any modules at all. The first group is suitable for automatic processing. The last group reflects the QFlags not exported to PyQt or coming from modules not present in PyQt - ''' + """ d = { 'flag_and_module_identified': [ flag_info for flag_info in qflag_location @@ -211,11 +211,11 @@ def group_qflags(qflag_location: List[QFlagLocationInfo] ) -> Dict[str, List[QFl def extract_qflags_to_process(qflags_modules_analysis_json: str, qflags_to_process_json: str, ) -> None: - '''Take the json file as input describing qflags and their modules and output a json file of qflags planned to be processed. + """Take the json file as input describing qflags and their modules and output a json file of qflags planned to be processed. The qflags which are located in a single module will be selected for further processing. The others are marked as skipped with a proper reason. - ''' + """ with open(qflags_modules_analysis_json) as f: d = json.load(f) @@ -242,7 +242,7 @@ def extract_qflags_to_process(qflags_modules_analysis_json: str, def process_qflag(qflag_to_process_json: str, qflag_result_json: str, auto_commit: bool) -> int: - '''Read the qflags to process from the json file + """Read the qflags to process from the json file Process one qflag, by either: * identifying that this flag is already processed and add the flag to qflags_alraedy_done @@ -258,7 +258,7 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str, auto_commi * auto_commit: if True, a git commit is performed after each successful QFlag validation Return number of remaining flags to process (0 when everything done) - ''' + """ with open(qflag_to_process_json) as f: d = json.load(f) @@ -276,8 +276,8 @@ def process_qflag(qflag_to_process_json: str, qflag_result_json: str, auto_commi result_json = json.loads(f.read()) def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: - '''Return True if the qflag is already included in one of the result lists - of result_json''' + """Return True if the qflag is already included in one of the result lists + of result_json""" flag_desc = (flag_info.module_name, flag_info.module_idx, flag_info.qflag_class, flag_info.enum_class) already_done_set = set( (flag_info_dict['module_name'], @@ -391,14 +391,14 @@ def qflag_already_processed(flag_info: QFlagLocationInfo) -> bool: class QFlagGenResult(Enum): - '''Enum indicating the result of generating the possibly missing stubs on the qflag classes''' + """Enum indicating the result of generating the possibly missing stubs on the qflag classes""" CodeModifiedSuccessfully = 0 CodeAlreadyModified = 1 ErrorDuringProcessing = 2 def generate_missing_stubs(flag_info: 'QFlagLocationInfo') -> Tuple[QFlagGenResult, str, str]: - ''' + """ Check that the QFlag enum+class are present in the module and check whether they support all the advanced QFlag operations. @@ -450,7 +450,7 @@ class not found, class found multiple times, ... The detail of the error is provided in the second argument of the return value. mod_content is empty (not useful) -''' +""" log_progress('Opening module %s' % flag_info.module_name) with open(flag_info.module_path) as f: mod_content = f.read() @@ -540,7 +540,7 @@ class not found, class found multiple times, ... class MethodPresent(Enum): - '''An enum to reflect if a method is already present or not''' + """An enum to reflect if a method is already present or not""" Unset = 0 All = 1 Not = 2 @@ -650,8 +650,8 @@ def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: def check_enum_method_present(self, enum_node: cst.ClassDef) -> bool: - '''Check if the class contains method __or__ and __ror__ with one argument and if class - inherit from int''' + """Check if the class contains method __or__ and __ror__ with one argument and if class + inherit from int""" if len(enum_node.bases) == 0 or enum_node.bases[0].value.value != 'int': # class does not inherit from int, not the one we are looking for return False @@ -675,8 +675,8 @@ def check_enum_method_present(self, enum_node: cst.ClassDef) -> bool: def collect_enum_values(self, enum_node: cst.ClassDef) -> None: - '''Collect two actual values for the enum and store them into self.enum_value1 and enum_value2 - ''' + """Collect two actual values for the enum and store them into self.enum_value1 and enum_value2 + """ # find all lines consisting of an assignment to an ellipsis, like "AlignLeft = ..." enum_values = matchers.findall(enum_node.body, matchers.SimpleStatementLine( body=[matchers.Assign(value=matchers.Ellipsis())])) @@ -693,7 +693,7 @@ def collect_enum_values(self, enum_node: cst.ClassDef) -> None: def check_qflag_method_present(self, qflag_node: cst.ClassDef) -> bool: - '''Check if the class contains method: + """Check if the class contains method: def __or__ def __and__ def __xor__ @@ -705,7 +705,7 @@ def __rxor__ def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier']) -> None: def __init__(self, f: typing.Union['Qt.KeyboardModifiers', 'Qt.KeyboardModifier', int]) -> None: - ''' + """ if (len(qflag_node.bases) == 0 or not matchers.matches(qflag_node.bases[0], matchers.Arg(value=matchers.Attribute(value=matchers.Name('sip'), @@ -845,7 +845,7 @@ def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: - '''Add the two methods __or__ and __ror__ to the class body''' + """Add the two methods __or__ and __ror__ to the class body""" # we keep comments separated to align them properly in the final file or_behavior = (self.or_converts_to_multi, self.or_int_converts_to_multi, self.int_or_converts_to_multi) @@ -888,11 +888,11 @@ def transform_enum_class(self, original_node: cst.ClassDef, updated_node: cst.Cl def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: - ''' + """ On the qflag class, add one more overload __init__() and add more methods + @typing.overload + def __init__(self, f: int) -> None: ... - ''' + """ init_methods = matchers.findall(updated_node.body, matchers.FunctionDef(name=matchers.Name('__init__'))) if len(init_methods) == 1: # we do not handle the case where there is only one init function @@ -946,13 +946,13 @@ def transform_qflag_class(self, original_node: cst.ClassDef, updated_node: cst.C @functools.lru_cache(maxsize=1) def read_qflag_test_template(template_fname: str) -> Tuple[List[str], List[str], List[str]]: - '''Return the source of the template for generating qflags test. + """Return the source of the template for generating qflags test. Return 3 parts as a list of strings: - the first part should be unmodified - the second part should be replaced for a specific QFlag class - the third part should be unmodified - ''' + """ # the markers inside the above template to identify the parts to replace MARKER_SPECIFIC_START = '### Specific part' @@ -985,15 +985,15 @@ def read_qflag_test_template(template_fname: str) -> Tuple[List[str], List[str], def gen_test_fname(fli: QFlagLocationInfo) -> str: - '''Generate the name of the test file which will verify this qflag''' + """Generate the name of the test file which will verify this qflag""" return 'test_{fli.module_name}_{fli.qflag_class}_{fli.enum_class}.py'.format(fli=fli) def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: - '''Generate a qflag test file. + """Generate a qflag test file. The filename is inferred from flag_info using gen_test_fname() - ''' + """ # the template after which we model all generated qflag tests TEMPLATE_QFLAGS_TESTS = 'qflags_test_template.py' @@ -1032,7 +1032,7 @@ def generate_qflag_test_file(flag_info: QFlagLocationInfo) -> None: def generate_qflags_to_process(qt_qflag_grep_result_fname): - '''Run the generation process from the grep output parsing to the generation of json file listing the flags to process''' + """Run the generation process from the grep output parsing to the generation of json file listing the flags to process""" location_qflags = identify_qflag_location(qt_qflag_grep_result_fname, QTBASE_MODULES) log_progress('%d qflags extracted from grep file' % len(location_qflags)) qflags_groups = group_qflags(location_qflags) From c086de2f474c1afacc1d14817ccf5b1954e233a8 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Dec 2021 22:02:18 +0100 Subject: [PATCH 397/421] Update tests/test_stubs.py Co-authored-by: Kyle Altendorf --- tests/test_stubs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index eba4c108..d59ef8cb 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -14,8 +14,7 @@ def gen_tests(): def gen_abs_qflags_tests(): '''List of all tests included in the directory qflags''' - for filename in (TESTS_DIR/'qflags').glob('test_*.py'): - yield filename + yield from TESTS_DIR.joinpath('qflags').glob('test_*.py') @pytest.mark.parametrize('filename', From f93442b2e41daa90b8ff6cfb0212723846a8cb85 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Dec 2021 22:04:22 +0100 Subject: [PATCH 398/421] Update tests/test_stubs.py Co-authored-by: Kyle Altendorf --- tests/test_stubs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index d59ef8cb..c22aa86f 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -8,9 +8,9 @@ def gen_tests(): """List of all tests files included in the directory tests""" - for filename in TESTS_DIR.glob('*.py'): - if not str(filename.parts[-1]).startswith('test_'): - yield filename + for path in TESTS_DIR.glob('*.py'): + if not path.name.startswith('test_'): + yield path def gen_abs_qflags_tests(): '''List of all tests included in the directory qflags''' From 3d24115265923bb440f3abf6e5816908539837f3 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Dec 2021 22:05:53 +0100 Subject: [PATCH 399/421] Update tests/test_stubs.py Co-authored-by: Kyle Altendorf --- tests/test_stubs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index c22aa86f..f8347698 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -36,7 +36,7 @@ def test_stubs(filename: Path) -> None: def test_stubs_qflags() -> None: """Run mypy over qflags files.""" - stdout, stderr, exitcode = api.run([str(f) for f in gen_abs_qflags_tests()]) + stdout, stderr, exitcode = api.run([os.fspath(path) for path in gen_abs_qflags_tests()]) if stdout: print(stdout) if stderr: From f53eb62dea021ef07890ade814921f0c9f65517f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Dec 2021 22:06:32 +0100 Subject: [PATCH 400/421] Use os.fspath instead of str() Co-authored-by: Kyle Altendorf --- tests/test_stubs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index f8347698..90692983 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -23,7 +23,7 @@ def gen_abs_qflags_tests(): ) def test_stubs(filename: Path) -> None: """Run mypy over example files.""" - stdout, stderr, exitcode = api.run([str(filename)]) + stdout, stderr, exitcode = api.run([os.fspath(path)]) if stdout: print(stdout) if stderr: From 7a4158826d9836343516bff39c26e3146f082547 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Dec 2021 22:06:47 +0100 Subject: [PATCH 401/421] Typo Co-authored-by: Kyle Altendorf --- tests/test_stubs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index 90692983..b33882bd 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -46,7 +46,7 @@ def test_stubs_qflags() -> None: assert not stderr assert exitcode == 0 -# note: no need to run explicitely pytest over qflags, because pytest finds them automatically +# note: no need to run explicitly pytest over qflags, because pytest finds them automatically @pytest.mark.parametrize('filename', list(gen_tests()), From 8234819171d8b440c0f19782ca8929bb8ac43ba8 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Dec 2021 22:16:21 +0100 Subject: [PATCH 402/421] Improve style: use """ instead of ''', better use of Path, ... --- tests/test_stubs.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index eba4c108..873aefd5 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -13,14 +13,14 @@ def gen_tests(): yield filename def gen_abs_qflags_tests(): - '''List of all tests included in the directory qflags''' + """List of all tests included in the directory qflags""" for filename in (TESTS_DIR/'qflags').glob('test_*.py'): yield filename @pytest.mark.parametrize('filename', list(gen_tests()), - ids=[v.parts[-1] for v in gen_tests()] + ids=[v.relative_to(TESTS_DIR).as_posix() for v in gen_tests()] ) def test_stubs(filename: Path) -> None: """Run mypy over example files.""" @@ -37,7 +37,7 @@ def test_stubs(filename: Path) -> None: def test_stubs_qflags() -> None: """Run mypy over qflags files.""" - stdout, stderr, exitcode = api.run([str(f) for f in gen_abs_qflags_tests()]) + stdout, stderr, exitcode = api.run([os.fspath(f) for f in gen_abs_qflags_tests()]) if stdout: print(stdout) if stderr: @@ -49,12 +49,11 @@ def test_stubs_qflags() -> None: # note: no need to run explicitely pytest over qflags, because pytest finds them automatically -@pytest.mark.parametrize('filename', +@pytest.mark.parametrize('filepath', list(gen_tests()), ids=[v.parts[-1] for v in gen_tests()] ) -def test_files(filename): +def test_files(filepath): """Run the test files to make sure they work properly.""" - with open(str(filename), 'r') as f: - code = f.read() - exec(compile(code, filename, 'exec'), {}) + code = filepath.read_text(encoding='utf-8') + exec(compile(code, filepath, 'exec'), {}) From 20cd408aa93f0621fbbf34a94d0ca322f1352905 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Sun, 28 Nov 2021 22:07:57 +0100 Subject: [PATCH 403/421] Add tests for QSize + support division --- PyQt5-stubs/QtCore.pyi | 26 +++++++++------ tests/qsize.py | 72 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 10 deletions(-) create mode 100644 tests/qsize.py diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 23a4bf73..758537cc 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -10770,14 +10770,17 @@ class QSize(sip.simplewrapper): @typing.overload def __init__(self, a0: 'QSize') -> None: ... - def __add__(self, value: 'QSize') -> 'QSize': ... def __eq__(self, value: object) -> bool: ... - def __iadd__(self, value: 'QSize') -> 'QSize': ... - def __imul__(self, value: float) -> 'QSize': ... - def __isub__(self, value: 'QSize') -> 'QSize': ... - def __mul__(self, value: float) -> 'QSize': ... def __ne__(self, value: object) -> bool: ... + def __add__(self, value: 'QSize') -> 'QSize': ... + def __iadd__(self, value: 'QSize') -> 'QSize': ... def __sub__(self, value: 'QSize') -> 'QSize': ... + def __isub__(self, value: 'QSize') -> 'QSize': ... + def __mul__(self, value: 'float') -> 'QSize': ... + def __rmul__(self, value: 'float') -> 'QSize': ... + def __imul__(self, value: 'float') -> 'QSize': ... + def __truediv__(self, value: 'float') -> 'QSize': ... + def __itruediv__(self, value: 'float') -> 'QSize': ... def shrunkBy(self, m: QMargins) -> 'QSize': ... def grownBy(self, m: QMargins) -> 'QSize': ... @@ -10815,14 +10818,17 @@ class QSizeF(sip.simplewrapper): @typing.overload def __init__(self, a0: 'QSizeF') -> None: ... - def __add__(self, value: 'QSizeF') -> 'QSizeF': ... def __eq__(self, value: object) -> bool: ... - def __iadd__(self, value: 'QSizeF') -> 'QSizeF': ... - def __imul__(self, value: float) -> 'QSizeF': ... - def __isub__(self, value: 'QSizeF') -> 'QSizeF': ... - def __mul__(self, value: float) -> 'QSizeF': ... def __ne__(self, value: object) -> bool: ... + def __add__(self, value: 'QSizeF') -> 'QSizeF': ... + def __iadd__(self, value: 'QSizeF') -> 'QSizeF': ... def __sub__(self, value: 'QSizeF') -> 'QSizeF': ... + def __isub__(self, value: 'QSizeF') -> 'QSizeF': ... + def __mul__(self, value: 'float') -> 'QSizeF': ... + def __rmul__(self, value: 'float') -> 'QSizeF': ... + def __imul__(self, value: 'float') -> 'QSizeF': ... + def __truediv__(self, value: 'float') -> 'QSizeF': ... + def __itruediv__(self, value: 'float') -> 'QSizeF': ... def shrunkBy(self, m: QMarginsF) -> 'QSizeF': ... def grownBy(self, m: QMarginsF) -> 'QSizeF': ... diff --git a/tests/qsize.py b/tests/qsize.py new file mode 100644 index 00000000..4966cd97 --- /dev/null +++ b/tests/qsize.py @@ -0,0 +1,72 @@ +from PyQt5 import QtCore + +# QSize tests +qs1 = QtCore.QSize(1,2) +qs2 = QtCore.QSize(3,4) +qs3 = QtCore.QSize(5,6) + +qs3 = qs1 + qs2 +assert type(qs3) == QtCore.QSize +qs3 = qs1 - qs2 +assert type(qs3) == QtCore.QSize +qs3 += qs1 +assert type(qs3) == QtCore.QSize +qs3 -= qs2 +assert type(qs3) == QtCore.QSize + +qs3 = qs1 * 3 +assert type(qs3) == QtCore.QSize +qs3 = qs1 * 3.0 +assert type(qs3) == QtCore.QSize + +qs3 = 3 * qs1 +assert type(qs3) == QtCore.QSize +qs3 = 3.0 * qs1 +assert type(qs3) == QtCore.QSize + +qs3 = qs1 / 2.0 +assert type(qs3) == QtCore.QSize + +qs3 *= 3 +assert type(qs3) == QtCore.QSize +qs3 *= 3.0 +assert type(qs3) == QtCore.QSize + +qs3 /= 3.0 +assert type(qs3) == QtCore.QSize + + +# QSizeF tests +qsf1 = QtCore.QSizeF(1.0,2.0) +qsf2 = QtCore.QSizeF(3.0,4.0) +qsf3 = QtCore.QSizeF(5.0,6.0) + +qsf3 = qsf1 + qsf2 +assert type(qsf3) == QtCore.QSizeF +qsf3 = qsf1 - qsf2 +assert type(qsf3) == QtCore.QSizeF +qsf3 += qsf1 +assert type(qsf3) == QtCore.QSizeF +qsf3 -= qsf2 +assert type(qsf3) == QtCore.QSizeF + +qsf3 = qsf1 * 3 +assert type(qsf3) == QtCore.QSizeF +qsf3 = qsf1 * 3.0 +assert type(qsf3) == QtCore.QSizeF + +qsf3 = 3 * qsf1 +assert type(qsf3) == QtCore.QSizeF +qsf3 = 3.0 * qsf1 +assert type(qsf3) == QtCore.QSizeF + +qsf3 = qsf1 / 2.0 +assert type(qsf3) == QtCore.QSizeF + +qsf3 *= 3 +assert type(qsf3) == QtCore.QSizeF +qsf3 *= 3.0 +assert type(qsf3) == QtCore.QSizeF + +qsf3 /= 3.0 +assert type(qsf3) == QtCore.QSizeF From 4b108351050fae9160a914f828d4be50f0633fd2 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 15 Dec 2021 22:53:54 +0100 Subject: [PATCH 404/421] CI should be exactly like on pyqt5-stubs --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 756e65e6..333361ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,9 @@ name: CI on: - workflow_dispatch: push: branches: - master - - more-qflags tags: - v* pull_request: From e3dad02f47d436cfcdeb3fc197ec7f6b8ebcb642 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 24 Dec 2021 22:56:46 +0100 Subject: [PATCH 405/421] Add PYQT_CONFIGURATION Dict detected by mypy 0.930 and missed by previous versions --- PyQt5-stubs/QtCore.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 23a4bf73..d775bb1c 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -12880,6 +12880,7 @@ class QSysInfo(sip.simplewrapper): PYQT_VERSION = ... # type: int PYQT_VERSION_STR = ... # type: str +PYQT_CONFIGURATION = ... # type: Dict[str, str] QT_VERSION = ... # type: int QT_VERSION_STR = ... # type: str From a1c7bf28e0ec96c32c0b2531e423687520167c65 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Fri, 24 Dec 2021 22:59:00 +0100 Subject: [PATCH 406/421] Fix typo --- PyQt5-stubs/QtCore.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index d775bb1c..0f518daf 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -12880,7 +12880,7 @@ class QSysInfo(sip.simplewrapper): PYQT_VERSION = ... # type: int PYQT_VERSION_STR = ... # type: str -PYQT_CONFIGURATION = ... # type: Dict[str, str] +PYQT_CONFIGURATION = ... # type: typing.Dict[str, str] QT_VERSION = ... # type: int QT_VERSION_STR = ... # type: str From b04042cfe9eebb6beabb1cccdb94065bb0746c9f Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 27 Dec 2021 18:41:23 +0100 Subject: [PATCH 407/421] Add changelog entry for pull request --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55615608..eb29d8bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * [#156](https://github.com/python-qt-tools/PyQt5-stubs/pull/156) add operators to `QSize` and `QSizeF` * [#153](https://github.com/python-qt-tools/PyQt5-stubs/pull/153) Support all implemented arithmetic operations for QFlags based classes in modules QtCore, QtWidgets, QtGui, QtNetwork, QtDBus, QtOpenGL, QtPrintsupport, QtSql, QtTest, QtXml +* [#184](https://github.com/python-qt-tools/PyQt5-stubs/pull/184) Fix missing module variable + detected by latest mypy 0.930 ## 5.15.2.0 From aca6cdfb9eee0840992f74f65d39034e40836589 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 27 Dec 2021 18:44:29 +0100 Subject: [PATCH 408/421] Remove unneedod quotes around float --- PyQt5-stubs/QtCore.pyi | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index df962f81..4f174cbb 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -10776,11 +10776,11 @@ class QSize(sip.simplewrapper): def __iadd__(self, value: 'QSize') -> 'QSize': ... def __sub__(self, value: 'QSize') -> 'QSize': ... def __isub__(self, value: 'QSize') -> 'QSize': ... - def __mul__(self, value: 'float') -> 'QSize': ... - def __rmul__(self, value: 'float') -> 'QSize': ... - def __imul__(self, value: 'float') -> 'QSize': ... - def __truediv__(self, value: 'float') -> 'QSize': ... - def __itruediv__(self, value: 'float') -> 'QSize': ... + def __mul__(self, value: float) -> 'QSize': ... + def __rmul__(self, value: float) -> 'QSize': ... + def __imul__(self, value: float) -> 'QSize': ... + def __truediv__(self, value: float) -> 'QSize': ... + def __itruediv__(self, value: float) -> 'QSize': ... def shrunkBy(self, m: QMargins) -> 'QSize': ... def grownBy(self, m: QMargins) -> 'QSize': ... @@ -10824,11 +10824,11 @@ class QSizeF(sip.simplewrapper): def __iadd__(self, value: 'QSizeF') -> 'QSizeF': ... def __sub__(self, value: 'QSizeF') -> 'QSizeF': ... def __isub__(self, value: 'QSizeF') -> 'QSizeF': ... - def __mul__(self, value: 'float') -> 'QSizeF': ... - def __rmul__(self, value: 'float') -> 'QSizeF': ... - def __imul__(self, value: 'float') -> 'QSizeF': ... - def __truediv__(self, value: 'float') -> 'QSizeF': ... - def __itruediv__(self, value: 'float') -> 'QSizeF': ... + def __mul__(self, value: float) -> 'QSizeF': ... + def __rmul__(self, value: float) -> 'QSizeF': ... + def __imul__(self, value: float) -> 'QSizeF': ... + def __truediv__(self, value: float) -> 'QSizeF': ... + def __itruediv__(self, value: float) -> 'QSizeF': ... def shrunkBy(self, m: QMarginsF) -> 'QSizeF': ... def grownBy(self, m: QMarginsF) -> 'QSizeF': ... From ae4b6b3556c6951406a305963ed76801816c0a5e Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 27 Dec 2021 18:45:52 +0100 Subject: [PATCH 409/421] Add all operations for QSize handling --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb29d8bd..ac7d5084 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,9 +19,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * [#156](https://github.com/python-qt-tools/PyQt5-stubs/pull/156) add operators to `QSize` and `QSizeF` * [#153](https://github.com/python-qt-tools/PyQt5-stubs/pull/153) Support all implemented arithmetic operations for QFlags based classes in modules QtCore, QtWidgets, QtGui, QtNetwork, QtDBus, QtOpenGL, QtPrintsupport, QtSql, QtTest, QtXml +* [#183](https://github.com/python-qt-tools/PyQt5-stubs/pull/183) Add missing operations on QSize * [#184](https://github.com/python-qt-tools/PyQt5-stubs/pull/184) Fix missing module variable detected by latest mypy 0.930 - + ## 5.15.2.0 ### Added From 5a34f17ca1513574660b825aba12cf2cc32fd561 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Mon, 27 Dec 2021 21:27:54 +0100 Subject: [PATCH 410/421] Code beautifying --- tests/test_stubs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_stubs.py b/tests/test_stubs.py index 20c0f4a4..2ed54b44 100644 --- a/tests/test_stubs.py +++ b/tests/test_stubs.py @@ -51,7 +51,7 @@ def test_stubs_qflags() -> None: @pytest.mark.parametrize('filepath', list(gen_tests()), - ids=[v.parts[-1] for v in gen_tests()] + ids=[v.name for v in gen_tests()] ) def test_files(filepath): """Run the test files to make sure they work properly.""" From 53d017d01db42633974f5ad1833019b0d80a758b Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 27 Dec 2021 19:20:56 -0500 Subject: [PATCH 411/421] more macos constants --- PyQt5-stubs/QtCore.pyi | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 5d05a674..20aa6be9 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -12909,6 +12909,63 @@ class QSysInfo(sip.simplewrapper): MV_WATCHOS_3_0 = ... # type: int MV_YOSEMITE = ... # type: int + MV_10_0 = ... # type: int + MV_10_1 = ... # type: int + MV_10_10 = ... # type: int + MV_10_11 = ... # type: int + MV_10_12 = ... # type: int + MV_10_2 = ... # type: int + MV_10_3 = ... # type: int + MV_10_4 = ... # type: int + MV_10_5 = ... # type: int + MV_10_6 = ... # type: int + MV_10_7 = ... # type: int + MV_10_8 = ... # type: int + MV_10_9 = ... # type: int + MV_9 = ... # type: int + MV_CHEETAH = ... # type: int + MV_ELCAPITAN = ... # type: int + MV_IOS = ... # type: int + MV_IOS_10_0 = ... # type: int + MV_IOS_4_3 = ... # type: int + MV_IOS_5_0 = ... # type: int + MV_IOS_5_1 = ... # type: int + MV_IOS_6_0 = ... # type: int + MV_IOS_6_1 = ... # type: int + MV_IOS_7_0 = ... # type: int + MV_IOS_7_1 = ... # type: int + MV_IOS_8_0 = ... # type: int + MV_IOS_8_1 = ... # type: int + MV_IOS_8_2 = ... # type: int + MV_IOS_8_3 = ... # type: int + MV_IOS_8_4 = ... # type: int + MV_IOS_9_0 = ... # type: int + MV_IOS_9_1 = ... # type: int + MV_IOS_9_2 = ... # type: int + MV_IOS_9_3 = ... # type: int + MV_JAGUAR = ... # type: int + MV_LEOPARD = ... # type: int + MV_LION = ... # type: int + MV_MAVERICKS = ... # type: int + MV_MOUNTAINLION = ... # type: int + MV_PANTHER = ... # type: int + MV_PUMA = ... # type: int + MV_SIERRA = ... # type: int + MV_SNOWLEOPARD = ... # type: int + MV_TIGER = ... # type: int + MV_TVOS = ... # type: int + MV_TVOS_10_0 = ... # type: int + MV_TVOS_9_0 = ... # type: int + MV_TVOS_9_1 = ... # type: int + MV_TVOS_9_2 = ... # type: int + MV_Unknown = ... # type: int + MV_WATCHOS = ... # type: int + MV_WATCHOS_2_0 = ... # type: int + MV_WATCHOS_2_1 = ... # type: int + MV_WATCHOS_2_2 = ... # type: int + MV_WATCHOS_3_0 = ... # type: int + MV_YOSEMITE = ... # type: int + MacVersion = ... # type: QSysInfo.MacintoshVersion @staticmethod From 19942ff02c6b4cc0d79110f9aabbe8e4893f7d57 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 27 Dec 2021 19:29:26 -0500 Subject: [PATCH 412/421] maybe --- PyQt5-stubs/QtCore.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PyQt5-stubs/QtCore.pyi b/PyQt5-stubs/QtCore.pyi index 20aa6be9..8e74e0eb 100644 --- a/PyQt5-stubs/QtCore.pyi +++ b/PyQt5-stubs/QtCore.pyi @@ -12851,7 +12851,7 @@ class QSysInfo(sip.simplewrapper): def windowsVersion() -> 'QSysInfo.WinVersion': ... if sys.platform == "darwin": - class MacintoshVersion(int): + class MacVersion(int): MV_10_0 = ... # type: int MV_10_1 = ... # type: int MV_10_10 = ... # type: int @@ -12966,10 +12966,10 @@ class QSysInfo(sip.simplewrapper): MV_WATCHOS_3_0 = ... # type: int MV_YOSEMITE = ... # type: int - MacVersion = ... # type: QSysInfo.MacintoshVersion + MacintoshVersion = ... # type: QSysInfo.MacVersion @staticmethod - def macVersion() -> 'QSysInfo.MacintoshVersion': ... + def macVersion() -> 'QSysInfo.MacVersion': ... @typing.overload def __init__(self) -> None: ... From 7c11053d62ee302c7914d4d17e899a79d10b0d26 Mon Sep 17 00:00:00 2001 From: Philippe F Date: Wed, 29 Dec 2021 15:55:17 +0100 Subject: [PATCH 413/421] Update CHANGELOG.md Co-authored-by: Kyle Altendorf --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 102d682e..b40f03a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * [#184](https://github.com/python-qt-tools/PyQt5-stubs/pull/184) Fix missing module variable detected by latest mypy 0.930 * [#183](https://github.com/python-qt-tools/PyQt5-stubs/pull/183) Add missing operations on QSize - ## 5.15.2.0 ### Added From cd0c74401d9d4fb50761b9849e7a229d6470c4d7 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Tue, 4 Jan 2022 06:28:04 +0100 Subject: [PATCH 414/421] Fix annotations for methods with QTableWidgetItem in QTableWidget --- PyQt5-stubs/QtWidgets.pyi | 54 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 73377c7b..d55ec52e 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -10214,11 +10214,11 @@ class QTableWidget(QTableView): @typing.overload def __init__(self, rows: int, columns: int, parent: typing.Optional[QWidget] = ...) -> None: ... - def isPersistentEditorOpen(self, item: QTableWidgetItem) -> bool: ... # type: ignore[override] + def isPersistentEditorOpen(self, item: typing.Optional[QTableWidgetItem]) -> bool: ... # type: ignore[override] def dropEvent(self, event: QtGui.QDropEvent) -> None: ... def event(self, e: QtCore.QEvent) -> bool: ... - def itemFromIndex(self, index: QtCore.QModelIndex) -> QTableWidgetItem: ... - def indexFromItem(self, item: QTableWidgetItem) -> QtCore.QModelIndex: ... + def itemFromIndex(self, index: QtCore.QModelIndex) -> typing.Optional[QTableWidgetItem]: ... + def indexFromItem(self, item: typing.Optional[QTableWidgetItem]) -> QtCore.QModelIndex: ... def items(self, data: QtCore.QMimeData) -> typing.List[QTableWidgetItem]: ... def supportedDropActions(self) -> QtCore.Qt.DropActions: ... def dropMimeData(self, row: int, column: int, data: QtCore.QMimeData, action: QtCore.Qt.DropAction) -> bool: ... @@ -10245,14 +10245,14 @@ class QTableWidget(QTableView): def removeRow(self, row: int) -> None: ... def insertColumn(self, column: int) -> None: ... def insertRow(self, row: int) -> None: ... - def scrollToItem(self, item: QTableWidgetItem, hint: QAbstractItemView.ScrollHint = ...) -> None: ... - def setItemPrototype(self, item: QTableWidgetItem) -> None: ... - def itemPrototype(self) -> QTableWidgetItem: ... - def visualItemRect(self, item: QTableWidgetItem) -> QtCore.QRect: ... + def scrollToItem(self, item: typing.Optional[QTableWidgetItem], hint: QAbstractItemView.ScrollHint = ...) -> None: ... + def setItemPrototype(self, item: typing.Optional[QTableWidgetItem]) -> None: ... + def itemPrototype(self) -> typing.Optional[QTableWidgetItem]: ... + def visualItemRect(self, item: typing.Optional[QTableWidgetItem]) -> QtCore.QRect: ... @typing.overload - def itemAt(self, p: QtCore.QPoint) -> QTableWidgetItem: ... + def itemAt(self, p: QtCore.QPoint) -> typing.Optional[QTableWidgetItem]: ... @typing.overload - def itemAt(self, ax: int, ay: int) -> QTableWidgetItem: ... + def itemAt(self, ax: int, ay: int) -> typing.Optional[QTableWidgetItem]: ... def visualColumn(self, logicalColumn: int) -> int: ... def visualRow(self, logicalRow: int) -> int: ... def findItems(self, text: str, flags: typing.Union[QtCore.Qt.MatchFlags, QtCore.Qt.MatchFlag]) -> typing.List[QTableWidgetItem]: ... @@ -10261,10 +10261,10 @@ class QTableWidget(QTableView): def setRangeSelected(self, range: QTableWidgetSelectionRange, select: bool) -> None: ... def removeCellWidget(self, arow: int, acolumn: int) -> None: ... def setCellWidget(self, row: int, column: int, widget: QWidget) -> None: ... - def cellWidget(self, row: int, column: int) -> QWidget: ... - def closePersistentEditor(self, item: QTableWidgetItem) -> None: ... # type: ignore[override] - def openPersistentEditor(self, item: QTableWidgetItem) -> None: ... # type: ignore[override] - def editItem(self, item: QTableWidgetItem) -> None: ... + def cellWidget(self, row: int, column: int) -> typing.List[QWidget]: ... + def closePersistentEditor(self, item: typing.Optional[QTableWidgetItem]) -> None: ... # type: ignore[override] + def openPersistentEditor(self, item: typing.Optional[QTableWidgetItem]) -> None: ... # type: ignore[override] + def editItem(self, item: typing.Optional[QTableWidgetItem]) -> None: ... def isSortingEnabled(self) -> bool: ... def setSortingEnabled(self, enable: bool) -> None: ... def sortItems(self, column: int, order: QtCore.Qt.SortOrder = ...) -> None: ... @@ -10273,25 +10273,25 @@ class QTableWidget(QTableView): @typing.overload def setCurrentCell(self, row: int, column: int, command: typing.Union[QtCore.QItemSelectionModel.SelectionFlags, QtCore.QItemSelectionModel.SelectionFlag]) -> None: ... @typing.overload - def setCurrentItem(self, item: QTableWidgetItem) -> None: ... + def setCurrentItem(self, item: typing.Optional[QTableWidgetItem]) -> None: ... @typing.overload - def setCurrentItem(self, item: QTableWidgetItem, command: typing.Union[QtCore.QItemSelectionModel.SelectionFlags, QtCore.QItemSelectionModel.SelectionFlag]) -> None: ... - def currentItem(self) -> QTableWidgetItem: ... + def setCurrentItem(self, item: typing.Optional[QTableWidgetItem], command: typing.Union[QtCore.QItemSelectionModel.SelectionFlags, QtCore.QItemSelectionModel.SelectionFlag]) -> None: ... + def currentItem(self) -> typing.Optional[QTableWidgetItem]: ... def currentColumn(self) -> int: ... def currentRow(self) -> int: ... def setHorizontalHeaderLabels(self, labels: typing.Iterable[str]) -> None: ... def setVerticalHeaderLabels(self, labels: typing.Iterable[str]) -> None: ... - def takeHorizontalHeaderItem(self, column: int) -> QTableWidgetItem: ... - def setHorizontalHeaderItem(self, column: int, item: QTableWidgetItem) -> None: ... - def horizontalHeaderItem(self, column: int) -> QTableWidgetItem: ... - def takeVerticalHeaderItem(self, row: int) -> QTableWidgetItem: ... - def setVerticalHeaderItem(self, row: int, item: QTableWidgetItem) -> None: ... - def verticalHeaderItem(self, row: int) -> QTableWidgetItem: ... - def takeItem(self, row: int, column: int) -> QTableWidgetItem: ... - def setItem(self, row: int, column: int, item: QTableWidgetItem) -> None: ... - def item(self, row: int, column: int) -> QTableWidgetItem: ... - def column(self, item: QTableWidgetItem) -> int: ... - def row(self, item: QTableWidgetItem) -> int: ... + def takeHorizontalHeaderItem(self, column: int) -> typing.Optional[QTableWidgetItem]: ... + def setHorizontalHeaderItem(self, column: int, item: typing.Optional[QTableWidgetItem]) -> None: ... + def horizontalHeaderItem(self, column: int) -> typing.Optional[QTableWidgetItem]: ... + def takeVerticalHeaderItem(self, row: int) -> typing.Optional[QTableWidgetItem]: ... + def setVerticalHeaderItem(self, row: int, item: typing.Optional[QTableWidgetItem]) -> None: ... + def verticalHeaderItem(self, row: int) -> typing.Optional[QTableWidgetItem]: ... + def takeItem(self, row: int, column: int) -> typing.Optional[QTableWidgetItem]: ... + def setItem(self, row: int, column: int, item: typing.Optional[QTableWidgetItem]) -> None: ... + def item(self, row: int, column: int) -> typing.Optional[QTableWidgetItem]: ... + def column(self, item: typing.Optional[QTableWidgetItem]) -> int: ... + def row(self, item: typing.Optional[QTableWidgetItem]) -> int: ... def columnCount(self) -> int: ... def setColumnCount(self, columns: int) -> None: ... def rowCount(self) -> int: ... From 96060d7318fc234097fa6a64bc91dea09f262fac Mon Sep 17 00:00:00 2001 From: TilmanK Date: Wed, 5 Jan 2022 05:29:08 +0100 Subject: [PATCH 415/421] Fixes QListWiget and QTreeWidget --- PyQt5-stubs/QtWidgets.pyi | 110 +++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index 9061022d..a03c8dcf 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -7358,15 +7358,15 @@ class QListWidget(QListView): def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... - def isPersistentEditorOpen(self, item: QListWidgetItem) -> bool: ... # type: ignore[override] + def isPersistentEditorOpen(self, item: typing.Optional[QListWidgetItem]) -> bool: ... # type: ignore[override] def setSelectionModel(self, selectionModel: QtCore.QItemSelectionModel) -> None: ... - def removeItemWidget(self, aItem: QListWidgetItem) -> None: ... + def removeItemWidget(self, aItem: typing.Optional[QListWidgetItem]) -> None: ... def dropEvent(self, event: QtGui.QDropEvent) -> None: ... def isSortingEnabled(self) -> bool: ... def setSortingEnabled(self, enable: bool) -> None: ... def event(self, e: QtCore.QEvent) -> bool: ... - def itemFromIndex(self, index: QtCore.QModelIndex) -> QListWidgetItem: ... - def indexFromItem(self, item: QListWidgetItem) -> QtCore.QModelIndex: ... + def itemFromIndex(self, index: QtCore.QModelIndex) -> typing.Optional[QListWidgetItem]: ... + def indexFromItem(self, item: typing.Optional[QListWidgetItem]) -> QtCore.QModelIndex: ... def items(self, data: QtCore.QMimeData) -> typing.List[QListWidgetItem]: ... def supportedDropActions(self) -> QtCore.Qt.DropActions: ... def dropMimeData(self, index: int, data: QtCore.QMimeData, action: QtCore.Qt.DropAction) -> bool: ... @@ -7382,46 +7382,46 @@ class QListWidget(QListView): itemDoubleClicked: typing.ClassVar[QtCore.pyqtSignal] itemClicked: typing.ClassVar[QtCore.pyqtSignal] itemPressed: typing.ClassVar[QtCore.pyqtSignal] - def scrollToItem(self, item: QListWidgetItem, hint: QAbstractItemView.ScrollHint = ...) -> None: ... + def scrollToItem(self, item: typing.Optional[QListWidgetItem], hint: QAbstractItemView.ScrollHint = ...) -> None: ... def clear(self) -> None: ... def findItems(self, text: str, flags: typing.Union[QtCore.Qt.MatchFlags, QtCore.Qt.MatchFlag]) -> typing.List[QListWidgetItem]: ... def selectedItems(self) -> typing.List[QListWidgetItem]: ... - def closePersistentEditor(self, item: QListWidgetItem) -> None: ... # type: ignore[override] - def openPersistentEditor(self, item: QListWidgetItem) -> None: ... # type: ignore[override] - def editItem(self, item: QListWidgetItem) -> None: ... + def closePersistentEditor(self, item: typing.Optional[QListWidgetItem]) -> None: ... # type: ignore[override] + def openPersistentEditor(self, item: typing.Optional[QListWidgetItem]) -> None: ... # type: ignore[override] + def editItem(self, item: typing.Optional[QListWidgetItem]) -> None: ... def sortItems(self, order: QtCore.Qt.SortOrder = ...) -> None: ... - def visualItemRect(self, item: QListWidgetItem) -> QtCore.QRect: ... - def setItemWidget(self, item: QListWidgetItem, widget: QWidget) -> None: ... - def itemWidget(self, item: QListWidgetItem) -> QWidget: ... + def visualItemRect(self, item: typing.Optional[QListWidgetItem]) -> QtCore.QRect: ... + def setItemWidget(self, item: typing.Optional[QListWidgetItem], widget: QWidget) -> None: ... + def itemWidget(self, item: typing.Optional[QListWidgetItem]) -> QWidget: ... @typing.overload - def itemAt(self, p: QtCore.QPoint) -> QListWidgetItem: ... + def itemAt(self, p: QtCore.QPoint) -> typing.Optional[QListWidgetItem]: ... @typing.overload - def itemAt(self, ax: int, ay: int) -> QListWidgetItem: ... + def itemAt(self, ax: int, ay: int) -> typing.Optional[QListWidgetItem]: ... @typing.overload def setCurrentRow(self, row: int) -> None: ... @typing.overload def setCurrentRow(self, row: int, command: typing.Union[QtCore.QItemSelectionModel.SelectionFlags, QtCore.QItemSelectionModel.SelectionFlag]) -> None: ... def currentRow(self) -> int: ... @typing.overload - def setCurrentItem(self, item: QListWidgetItem) -> None: ... + def setCurrentItem(self, item: typing.Optional[QListWidgetItem]) -> None: ... @typing.overload - def setCurrentItem(self, item: QListWidgetItem, command: typing.Union[QtCore.QItemSelectionModel.SelectionFlags, QtCore.QItemSelectionModel.SelectionFlag]) -> None: ... - def currentItem(self) -> QListWidgetItem: ... + def setCurrentItem(self, item: typing.Optional[QListWidgetItem], command: typing.Union[QtCore.QItemSelectionModel.SelectionFlags, QtCore.QItemSelectionModel.SelectionFlag]) -> None: ... + def currentItem(self) -> typing.Optional[QListWidgetItem]: ... def __len__(self) -> int: ... def count(self) -> int: ... - def takeItem(self, row: int) -> QListWidgetItem: ... - def addItems(self, labels: typing.Iterable[str]) -> None: ... + def takeItem(self, row: int) -> typing.Optional[QListWidgetItem]: ... + def addItems(self, labels: typing.Iterable[typing.Optional[str]]) -> None: ... @typing.overload - def addItem(self, aitem: QListWidgetItem) -> None: ... + def addItem(self, aitem: typing.Optional[QListWidgetItem]) -> None: ... @typing.overload - def addItem(self, label: str) -> None: ... + def addItem(self, label: typing.Optional[str]) -> None: ... def insertItems(self, row: int, labels: typing.Iterable[str]) -> None: ... @typing.overload - def insertItem(self, row: int, item: QListWidgetItem) -> None: ... + def insertItem(self, row: int, item: typing.Optional[QListWidgetItem]) -> None: ... @typing.overload def insertItem(self, row: int, label: str) -> None: ... - def row(self, item: QListWidgetItem) -> int: ... - def item(self, row: int) -> QListWidgetItem: ... + def row(self, item: typing.Optional[QListWidgetItem]) -> int: ... + def item(self, row: int) -> typing.Optional[QListWidgetItem]: ... class QMainWindow(QWidget): @@ -11383,22 +11383,22 @@ class QTreeWidget(QTreeView): def __init__(self, parent: typing.Optional[QWidget] = ...) -> None: ... - def isPersistentEditorOpen(self, item: QTreeWidgetItem, column: int = ...) -> bool: ... # type: ignore[override] + def isPersistentEditorOpen(self, item: typing.Optional[QTreeWidgetItem], column: int = ...) -> bool: ... # type: ignore[override] def setSelectionModel(self, selectionModel: QtCore.QItemSelectionModel) -> None: ... - def removeItemWidget(self, item: QTreeWidgetItem, column: int) -> None: ... - def itemBelow(self, item: QTreeWidgetItem) -> QTreeWidgetItem: ... - def itemAbove(self, item: QTreeWidgetItem) -> QTreeWidgetItem: ... - def setFirstItemColumnSpanned(self, item: QTreeWidgetItem, span: bool) -> None: ... - def isFirstItemColumnSpanned(self, item: QTreeWidgetItem) -> bool: ... + def removeItemWidget(self, item: typing.Optional[QTreeWidgetItem], column: int) -> None: ... + def itemBelow(self, item: typing.Optional[QTreeWidgetItem]) -> typing.Optional[QTreeWidgetItem]: ... + def itemAbove(self, item: typing.Optional[QTreeWidgetItem]) -> typing.Optional[QTreeWidgetItem]: ... + def setFirstItemColumnSpanned(self, item: typing.Optional[QTreeWidgetItem], span: bool) -> None: ... + def isFirstItemColumnSpanned(self, item: typing.Optional[QTreeWidgetItem]) -> bool: ... def setHeaderLabel(self, alabel: str) -> None: ... def invisibleRootItem(self) -> QTreeWidgetItem: ... def dropEvent(self, event: QtGui.QDropEvent) -> None: ... def event(self, e: QtCore.QEvent) -> bool: ... - def itemFromIndex(self, index: QtCore.QModelIndex) -> QTreeWidgetItem: ... - def indexFromItem(self, item: QTreeWidgetItem, column: int = ...) -> QtCore.QModelIndex: ... + def itemFromIndex(self, index: QtCore.QModelIndex) -> typing.Optional[QTreeWidgetItem]: ... + def indexFromItem(self, item: typing.Optional[QTreeWidgetItem], column: int = ...) -> QtCore.QModelIndex: ... def supportedDropActions(self) -> QtCore.Qt.DropActions: ... - def dropMimeData(self, parent: QTreeWidgetItem, index: int, data: QtCore.QMimeData, action: QtCore.Qt.DropAction) -> bool: ... - def mimeData(self, items: typing.Iterable[QTreeWidgetItem]) -> QtCore.QMimeData: ... + def dropMimeData(self, parent: typing.Optional[QTreeWidgetItem], index: int, data: QtCore.QMimeData, action: QtCore.Qt.DropAction) -> bool: ... + def mimeData(self, items: typing.Iterable[typing.Optional[QTreeWidgetItem]]) -> QtCore.QMimeData: ... def mimeTypes(self) -> typing.List[str]: ... itemSelectionChanged: typing.ClassVar[QtCore.pyqtSignal] currentItemChanged: typing.ClassVar[QtCore.pyqtSignal] @@ -11411,42 +11411,42 @@ class QTreeWidget(QTreeView): itemClicked: typing.ClassVar[QtCore.pyqtSignal] itemPressed: typing.ClassVar[QtCore.pyqtSignal] def clear(self) -> None: ... - def collapseItem(self, item: QTreeWidgetItem) -> None: ... - def expandItem(self, item: QTreeWidgetItem) -> None: ... - def scrollToItem(self, item: QTreeWidgetItem, hint: QAbstractItemView.ScrollHint = ...) -> None: ... + def collapseItem(self, item: typing.Optional[QTreeWidgetItem]) -> None: ... + def expandItem(self, item: typing.Optional[QTreeWidgetItem]) -> None: ... + def scrollToItem(self, item: typing.Optional[QTreeWidgetItem], hint: QAbstractItemView.ScrollHint = ...) -> None: ... def findItems(self, text: str, flags: typing.Union[QtCore.Qt.MatchFlags, QtCore.Qt.MatchFlag], column: int = ...) -> typing.List[QTreeWidgetItem]: ... def selectedItems(self) -> typing.List[QTreeWidgetItem]: ... - def setItemWidget(self, item: QTreeWidgetItem, column: int, widget: QWidget) -> None: ... - def itemWidget(self, item: QTreeWidgetItem, column: int) -> QWidget: ... - def closePersistentEditor(self, item: QTreeWidgetItem, column: int = ...) -> None: ... # type: ignore[override] - def openPersistentEditor(self, item: QTreeWidgetItem, column: int = ...) -> None: ... # type: ignore[override] - def editItem(self, item: QTreeWidgetItem, column: int = ...) -> None: ... + def setItemWidget(self, item: typing.Optional[QTreeWidgetItem], column: int, widget: QWidget) -> None: ... + def itemWidget(self, item: typing.Optional[QTreeWidgetItem], column: int) -> QWidget: ... + def closePersistentEditor(self, item: typing.Optional[QTreeWidgetItem], column: int = ...) -> None: ... # type: ignore[override] + def openPersistentEditor(self, item: typing.Optional[QTreeWidgetItem], column: int = ...) -> None: ... # type: ignore[override] + def editItem(self, item: typing.Optional[QTreeWidgetItem], column: int = ...) -> None: ... def sortItems(self, column: int, order: QtCore.Qt.SortOrder) -> None: ... def sortColumn(self) -> int: ... - def visualItemRect(self, item: QTreeWidgetItem) -> QtCore.QRect: ... + def visualItemRect(self, item: typing.Optional[QTreeWidgetItem]) -> QtCore.QRect: ... @typing.overload - def itemAt(self, p: QtCore.QPoint) -> QTreeWidgetItem: ... + def itemAt(self, p: QtCore.QPoint) -> typing.Optional[QTreeWidgetItem]: ... @typing.overload - def itemAt(self, ax: int, ay: int) -> QTreeWidgetItem: ... + def itemAt(self, ax: int, ay: int) -> typing.Optional[QTreeWidgetItem]: ... @typing.overload - def setCurrentItem(self, item: QTreeWidgetItem) -> None: ... + def setCurrentItem(self, item: typing.Optional[QTreeWidgetItem]) -> None: ... @typing.overload - def setCurrentItem(self, item: QTreeWidgetItem, column: int) -> None: ... + def setCurrentItem(self, item: typing.Optional[QTreeWidgetItem], column: int) -> None: ... @typing.overload - def setCurrentItem(self, item: QTreeWidgetItem, column: int, command: typing.Union[QtCore.QItemSelectionModel.SelectionFlags, QtCore.QItemSelectionModel.SelectionFlag]) -> None: ... + def setCurrentItem(self, item: typing.Optional[QTreeWidgetItem], column: int, command: typing.Union[QtCore.QItemSelectionModel.SelectionFlags, QtCore.QItemSelectionModel.SelectionFlag]) -> None: ... def currentColumn(self) -> int: ... - def currentItem(self) -> QTreeWidgetItem: ... + def currentItem(self) -> typing.Optional[QTreeWidgetItem]: ... def setHeaderLabels(self, labels: typing.Iterable[str]) -> None: ... - def setHeaderItem(self, item: QTreeWidgetItem) -> None: ... - def headerItem(self) -> QTreeWidgetItem: ... + def setHeaderItem(self, item: typing.Optional[QTreeWidgetItem]) -> None: ... + def headerItem(self) -> typing.Optional[QTreeWidgetItem]: ... def addTopLevelItems(self, items: typing.Iterable[QTreeWidgetItem]) -> None: ... def insertTopLevelItems(self, index: int, items: typing.Iterable[QTreeWidgetItem]) -> None: ... - def indexOfTopLevelItem(self, item: QTreeWidgetItem) -> int: ... - def takeTopLevelItem(self, index: int) -> QTreeWidgetItem: ... - def addTopLevelItem(self, item: QTreeWidgetItem) -> None: ... - def insertTopLevelItem(self, index: int, item: QTreeWidgetItem) -> None: ... + def indexOfTopLevelItem(self, item: typing.Optional[QTreeWidgetItem]) -> int: ... + def takeTopLevelItem(self, index: int) -> typing.Optional[QTreeWidgetItem]: ... + def addTopLevelItem(self, item: typing.Optional[QTreeWidgetItem]) -> None: ... + def insertTopLevelItem(self, index: int, item: typing.Optional[QTreeWidgetItem]) -> None: ... def topLevelItemCount(self) -> int: ... - def topLevelItem(self, index: int) -> QTreeWidgetItem: ... + def topLevelItem(self, index: int) -> typing.Optional[QTreeWidgetItem]: ... def setColumnCount(self, columns: int) -> None: ... def columnCount(self) -> int: ... From e9fa77d73cdaa721f0e742149e18750b6c3b0835 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Wed, 5 Jan 2022 05:31:38 +0100 Subject: [PATCH 416/421] Added CHANGELOG.md entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b40f03a8..394ea18f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * [#184](https://github.com/python-qt-tools/PyQt5-stubs/pull/184) Fix missing module variable detected by latest mypy 0.930 * [#183](https://github.com/python-qt-tools/PyQt5-stubs/pull/183) Add missing operations on QSize +* [#189](https://github.com/python-qt-tools/PyQt5-stubs/pull/189) Fix QListWidget, QTreeWidget and QTableWidget so that their respective items are now optional in many places when used as argument or return value ## 5.15.2.0 ### Added From db515e729c4d4b8226c42a339a35643eaa9b1303 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Fri, 7 Jan 2022 17:34:45 +0100 Subject: [PATCH 417/421] Fix as suggested by @bluebird75 --- tests/qlineedit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qlineedit.py b/tests/qlineedit.py index 1bc6caf4..e24bbe34 100644 --- a/tests/qlineedit.py +++ b/tests/qlineedit.py @@ -2,6 +2,6 @@ from PyQt5.QtWidgets import QApplication, QLineEdit # test that QLineEdit.setText() accepts None as parameter -app = QApplication([]) +app = QApplication(['my_program', '-platform', 'offscreen']) edit = QLineEdit() edit.setText(None) From 36240cb821fd915ecc5c546e368e98e852a37b72 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Thu, 2 Sep 2021 12:13:15 +0200 Subject: [PATCH 418/421] Fixes annotation for QLineEdit to allow None as argument. --- PyQt5-stubs/QtWidgets.pyi | 2 +- tests/qlineedit.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/qlineedit.py diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index a03c8dcf..a221e461 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -7147,7 +7147,7 @@ class QLineEdit(QWidget): def undo(self) -> None: ... def selectAll(self) -> None: ... def clear(self) -> None: ... - def setText(self, a0: str) -> None: ... + def setText(self, a0: Optional[str]) -> None: ... def hasAcceptableInput(self) -> bool: ... def setInputMask(self, inputMask: str) -> None: ... def inputMask(self) -> str: ... diff --git a/tests/qlineedit.py b/tests/qlineedit.py new file mode 100644 index 00000000..1bc6caf4 --- /dev/null +++ b/tests/qlineedit.py @@ -0,0 +1,7 @@ +"""Tests for QLineEdit.""" +from PyQt5.QtWidgets import QApplication, QLineEdit + +# test that QLineEdit.setText() accepts None as parameter +app = QApplication([]) +edit = QLineEdit() +edit.setText(None) From 18fc87648f1f3fbae6ac75153d01f7806d4d38a8 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Thu, 2 Sep 2021 12:17:29 +0200 Subject: [PATCH 419/421] Added changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 394ea18f..f3d0302e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). detected by latest mypy 0.930 * [#183](https://github.com/python-qt-tools/PyQt5-stubs/pull/183) Add missing operations on QSize * [#189](https://github.com/python-qt-tools/PyQt5-stubs/pull/189) Fix QListWidget, QTreeWidget and QTableWidget so that their respective items are now optional in many places when used as argument or return value +* [#165](https://github.com/python-qt-tools/PyQt5-stubs/pull/165) allow `None` as argument for `QLineEdit.setText()` + ## 5.15.2.0 ### Added From 03e36409ec13b9bc7a6303a6612b0aa33034a219 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Thu, 2 Sep 2021 12:35:41 +0200 Subject: [PATCH 420/421] Fixes missing import. --- PyQt5-stubs/QtWidgets.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyQt5-stubs/QtWidgets.pyi b/PyQt5-stubs/QtWidgets.pyi index a221e461..161f6e0b 100644 --- a/PyQt5-stubs/QtWidgets.pyi +++ b/PyQt5-stubs/QtWidgets.pyi @@ -7147,7 +7147,7 @@ class QLineEdit(QWidget): def undo(self) -> None: ... def selectAll(self) -> None: ... def clear(self) -> None: ... - def setText(self, a0: Optional[str]) -> None: ... + def setText(self, a0: typing.Optional[str]) -> None: ... def hasAcceptableInput(self) -> bool: ... def setInputMask(self, inputMask: str) -> None: ... def inputMask(self) -> str: ... From 65f7b1980980d3713ddfe29a8a5ba6266182d676 Mon Sep 17 00:00:00 2001 From: TilmanK Date: Fri, 7 Jan 2022 17:34:45 +0100 Subject: [PATCH 421/421] Fix as suggested by @bluebird75 --- tests/qlineedit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qlineedit.py b/tests/qlineedit.py index 1bc6caf4..e24bbe34 100644 --- a/tests/qlineedit.py +++ b/tests/qlineedit.py @@ -2,6 +2,6 @@ from PyQt5.QtWidgets import QApplication, QLineEdit # test that QLineEdit.setText() accepts None as parameter -app = QApplication([]) +app = QApplication(['my_program', '-platform', 'offscreen']) edit = QLineEdit() edit.setText(None)