Skip to content

betterproto-2.0.0b5 fails to generate message classes when proto package name contains upper case letters #437

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
hf-kklein opened this issue Oct 24, 2022 · 2 comments
Labels
compiler-bug The compiler is broken

Comments

@hf-kklein
Copy link
Contributor

Steps to reproduce

Install betterproto-2.0.0b5 + tooling:

pip install --pre betterproto[compiler]
pip install grpcio-tools

other versions:

grpcio==1.50.0
grpcio-tools==1.50.0
grpclib==0.4.3

Create an example.proto

syntax = "proto3";

package mypackage; // this is the only change to the MWE from README.md

message EchoRequest {
  string value = 1;
  // Number of extra times to echo
  uint32 extra_times = 2;
}

message EchoResponse {
  repeated string values = 1;
}

message EchoStreamResponse  {
  string value = 1;
}

service Echo {
  rpc Echo(EchoRequest) returns (EchoResponse);
  rpc EchoStream(EchoRequest) returns (stream EchoStreamResponse);
}

Create the directory

mkdir lib

Generate Python Code:

python -m grpc_tools.protoc -I . --python_betterproto_out=lib example.proto

Check that lib/mypackage/__init__.py contains no unresolvable imports. ✔

Up to here, this is just the MWE from README.md with a different but all-lower package name.

Introduce Upper Case Letters in the Package Name

Now modify the above example.proto and change the all-lower case package mypackage in line 3 to an UpperCamel package MyPackage.

Repeat the next steps up to the code generation (don't forget to clean up lib before re-generating).

The newly generate lib/MyPackage/__init__.py now contains unresolvable imports:

from .. import (
    MyPackageEchoResponse as _MyPackageEchoResponse__,
    MyPackageEchoStreamResponse as _MyPackageEchoStreamResponse__,
)

The lib/__init__.py does not contain anything to import.
No classes MyPackageEchoResponse or MyPackageEchoStreamResponse have been generated ❌

Expected Behaviour

The code generation shall work for mixed casing package names.

@hf-kklein
Copy link
Contributor Author

For a similar casing issue in the message name see #438.

@2AtM7
Copy link

2AtM7 commented May 2, 2023

Hi, any plans on fixing this issue? Seems like there has been a fix (#436) for #438, which is a similar issue, but not sure if this one was also taken care of by the same PR.
Also, any plans for a new release or beta including the above fix? The current beta (2.0.0b5) seems to be 9 months old :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
compiler-bug The compiler is broken
Projects
None yet
Development

No branches or pull requests

3 participants