Skip to main content

Safe, atomic formatting with black and µsort

Project description

µfmt

Safe, atomic formatting with black and µsort

version documentation changelog license build status code coverage

µfmt is a safe, atomic code formatter for Python built on top of black and µsort:

Black makes code review faster by producing the smallest diffs possible. Blackened code looks the same regardless of the project you’re reading.

μsort is a safe, minimal import sorter. Its primary goal is to make no “dangerous” changes to code, and to make no changes on code style.

µfmt formats files in-memory, first with µsort and then with black, before writing any changes back to disk. This enables a combined, atomic step in CI/CD workflows for checking or formatting files, without any with conflict or intermediate changes between the import sorter and the code formatter.

Install

µfmt requires Python 3.6 or newer. You can install it from PyPI:

$ pip install ufmt

Usage

To format one or more files or directories in place:

$ ufmt format <path> [<path> ...]

To validate files are formatted correctly:

$ ufmt check <path> [<path> ...]

License

µfmt is copyright John Reese, and licensed under the MIT license. I am providing code in this repository to you under an open source license. This is my personal repository; the license you receive to my code is from me and not from my employer. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ufmt-1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

ufmt-1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file ufmt-1.0.tar.gz.

File metadata

  • Download URL: ufmt-1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for ufmt-1.0.tar.gz
Algorithm Hash digest
SHA256 d2b806cc7b67bdab98d552552369e37c1d1f9e9a4156682fdf7a5146ccbcfa80
MD5 50a12b5c84bc7d031cf1588ec727515e
BLAKE2b-256 3242a4acffe07808435681be9f4eaeceb5becc9c7c065efdac36ec79831ea757

See more details on using hashes here.

File details

Details for the file ufmt-1.0-py3-none-any.whl.

File metadata

  • Download URL: ufmt-1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.25.1

File hashes

Hashes for ufmt-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54acdcab59d62ef9eff0032659330577de0b48b3de41edd528562a5586147398
MD5 d0a709e90fe2e8ccf22082417916299e
BLAKE2b-256 42f2a2cc12130ec4996b5a1beee0bc9bba7f278ddee04aa02a61f08dc53e8ce9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page