Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using [project.readme] it gets shifted to inside [project] and breaks pyproject.toml. #110

Closed
ocefpaf opened this issue Jul 11, 2023 · 8 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ocefpaf
Copy link

ocefpaf commented Jul 11, 2023

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 Unidata/netcdf4-python#1267 in Unidata/netcdf4-python@1872af6.

Thanks for the awesome tool!

Feel free to close this if what I'm doing is out of scope for this tool.

@gaborbernat
Copy link
Member

PR welcome to fix it.

@ocefpaf
Copy link
Author

ocefpaf commented Jul 11, 2023

PR welcome to fix it.

I'd be happy to if I understand first:

  1. that it is really pyproject-fmt
  2. how pyproject-fmt works :-)

@gaborbernat
Copy link
Member

Yes to both.

@mj0nez
Copy link
Contributor

mj0nez commented Aug 9, 2023

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.

@adamchainz
Copy link
Contributor

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",
]

@gaborbernat
Copy link
Member

PR welcome 👍

@adamchainz
Copy link
Contributor

I think per diazona/setuptools-pyproject-migration#112 and diazona/setuptools-pyproject-migration#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.

@gaborbernat
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants