Skip to main content

A fast Python CLI tool for formatting and sorting YAML files with pre-commit integration

Project description

🔧 pyamit

A Python CLI tool for formatting and sorting YAML files, perfect for pre-commit hooks

pyamit (Pyyamlprecommit) is a fast, reliable tool that formats YAML files with consistent indentation and optional key sorting. Built with Typer and PyYAML, it's designed to integrate seamlessly with pre-commit for automated YAML formatting in your projects.

✨ Features

  • 🚀 Fast formatting - Quick YAML processing with PyYAML
  • 🔢 Key sorting - Optional alphabetical key sorting
  • 📏 Custom indentation - Configurable indent levels (default: 2 spaces)
  • 🪝 Pre-commit ready - Easy integration with pre-commit hooks
  • 🧪 Well tested - Comprehensive test suite with pytest
  • 🎨 Auto-formatted - Code linted and formatted with Ruff

📦 Installation

Using uv (recommended)

uv install

Using pip

pip install .

For development

git clone <repository-url>
cd pyamit
uv install --dev

🚀 Usage

Basic formatting

pyamit file1.yaml file2.yaml

Sort keys alphabetically

pyamit --sort-keys file1.yaml file2.yaml

Custom indentation

pyamit --indent 4 file1.yaml file2.yaml

Combine options

pyamit --sort-keys --indent 4 file1.yaml file2.yaml

Get help

pyamit --help

🪝 Pre-commit Integration

Once installed via pip/uv, you can integrate pyamit into your pre-commit hooks.

Add to your .pre-commit-config.yaml:

repos:
  - repo: local
    hooks:
      - id: pyamit
        name: Format YAML files
        entry: pyamit
        language: system
        files: \.yaml$
        args: [--sort-keys]

For this project

The included pre-commit config ensures code quality:

pre-commit install
pre-commit run --all-files

🛠️ Development

Run tests

uv run pytest

Lint and format code

uv run ruff check . --fix
uv run ruff format .

Use pre-commit hooks

pre-commit install
pre-commit run --all-files

CI/CD

This project uses GitHub Actions for continuous integration and deployment with optimized uv workflows:

  • Multi-Python Testing: Tests across Python 3.11, 3.12, and 3.13
  • Pre-commit Hooks: Automated linting and formatting with cached hooks
  • uv Caching: Dependency and virtual environment caching for faster builds
  • Publishing: Automatic PyPI publishing on releases using OIDC trusted publishing
  • Cache Optimization: uv cache pruning for efficient CI resource usage

📋 Requirements

  • Python 3.11+
  • uv (for development)

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

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

pyamit-0.1.0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyamit-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file pyamit-0.1.0.tar.gz.

File metadata

  • Download URL: pyamit-0.1.0.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyamit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 19fa3d49248cdd151fb8466cb88ca25769822011ab556511fbc2b69774cb2e37
MD5 fbeffdca89534e30917de6e9b5b3e519
BLAKE2b-256 c77b48f611516e0cd816267b46e1c463e88f832b56e3eb2ca6d5f89e74428dc0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyamit-0.1.0.tar.gz:

Publisher: workflow.yml on mounirmesselmeni/pyamit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyamit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyamit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyamit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57ea532d6a39cc5f7a0dc87aa1dddc5418e895846fc060f032c61853347d171e
MD5 eec9c36370aa4402e2f6beab30f8fdde
BLAKE2b-256 ed50c1ca4c4a1495bf91b2521e6f06052b0e48d599010550e3ac91d926297179

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyamit-0.1.0-py3-none-any.whl:

Publisher: workflow.yml on mounirmesselmeni/pyamit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page