skillfed

ufmt

Safe, atomic formatting with black and µsort

ufmt v2.9.1 2.3M downloads/30d#3,127 on PyPI110
Permissive license Active released

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 ufmt

uv

uv add ufmt

poetry

poetry add ufmt

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseTopic :: UtilitiesTyping :: Typed

Tags

python code formatter with import sortingatomic black and usort formattingsafe import sorter and code formattercombined black µsort formatterpython formatter ci/cd workflowprevent formatting conflicts formatterin-memory formatting python
code-formattingci-cd

More Utilities packages