`box_from_file` returns `ruamel.yaml.scalarfloat.ScalarFloat` instead of `float` for floating-point values
评估
调研方向
从 box_from_file 入口开始,复现包含 Float 值的 YAML MRE,然后跟踪 ruamel YAML 标量值是如何被保留的。完成标准是,加载的值和 Box.to_dict() 的结果都使用内置的 float 类型;如果仓库的测试结构能确定合适的位置,则添加或更新回归测试。
由索引模型根据 Issue 内容生成。
描述
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 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
cdgriffith/Box 的其他 Issue
-
subclass of `Box` does not unpickle correctly可能已有人在做 @koriyoshi2041 于 142 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
cdgriffith/Box#308 ·
-
难度 3/5 1-2 天 新手友好度 42/100
cdgriffith/Box#307 · 1 条评论 ·
-
Dotted keys read from YAML are lost with box_dots / default_box可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 48/100
cdgriffith/Box#305 ·
-
[Bug] Camel killer box and box dots gives unexpected behaviour可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 30/100
cdgriffith/Box#300 ·
-
难度 3/5 1-2 天 新手友好度 42/100
cdgriffith/Box#298 ·
相似的 Issue
-
tunneld on Windows: Wi-Fi devices are not discovered because uvicorn runs on a ProactorEventLoop未关闭
难度 2/5 1-3 小时 新手友好度 76/100
doronz88/pymobiledevice3#2051 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
collabnix/awesome-mcp-lists#230 ·
维护者通常 9 天内回复
-
Groc schedules with out of range values pass config validation and fail later when the scheduler is built可能已有人在做 @auraseb 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
autowarefoundation/autoware_carla_scenario#342 ·
维护者通常 1 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 72/100
ianktoo/project-monitor#14 ·