Double underscore breaks existing code in betterproto v2/master
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu bằng cách chạy lệnh grpc_tools.protoc đã được báo cáo với src/test.proto và xác nhận rằng field__json được sinh thành field_json. Sau đó, lần theo cách betterproto v2 xử lý tên trường Python có liên quan đến quá trình sinh mã. Công việc được xem là hoàn tất khi dataclass được sinh ra vẫn giữ field__json và biểu diễn dưới dạng từ điển/JSON của nó vẫn nhất quán với tên trường proto ban đầu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Double underscore breaks existing code
Reproduction Steps
When we try compiling the following proto-file, the field field__json becomes field_json
syntax = "proto3";
package test;
message TestMessage {
string field__json = 1;
}
@dataclass(eq=False, repr=False, config={"extra": "forbid"})
class TestMessage(betterproto.Message):
field__json: str = betterproto.string_field(1)
python -m grpc_tools.protoc --python_betterproto_opt=pydantic_dataclasses --python_betterproto_out=src -Isrc src/test.proto
Expected Results
If we build the same code with betterproto v1, or with the standard compiler (python -m grpc_tools.protoc --python_out=src --pyi_out=src src/test.proto) the field name will remain unchanged.
Not only does this break current code, but this will also impact how a dict/JSON is being generated based on the data class/structure.
I would imagine this behaviour as unwanted and if we want to sanitize filed name, I think it would be better to do in the original proto-file (e.g. using tools like buf).
Actual Results
above
System Information
protoc --version; python --version; poetry run pip show betterproto
libprotoc 27.3
zsh: command not found: python
Name: betterproto
Version: 2.0.0b7
Summary: A better Protobuf / gRPC generator & library
Home-page: https://github.com/danielgtaylor/python-betterproto
Author: Daniel G. Taylor
Author-email: [email protected]
License: MIT
Location: /Users/mikhailgalanin/Library/Caches/pypoetry/virtualenvs/betterproto-repro-O0YfRvug-py3.12/lib/python3.12/site-packages
Requires: grpclib, python-dateutil, typing-extensions
Required-by: betterproto-repro
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.
- Ngôn ngữ chính
- Python
- Star
- 1.8k
- Fork
- 235
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của danielgtaylor/python-betterproto
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
-
bug investigation needed
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
-
bug investigation needed
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
bug investigation needed
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
danielgtaylor/python-betterproto#676 · 3 bình luận ·
Tất cả issue của danielgtaylor/python-betterproto
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
521xueweihan/HelloGitHub#4063 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Vanilla-OS/apx-gui#112 ·
-
Devstral and Voxtral: section 5 fails in us-east-1 with 400 "Model does not support audio modality"Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws-samples/sample-per-model-bedrock#409 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DuckDB 2.0 breaks to_pyarrow_batchesCó thể đã có người làm @DG47 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ibis-project/ibis#12196 ·
Maintainer thường phản hồi trong vòng 1 ngày