Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#264 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@vinson0522 已经在做这个了。

开始于 2026年8月14日。

  • #321 来自 @vinson0522 —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
data

调研方向

从 box_from_file 入口开始,复现包含 Float 值的 YAML MRE,然后跟踪 ruamel YAML 标量值是如何被保留的。完成标准是,加载的值和 Box.to_dict() 的结果都使用内置的 float 类型;如果仓库的测试结构能确定合适的位置,则添加或更新回归测试。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Python
星标
2.8k
派生
145
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cdgriffith/Box 的其他 Issue

查看 cdgriffith/Box 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。