danielgtaylor / danielgtaylor/python-betterproto
In generated field name, an undescore is introduced after a number
- 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ả
### Summary
Underscore is added after a number in the field name, e.g. `c2s` becomes `c2_s`.
### Reproduction Steps
```proto
syntax = "proto3";
message Example {
string c2s = 1;
}
```
```bash
protoc --python_betterproto_out=lib example.proto
```
### Expected Results
Expecting `c2s`.
```python
# Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: example.proto
# plugin: python-betterproto
# This file has been @generated
from dataclasses import dataclass
import betterproto
@dataclass(eq=False, repr=False)
class Example(betterproto.Message):
c2s: str = betterproto.string_field(1)
```
### Actual Results
Generates `c2_s` instead.
```python
# Generated by the protocol buffer compiler. DO NOT EDIT!
# sources: example.proto
# plugin: python-betterproto
# This file has been @generated
from dataclasses import dataclass
import betterproto
@dataclass(eq=False, repr=False)
class Example(betterproto.Message):
c2_s: str = betterproto.string_field(1)
```
### System Information
libprotoc 27.1
Python 3.8.20
Name: betterproto
Version: 2.0.0b7
Location: /Users/.../demo/.venv/lib/python3.8/site-packages
Requires: grpclib, python-dateutil, typing-extensions
Required-by: demo
### Checklist
- [x] I have searched the issues for duplicates.
- [x] I have shown the entire traceback, if possible.
- [x] I have verified this issue occurs on the latest prelease of betterproto which can be installed using `pip install -U --pre betterproto`, if possible.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách chạy lệnh protoc đã được báo cáo với message example.proto và so sánh tên field được tạo ra với output mong đợi. Truy vết entry point của generator chuyển đổi tên field protobuf thành tên Python; công việc được hoàn tất khi một field như c2s vẫn là c2s thay vì trở thành c2_s, kèm coverage hồi quy nếu các test hiện có của project có chỗ phù hợp.
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
- tooling
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 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
- 45/100