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

Autocompletion not working in VS Code with Pydantic #9175

Closed
1 task done
holyoaks opened this issue Apr 5, 2024 · 7 comments
Closed
1 task done

Autocompletion not working in VS Code with Pydantic #9175

holyoaks opened this issue Apr 5, 2024 · 7 comments
Labels
bug V2 Bug related to Pydantic V2

Comments

@holyoaks
Copy link

holyoaks commented Apr 5, 2024

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

I followed the instructions at https://docs.pydantic.dev/latest/integrations/visual_studio_code/#configure-vs-code but no matter what I do, I do not get autocompletion. I'm using Pylance (as noted in the docs, the default) as my language server, and can confirm Pydantic ==2.6.4 is installed in my virtual environment that VS Code is using. When I enable basic | standard | strict type checking in VS Code, I DO get type checking, but I always get BaseModelSubclass(**data) as the autocomplete for all of my Pydantic BaseModel subclasses. What might be wrong here?

Example Code

No response

Python, Pydantic & OS Version

pydantic version: 2.6.4
        pydantic-core version: 2.16.3
          pydantic-core build: profile=release pgo=false
                 install path: /var/www/venv/lib/python3.11/site-packages/pydantic
               python version: 3.11.6 (main, Oct  8 2023, 05:06:43) [GCC 13.2.0]
                     platform: Linux-6.6.16-linuxkit-aarch64-with-glibc2.38
             related packages: fastapi-0.110.0 email-validator-2.0.0 typing_extensions-4.10.0
                       commit: unknown
@holyoaks holyoaks added bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation labels Apr 5, 2024
@sydney-runkle
Copy link
Member

@holyoaks,

Thanks for reporting. I'm not sure what the issue is - maybe someone else from the community has experienced this problem / has a fix? Can leave this open for now 👍

@sydney-runkle sydney-runkle removed the pending Awaiting a response / confirmation label Apr 9, 2024
@Viicos
Copy link
Contributor

Viicos commented Apr 15, 2024

but I always get BaseModelSubclass(**data) as the autocomplete for all of my Pydantic BaseModel subclasses

Could you share a screenshot of what you get in VSCode?

@holyoaks
Copy link
Author

A better one
Screenshot 2024-04-15 at 3 28 59 PM

@Viicos
Copy link
Contributor

Viicos commented Apr 16, 2024

Interesting, it shows the signature of BaseModel and not Test 🤔

I see a warning on your BaseModel import, what is it saying? I'm guessing you are already on the latest version of Pylance, but could you also give your current version?

@holyoaks
Copy link
Author

holyoaks commented Apr 16, 2024

@Viicos That's simply a Ruff warning (Import block is un-sorted or un-formatted Ruff I001; I had not yet saved the file when I made the screenshot. My version of Pylance is v2024.4.1

@holyoaks
Copy link
Author

As of today, without any changes on my part (that I'm aware of) the autocompletion started working. I have no idea.

@sydney-runkle
Copy link
Member

Haha, ok! Marking as resolved then. Thanks @holyoaks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V2 Bug related to Pydantic V2
Projects
None yet
Development

No branches or pull requests

3 participants