-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
made pydantic change #1879
made pydantic change #1879
Conversation
Thanks for the PR but I'm sorry I don't quite understand the change here, this means that when you call |
Thanks for the reply! Sorry I was not as clear as I thought, this might be a bigger problem than I had originally looked at. So here is what was happening: Since "warnings is only supported in Pydantic V2" This would be correct I would want warnings to be set to False. The problem is the "if warnings != True:", since warning is False, raises the ValueError telling me that warnings cannot be true when I have Pydantic V1. So I changed that line so that if Pydantic is not V2 and warnings is True then raise the error about not being able to set warnings to True with Pydantic V1. After I made that change my code worked as intended and I no longer had issues. I just think that the statement is backwards because that if statement only runs if Pydantic is not V2 then only raises an error if warnings is set to not set True. Shouldn't it raise the error when the user is trying to use warnings in Pydantic V1? |
What |
I just updated to version 1.55.0 then ran the functions, and I got the same errors as before. So then I went back into _models.py and changed that if statement back to == True instead of != True. Which resolved the error again |
oh, can you open an issue with a minimal reproduction? |
I created that issue, here is the link: #1882 (comment) |
thanks, closing this in favour of a different fix! |
Changes being requested
In the model_dump_json method of the BaseModel class on line 365 the if statement was essentially set to always throw the ValueError if you have done what you are supposed to. I changed the "if warnings != True: -> raise ValueError" to "if warnings == True: -> raise ValueError" so now the code will properly handle when you have pydantic v1 and set your warnings to False.
Additional context & links