Incorrect JSON serialization of repeated int64
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 tái hiện vấn đề với ExampleContract được tạo và lệnh gọi to_json() của nó, so sánh các phần tử int64 lặp lại với trường mặc định được bao bọc. Truy vết đường dẫn tuần tự hóa JSON được message Python được tạo sử dụng. Công việc được hoàn tất khi các giá trị int64 lặp lại được tuần tự hóa thành các giá trị JSON dạng số, khớp với đầu ra mong đợi, mà không thay đổi hành vi của trường được bao bọc.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
When I create a contract with a repeated int64 variable, it serializes into repeated string, which is an unpredictable behaviour
Reproduction Steps
- Create a contract:
// ExampleContract describes example of contract.
message ExampleContract {
// List of int64.
repeated int64 items = 1;
// Default int64 value.
google.protobuf.Int64Value default = 2;
}
- Compile to python:
@dataclass(eq=False, repr=False)
class ExampleContract(betterproto.Message):
"""
ExampleContract describes example of contract.
"""
items: List[int] = betterproto.int64_field(1)
"""List of int64."""
default: Optional[int] = betterproto.message_field(2, wraps=betterproto.TYPE_INT64)
"""Default int64 value."""
- Create instance of class and serialize it to JSON:
ec = ExampleContract(items=[5, 10], default=10)
print(ec.to_json())
Expected Results
{"items": [5, 10], "default": 10}
Actual Results
{"items": ["5", "10"], "default": 10}
System Information
libprotoc 25.3, Python 3.12.7
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: /opt/conda/lib/python3.12/site-packages
Requires: grpclib, python-dateutil, typing-extensions
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ó 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 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
danielgtaylor/python-betterproto#673 · 1 bình luận ·
Tất cả issue của danielgtaylor/python-betterproto
Issue tương tự
-
Use mhctools predictor_required=False for saved-result rescoringCó thể đã có người làm @iskandr đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
521xueweihan/HelloGitHub#4051 · 1 bình luận ·
-
bug documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
awslabs/visual-asset-management-system#514 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend bug spec:REQ-053
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
nolte/kamerplanter#2547 ·
Maintainer thường phản hồi trong vòng 1 ngày