Usage of Field and BaseSettings, migration to v2 #7701
Replies: 3 comments 5 replies
-
As the |
Beta Was this translation helpful? Give feedback.
-
Anyone else has a clue here? Before, we were able to do this:
Where pydantic would take the |
Beta Was this translation helpful? Give feedback.
-
So, getting back to trying to migrate to pydantic v2, and still hitting this issue. I think it relates to this: https://docs.pydantic.dev/latest/concepts/pydantic_settings/#parsing-environment-variable-values
My issue being, BaseSettings really doesn't work at all if the type is not a BaseModel, and even simply inherit from
With the following .env:
It's quite bothersome (because of the added json around the value), and I'm not even sure how to make it work when variables are injected in the env file, like from a k8s config for example. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm trying to migrate our projects to pydantic v2, but have some issues in the Fields / BaseSettings usage (although it very likely relies around Field). The following used to work, but not any more, and I didn't find a correct way to fix this.
It fails complaining about the type of SOME_URL
I Have tried using Annotated without success
The only way that works, but that I'd like to avoid, is to instantiate the object in the Settings.
For some reason, the original code works if I use directly HttpUrl instead of the Url subclass.
Beta Was this translation helpful? Give feedback.
All reactions