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
v1.2 change in optional behaviour #1047
Comments
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? |
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. |
Better documentation of this in #1048, comment there if it's not okay, otherwise I'll release that update to the docs soon. |
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? |
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 |
Agreed. |
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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)
The text was updated successfully, but these errors were encountered: