-
Notifications
You must be signed in to change notification settings - Fork 12.2k
pydantic : replace uses of __annotations__ with get_type_hints #8474
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
Conversation
Thanks! Confirmed On Ubuntu 22.04.4 with python 3.10, it still fails but I don't know if it's worth fixing.
I added a print and it happens on |
Weird, since I've used Python 3.11.9 on NixOS in my tests.
I can confirm I get the same error with Python 3.9.2 in a Debian 11 container. So this means it works for Python 3.11 and 3.12, but fails for Python 3.9 and 3.10. (I wonder if it also failed previously, e.g. on commit a8db2a9, right before #8341 was merged (EDIT: Yes, it DID fail before too, at least with Python 3.9)) I'll try to investigate the cause. |
Confirmed on python 3.10.12. Thanks a lot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non owner approval
…org#8474) * pydantic : replace uses of __annotations__ with get_type_hints * pydantic : fix Python 3.9 and 3.10 support
This should fix #8471.
The problem was triggered in #8341 by adding this specific line:
https://github.com/ggerganov/llama.cpp/blob/17eb6aa8a992cda37ee65cf848d9289bd6cad860/examples/pydantic_models_to_grammar_examples.py#L2
This uncovered the existing problem in
examples/pydantic_models_to_grammar.py
of directly usingobj.__annotations__
instead of usingtyping.get_type_hints
as suggested in PEP563.I've tested the script with
Qwen2-0.5B-Instruct
.There is no longer an error.