-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Change Pydantic from_orm to model_validate (#284) #285
Change Pydantic from_orm to model_validate (#284) #285
Conversation
…e related to Forecast model (#284)
…lue models (#284) Updated from_orm class method in Forecast and ForecastValue models, so they call model_validate instead of the deprecated from_orm method. Created a class method model_validate in Forecast and ForecastValue models, so they work as from_orm class methods worked.
Updated Forecast and ForecastValue models from_orm call to model_validate call.
Updated Forecast and ForecastValue models from_orm call to model_validate call.
Created model_validate_latest method that does the same thing as from_orm_latest. So it is consistent to the syntax of pydantic V2
…st and ForecastValue models
for more information, see https://pre-commit.ci
Hello, The tests failed because I use "from_attributes: bool | None = None" typing annotation, as I assumed the project used python >= 3.10. I can change that annotation for compatibility issues if it is not the case. |
Thanks so much for this, really helpful doing all this. |
Pull Request
Description
This PR refers to the issue #284 : from_orm method is deprecated in pydantic V2
I updated the models and tests that called the deprecated pydantic method from_orm. They now call model_validate as advised in the Pydantic migration guide.
The Forecast and ForecastValue models had methods that overwrote the pydantic from_orm method. I leaved those methods in the models, but they now call model_validate instead of from_orm. I also created model_validate methods for those classes, having the same behavior as calling from_orm.
How Has This Been Tested?
I tested via the test framework as seen in the readme file. As the modification are minors, it should be enough.
Checklist: