danielgtaylor / python-betterproto

Clean, modern, Python 3.6+ code generator & library for Protobuf 3 and async gRPC
MIT License
1.56k stars 218 forks source link

Snake casing WORD regex mistakingly splitting lowercase mixed-digit field names #262

Open michael-sayapin opened 3 years ago

michael-sayapin commented 3 years ago

Proto file:

message BadRegexTestMessage {
  uint64 ds18b20_serial_code = 1;
}

Result:

class BadRegexTestMessage(betterproto.Message):
    ds18_b20_serial_code: int = betterproto.uint64_field(1)

ds18b20 becomes ds18_b20.

michael-sayapin commented 3 years ago

A proposed fix would be changing WORD = "[A-Z]*[a-z]*[0-9]*" for WORD = "[A-Z]*[a-z0-9]*".