danielgtaylor / python-betterproto

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

warnings package not imported for deprecated warning. #239

Open jbkoh opened 3 years ago

jbkoh commented 3 years ago

Hi there, thanks for the great project!

My environment: betterproto: v2.0.0b3 python: v3.8.5 OS: Ubuntu 20.04

I use deprecated option in a message definition. betterproto generates a warnings.warn properly, but the warnings package is not imported, so it throws NameError: name 'warnings' is not defined. I manually add the line for now, but it'd be great if it can be fixed in the package.

Thanks!

Gobot1234 commented 2 years ago

To reprodue

syntax = "proto3";
message Foo {
  option deprecated = true;
  string old_field = 1;
}

seems like https://github.com/danielgtaylor/python-betterproto/blob/496eba27506a2fe18df409c4cd34a47d8ce04ffe/src/betterproto/plugin/models.py#L280 needs a case for if message.deprecated