Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upv1.2 change in optional behaviour #1047
Comments
This comment has been minimized.
This comment has been minimized.
Thanks for reporting and sorry about creating the regression. We should have noticed this. I suspect that releasing #1031 as part of a patch release was a mistake. It should have been part of v2. There are two problems here: change in optional behaviourThe meaning of create_modelThis has affected I don't see a sensible work around here without more breaking changes. I think the best solution is to use fields = {'field1': (str, ...), 'field2': (Optional[str], None)} Which is presumably the behaviour you want? |
This comment has been minimized.
This comment has been minimized.
In summary I think the best we can do here is better documentation. If anyone disagrees and has any clever suggestions of workarounds, please let us know. |
This comment has been minimized.
This comment has been minimized.
Better documentation of this in #1048, comment there if it's not okay, otherwise I'll release that update to the docs soon. |
This comment has been minimized.
This comment has been minimized.
Agreed I think it would be pretty easy to add support for single-element tuples provided to It wouldn't mitigate the need to change code to make create_model work as it did before for optional fields (since Thoughts? |
This comment has been minimized.
This comment has been minimized.
I agree it would be more consistent and a good idea. It won't cause a regression, but it also won't solve this one. Ultimately we will change the behavior of |
This comment has been minimized.
This comment has been minimized.
Agreed. |
from @bartv on #990
It seems that this change caused a regression in the latest release. The behavior between static and dynamic classes is different now.
With pydantic 1.1.1 both test cases succeed, with pydantic 1.2 the dynamic test case fails.
Is this expected? Based on the changelog and the documentation I am inclined to think it is not. Should I open a separate bug?
Originally posted by @bartv in #990 (comment)