python-betterproto icon indicating copy to clipboard operation
python-betterproto copied to clipboard

Missing betterproto_lib_google_protobuf import if only used as rpc call parameter.

Open dries007 opened this issue 3 years ago • 1 comments

I'm using 2.0.0b5.

The following file results in broken python:

syntax = "proto3";

package experiment;

import "google/protobuf/empty.proto";

message Reply {
    bool happy = 1;
}

service Testcase {
  rpc call(google.protobuf.Empty) returns (Reply);
}

Specifically, the import import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf is missing from the output file.

When any google.protobuf imported field is used anywhere else, it does work correctly, for example, the following files all work:

syntax = "proto3";

package experiment;

import "google/protobuf/empty.proto";

message Reply {
    bool happy = 1;
}

service Testcase {
  rpc call(Reply) returns (google.protobuf.Empty);
}
syntax = "proto3";

package experiment;

import "google/protobuf/empty.proto";

message Reply {
    bool happy = 1;
    google.protobuf.Empty e = 2;
}

service Testcase {
  rpc call(google.protobuf.Empty) returns (Reply);
}

dries007 avatar Aug 18 '22 13:08 dries007

Might be related, seems to be a similar case of parameter/input not being added to imports https://github.com/danielgtaylor/python-betterproto/issues/426

adriangaro avatar Sep 27 '22 15:09 adriangaro