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

[Feature request] [VS Code] No auto complete when using pydantic.dataclasses.dataclass #4006

Closed
giuliano-macedo opened this issue Apr 24, 2022 · 3 comments · Fixed by #4007
Closed

Comments

@giuliano-macedo
Copy link
Contributor

giuliano-macedo commented Apr 24, 2022

Feature request

Similar to the issue that #2721 solves, VS Code can't auto complete models constructor parameters when using pydantic.dataclasses.dataclass.

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

             pydantic version: 1.9.0
            pydantic compiled: True
                 install path: /tmp/hello-world/.venv/lib/python3.10/site-packages/pydantic
               python version: 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0]
                     platform: Linux-5.10.105-1-MANJARO-x86_64-with-glibc2.35
     optional deps. installed: ['typing-extensions']

Example Code:

import pydantic
from pydantic.dataclasses import dataclass

@dataclass
class Hello:
    n: int
    s: str

hello = Hello(n=1, s="a")
hello.n

VS Code:

pydantic-bug-2022-04-24_09.29.26.mp4

Workaround:

You can import python pure dataclass instead of pydantic's dataclass when type checking, as stated by @JosXa here:

from pydantic.dataclasses import dataclass
from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from dataclasses import dataclass
else:
    from pydantic.dataclasses import dataclass as dataclass
@giuliano-macedo giuliano-macedo added the bug V1 Bug related to Pydantic V1.X label Apr 24, 2022
@giuliano-macedo giuliano-macedo changed the title [VS Code] No auto completion when using pydantic.dataclasses.dataclass [Bug] [VS Code] No auto completion when using pydantic.dataclasses.dataclass Apr 24, 2022
@samuelcolvin
Copy link
Member

There is not bug in pydantic described here.

@giuliano-macedo
Copy link
Contributor Author

@samuelcolvin Are you sure? it's simillar to the issue that this PR solves: #2721

Or you mean this issue should be a feature request? ( I was undecided about this when creating this issue sry)

@samuelcolvin
Copy link
Member

Maybe it's the same as #2721. There was m really wasn't enough detail on the issue.

Either way, it's a feature request.

@samuelcolvin samuelcolvin reopened this Apr 24, 2022
@samuelcolvin samuelcolvin added feature request and removed bug V1 Bug related to Pydantic V1.X labels Apr 24, 2022
@giuliano-macedo giuliano-macedo changed the title [Bug] [VS Code] No auto completion when using pydantic.dataclasses.dataclass [Feature request] [VS Code] No auto completion when using pydantic.dataclasses.dataclass Apr 24, 2022
@giuliano-macedo giuliano-macedo changed the title [Feature request] [VS Code] No auto completion when using pydantic.dataclasses.dataclass [Feature request] [VS Code] No auto complete when using pydantic.dataclasses.dataclass Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants