You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// proto/test.proto
syntax = "proto3";
package p;
service Service {
rpc Method(Empty) returns (Empty) {}
}
message Empty {}
This doesn't:
// proto/test.proto
syntax = "proto3";
package P;
service Service {
rpc Method(Empty) returns (Empty) {}
}
message Empty {}
With the latter, betterproto compiles to this:
# Generated by the protocol buffer compiler. DO NOT EDIT!# sources: test.proto# plugin: python-betterproto# This file has been @generatedfromdataclassesimportdataclassfromtypingimport (
TYPE_CHECKING,
Dict,
Optional,
)
importbetterprotoimportgrpclibfrombetterproto.grpc.grpclib_serverimportServiceBasefrom .. importPEmptyas_PEmpty__# [...]
The from .. import PEmpty is invalid import as nothing exists in the parent package.
I have got the same issue. I'm running the generation on Linux with betterproto v2.0.0b6. Adding any uppercase letter to any part of the package name in the .proto causes the same import error, where there are imports that don't exist in the parent __init__.py. Problem goes away if I use all lowercase letters.
However, your package naming should probably follow the style guide, which suggests using all lowercase letters. Adhering to this guideline would prevent this issue from occurring in the first place.
Summary
Title
Reproduction Steps
This protofile works:
This doesn't:
With the latter, betterproto compiles to this:
The
from .. import PEmpty
is invalid import as nothing exists in the parent package.Command used:
python3 -m grpc_tools.protoc --proto_path=./proto/ --python_betterproto_out=./proto/ proto/*.proto
Python environment (output of
pip freeze
):Expected Results
Correct code generated
Actual Results
Incorrect code generated
System Information
libprotoc 3.12.4
Python 3.11.0rc1
Name: betterproto
Version: 2.0.0b6
Summary: A better Protobuf / gRPC generator & library
Home-page: https://github.com/danielgtaylor/python-betterproto
Author: Daniel G. Taylor
Author-email: [email protected]
License: MIT
Location:
Requires: grpclib, python-dateutil, typing-extensions
Required-by:
Checklist
pip install -U --pre betterproto
, if possible.The text was updated successfully, but these errors were encountered: