Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Missing import in generated code when using well known types

Offen
#552 1 Kommentar 4 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
python
Bereich
tooling

Rechercherichtung

Beginne damit, das Problem mit foo.proto und dem angegebenen Befehl python -m grpc_tools.protoc zu reproduzieren, und untersuche anschließend die generierte init.py. Vergleiche die Ausgabe, wenn google.protobuf.Empty als RPC-Rückgabewert verwendet wird. Als erledigt gilt die Aufgabe, wenn die Ausgabe für diesen Edge Case betterproto.lib.google.protobuf unter dem referenzierten Alias importiert und der generierte Code erfolgreich kompiliert wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug investigation needed
Summary

When compiling a proto file which references well known types, protoc should generate the line import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf. This does not happen in the following edge case.

Reproduction Steps

Create a file foo.proto whith the following content

syntax = "proto3";
import "google/protobuf/empty.proto";

service foo {
    rpc foo (google.protobuf.Empty) returns (MyEmpty);
}

message MyEmpty {}

and compile it by running python -m grpc_tools.protoc -I . --python_betterproto_out=lib foo.proto.

Expected Results

The generated file __init__.py references a module betterproto_lib_google_protobuf, so it should import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf.

Note that it actually would be imported if I had used google.protobuf.Empty as the return value of the RPC above.

Actual Results

The generated file __init__.py does not import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf

System Information

libprotoc 25.0
Python 3.10.12
betterproto 2.0.0b6 (tested with released version and github master branch)

Checklist
  • I have searched the issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have verified this issue occurs on the latest prelease of betterproto which can be installed using pip install -U --pre betterproto, if possible.
Vorherrschende Sprache
Python
Sterne
1.8k
Forks
235
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus danielgtaylor/python-betterproto

Alle Issues in danielgtaylor/python-betterproto

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.