Description
When updating a single TOML value in pyproject.toml, yq rewrites unrelated fields and changes the TOML semantics.
The command I ran was:
yq -p toml -o toml -i '.project.version = "0.5.2"' pyproject.toml
yq version:
$ yq --version
yq (https://github.com/mikefarah/yq/) version v4.53.2
Input
Relevant part of the original pyproject.toml:
[project]
name = "scopeql"
version = "0.5.1"
requires-python = ">=3.10"
description = "A command-line interface for ScopeDB"
authors = [{ name = "ScopeDB Inc.", email = "tison@scopedb.io" }]
classifiers = [
"Environment :: Console",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Rust",
]
license = { file = "LICENSE" }
readme = "README.md"
[project.urls]
Homepage = "https://github.com/scopedb/scopeql"
Actual output
After running the command, the file becomes:
[project]
name = "scopeql"
version = "0.5.2"
requires-python = ">=3.10"
description = "A command-line interface for ScopeDB"
classifiers = ["Environment :: Console", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Programming Language ::
Rust"]
readme = "README.md"
[[project.authors]]
name = "ScopeDB Inc."
email = "tison@scopedb.io"
license = { file = "LICENSE" }
[project.urls]
Homepage = "https://github.com/scopedb/scopeql"
Problem
This is not only a formatting/key-order issue. The license key was originally project.license, but after serialization it appears after [[project.authors]], which makes it part
of the last project.authors table item instead of the project table.
So the output changes the meaning of the TOML document.
Expected behavior
Only project.version should be changed from 0.5.1 to 0.5.2.
At minimum, yq should preserve the TOML table scope correctly and keep license under [project], not under [[project.authors]].
Expected semantic output:
[project]
name = "scopeql"
version = "0.5.2"
requires-python = ">=3.10"
description = "A command-line interface for ScopeDB"
authors = [{ name = "ScopeDB Inc.", email = "tison@scopedb.io" }]
classifiers = [
"Environment :: Console",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Rust",
]
license = { file = "LICENSE" }
readme = "README.md"
Description
When updating a single TOML value in
pyproject.toml, yq rewrites unrelated fields and changes the TOML semantics.The command I ran was:
yq -p toml -o toml -i '.project.version = "0.5.2"' pyproject.tomlyq version:
Input
Relevant part of the original pyproject.toml:
Actual output
After running the command, the file becomes:
Problem
This is not only a formatting/key-order issue. The license key was originally project.license, but after serialization it appears after [[project.authors]], which makes it part
of the last project.authors table item instead of the project table.
So the output changes the meaning of the TOML document.
Expected behavior
Only project.version should be changed from 0.5.1 to 0.5.2.
At minimum, yq should preserve the TOML table scope correctly and keep license under [project], not under [[project.authors]].
Expected semantic output: