Formatter for pyproject.toml files
Project description
pyprojectsort
Formatter for pyproject.toml files.
This package enforces consistent formatting of pyproject.toml files, reducing merge request conflicts and saving time that would otherwise be spent on manual formatting. It also contributes to a cleaner git history and more readable code; enhancing overall project organisation and maintainability. Experience a streamlined workflow, reduced errors, and improved code readability with pyprojectsort
.
Features
- Alphabetically sorts pyproject.toml by:
- section
- section key
- list value
- Reformats pyproject.toml to a standardised style
- Double quotations
- Trailing commas
- Line per value for list length above three
- or less with explicit trailing commas
Installation
pyprojectsort
is available via PyPI (via Platform Wheels):
pip install pyprojectsort
Examples
With the following pyproject.toml
contained inside a directory:
[tool.ruff]
ignore = [
"G004",
"T201",
"ANN"
]
[project]
name = 'pyprojectsort'
[tool.radon]
show_mi = true
exclude = "tests/*,venv/*"
total_average = true
show_complexity = true
[build-system]
build-backend = "flit.buildapi"
requires = ["flit"]
Run the package from within the directory of the pyproject toml file:
pyprojectsort
The configuration will be reformatted as follows:
[build-system]
build-backend = "flit.buildapi"
requires = ["flit"]
[project]
name = "pyprojectsort"
[tool.radon]
exclude = "tests/*,venv/*"
show_complexity = true
show_mi = true
total_average = true
[tool.ruff]
ignore = [
"ANN",
"G004",
"T201",
]
The path to the pyproject toml file can also be specified from the command line:
pyprojectsort ../pyproject.toml
Check formatting
To check whether formatting would be applied to your file you may use the --check option.
pyprojectsort --check
When the file would be reformatted, the output message '{file_path}' would be reformatted
displays and the program terminates with exit code 1.
If the given file matches the style of pyprojectsort
, the output message '{file_path}' would be left unchanged
displays and the program terminates successfully.
License
pyprojectsort
is licensed under the MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyprojectsort-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f8412e3c123eaa0608f9c1dab915f1d4745ea9ab21399a87c944b98f906e730 |
|
MD5 | e83c3bb7a3e7911908cfe236afd8cdb5 |
|
BLAKE2b-256 | b5a1d7663e629552c89ba5af687629d66362ff3fbcfb66efb0e8d1ebe2b0bc16 |