You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently, we get an error when we define "discriminated union" for one field within BaseSettings, and use _env_file to construct the class which was working fine before.
(.venv_pydantic_settings_2_5_2) user@abehsu-us-vscode:~/abehsu/pydantic_testing$ python test.py
Traceback (most recent call last):
File "/home/user/abehsu/pydantic_testing/test.py", line 40, in <module>
result = Html(_env_file="/home/user/abehsu/pydantic_testing/test.env")
File "/home/user/abehsu/pydantic_testing/.venv_pydantic_settings_2_5_2/lib/python3.10/site-packages/pydantic_settings/main.py", line 152, in __init__
super().__init__(
File "/home/user/abehsu/pydantic_testing/.venv_pydantic_settings_2_5_2/lib/python3.10/site-packages/pydantic/main.py", line 212, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 2 validation errors for Html
contents__el_type
Extra inputs are not permitted [type=extra_forbidden, input_value='input', input_type=str]
For further information visit https://errors.pydantic.dev/2.9/v/extra_forbidden
contents__class_name
Extra inputs are not permitted [type=extra_forbidden, input_value='123', input_type=str]
For further information visit https://errors.pydantic.dev/2.9/v/extra_forbidden
Uh oh!
There was an error while loading. Please reload this page.
Hi All:
Recently, we get an error when we define "discriminated union" for one field within BaseSettings, and use _env_file to construct the class which was working fine before.
Enviroment
(.venv_pydantic_settings_2_5_2) user@jupyter:
/abehsu/pydantic_testing$ python --version/abehsu/pydantic_testing$ pip list | grep pydanticPython 3.10.12
(.venv_pydantic_settings_2_5_2) user@jupyter:
pydantic 2.9.2
pydantic_core 2.23.4
pydantic-settings 2.5.2
Error message
Code
==================================================
The same code can successfully if i use pydantic-settings 2.4.0 version.
After comparison, i find out it is because this line be added from last week's release (https://github.com/pydantic/pydantic-settings/blob/main/pydantic_settings/sources.py#L989) by this PR (287cb22), are there any suggestion?
https://github.com/pydantic/pydantic/blob/c9190eedd8c536cd1445876c4a078c29b04d3aa1/pydantic/_internal/_utils.py#L76-L82
The text was updated successfully, but these errors were encountered: