From e9957b68479754a65da4028e82b57360cb932e2a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 4 May 2020 18:26:10 +0200 Subject: [PATCH] Fix 'None' syntax error --- PyQt5-stubs/Qt3DAnimation.pyi | 2 +- PyQt5-stubs/Qt3DRender.pyi | 12 ++++++------ PyQt5-stubs/QtQuick.pyi | 2 +- issues.md | 22 ++++++++++++++++++++++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/PyQt5-stubs/Qt3DAnimation.pyi b/PyQt5-stubs/Qt3DAnimation.pyi index fb2197e4..6169ed8a 100644 --- a/PyQt5-stubs/Qt3DAnimation.pyi +++ b/PyQt5-stubs/Qt3DAnimation.pyi @@ -331,7 +331,7 @@ class Qt3DAnimation(sip.simplewrapper): class QKeyframeAnimation('QAbstractAnimation'): class RepeatMode(int): ... - None = ... # type: 'QKeyframeAnimation.RepeatMode' + None_ = ... # type: 'QKeyframeAnimation.RepeatMode' Constant = ... # type: 'QKeyframeAnimation.RepeatMode' Repeat = ... # type: 'QKeyframeAnimation.RepeatMode' diff --git a/PyQt5-stubs/Qt3DRender.pyi b/PyQt5-stubs/Qt3DRender.pyi index 9985a51c..e0aaed9f 100644 --- a/PyQt5-stubs/Qt3DRender.pyi +++ b/PyQt5-stubs/Qt3DRender.pyi @@ -244,7 +244,7 @@ class Qt3DRender(sip.simplewrapper): TargetBuffer = ... # type: 'QAbstractTexture.Target' class Status(int): ... - None = ... # type: 'QAbstractTexture.Status' + None_ = ... # type: 'QAbstractTexture.Status' Loading = ... # type: 'QAbstractTexture.Status' Ready = ... # type: 'QAbstractTexture.Status' Error = ... # type: 'QAbstractTexture.Status' @@ -721,7 +721,7 @@ class Qt3DRender(sip.simplewrapper): class QClearBuffers('QFrameGraphNode'): class BufferType(int): ... - None = ... # type: 'QClearBuffers.BufferType' + None_ = ... # type: 'QClearBuffers.BufferType' ColorBuffer = ... # type: 'QClearBuffers.BufferType' DepthBuffer = ... # type: 'QClearBuffers.BufferType' StencilBuffer = ... # type: 'QClearBuffers.BufferType' @@ -1140,7 +1140,7 @@ class Qt3DRender(sip.simplewrapper): class QMemoryBarrier('QFrameGraphNode'): class Operation(int): ... - None = ... # type: 'QMemoryBarrier.Operation' + None_ = ... # type: 'QMemoryBarrier.Operation' VertexAttributeArray = ... # type: 'QMemoryBarrier.Operation' ElementArray = ... # type: 'QMemoryBarrier.Operation' Uniform = ... # type: 'QMemoryBarrier.Operation' @@ -1181,7 +1181,7 @@ class Qt3DRender(sip.simplewrapper): class QMesh('QGeometryRenderer'): class Status(int): ... - None = ... # type: 'QMesh.Status' + None_ = ... # type: 'QMesh.Status' Loading = ... # type: 'QMesh.Status' Ready = ... # type: 'QMesh.Status' Error = ... # type: 'QMesh.Status' @@ -1663,7 +1663,7 @@ class Qt3DRender(sip.simplewrapper): CameraLensComponent = ... # type: 'QSceneLoader.ComponentType' class Status(int): ... - None = ... # type: 'QSceneLoader.Status' + None_ = ... # type: 'QSceneLoader.Status' Loading = ... # type: 'QSceneLoader.Status' Ready = ... # type: 'QSceneLoader.Status' Error = ... # type: 'QSceneLoader.Status' @@ -2193,7 +2193,7 @@ class Qt3DRender(sip.simplewrapper): class QTextureImage('QAbstractTextureImage'): class Status(int): ... - None = ... # type: 'QTextureImage.Status' + None_ = ... # type: 'QTextureImage.Status' Loading = ... # type: 'QTextureImage.Status' Ready = ... # type: 'QTextureImage.Status' Error = ... # type: 'QTextureImage.Status' diff --git a/PyQt5-stubs/QtQuick.pyi b/PyQt5-stubs/QtQuick.pyi index 0d554318..65335a07 100644 --- a/PyQt5-stubs/QtQuick.pyi +++ b/PyQt5-stubs/QtQuick.pyi @@ -1380,7 +1380,7 @@ class QSGTexture(QtCore.QObject): Anisotropy16x = ... # type: 'QSGTexture.AnisotropyLevel' class Filtering(int): ... - None = ... # type: 'QSGTexture.Filtering' + None_ = ... # type: 'QSGTexture.Filtering' Nearest = ... # type: 'QSGTexture.Filtering' Linear = ... # type: 'QSGTexture.Filtering' diff --git a/issues.md b/issues.md index cf255bf1..ae82c399 100644 --- a/issues.md +++ b/issues.md @@ -273,3 +273,25 @@ def Q_FLAGS(*a0) -> None: ... Add type annotation of type `typing.Any`. This should be fixed in the original PyQt5 stubs. + +## #7 Can't assign to keyword + +### Description + +When "None" is used as an enum member, mypy will fail. + +### Example + +```python +class RepeatMode(int): ... +None = ... # type: 'QKeyframeAnimation.RepeatMode' +``` + +**mypy error:** +`error: can't assign to keyword` + +### Solution + +Rename `None` to `None_`. + +This should be fixed in the original PyQt5 stubs -> [Reported upstream](https://www.riverbankcomputing.com/pipermail/pyqt/2020-May/042878.html)