danielgtaylor / danielgtaylor/python-betterproto

Import bug - Message from Capitalized package is mistaken for Nested Type

Đang mở
#87 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug has test low priority
Ngôn ngữ chính
Python
Star
1.8k
Fork
234
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

The compiler does not distinguish the following two cases:

```protobuf
package somepackage.Core;

message Message {}
```

```protobuf
package somepackage;

message Core {
message Message {}
}
```

as they are both:

```
somepackage.Core.Message
```

Protoc (as far as I've been able to figure out) reports the full type name, but not which part of that is the package, and which is the real type (`somepackage.Core: Message` vs `somepackage: Core.Message`).

In 99% of cases, this will not be a problem, because if users will follow the Protobuf Style Guide, packages will be `lowercase`, and types `CapitalCamelCase`, and the distinction can be made based on that.

https://developers.google.com/protocol-buffers/docs/style#packages

> Package name should be in lowercase, and should correspond to the directory hierarchy. e.g., if a file is in my/package/, then the package name should be my.package.

https://developers.google.com/protocol-buffers/docs/style?hl=cs-CZ#message-and-field-names

> Use CamelCase (with an initial capital) for message names – for example, SongServerRequest. Use underscore_separated_names for field names (including oneof field and extension names) – for example, song_name.

Despite these style guides, there may be some users who are using Capitalized packages and for some reason cannot change the packages to lowercase.

Then, these packages will not be imported correctly from depending packages / messages.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện hai ví dụ về package/message của protobuf và so sánh cách protoc báo cáo tên kiểu đầy đủ của chúng trong quá trình import phụ thuộc. Truy vết điểm vào của quá trình phân giải package và kiểu lồng nhau trong compiler, sau đó bổ sung coverage cho thấy cả hai trường hợp được import riêng biệt mà không làm hỏng hành vi của package viết thường.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
compilers
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.