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 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.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyamit-0.1.3.tar.gz.
File metadata
- Download URL: pyamit-0.1.3.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cdae60bb22ccfc83f33c42bcc1132d7d0ecdfb43f5faf22ea8afbef4c0252bc
|
|
| MD5 |
5841557b5720177dab0981b3ef260681
|
|
| BLAKE2b-256 |
7eb73c0981a039725eeff9bf6211e0fbbdc3613f879aa873c4dfdf223306fa1e
|
Provenance
The following attestation bundles were made for pyamit-0.1.3.tar.gz:
Publisher:
workflow.yml on mounirmesselmeni/pyamit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyamit-0.1.3.tar.gz -
Subject digest:
3cdae60bb22ccfc83f33c42bcc1132d7d0ecdfb43f5faf22ea8afbef4c0252bc - Sigstore transparency entry: 575774393
- Sigstore integration time:
-
Permalink:
mounirmesselmeni/pyamit@782a3931c7fcb59d74da80c5ea432419bd1b8423 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/mounirmesselmeni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@782a3931c7fcb59d74da80c5ea432419bd1b8423 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyamit-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pyamit-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
436b4fe9bd3faf4f141638d7babc32b2173c7ae975bb61b04e401276ee93675b
|
|
| MD5 |
fbfe3be2ee911ce4aebb70d8b9945241
|
|
| BLAKE2b-256 |
af4f3bd6b0546344cc41879c57a78564587cf0bc7475fa2900847778cf1a3cd3
|
Provenance
The following attestation bundles were made for pyamit-0.1.3-py3-none-any.whl:
Publisher:
workflow.yml on mounirmesselmeni/pyamit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyamit-0.1.3-py3-none-any.whl -
Subject digest:
436b4fe9bd3faf4f141638d7babc32b2173c7ae975bb61b04e401276ee93675b - Sigstore transparency entry: 575774405
- Sigstore integration time:
-
Permalink:
mounirmesselmeni/pyamit@782a3931c7fcb59d74da80c5ea432419bd1b8423 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/mounirmesselmeni
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@782a3931c7fcb59d74da80c5ea432419bd1b8423 -
Trigger Event:
release
-
Statement type: