Describe the bug
If you use the PyCharm-provided auto-completion in a model config, this produces a SyntaxError in the code as the import for Extra
is missing.
To Reproduce
class M(pydantic.BaseModel):
class Config:
ext
Trigger and perform the auto-completion.
Expected behavior
The plugin adds the import if there is no import so far.
If pydantic is imported in another way already, the plugin adds the appropriate import, like in the examples below
# import is already present
import pydantic
class M(pydantic.BaseModel):
class Config:
extra = pydantic.Extra.ignore
# alias import
import pydantic as p
class M(pydantic.BaseModel):
class Config:
extra = p.Extra.ignore
Environments (please complete the following information):
Additional context
Add any other context about the problem here.
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