Skip to content

Add pyproject.toml auto-formatting.#105

Merged
dpranke merged 3 commits intomainfrom
pyproject_fmt
Feb 1, 2026
Merged

Add pyproject.toml auto-formatting.#105
dpranke merged 3 commits intomainfrom
pyproject_fmt

Conversation

@dpranke
Copy link
Owner

@dpranke dpranke commented Jan 11, 2026

This change primarily adds a dev dependency on the pyproject-fmt package to auto-format the pyproject.toml file, and adds the logic to do so to ./run format. The implementation is kinda convoluted because the package has an inconvenient interface and returns a 1 when it successfully formats a file that needed changes, rather than returning 0.

This change also reformats json5/tool.py and updates the uv.lock file to pick up newer packages. I'm of mixed feelings about uv.lock updating existing packages whenever a new dependency is added (rather than only updating expackages when explicitly asked to do so), so I can see changing the logic for how we're managing packages in the future either back to explicitly pinning versions by default, or to do something else.

This change primarily adds a dev dependency on the pyproject-fmt
package to auto-format the pyproject.toml file, and adds the logic
to do so to `./run format`. The implementation is kinda convoluted
because the package has an inconvenient interface and returns a 1
when it successfully formats a file that needed changes, rather
than returning 0.

This change also reformats json5/tool.py and updates the uv.lock
file to pick up newer packages. I'm of mixed feelings about uv.lock
updating existing packages whenever a new dependency is added (rather
than only updating expackages when explicitly asked to do so), so
I can see changing the logic for how we're managing packages in the
future either back to explicitly pinning versions by default, or
to do something else.
@dpranke dpranke self-assigned this Jan 11, 2026
@dpranke
Copy link
Owner Author

dpranke commented Jan 11, 2026

@ulgens - thoughts?

@ulgens
Copy link
Contributor

ulgens commented Jan 11, 2026

@dpranke I prefer to use pyproject-fmt as a git hook, with the following config:

[tool.pyproject-fmt]
indent = 4
keep_full_version = true
max_supported_python = ...
  • It's isolated from the functional dependencies. I like the "wrap linters with git hook and use the hooks in CI" approach.
  • Using indent 4 mostly because of personal taste, but I also think it fits with Python's standard tab width.

@dpranke
Copy link
Owner Author

dpranke commented Jan 12, 2026

Yeah, git hooks would probably work too. I'll switch to your settings, as I have no strong opinions and 4 spaces appears to match what uv init does.

@dpranke dpranke merged commit b940347 into main Feb 1, 2026
14 checks passed
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

Successfully merging this pull request may close these issues.

2 participants