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

Feature request: extend `merge_update` into BoxLists

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

@Kaustbh 已经在做这个了。

开始于 2024年5月3日。

  • #323 来自 @ChrisJr404 —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
backend

调研方向

首先定位 issue 中描述的 merge_update 行为和 BoxLists 处理,然后检查现有的 merge 相关测试(如果有)。将当前的数据替换方式与预期的逐元素更新进行比较,并将完成标准定义为:保留现有的列表字典,同时添加匹配的传入元素中的字段。

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

描述

enhancement

Current

If I have these two BoxDicts:

In [1]: from box import Box
   ...: dict1 = Box({'data': [{'foo': 1, 'foobar': 20}, {'bar': 2}] }, box_dots=True)
   ...: dict2 = Box({'data': [{'foo': 1, 'baz': 10}] }, box_dots=True)
   ...: print(dict1.keys(dotted=True))
   ...: print(dict2.keys(dotted=True))
['data[0].foo', 'data[0].foobar', 'data[1].bar']
['data[0].baz', 'data[0].foo']

Then, if I use merge_update I get:

In [2]: dict1 + dict2
Out[2]: Box({'data': [{'foo': 1, 'baz': 10}]})

Expected behaviour

When merging the two datasets, it would be great if Box entered each list element and updated the dictionary:

In [1]: dict1 + dict2
Out[1]: Box({'data': [{'foo': 1, 'foobar': 20, 'baz': 10}, {'bar': 2}]})

Since the BoxDict has a pseudo-key for elements of the lists (e.g., 'data[0].foo') it feels like it should be possible.

Versions

python: 3.11
box: 7.1.1

主要语言
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 摘要。