Skip to content

Request for Formatting Style Preference Option: [project.scripts] vs [project] scripts.* #296

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

Open
zappuf opened this issue Apr 26, 2025 · 1 comment

Comments

@zappuf
Copy link

zappuf commented Apr 26, 2025

Following up on Issue #293, I’d like to propose an enhancement:

While it's clear that PEP 621 does not enforce a specific TOML layout and that [project.scripts] and [project] scripts.* are semantically equivalent, it would be very useful if pyproject-fmt provided an optional configuration setting to prefer one formatting style over the other during formatting.

Specifically, it would be helpful to offer users the ability to:

  • Prefer expanding [project.scripts] as a dedicated table (more readable and common in hand-written pyproject.toml files)
  • Or, alternatively, prefer flattening into [project] scripts.* entries (current behavior)

Possible Implementation Ideas:

  • A CLI flag (e.g., --prefer-expanded-tables)
  • A configuration setting in pyproject.toml for pyproject-fmt
  • Default behavior could remain unchanged if no preference is specified

Rationale:

  • Improves readability and consistency for users who manually maintain pyproject.toml
  • Reduces diffs when working across teams that expect a particular style
  • Enhances user control without sacrificing compliance with PEP 621

Thanks for considering this! I’m happy to help test or contribute if needed.

@gaborbernat
Copy link
Member

I am not sure what you mean by compliance with PEP 621, because given that that does not specify a specific style, we are already compliant. As for which is more common or readable, I think we'll need to agree to disagree. I actually did a poll about this a while back on Twitter and from like 100 answers it was 50-50 the distribution. I think this argument between one and another is really just a personal preference thing.

That being said I'm open to someone to create a pull request to support both styles. But I am not gonna do the work so guest contributions are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants