Non-functional code gets generated when a message field is named request
Reproduction Steps
Have a message field named request in your protofile, and use betterproto to generate the Python stubs.
Expected Results
A correct, working code is generated. One possible solution would be to auto-generate a variable name that does not collide with any of the argument names.
Clearly not intentionally, the local variable request overwrites the function argument request, which leads to a circular reference and a crash during serialization.
System Information
I don't use protoc, I compile using buf.
❯ buf --version
1.45.0
❯ python --version
Python 3.12.7
❯ pip show betterproto
Name: betterproto
Version: 1.2.5
Summary: A better Protobuf / gRPC generator & library
Home-page: http://github.com/danielgtaylor/python-betterproto
Author: Daniel G. Taylor
Author-email: danielgtaylor@gmail.com
License: MIT
Requires: grpclib, stringcase
Checklist
[X] I have searched the issues for duplicates.
[X] I have shown the entire traceback, if possible.
[X] I have verified this issue occurs on the latest prelease of betterproto which can be installed using pip install -U --pre betterproto, if possible.
Summary
Non-functional code gets generated when a message field is named
request
Reproduction Steps
Have a message field named
request
in your protofile, and usebetterproto
to generate the Python stubs.Expected Results
A correct, working code is generated. One possible solution would be to auto-generate a variable name that does not collide with any of the argument names.
Actual Results
A code similar to this is generated:
Clearly not intentionally, the local variable
request
overwrites the function argumentrequest
, which leads to a circular reference and a crash during serialization.System Information
I don't use
protoc
, I compile usingbuf
.Checklist
pip install -U --pre betterproto
, if possible.