shfmt-py
Python wrapper around invoking shfmt (https://github.com/mvdan/sh)
What it is and what it does
shfmt-py is a Python wrapper that downloads and bundles the shfmt shell script formatter binary for your operating system at install time. Once installed, it makes the shfmt command available on your PATH (or as shfmt.exe on Windows), allowing you to format shell scripts from the command line or integrate formatting into your development workflow via pre-commit hooks.
The package has no runtime dependencies and is independently versioned from the upstream shfmt project—each release notes specify which shfmt version is bundled. It supports Python 3.9 and later on CPython and PyPy, and provides platform-specific wheels for macOS (Intel and ARM), Linux (x86_64 and aarch64), and Windows. The wrapper handles the complexity of downloading the correct binary for your platform, so you get a consistent shfmt experience across development machines without manual binary management.
Use it for:
- Enforce consistent shell script formatting in CI/CD pipelines by installing shfmt-py and running it as a linter step.
- Set up a pre-commit hook to automatically format shell scripts before commits, using the sample .pre-commit-config.yaml configuration.
- Format shell scripts locally during development without manually downloading or managing the shfmt binary for your platform.
- Integrate shell script formatting into Python-based build or deployment tools that need to standardize script formatting.
- Ensure shell script style consistency across a team by pinning a specific shfmt-py version in a shared development environment.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Python-installable wrapper that bundles the shfmt shell script formatter binary for your platform, making it available as a command-line tool or pre-commit hook.
Yes, if you need to format shell scripts in a Python environment or CI/CD pipeline. The package is actively maintained, has no runtime dependencies, and provides convenient platform-specific binary distribution. Medium install friction (platform-specific downloads) is a minor trade-off for avoiding manual binary management. Be aware that the bundled shfmt version does not directly mirror the PyPI version—check release notes for the exact upstream version you're getting.
Install
shfmt-py on PyPI
pip
pip install shfmt-pyuv
uv add shfmt-pypoetry
poetry add shfmt-pyInstalling shfmt-py
Before you install
Medium install friction due to platform-specific binary downloads at install time. The package is actively maintained with a recent release (93 days ago) and supports current Python versions (3.9+). No runtime dependencies simplifies the installation footprint.
License in practice
MIT license permits commercial and private use with minimal restrictions—you may use, modify, and distribute this package freely as long as you include the license notice.
Quickstart
pip install shfmt-py
shfmt --version
shfmt -i 2 script.sh
Requires Python 3.9 or later. Binary downloads occur at install time; SSL certificate issues may occur on macOS and require manual certificate installation.
Verify before relying
- Whether the bundled shfmt version is documented clearly enough for users who need a specific upstream shfmt release.
- Performance impact of the binary download during installation on slow or unreliable networks.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 93 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 286,537/month — #8,042 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: shfmt_py-4.0.0-py2.py3-none-macosx_10_9_x86_64.whl; shfmt_py-4.0.0-py2.py3-none-macosx_11_0_arm64.whl; shfmt_py-4.0.0-py2.py3-none-manylinux2014_aarch64.whl; shfmt_py-4.0.0-py2.py3-none-manylinux2014_x86_64.whl; shfmt_py-4.0.0-py2.py3-none-win_amd64.whl
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
shellcheck-pyProvides a pip-installable shellcheck binary…
permissive · top 5,000 on PyPI
hadolint-coatlProvides a pip-installable hadolint binary…
permissive · top 15,000 on PyPI
clang-formatPackages the clang-format code formatter as a…
permissive · top 5,000 on PyPI
actionlint-pyactionlint-py provides a pip-installable…
permissive · top 15,000 on PyPI
reformat-gherkinAutomatically formats Gherkin feature files to…
permissive · top 15,000 on PyPI
add-trailing-commaAutomatically adds trailing commas to…
permissive · top 15,000 on PyPI
ruff-formatProvides Python bindings to Ruff's code…
permissive · top 15,000 on PyPI
beautyshBeautysh automatically formats and beautifies…
permissive · top 15,000 on PyPI
mdformat-ruffIntegrates ruff code formatting into mdformat…
permissive · top 15,000 on PyPI
actions-toolkitProvides a Python SDK for building GitHub…
permissive · top 15,000 on PyPI