Safe, atomic formatting with black and µsort
Project description
µfmt
Safe, atomic formatting with black and µsort
µ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, like for CI workflows:
$ ufmt check <path> [<path> ...]
To validate formatting and generate a diff of necessary changes:
$ ufmt diff <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
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
File details
Details for the file ufmt-1.1.tar.gz
.
File metadata
- Download URL: ufmt-1.1.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9556e95a9712f6c4f95a75fe52937e6337b43be249d60329b79363f473e85779 |
|
MD5 | 5205efbd2ff85f90e81218b7a1e75a82 |
|
BLAKE2b-256 | 5a108dd7d50bffd532233770cfae0eee1abcf10dc8b65c970d5905612f54df46 |
File details
Details for the file ufmt-1.1-py3-none-any.whl
.
File metadata
- Download URL: ufmt-1.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.25.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea9e01501104495ef76facc35564cbe5416e62f3d97ee64ab53d768e099551ec |
|
MD5 | e77d0742e6c0eb3a9ff151b09429a037 |
|
BLAKE2b-256 | 7dd74267985dc3315d33d24410c247a14edd1888d6c05365fb9e978396a2320c |