Why are literals left stripped?

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

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
devtools

调研方向

从引用的 jmespath.py 提交中第 137 行添加的 lstrip 开始,跟踪 join 如何处理其参数。将该行为与 JMESPath 规范以及 issue 中提到的 Go 实现进行比较,然后确定预期输出,并为此表达式添加或更新覆盖范围。

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

描述

I was confused by the behaviour of the following:

{
  "locations": [
    {"name": "Seattle", "state": "WA"},
    {"name": "New York", "state": "NY"},
    {"name": "Bellevue", "state": "WA"},
    {"name": "Olympia", "state": "WA"}
  ]
}

when queried with the following JMESPath expression:

locations[].{"CityState": join(` - `, [name, state])}

outputs the following:

[
  {
    "CityState": "Seattle- WA"
  },
  {
    "CityState": "New York- NY"
  },
  {
    "CityState": "Bellevue- WA"
  },
  {
    "CityState": "Olympia- WA"
  }
]

Note that this also occurs on the jmespath.org website so is presumably not just a Python implementation issue.

I noticed https://github.com/jmespath/jmespath.py/commit/4c87771b8d3bc88efd945943b5438ea28603e054#diff-ff12e4d40b1d1e1df346464bf6958de94c760d06acc3fce591b6ccf94e3b9449R137 adding the lstrip here but there's no explanation as to why that I can see and I can't see anything in the spec. I also didn't see anything jump out at me from a very quick look at the Go implementation but it's also a bit trickier to follow there.

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