ufmt
Safe, atomic formatting with black and µsort
What it is and what it does
ufmt is a Python code formatter that wraps black and µsort, running both tools in a single atomic operation. It formats files in-memory, first with µsort and then with black, before writing changes back to disk. This design prevents conflicts or intermediate states that can occur when running these tools separately in CI/CD pipelines.
The package is built for developers who want consistent, minimal diffs and safe handling without the risk of competing tools making conflicting changes. It integrates with GitHub Actions, pre-commit hooks, and Visual Studio Code, and supports checking, formatting, and diff-generation modes for different workflow needs.
Use it for:
- Enforce consistent Python formatting in CI/CD without conflicts between separate formatting steps.
- Set up pre-commit hooks to automatically format code before commits with atomic changes.
- Validate that files are properly formatted in pull requests using the check or diff modes.
- Use as the default formatter in VS Code for automatic formatting on save.
- Pin transitive dependencies in requirements files to ensure reproducible formatting across environments.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
ufmt combines black and µsort into a single atomic formatting pass, sorting imports and then formatting code in one operation before writing to disk.
Yes. ufmt solves a real problem—atomic, conflict-free formatting in CI workflows—with low install friction, active maintenance, no known vulnerabilities, and a permissive license. It is well-integrated into common development tools and suitable for teams that want safe, predictable formatting.
Install
ufmt on PyPI
pip
pip install ufmtuv
uv add ufmtpoetry
poetry add ufmtInstalling ufmt
Before you install
Low friction: pure Python wheel with 8 runtime dependencies (black, click, libcst, moreorless, tomlkit, trailrunner, typing-extensions, usort). Active maintenance with recent commits; last release 187 days ago. Requires Python 3.10 or newer.
License in practice
MIT license (permissive). No restrictions on commercial or private use; you may modify and distribute freely with attribution.
Quickstart
pip install ufmt
ufmt format myfile.py
ufmt check myfile.py
ufmt diff myfile.py
Requires Python 3.10 or newer.
Verify before relying
- Whether pinning transitive dependencies (black, µsort) is necessary in practice to prevent unexpected formatting changes in CI workflows.
- Performance characteristics when formatting large codebases or many files at once.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — black, click, libcst, moreorless, tomlkit, trailrunner, typing-extensions, usort |
| Maintenance | actively maintained — 187 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,337,651/month — #3,127 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ufmt-2.9.1-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
usortμsort sorts Python imports within detected…
permissive · top 5,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
darkerDarker reformats Python source code in Git…
permissive · top 15,000 on PyPI
mdformat-blackA plugin for mdformat that automatically…
permissive · top 15,000 on PyPI
sort-linesAlphabetizes lines in files based on…
permissive · top 15,000 on PyPI
docstrfmtAutomatically formats reStructuredText in files…
permissive · top 15,000 on PyPI
pyinkPyink is a Python code formatter forked from…
permissive · top 15,000 on PyPI
reformat-gherkinAutomatically formats Gherkin feature files to…
permissive · top 15,000 on PyPI
mdformat-ruffIntegrates ruff code formatting into mdformat…
permissive · top 15,000 on PyPI
isortisort sorts Python imports alphabetically and…
permissive · top 1,000 on PyPI