danielgtaylor / danielgtaylor/python-betterproto
Imports from adjacent .proto files does not work
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
First of all, I looked at the issue #408 and I am absolutely sure that I have `betterproto[compiler]` of version `2.0.0b5` installed
I have this file structure:
```
protos
├── common.proto
└── devices
└── rpi.proto
```
With `protos/common.proto`:
```
syntax = 'proto3';
package org.company.name.common;
message DeviceId {
string device_id = 1;
}
```
and `protos/devices/rpi.proto`:
```
syntax = 'proto3';
package org.company.name.rpi;
import "common.proto";
import "google/protobuf/empty.proto";
service RPI {
rpc Start(common.DeviceId) returns (google.protobuf.Empty) {}
rpc Stop(common.DeviceId) returns (google.protobuf.Empty) {}
```
I then generate betterproto files:
```
poetry run python -m grpc_tools.protoc \
-I protos \
--python_betterproto_out=package_name/grpc \
protos/common.proto \
protos/devices/rpi.proto \
```
## The BUG
In `package_name.grpc.org.company.name.rpi` any mentions of `DeviceId` are presented as `_common__.DeviceId`, with `_common__` not being imported. Launching that code does not work either, python has no idea what `_common__` is.
Contributor guide
Research direction
Reproduce the issue with protos/common.proto and protos/devices/rpi.proto using the shown grpc_tools.protoc command. Inspect the generated package_name/grpc output for the RPI service's DeviceId references and imports. Done means the generated Python module imports successfully and those references resolve without an undefined _common__ name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- grpc, python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100