-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Consider this example:
from magicgui.experimental import guiclass
@guiclass
class MyDataclass:
number: int = 0
if __name__ == '__main__':
obj = MyDataclass()
obj.gui.show(run=True)
Running pyright widget.py
gives:
widget.py:10:9 - error: Cannot access member "gui" for type "MyDataclass"
Member "gui" is unknown (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations
Obviously the type checker can't know about the gui
field that gets added to the class.
If you are interested in suggestions, dataclass_transform
can be used on a class not just a function, which allows you to create a superclass that has a gui
property or field but also acts like a dataclass:
from magicgui.experimental import GuiClass
class MyDataclass(GuiClass):
...
Metadata
Metadata
Assignees
Labels
No labels