Open mikhainin opened 1 week ago
This is something that we do to make your code pythonic. You may be interested in #570
From what I understood, this happens in the snake_case()
function. I could think of 2 ways how the experience can be improved:
use_strict_field_naming
) to change the behaviourstrict=False
to the function when generating the field name
patch-v1-define-snake-strictinness-via-cli-arg.patch
patch-v2-use-non-strict-case-when-generate-field.patch
Summary
Double underscore breaks existing code
Reproduction Steps
When we try compiling the following proto-file, the field
field__json
becomesfield_json
Expected Results
If we build the same code with betterproto v1, or with the standard compiler (
python -m grpc_tools.protoc --python_out=src --pyi_out=src src/test.proto
) the field name will remain unchanged.Not only does this break current code, but this will also impact how a dict/JSON is being generated based on the data class/structure.
I would imagine this behaviour as unwanted and if we want to sanitize filed name, I think it would be better to do in the original proto-file (e.g. using tools like
buf
).Actual Results
above
System Information
Checklist
pip install -U --pre betterproto
, if possible.