-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[PYTHON] generate code based on pydantic v2 #16655
Conversation
Signed-off-by: ふぁ <[email protected]>
Signed-off-by: ふぁ <[email protected]>
Signed-off-by: ふぁ <[email protected]>
Signed-off-by: ふぁ <[email protected]>
Signed-off-by: ふぁ <[email protected]>
Signed-off-by: ふぁ <[email protected]>
Signed-off-by: ふぁ <[email protected]>
Signed-off-by: ふぁ <[email protected]>
Signed-off-by: ふぁ <[email protected]>
"__root__\n" | ||
" DanishPig expected dict not int (type=type_error)") | ||
" Input should be a valid dictionary or instance of BasquePig [type=model_type, input_value=1, input_type=int]\n" | ||
" For further information visit https://errors.pydantic.dev/2.3/v/model_type, 1 validation error for DanishPig\n" |
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.
It is not wise to include the document url in the test
Since pydantic v2.4.0 was released a few hours ago, the URL has changed and the test will fail
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.
agreed. we didn't take into consideration upgrading pydantic to newer version when writing the test. please feel free to revise the test
@@ -34,5 +34,8 @@ from pprint import pprint | |||
{{#vendorExtensions.x-py-postponed-example-imports}} | |||
{{{.}}} | |||
{{/vendorExtensions.x-py-postponed-example-imports}} | |||
{{classname}}.update_forward_refs() | |||
try: | |||
{{classname}}.{{#usePydanticV2}}model_rebuild{{/usePydanticV2}}{{^usePydanticV2}}update_forward_refs{{/usePydanticV2}}() |
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.
should use .model_rebuild(raise_errors=False)
instead of try
.
However, this is a stopgap measure and in practice should be implemented without using raise_errors
.
I spent a lot of time trying to rebuild without raise_errors
, but couldn't come up with a good solution.
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.
I think we can remove the usePydanticV2
switch the template and the java class as python
client generator now only supports pydantic v2.
I didn't use the usePydanticV2 flag 🙈
then I am receiving following error:
Python version: 3.11.5 |
Continue to #16685 |
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)