🔧 pyamit
A Python CLI tool for formatting and sorting YAML files, perfect for repos:
- repo: https://github.com/mounirmesselmeni/pyamit
rev: v0.1.3 # Use the latest version
hooks:
- id: pyamit
Or use with custom arguments
- repo: https://github.com/mounirmesselmeni/pyamit
rev: v0.1.3
hooks:
- id: pyamit args: [--sort-keys, --sort-lists, --indent=4]ooks
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
Sort lists in YAML
pyamit --sort-lists file1.yaml file2.yaml
Custom indentation
pyamit --indent 4 file1.yaml file2.yaml
Combine options
pyamit --sort-keys --sort-lists --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, --sort-lists, --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 (97%+) 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
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Release files for pyamit 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyamit-0.1.3.tar.gz | 33.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyamit-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.4 kB
Release files / pyamit-0.1.3.tar.gz
| Download URL | pyamit-0.1.3.tar.gz |
|---|---|
| Size | 33.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3cdae60bb22ccfc83f33c42bcc1132d7d0ecdfb43f5faf22ea8afbef4c0252bc
|
|
BLAKE2b-256 checksum How to use checksums |
7eb73c0981a039725eeff9bf6211e0fbbdc3613f879aa873c4dfdf223306fa1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2025.
Transparency logRelease files / pyamit-0.1.3-py3-none-any.whl
| Download URL | pyamit-0.1.3-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
436b4fe9bd3faf4f141638d7babc32b2173c7ae975bb61b04e401276ee93675b
|
|
BLAKE2b-256 checksum How to use checksums |
af4f3bd6b0546344cc41879c57a78564587cf0bc7475fa2900847778cf1a3cd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 1, 2025.
Transparency log