Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Intellisense Not Working #402

Open
mahyarmirrashed opened this issue Feb 21, 2023 · 4 comments · Fixed by #411
Open

[Bug]: Intellisense Not Working #402

mahyarmirrashed opened this issue Feb 21, 2023 · 4 comments · Fixed by #411
Assignees
Labels
api/v0 bug Something isn't working

Comments

@mahyarmirrashed
Copy link

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?

@rpmcginty
Copy link
Contributor

rpmcginty commented Mar 3, 2023

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')

@PayemSaba
Copy link

Hey @rpmcginty I found a really nice way around this: change

def _process_class(cls, letter_case, undefined):

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 :-)

@mahyarmirrashed
Copy link
Author

@PayemSaba , I say go for it and create a PR if you can get it working. I can help if you'd like.

@george-zubrienko
Copy link
Collaborator

Reopening this issue as #411 has been reverted and it seems we don't have a good solution right now with the current API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api/v0 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants