Comments from original TOML end up in the wrong spot
还没有人认领这个 Issue。
评估
调研方向
从提供的 TOML 复现示例开始,跟踪在已解析的表数组上执行的 result.append("rate_limit", route_ratelimit) 和 route_ratelimit.append("requests", route_ratelimit_requests) 操作。确认第二条 route 注释为何会移动,然后确保它仍紧挨着位于第二个 [[routes]] 条目上方,并重新运行示例以验证输出。
由索引模型根据 Issue 内容生成。
描述
Hello,
I am using the tomlkit Python library to modify an existing TOML file.
The original file looks like this:
## My POST route comment
[[routes]]
method = 'POST'
path = '/my/post/path'
topic = 'my-topic.0'
## My GET route comment
[[routes]]
method = 'GET'
path = '/my/get/path/{key}'
topic = 'my-topic.1'
I add two tables to that original array of tables "[[routes]]", with method = 'POST' and path = '/my/post/path'. When I do that, the resulting file becomes:
## My POST route comment
[[routes]]
method = 'POST'
path = '/my/post/path'
topic = 'my-topic.0'
## My GET route comment
[routes.rate_limit]
enabled = true
[routes.rate_limit.requests]
per_second = 25
[[routes]]
method = 'GET'
path = '/my/get/path/{key}'
topic = 'my-topic.1'
The comment ends up in the wrong spot. What can I do to make sure it stays on top of my second "[[routes]]" such as:
## My POST route comment
[[routes]]
method = 'POST'
path = '/my/post/path'
topic = 'my-topic.0'
[routes.rate_limit]
enabled = true
[routes.rate_limit.requests]
per_second = 25
## My GET route comment
[[routes]]
method = 'GET'
path = '/my/get/path/{key}'
topic = 'my-topic.1'
This is an extract of the code I use to add my 2 tables:
# result is <class 'tomlkit.items.Table'>
route_ratelimit = tomlkit.table()
route_ratelimit.add("enabled", True)
route_ratelimit_requests = tomlkit.table()
route_ratelimit_requests.add("per_second", 25)
result.append("rate_limit", route_ratelimit)
route_ratelimit.append("requests", route_ratelimit_requests)
Thank you for your assistance.
- 主要语言
- Python
- 星标
- 850
- 派生
- 163
- 平均合并
- 13 分钟
- 30 天内合并 PR
- 2
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-poetry/tomlkit 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
python-poetry/tomlkit#546 · 2 条评论 ·
-
难度 3/5 1-2 天 新手友好度 68/100
python-poetry/tomlkit#603 ·
-
难度 3/5 1-2 天 新手友好度 52/100
python-poetry/tomlkit#580 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 72/100
python-poetry/tomlkit#577 ·
-
难度 5/5 一周以上 新手友好度 20/100
python-poetry/tomlkit#574 · 5 条评论 ·
查看 python-poetry/tomlkit 的全部 Issue
相似的 Issue
-
agent-ready documentation needs-triage
难度 1/5 1-3 小时 新手友好度 88/100
-
documentation
难度 1/5 1 小时以内 新手友好度 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
-
instance instance add
难度 1/5 1 小时以内 新手友好度 72/100
searxng/searx-instances#939 · 1 条评论 ·
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100