-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyqtProperty setter always raises an error #9911
Comments
On the Qt mailing-list someone already posted these two links to the mypy source-code: mypy has some special casing to make pythons EDIT: |
The way to do that without baking knowledge of qt into mypy is to write a mypy extension. |
Should the plugin hook I suggested in #9915 get added to mypy you could solve this using the following mypy plugin (function and class names subject to change): from typing import Callable, Optional
from typing import Type
from mypy.plugin import (
Plugin, DecoratorContext,
)
def plugin(version: str) -> Type[Plugin]:
return PyQt5Plugin
class PyQt5Plugin(Plugin):
"""PyQt5 Plugin"""
def get_decorator_hook(self, fullname: str
) -> Optional[Callable[[DecoratorContext], None]]:
if fullname == 'PyQt5.QtCore.pyqtProperty':
return pyqt_property_callback
return None
def pyqt_property_callback(ctx: DecoratorContext):
ctx.decorator.func.is_property = True |
Get rid of uwsift/control/qml_utils.py:87: error: Name "layerModel" already defined on line 83 [no-redef] uwsift/control/qml_utils.py:96: error: Name "convFuncModel" already defined on line 92 [no-redef] uwsift/control/qml_utils.py:132: error: Name "layerToDisplay" already defined on line 127 [no-redef] uwsift/control/qml_utils.py:144: error: Name "dateToDisplay" already defined on line 137 [no-redef] uwsift/control/qml_utils.py:221: error: Property "timestamps" defined in "TimebaseModel" is read-only [misc] uwsift/control/qml_utils.py:222: error: Cannot assign to a method [assignment] uwsift/control/qml_utils.py:222: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[..., Any]") [assignment] uwsift/control/qml_utils.py:243: error: Name "currentTimestamp" already defined on line 239 [no-redef] uwsift/control/qml_utils.py:261: error: Name "timestamps" already defined on line 248 [no-redef] uwsift/control/qml_utils.py:261: error: "Callable[[TimebaseModel], Any]" has no attribute "setter" [attr-defined] by - ignoring false positives for pyqtProperty setters, see python/mypy#9911 - Avoiding to initialize variable with None which can also be initialized with something more useful right away.
Bug Report
It seems that Mypy is not enjoying
pyqtProperty
setters. Someone already asked on the Qt mailing-list.To Reproduce
Expected Behavior
Mypy should be happy.
Actual Behavior
Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: