Custom "None" value when search fails

未关闭
#186 10 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

@uhlikfil 已经在做这个了。

开始于 2023年6月1日。

  • #311 来自 @uhlikfil —— 未关闭

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
backend

调研方向

从 jmespath.search 入口点开始,阅读 issue 113 中链接的讨论,以了解现有行为和提出的替代方案。定义一种受支持的方式,以便在搜索失败时返回自定义值,然后验证它无需进行两次搜索,并且能为现有调用方保留当前行为。

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

描述

Hi, thanks for this awesome lib!
One question: it seems to be impossible to set a custom return in case the search fails.

E.g.

not_found = object()
jmespath.search('foo.aaa', {'foo': {'bar': 'baz'}})  # I need `not_found`, not `None`

Is this by design or are you open to supporting that?
I see this was discussed at https://github.com/jmespath/jmespath.py/issues/113
But the proposed solution of contains isn't great, as it requires 2 searches.

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

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

jmespath/jmespath.py 的其他 Issue

查看 jmespath/jmespath.py 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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