New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field
metadata from Annotated
is lost after a call to update_forward_refs
#3282
Comments
I reproduced your bug and debugged a little, and I 100% agree: the root of the problem is that the I tried to propose a fix here: #3283 |
It looks like this is now fixed in both v1 and v2 |
Whoa! Why was this issue closed without merging the fix?
reproducer is exactly the same:
throws but if we change the order of declarations, validation successfully loads the alias and test succeeds:
|
@dmontagu could you please reopen this issue, or should I probably file a new one? |
I'm not sure why I closed it, clearly it's still an issue. Apologies for that. |
@mshonichev I think I've got a fix for it ready in #7698 (at least for pydantic v2), thanks for bringing this to my attention again, and apologies for closing it before when it wasn't actually fixed. |
Also @mshonichev, I added a different test in #7698, but I can confirm that your snippet above does not error with the change in that PR. |
Checks
Bug
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:With the postponed evaluation of annotations enabled, the
Field
metadata seems to be lost after theupdate_forward_refs
call. Apart from that it seemed to be working fine, it parsed the JSON if the field name wasfoo
. I also tried theallow_mutation
argument, it was not working as well.Without the
from __future__ import annotations
import, all of the following worked:The text was updated successfully, but these errors were encountered: