-
Notifications
You must be signed in to change notification settings - Fork 5
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
Optional fields do not generate correct defaults in Pydantic #22
Comments
Thanks for the feedback, I will fix this in version 0.2.0.1. |
…orrect-defaults-in-pydantic Modify, Fix, fix #22
@so1n There's another bug created that's caused by the fix. For fields such as:
It now generates this:
which is not allowed in Pydantic. You cannot have default_factory and a default. |
Please provide the Protobuf file or Message, I can't reproduce the problem at the moment |
@so1n Here it is:
Output:
It doesn't happen if you only have a single repeated field |
Describe the bug
A clear and concise description of what the bug is.
Using proto v3
Marking a field as optional in Proto doesn't seem to change anything in the generated Pydantic model.
To Reproduce
.proto
Output:
Expected behavior
This is the expected output:
Note that without setting
default = None
in Pydantic, it's impossible to constructB()
with no args. You have to construct it viaB(a=None)
.The text was updated successfully, but these errors were encountered: