protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format

Home Page:http://protobuf.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Python] Generate trailing underscore for fields that shadow reserved keywords

noahseger opened this issue · comments

What language does this apply to?
Python

Describe the problem you are trying to solve.

Fields named, for example from, are inaccessible because they shadow the Python keyword.

https://stackoverflow.com/a/30145419

Describe the solution you'd like
Additionally (backwards compatible) generate a field named like from_ in the Python protoc and PYI protoc.

This convention is documented in PEP8:

single_trailing_underscore_: used by convention to avoid conflicts with Python keyword, e.g.

https://peps.python.org/pep-0008/#descriptive-naming-styles

Describe alternatives you've considered
getattr/setattr hacks.

Additional context
N/A