tox-dev / pyproject-fmt-rust

MIT License
11 stars 7 forks source link

Some fields ignore column-width #26

Closed henryiii closed 4 months ago

henryiii commented 4 months ago

If you set column-width, some fields ignore it and get rewritten anyway. It should be noted that column-width does seem to respect trailing commas, so a = [ "b",\n] is kept even if it's set. (Also, I think it should be clarified in the docs that the column width is in characters, not entries).

Before:

[build-system]
build-backend = "hatchling.build"
requires = [ "hatchling" ]

[project]
keywords = [ "package" ]
authors = [ { name = "Kitware" } ]
dynamic = [ "version" ]
dependencies = [ "sphinx" ]

[tool.hatch]
build.targets.wheel.packages = [ "sphinxcontrib" ]

[tool.pytest.ini_options]
testpaths = [ "tests" ]

[tool.pyproject-fmt]
column_width = 80

After:

[build-system]
build-backend = "hatchling.build"
requires = [
  "hatchling",
]

[project]
keywords = [
  "package",
]
authors = [ { name = "Kitware" } ]
classifiers = [
  "Programming Language :: Python :: 3 :: Only",
  "Programming Language :: Python :: 3.8",
  "Programming Language :: Python :: 3.9",
  "Programming Language :: Python :: 3.10",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
]
dynamic = [
  "version",
]
dependencies = [
  "sphinx",
]

[tool.hatch]
build.targets.wheel.packages = [ "sphinxcontrib" ]

[tool.pyproject-fmt]
column_width = 80

[tool.pytest.ini_options]
testpaths = [ "tests" ]

This does seem to be happening on sorted fields. I think the presence of the trailing comma should be kept for sorting.