Ask Your Question

Support for 3.7 @dataclasses?

asked 2019-04-12 10:26:54 -0500

Ed W's avatar

updated 2019-04-13 07:34:06 -0500

Python introduced a new decorator "@dataclasses" in 3.7 Any chance in the future you'll support code completion for these? Currently Wing doesn't appear to recognize that valid attributes exist, and that when initializing a new object code completion does not indicate that parameters are required.

from dataclasses import dataclass

class Car:    
    make: str
    model: str
    year: int

car = Car("Datsun", "B210", 1970 )
print (car.make)

Thanks - Ed

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2019-04-14 17:42:44 -0500

Dataclasses will be supported in Wing 7. Attributes are partially supported, though there's a bug that omits them from autocomplete lists. That bug should be fixed soon and support for parameters in the constructor will be added in a future Wing 7 update.

edit flag offensive delete link more

answered 2022-01-25 11:42:22 -0500

CH's avatar

I'm also experimenting with dataclasses in WingPro and seem to have one of the the abovementioned issues. Is the feature not yet available or is there some way to enable auto-complete for dataclass constructors?

In other places I could use assert isinstance() to hint WingIde to the correct object type and use the attributes, but I don't see how I could do that with constructors?

Unfortunately I have to look up the definition of the dataclass while using the constructor, which makes the time save of the @dataclass descriptor a mute point. I might re-implement the init method just to get the auto-complete going.

Thanks, CH

edit flag offensive delete link more


Support for parameters in the constructor has not been implemented. We'll try to increase the priority on that.

Wingware Support's avatar Wingware Support  ( 2022-01-26 09:07:58 -0500 )edit

That would be great to have, since dataclasses are really awesome :)

KhazAkar's avatar KhazAkar  ( 2022-05-04 09:20:32 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-04-12 10:26:54 -0500

Seen: 1,160 times

Last updated: Jan 25 '22