pyprojectsort


Namepyprojectsort JSON
Version 0.4.0 PyPI version JSON
download
home_pageNone
SummaryFormatter for pyproject.toml files
upload_time2024-12-31 22:39:10
maintainerNone
docs_urlNone
authorKieran Ryan
requires_python>=3.7
licenseNone
keywords formatter pyproject
VCS
bugtrack_url
requirements natsort tomli tomli-w
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyprojectsort

[![PyPI Version](https://badge.fury.io/py/pyprojectsort.svg)](https://pypi.org/project/pyprojectsort/)
![LICENSE](https://img.shields.io/badge/license-MIT-blue)
[![Python versions](https://img.shields.io/pypi/pyversions/pyprojectsort.svg)](https://pypi.org/pypi/pyprojectsort)
![Supported platforms](https://img.shields.io/badge/platforms-macOS%20%7C%20Windows%20%7C%20Linux-green)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
![Pipeline status](https://github.com/kieran-ryan/python-package-template/actions/workflows/main.yml/badge.svg)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/kieran-ryan/pyprojectsort/main.svg)](https://results.pre-commit.ci/latest/github/kieran-ryan/pyprojectsort/main)

Formatter for pyproject.toml files.

This package enforces consistent formatting of pyproject.toml files, reducing merge request conflicts and saving time otherwise 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

- Alphanumerically sorts pyproject.toml by:
  - section
  - section key
  - list value
- Reformats pyproject.toml to a standardised style
  - line per list value
  - double quotations
  - trailing commas
  - indentation
  - end of file newline

## Installation

`pyprojectsort` is available via [PyPI](https://pypi.org/project/pyprojectsort/):

```console
pip install pyprojectsort
```

### Using pyprojectsort with [pre-commit](https://pre-commit.com)

To use as an automated git hook, add this to your `.pre-commit-config.yaml`:

```yaml
- repo: https://github.com/kieran-ryan/pyprojectsort
  rev: v0.3.0
  hooks:
    - id: pyprojectsort
```

## Examples

With the following `pyproject.toml`:

```toml
[tool.ruff]
ignore = ["G004",
"T201",
    "ANN"
]

[project]
name = 'pyprojectsort'
authors = [
    { name = "Kieran Ryan" },
    "Author Name <author@email.com>",
    {name="Author Name"}
]

[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 its directory:

```console
pyprojectsort
```

The configuration will be reformatted as follows:

```toml
[build-system]
build-backend = "flit.buildapi"
requires = [
    "flit",
]

[project]
authors = [
    "Author Name <author@email.com>",
    { name = "Author Name" },
    { name = "Kieran Ryan" },
]
name = "pyprojectsort"

[tool.radon]
exclude = "tests/*,venv/*"
show_complexity = true
show_mi = true
total_average = true

[tool.ruff]
ignore = [
    "ANN",
    "G004",
    "T201",
]
```

The pyproject file path can alternatively be specified:

```console
pyprojectsort ../pyproject.toml
```

### Check formatting

The **--check** option can be used to determine whether your file would be reformatted.

```console
pyprojectsort --check
```

If the file needs reformatting, the program exits with an error code. This is useful for [pipeline integration](https://github.com/kieran-ryan/pyprojectsort/blob/d9cf5e1e646e1e5260f7cf0168ecd0a05ce8ed11/.github/workflows/main.yml#L30) as it prevents writing back changes so that a clean repository is maintained for subsequent jobs.

The **--diff** option provides similar functionality but also displays any changes that would be made.

```console
pyprojectsort --diff
```

The diff of an alphabetically reordered array will appear as follows:

```diff
@@ -6,8 +6,8 @@
[project]
authors = [
+ { name = "Author Name" },
  { name = "Kieran Ryan" },
- { name = "Author Name" },
]
```

## License

`pyprojectsort` is licensed under the [MIT License](https://opensource.org/licenses/MIT).


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyprojectsort",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "formatter, pyproject",
    "author": "Kieran Ryan",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/fa/b5/84ce6207d1b66c07987ff65b5a88a523f58fee5508bbc5e92fff67c625cd/pyprojectsort-0.4.0.tar.gz",
    "platform": null,
    "description": "# pyprojectsort\n\n[![PyPI Version](https://badge.fury.io/py/pyprojectsort.svg)](https://pypi.org/project/pyprojectsort/)\n![LICENSE](https://img.shields.io/badge/license-MIT-blue)\n[![Python versions](https://img.shields.io/pypi/pyversions/pyprojectsort.svg)](https://pypi.org/pypi/pyprojectsort)\n![Supported platforms](https://img.shields.io/badge/platforms-macOS%20%7C%20Windows%20%7C%20Linux-green)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)\n[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)\n![Pipeline status](https://github.com/kieran-ryan/python-package-template/actions/workflows/main.yml/badge.svg)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/kieran-ryan/pyprojectsort/main.svg)](https://results.pre-commit.ci/latest/github/kieran-ryan/pyprojectsort/main)\n\nFormatter for pyproject.toml files.\n\nThis package enforces consistent formatting of pyproject.toml files, reducing merge request conflicts and saving time otherwise 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`.\n\n## Features\n\n- Alphanumerically sorts pyproject.toml by:\n  - section\n  - section key\n  - list value\n- Reformats pyproject.toml to a standardised style\n  - line per list value\n  - double quotations\n  - trailing commas\n  - indentation\n  - end of file newline\n\n## Installation\n\n`pyprojectsort` is available via [PyPI](https://pypi.org/project/pyprojectsort/):\n\n```console\npip install pyprojectsort\n```\n\n### Using pyprojectsort with [pre-commit](https://pre-commit.com)\n\nTo use as an automated git hook, add this to your `.pre-commit-config.yaml`:\n\n```yaml\n- repo: https://github.com/kieran-ryan/pyprojectsort\n  rev: v0.3.0\n  hooks:\n    - id: pyprojectsort\n```\n\n## Examples\n\nWith the following `pyproject.toml`:\n\n```toml\n[tool.ruff]\nignore = [\"G004\",\n\"T201\",\n    \"ANN\"\n]\n\n[project]\nname = 'pyprojectsort'\nauthors = [\n    { name = \"Kieran Ryan\" },\n    \"Author Name <author@email.com>\",\n    {name=\"Author Name\"}\n]\n\n[tool.radon]\nshow_mi = true\nexclude = \"tests/*,venv/*\"\ntotal_average = true\nshow_complexity = true\n\n[build-system]\nbuild-backend = \"flit.buildapi\"\nrequires = [\"flit\"]\n```\n\nRun the package from within its directory:\n\n```console\npyprojectsort\n```\n\nThe configuration will be reformatted as follows:\n\n```toml\n[build-system]\nbuild-backend = \"flit.buildapi\"\nrequires = [\n    \"flit\",\n]\n\n[project]\nauthors = [\n    \"Author Name <author@email.com>\",\n    { name = \"Author Name\" },\n    { name = \"Kieran Ryan\" },\n]\nname = \"pyprojectsort\"\n\n[tool.radon]\nexclude = \"tests/*,venv/*\"\nshow_complexity = true\nshow_mi = true\ntotal_average = true\n\n[tool.ruff]\nignore = [\n    \"ANN\",\n    \"G004\",\n    \"T201\",\n]\n```\n\nThe pyproject file path can alternatively be specified:\n\n```console\npyprojectsort ../pyproject.toml\n```\n\n### Check formatting\n\nThe **--check** option can be used to determine whether your file would be reformatted.\n\n```console\npyprojectsort --check\n```\n\nIf the file needs reformatting, the program exits with an error code. This is useful for [pipeline integration](https://github.com/kieran-ryan/pyprojectsort/blob/d9cf5e1e646e1e5260f7cf0168ecd0a05ce8ed11/.github/workflows/main.yml#L30) as it prevents writing back changes so that a clean repository is maintained for subsequent jobs.\n\nThe **--diff** option provides similar functionality but also displays any changes that would be made.\n\n```console\npyprojectsort --diff\n```\n\nThe diff of an alphabetically reordered array will appear as follows:\n\n```diff\n@@ -6,8 +6,8 @@\n[project]\nauthors = [\n+ { name = \"Author Name\" },\n  { name = \"Kieran Ryan\" },\n- { name = \"Author Name\" },\n]\n```\n\n## License\n\n`pyprojectsort` is licensed under the [MIT License](https://opensource.org/licenses/MIT).\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Formatter for pyproject.toml files",
    "version": "0.4.0",
    "project_urls": {
        "Changelog": "https://github.com/kieran-ryan/pyprojectsort/blob/main/CHANGELOG.md",
        "Documentation": "https://kieran-ryan.github.io/pyprojectsort",
        "Source": "https://github.com/kieran-ryan/pyprojectsort",
        "Tracker": "https://github.com/kieran-ryan/pyprojectsort/issues"
    },
    "split_keywords": [
        "formatter",
        " pyproject"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "033429edefa451aadb2fefb302519260668e5253f65d356cb8d5ed96d830f78c",
                "md5": "a881603430bb2b39336a627b35fd7b3d",
                "sha256": "6209ac47e67cd1131d8ffbb711349d26a7e2d38429910fc5a7b1c998f7b13cee"
            },
            "downloads": -1,
            "filename": "pyprojectsort-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a881603430bb2b39336a627b35fd7b3d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6853,
            "upload_time": "2024-12-31T22:39:08",
            "upload_time_iso_8601": "2024-12-31T22:39:08.704512Z",
            "url": "https://files.pythonhosted.org/packages/03/34/29edefa451aadb2fefb302519260668e5253f65d356cb8d5ed96d830f78c/pyprojectsort-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fab584ce6207d1b66c07987ff65b5a88a523f58fee5508bbc5e92fff67c625cd",
                "md5": "76fe0cf7901414ddf0050d8a2b73dcd7",
                "sha256": "c6a3a4efd86c085eb182fa125dce9ace6b817ad77bb2afbfbc31e52ce26cfa32"
            },
            "downloads": -1,
            "filename": "pyprojectsort-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "76fe0cf7901414ddf0050d8a2b73dcd7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5858,
            "upload_time": "2024-12-31T22:39:10",
            "upload_time_iso_8601": "2024-12-31T22:39:10.738544Z",
            "url": "https://files.pythonhosted.org/packages/fa/b5/84ce6207d1b66c07987ff65b5a88a523f58fee5508bbc5e92fff67c625cd/pyprojectsort-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-31 22:39:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kieran-ryan",
    "github_project": "pyprojectsort",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "natsort",
            "specs": [
                [
                    ">=",
                    "8.4.0"
                ],
                [
                    "<",
                    "9"
                ]
            ]
        },
        {
            "name": "tomli",
            "specs": [
                [
                    "<",
                    "3"
                ],
                [
                    ">=",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "tomli-w",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        }
    ],
    "lcname": "pyprojectsort"
}
        
Elapsed time: 0.40850s