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.

For your projects

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

repos:
  - repo: https://github.com/mounirmesselmeni/pyamit
    rev: v0.1.1 # Use the latest version
    hooks:
      - id: pyamit

  # Or use with custom arguments
  - repo: https://github.com/mounirmesselmeni/pyamit
    rev: v0.1.1
    hooks:
      - id: pyamit
        args: [--sort-keys, --indent=4]

Alternative: Local installation

If you prefer to install locally:

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
  • Coverage Reporting: Automated test coverage reporting (93%+) with coverage publishing
  • 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.1.tar.gz (30.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.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyamit-0.1.1.tar.gz
  • Upload date:
  • Size: 30.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.1.tar.gz
Algorithm Hash digest
SHA256 ddb18f2fc67efba00bd7ef055d45ef815ee87dc3ce008602ba47c830828b93eb
MD5 0f8b331f4d63005c41dc43f6001f3bf7
BLAKE2b-256 11f1e541f160877529506c26b178b2a88d374df3b8c54bb6d07d44b1e1cc87b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyamit-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: pyamit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d2011efa7908a25c913cc8c22313e36907a81f309827a18a54acda9c1921179b
MD5 93049fd29e81b17767ed6d04bf85575c
BLAKE2b-256 479d190c964255524f16167caf335225323f57238cfdca586763c4d36506586d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyamit-0.1.1-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