pyproject-fmt
pyproject-fmt copied to clipboard
When using [project.readme] it gets shifted to inside [project] and breaks pyproject.toml.
Sorry if I'm doing something wrong but when running the pyproject-fmt it breaks our pyproject.toml and moving it manually to below the "dynamic" entry fixes it.
One can see that in first commit of https://github.com/Unidata/netcdf4-python/pull/1267 in https://github.com/Unidata/netcdf4-python/pull/1267/commits/1872af61568a58807f221a435516573fc086e0f1.
Thanks for the awesome tool!
Feel free to close this if what I'm doing is out of scope for this tool.
PR welcome to fix it.
PR welcome to fix it.
I'd be happy to if I understand first:
- that it is really
pyproject-fmt - how
pyproject-fmtworks :-)
Yes to both.
Hey, I have tried to come up with a solution for this but think it’s actually an issue with the usage of the TOML-syntax. In their docs it’s emphasized, that you should not introduce sub-tables (e.g. [project.readme]) after the top-level table ([project]). The reason is, that readme and another field of the same level are treated equally, even if their actual rendering might look different. So you could switch the order in your file and introduce all sub-tables (readme, scripts, urls…) beforehand like:
[project.readme]
text = '''netCDF version 4 has many features not found in earlier versions of the library...
'''
content-type = "text/x-rst"
[project]
name = "netcdf4"
description = "Provides an object-oriented python interface to the netCDF version 4 library"
dynamic = [
"version",
]
This should not break your file.
I just encountered this - minimal example:
[project]
name = "widgetizer"
keywords = ["widgets"]
[project.readme]
file = "README.rst"
…gets reformatted to:
[project]
name = "widgetizer"
[project.readme]
file = "README.rst"
keywords = [
"widgets",
]
Sorting project.readme first works as suggested, leaving the file as:
[project.readme]
file = "README.rst"
[project]
name = "widgetizer"
keywords = [
"widgets",
]
PR welcome 👍
I think per https://github.com/diazona/setuptools-pyproject-migration/pull/112 and https://github.com/diazona/setuptools-pyproject-migration/pull/114 , it would be a good feature if pyproject-fmt converted a few keys to inline variants: authors, license, maintainers, and readme. This would match the setuptools docs too.
Done via https://github.com/tox-dev/pyproject-fmt/releases/tag/2.0.0