First time here? Check out the FAQ!
1

Support for 3.7 @dataclasses?

Python introduced a new decorator "@dataclasses" in 3.7 https://www.python.org/dev/peps/pep-0557/ 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

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

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

Thanks - Ed

Ed W's avatar
13
Ed W
asked 2019-04-12 10:26:54 -0500
Wingware Support's avatar
4.1k
Wingware Support
updated 2019-04-13 07:34:06 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

1

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.

Wingware Support's avatar
4.1k
Wingware Support
answered 2019-04-14 17:42:44 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

I'm also experimenting with dataclasses in WingPro 8.1.2.1 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

CH's avatar
1
CH
answered 2022-01-25 11:42:22 -0500
edit flag offensive 0 remove flag delete link

Comments

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
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer