python-language-server
                                
                                 python-language-server copied to clipboard
                                
                                    python-language-server copied to clipboard
                            
                            
                            
                        Support @dataclass classes
Classes decorated as @dataclass get a slew of methods added to them, which we currently cannot detect: https://docs.python.org/3/library/dataclasses.html
For 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 like namedtuple 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.
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 __blah members before normal members), but type hints don't always show when hovering over a member name (but a member is consistent; it either shows the type or doesn't).
Like this:

Here^ I was hovering over dirs in app.dirs. app's type is correctly inferred and shows on hover, its members show in autocomplete, but members' types don't show on hover.
https://github.com/Microsoft/vscode-python/issues/3598 discovered that dataclasses currently have their attributes flagged as use-before-def. Do you want that reported as a separate issue?
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 __pycache__.
@alphacentauri12, what do you add to the docstring? full definition of the args used?