danielgtaylor / danielgtaylor/python-betterproto
Import not generated for package/module if only referenced in service declaration.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
As a basic example I have the below, the generated service will not import the `test` package, however if i reference any message in the return it imports it correctly.
```syntax = "proto3";
package test;
import "test2.proto";
message TestMessage {}
service Test {
rpc test(test2.DemoRequest) returns (TestMessage);
}
```
From a shallow look seems to stem from the `ServiceMethodCompiler.__post_init__` method. The return type is referenced using `py_output_message_type` which calls `get_type_reference` which adds it to imports, however nowhere in the `__post_init__` is the input type referenced for it to be added with `get_type_reference` to imports.
Contributor guide
Assessment
This issue has not been assessed yet.