Describe the bug
Even though from pydantic import BaseModel
(in Pydantic v1 and v2) is supported, the import from pydantic.v1 import BaseModel
does not seem to be supported by the Plugin
To Reproduce
Steps to reproduce the behavior:
from pydantic import BaseModel
class Person(BaseModel):
first_name: str
last_name: str
john = Person() # Test position 1
from pydantic.v1 import BaseModel
class Person2(BaseModel):
first_name: str
last_name: str
john2 = Person2() # Test position 2
john
and john2
) and press the key bind for basic code completion (Ctrl + Space)Expected behavior
Parameter info and basic code completion for child classes of pydantic.v1.BaseModel - Behavior just like for Pydantic v1 and v2
Screenshots
Unexpected behavior / Bug:
Expected behavior:
Environments (please complete the following information):
Additional context
We are in the transition of our python package from pydantic v1 to pydantic v2. As suggested in the migration guide , we are using
from pydantic.v1 import BaseModel
Unfortunately, the parameter info and basic code completion, available with BaseModel (imported via from pydantic import BaseModel
from Pydantic v1 or v2), are not available anymore.
Temporary / Hacky workaround
For type checking to work in VS Code, we have created a decorator:
if TYPE_CHECKING:
from dataclasses import dataclass as _basemodel_decorator
from pydantic import BaseModel # Added line
else:
_basemodel_decorator = lambda x: x # noqa: E731
I have added a line to this decorator, with which the Pydantic Plugin works again, but the code checker outputs deprecation warning and other error associated with the migration from Pydantic v1 to v2.
I don't know if this is overly complex to fix / implement, but I would be incredibly happy to be able to use this awesome Plugin for our python package again!
Best regards, Lukas
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too