-
Notifications
You must be signed in to change notification settings - Fork 133
Support @dataclass classes #399
Comments
One point for completely 'vanilla' dataclasses: Initialized variables of a dataclass type offer correct completions (usually even better sorted than completions for a manually-created class with the same members, which can show several Here^ I was hovering over |
microsoft/vscode-python#3598 discovered that dataclasses currently have their attributes flagged as |
No, that's probably #395. The new LS hasn't reimplemented that diagnostic yet, either way, so I'd be hoping to implement it without these bugs (in a less hacky way). |
Hi, any idea if there's any progress on this? jedi (in vscode) has pretty good support for it (dataclass autocomplete). Perhaps you can look at their solution for inspiration? |
@jakebailey I also had this problem and I think I might have solved it by adding a docstring. If it is still not working delete the folder |
@alphacentauri12, what do you add to the docstring? full definition of the args used? |
Uh oh!
There was an error while loading. Please reload this page.
Classes decorated as
@dataclass
get a slew of methods added to them, which we currently cannot detect: https://docs.python.org/3/library/dataclasses.htmlFor example, if I declared a
Point
class as a dataclass, I'd expect to see some extra info when trying to instantiate one:It should look the same as:
(Where I've explicitly defined
__init__
as the Python docs do.)Unfortunately, it's not as simple as "see
@dataclass
, add these methods", since the decorator allows for customizing which methods get added. I expect this will need to operate a lot likenamedtuple
and need to look at the call to determine what to add. Also note the rules like "if__init__
exists, it's not overridden" which will need to be considered.The text was updated successfully, but these errors were encountered: