Pydantic: How do I get field level autocompletion in IDEs?

Created on 18 Feb 2020  路  3Comments  路  Source: samuelcolvin/pydantic

Question

How do I get field level autocompletion in IDEs?

For example, when using pydantic in VSCode, the following code snippet shows **data: Any which are the params for __init__ on BaseModel

from pydantic import BaseModel

class MyModel(BaseModel):
    name: str
    age: int

my_model_obj = MyModel()

Maybe i'm missing something, but would love to have autompletion for name and age.

image

I understand that the IDE will provide completion for BaseModels init params, which is **data but thought that i'd ask incase i'm missing something here.

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

             pydantic version: 1.4
            pydantic compiled: False
                 install path: ~/.venv/dummyenv/lib/python3.7/site-packages/pydantic
               python version: 3.7.4 (default, Sep  7 2019, 18:27:02)  [Clang 10.0.1 (clang-1001.0.46.4)]
                     platform: Darwin-19.2.0-x86_64-i386-64bit
     optional deps. installed: ['typing-extensions', 'email-validator']
question

Most helpful comment

There is a pydantic plugin you can use with PyCharm that will enable this (you can find it by searching in the plugin marketplace).

I don't think anyone has done this for VSCode, and I'm not sure what it looks like to write a VSCode plugin, but it would certainly be appreciated!

All 3 comments

There is a pydantic plugin you can use with PyCharm that will enable this (you can find it by searching in the plugin marketplace).

I don't think anyone has done this for VSCode, and I'm not sure what it looks like to write a VSCode plugin, but it would certainly be appreciated!

https://pydantic-docs.helpmanual.io/pycharm_plugin/

If anyone wants the challenge of building a vscode plugin we would be happy to link to it from the docs as we do for the pycharm plugin.

Thank you for the quick response!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

samuelcolvin picture samuelcolvin  路  3Comments

timonbimon picture timonbimon  路  3Comments

dmontagu picture dmontagu  路  3Comments

mgresko picture mgresko  路  3Comments

sommd picture sommd  路  3Comments