All Projects → omnilib → ufmt

omnilib / ufmt

Licence: MIT license
Safe, atomic formatting with black and µsort

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to ufmt

awesome-python-code-formatters
A curated list of awesome Python code formatters
Stars: ✭ 168 (+265.22%)
Mutual labels:  formatter, formatting, black
Editorconfig Netbeans
A NetBeans IDE plugin supporting the EditorConfig standard. ⛺
Stars: ✭ 123 (+167.39%)
Mutual labels:  formatter, formatting
Vse Formatdocumentonsave
Visual Studio - Format Document on Save
Stars: ✭ 61 (+32.61%)
Mutual labels:  formatter, formatting
Sublime-uroboroSQL-formatter
Beautiful SQL Formatter for Sublime Text 3
Stars: ✭ 25 (-45.65%)
Mutual labels:  formatter, formatting
formatting
源码格式自动化调整工具
Stars: ✭ 37 (-19.57%)
Mutual labels:  formatter, formatting
kirai
String formatting library for Java, Android, Web and Unix Terminal
Stars: ✭ 69 (+50%)
Mutual labels:  formatter, formatting
Nginx Config Formatter
nginx config file formatter/beautifier written in Python.
Stars: ✭ 222 (+382.61%)
Mutual labels:  formatter, formatting
Juliaformatter.jl
An opinionated code formatter for Julia. Plot twist - the opinion is your own.
Stars: ✭ 217 (+371.74%)
Mutual labels:  formatter, formatting
unicode-formatter
Convert portions of text to fancy text using unicode fonts for use on Twitter and other sites that don't support rich text
Stars: ✭ 31 (-32.61%)
Mutual labels:  formatter, formatting
blackbricks
Black for Databricks notebooks
Stars: ✭ 40 (-13.04%)
Mutual labels:  formatter, black
teks
Easily get custom go template based outputs to your command-line tool. Like in docker/kubernetes
Stars: ✭ 41 (-10.87%)
Mutual labels:  formatter, formatting
Golite
Add essential language support for the Go language to Sublime Text 3.
Stars: ✭ 14 (-69.57%)
Mutual labels:  formatter, formatting
dockerfile-utils
A library and command line interface for formatting and linting Dockerfiles.
Stars: ✭ 17 (-63.04%)
Mutual labels:  formatter, formatting
snakefmt
The uncompromising Snakemake code formatter
Stars: ✭ 78 (+69.57%)
Mutual labels:  formatter, black
AutoFormatInputWatcher
This repository contains input watcher for auto formatting digits in edit text
Stars: ✭ 15 (-67.39%)
Mutual labels:  formatter, formatting
idea-uroborosql-formatter
Beautiful SQL Formatter for IntelliJ Platform
Stars: ✭ 18 (-60.87%)
Mutual labels:  formatter, formatting
laravel-formatters
«‎Formatter» pattern for Laravel
Stars: ✭ 86 (+86.96%)
Mutual labels:  formatter, formatting
pre-commit-hooks
Standardizing our code quality tooling 🛠️
Stars: ✭ 44 (-4.35%)
Mutual labels:  formatter, black
rspec-github
Formatter for RSpec to show errors in GitHub action annotations
Stars: ✭ 33 (-28.26%)
Mutual labels:  formatter
mirtop
command lines tool to annotate miRNAs with a standard mirna/isomir naming
Stars: ✭ 16 (-65.22%)
Mutual labels:  formatter

µfmt

Safe, atomic formatting with black and µsort

version documentation changelog license

µ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 chance of 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

If you want to prevent unexpected formatting changes that can break your CI workflow, make sure to pin your transitive dependencies–including black, µsort, and µfmt–to your preferred versions.

If you use requirements.txt, this might look like:

black==22.3.0
ufmt==1.3.2
usort==1.0.2

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> ...]

pre-commit hook

µfmt provides a pre-commit hook. To format your diff before every commit, add the following to your .pre-commit-config.yaml file:

  - repo: https://github.com/omnilib/ufmt
    rev: v1.3.2
    hooks:
      - id: ufmt

You can change the rev to any version >= 1.3.0. To pin black and usort, use the additional_dependencies option:

    hooks: 
      - id: ufmt 
        additional_dependencies: 
          - black == 22.3.0
          - usort == 1.0.2

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].