python-betterproto
python-betterproto copied to clipboard
Enum Prefix is not stripped
According to the Style Guide, protobuf enums should have the enum name as a prefix for all enum values, to avoid naming conflicts in languages like C, where all values from all enums are in the global namespace. Protobuf compilers for languages with scoped enums like C# will strip these prefixes if they match the enum name. Since enums in betterproto are scoped as well, these prefixes should be stripped.
Example:
enum ArithmeticOperator {
ARITHMETIC_OPERATOR_NONE = 0;
ARITHMETIC_OPERATOR_PLUS = 1;
ARITHMETIC_OPERATOR_MINUS = 2;
}
should become
class ArithmeticOperator(betterproto.Enum):
NONE = 0
PLUS = 1
MINUS = 2
so that we can use it as
if something.operator == ArithmeticOperator.PLUS:
do_addition()
instead of
if something.operator == ArithmeticOperator.ARITHMETIC_OPERATOR_PLUS:
do_addition()
I'm happy to make a PR for this
This should be fixed by #187 :)
This his a huge deal for my team. Can we have an ETA?
Thanks the the meantime I've been using your branch @Gobot1234 with no issues
Should be soon hopefully I just needed a re-review from Nat.