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
Using model_construct on a model that has a field with AliasChoices for the validation_alias throws a TypeError exception. This issue is new to v2.7.0. Example code works with v2.6.4.
Traceback (most recent call last):
File "/home/bryan/src/temp/pydantic-regression/my.py", line 6, in <module>
FooBase.model_construct().dict()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/twispt/src/temp/pydantic-regression/.venv/lib/python3.11/site-packages/pydantic/main.py", line 228, in model_construct
elif field.validation_alias is not None and field.validation_alias in values:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'AliasChoices'
twispt
changed the title
TypeError in model_construct where field has a validation_alias with AliasChoices
v2.7.0 TypeError in model_construct where field has a validation_alias with AliasChoices
Apr 11, 2024
I am running into the same issue, and can confirm the code works on v2.6.4 but not on v2.7.0
in v2.6.4 i do not see a reference to field.validation_alias in model_consruct whereas the check occurs in v2.7.0
Initial Checks
Description
Using
model_construct
on a model that has a field with AliasChoices for thevalidation_alias
throws a TypeError exception. This issue is new tov2.7.0
. Example code works withv2.6.4
.Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: