dataclasses-json
dataclasses-json copied to clipboard
[Bug]: Intellisense Not Working
I am using dataclasses-json
in my project. I am using the following sample code:
from dataclasses import dataclass
from dataclasses_json import dataclass_json
@dataclass_json
@dataclass(frozen=True)
class Minion:
name: str
minion = Minion("very evil minion")
minion.to_json()
However, the .to_json()
method is not in VSCode's intellisense. I cannot seem to understand why. Some of the fields provided by dataclass
decorator are there, however. Can anybody replicate?
It's written in the README that there is better support when subclassing DataClassJsonMixin
over using the decorator.
from dataclasses import dataclass
from dataclasses_json import DataClassJsonMixin
@dataclass
class Person(DataClassJsonMixin):
name: str
lidatong = Person('lidatong')
Hey @rpmcginty I found a really nice way around this: change https://github.com/lidatong/dataclasses-json/blob/39b4c2f4462282576d72a72ade048ef49e2133bb/dataclasses_json/api.py#L127 to
def _process_class(cls, letter_case, undefined) -> Type[DataClassJsonMixin]:
When I made this change locally, pycharm immediately recognized all the methods. I imagine VSCode will benefit similarly. I'd open a PR myself but you seem to know your way around this repo :-)
@PayemSaba , I say go for it and create a PR if you can get it working. I can help if you'd like.
Reopening this issue as https://github.com/lidatong/dataclasses-json/pull/411 has been reverted and it seems we don't have a good solution right now with the current API