danielgtaylor / danielgtaylor/python-betterproto
Nested packages causes invalid imports
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 234
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Compilation of proto files using 2.0.0b3
```sh
protoc -I . --python_betterproto_out=prototest base.proto example.proto
```
```proto
# base.proto
syntax = "proto3";
package Foo;
message Bar {
string value = 1;
}
```
```proto
# example.proto
syntax = "proto3";
import "base.proto";
package Foo.Example;
message Example {
Bar value = 1;
}
```
returns `Foo/__init__.py`
```python
# Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: base.proto
# plugin: python-betterproto
from dataclasses import dataclass
import betterproto
from betterproto.grpc.grpclib_server import ServiceBase
@dataclass(eq=False, repr=False)
class Bar(betterproto.Message):
value: str = betterproto.string_field(1)
```
`Foo/Example/__init__.py`
```python
# Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: example.proto
# plugin: python-betterproto
from dataclasses import dataclass
import betterproto
from betterproto.grpc.grpclib_server import ServiceBase
@dataclass(eq=False, repr=False)
class Example(betterproto.Message):
value: "__FooBar__" = betterproto.message_field(1)
from ... import FooBar as __FooBar__
```
The last import in `Foo/Example/__init__.py` is invalid, since there is no `FooBar` module. It probably should have been `from Foo import Bar as __FooBar__`.
コントリビューションガイド
調査の方向性
示されている protoc コマンドで問題を再現し、生成された Foo/__init__.py および Foo/Example/__init__.py ファイルを調査します。生成中にインポートされた Bar メッセージがどのように解決されるかを追跡します。ネストされたパッケージの出力に Bar への有効な import が含まれ、生成されたファイルが正常にコンパイルできれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100