danielgtaylor / danielgtaylor/python-betterproto

overriding files with incorrect content -> package name should not be file name

Open
#300 0 comments 0 reactions 0 assignees View on GitHub
compiler-bug
Dominant language
Python
Stars
1.8k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

I feel that I use the plugin in a wrong way or there is something not designed correctly.

example:

I have directory with three files

status.proto

```
message Success {
}

```
and
package svcs
servicesA.proto

```
package svcs
import "status.proto"
service ServiceA {
... rpcs
}
```
service.B.proto

```
package svcs
import "status.proto"
service ServiceB {
... rpcs
}
```
running protoc 3 times (serviceA.proto, serviceB.proto status.proto) in that order:
1. svcs.py with content of A
2. svcs.py with content of B
3. svcs.py with content of status.proto

I have been using protobuf for more than 12 years, but this is not correct. It is normal to have one package with multiple file being included around and similar things. the generator must either append or somehow deal with it. It is not correct expectation that each file will have a different namespace

mine current workaround - still I need to test it
```
for proto_file in request.proto_file:
- out = proto_file.package
- if out == "google.protobuf":
+ out = proto_file.package + "." + proto_file.name.rsplit('.', 1)[0]
+ if out.startswith("google"):
continue
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.