Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`box_from_file` returns `ruamel.yaml.scalarfloat.ScalarFloat` instead of `float` for floating-point values

Đang mở
#264 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

@vinson0522 đang làm issue này rồi.

Từ ngày 14/8/2026.

  • #321 của @vinson0522 — đang mở

Đá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
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
data

Hướng nghiên cứu

Bắt đầu từ điểm vào box_from_file và tái hiện YAML MRE với giá trị Float, sau đó theo dõi cách các giá trị vô hướng của ruamel YAML được giữ lại. Hoàn tất nghĩa là giá trị đã tải và kết quả của Box.to_dict() sử dụng kiểu float tích hợp sẵn; hãy thêm hoặc cập nhật một bài kiểm thử hồi quy nếu cấu trúc kiểm thử của repository xác định được vị trí phù hợp.

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

Mô tả

bug

When I load a Box from a YAML file, the floating-pont values are represented as a type from the ruamel YAML library, and not cast to the builtin float type. This resulted in a difficult bug (as without explicitly calling type() on it, it is rendered visually as a float) where these are being improperly serialised when interacting with another library, as it doesn't know how to handle them. This happens even if I convert the box to a builtin dictionary with Box.to_dict().

MRE:

Float: 0.1
import box

float = box.box_from_file('Float.yaml')

print(     float.Float )
print(type(float.Float))

outputs

0.1
<class 'ruamel.yaml.scalarfloat.ScalarFloat'>

I assume it would be more appropriate for all types from YAML/JSON/etc that can be represented as builtin to be converted as part of the process.

I would look into this further, but my debugger seems to refuse to step into the function or hit any manually-added breakpoints - I see .pyi and C wrappers, so looks like it might be implemented internally in C.

Thanks

Ngôn ngữ chính
Python
Star
2.8k
Fork
145
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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cdgriffith/Box

Tất cả issue của cdgriffith/Box

Issue tương tự

Thêm issue về Python

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.