pylance-release
pylance-release copied to clipboard
Support dataclasses
Python and pydantic dataclasses
support would be great, since at the moment (at least in strict mode) pylance complains about use of named parameters in dataclass __init__
functions:
@dataclass
class MyClass:
a: str
b: str
MyClass(a="Hello", b="World!")
^^^^^^^^^^^^^^^^^^^^^
Error: Expected 0 positional argumentsPylance[reportGeneralTypeIssues](https://github.com/microsoft/pylance-release/blob/main/DIAGNOSTIC_SEVERITY_RULES.md#diagnostic-severity-rules)
I understand that __init__
is generated in runtime, however, I think dataclasses are used often enough, so we could try to come up with some kind of workaround.
Pyright (the static type checker that underlies pylance) already provides support for stdlib dataclasses. It also supports most functionality for pydantic dataclasses. If you are using pydantic, please verify that you have an up-to-date version installed, as older versions of pydantic will not work. I suspect that's why you're seeing the problem you're reporting here.
I had this issue before when the python extensions became deprecated and moved to official Microsoft. Currently I face no such issue with dataclasses.
Closing old issue. Presuming updating Pydantic worked. If this is still a problem, please reopen with the information requested. thanks