• Stars
    star
    389
  • Rank 110,500 (Top 3 %)
  • Language
    Python
  • License
    Other
  • Created about 4 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The slightly less uncompromising Python code formatter.

Blue

Some folks like black but I prefer blue.

What is blue?

blue is a somewhat less uncompromising code formatter than black, the OG of Python formatters. We love the idea of automatically formatting Python code, for the same reasons that inspired black, however we take issue with some of the decisions black makes. Kudos to black for pioneering code formatting for Python, and for its excellent implementation.

Where the blue maintainers disagree with the stylistic (and unconfigurable) choices made by black, we monkeypatch to change these decisions to our own liking. We intend for these differences to be minimal; even in cases where we'd prefer something different, there's a lot we can live with for the sake of consistency.

We'd prefer not to fork or monkeypatch. Instead, our hope is that eventually we'll be able to work with the black maintainers to add just a little bit of configuration and merge back into the black project. We'd be ecstatic if blue eventually were retired. Until then, we'll maintain our small set of hacks on top of black and carefully consider what other deviations are needed to assuage our sensitive, but experienced, eye.

How do I use blue?

Exactly the same as you would use black. Invoke and configure blue as you would black -- just replace the black command with blue, sit back, and enjoy even betterly formatted Python code! You can refer to black's documentation for anything not listed here.

Try it out now using iblueit.dev.

So what's different?

Here is a brief list of differences between blue and black:

  • blue defaults to single-quoted strings. This is probably the most painful black choice to our eyes, and the thing that inspired blue. We strongly prefer using single quoted strings over double quoted strings for everything except docstrings and triple quoted strings (TQS). Don't ask us why we prefer double-quotes for TQS; it just looks better to us! For all other strings, blue defaults to single quoted strings. In the case of docstrings, those always use TQS with double-quotes.
  • blue defaults to line lengths of 79 characters. Nearly every project creates a pyproject.toml just to change this one setting so making it consistent with PEP 8 seems relatively harmless.
  • blue preserves the whitespace before the hash mark for right hanging comments.
  • blue supports multiple config files: pyproject.toml, setup.cfg, tox.ini, and .blue.

We are accumulating a list of other deviations we are considering. As we decide to implement any particular suggestion, we'll turn those into individual issues and tackle them one-by-one. If you have suggestions for other deviations from black's choices, please open a separate ticket on our tracker, and we'll see how it goes!

Why "blue"?

Several reasons! If your formatter is going to beat up your code, it'll leave it black and blue, or maybe in this case, black or blue. Blue is better!

We also thought about "tan" because, yum! But that project name was already taken. Frankly, "blue" was also taken, but largely unused. Our thanks to Nick Ficano for donating the project namespace to us!

Blue is also the color of LinkedIn, the authors' gracious employer, and we intend to socialize its use within our company code base.

Contributors

blue thanks this list of contributors for all its wonderful goodness.

blue is licensed under the terms of the Apache License Version 2.0. black is licensed under the terms of the MIT license.

Project details

More Repositories

1

python-sortedcontainers

Python Sorted Container Types: Sorted List, Sorted Dict, and Sorted Set
Python
3,494
star
2

free-python-games

Free Python Games
Python
3,408
star
3

python-diskcache

Python disk-backed cache (Django-compatible). Faster than Redis and Memcached. Pure-Python.
Python
2,331
star
4

python-wordsegment

English word segmentation, written in pure-Python, and based on a trillion-word corpus.
Python
365
star
5

python-pattern-matching

Python pattern matching like functional languages.
Python
162
star
6

py-tree-sitter-languages

Binary Python wheels for all tree sitter languages.
Python
149
star
7

python-sortedcollections

Python Sorted Collections Library
Python
102
star
8

python-runstats

Python module for computing statistics and regression in a single pass.
Python
96
star
9

python-tribool

Python implementation of Tribool data type.
Python
20
star
10

gpt-prompt-notes

GPT Prompt Notes
15
star
11

scikit-sequitur

SciKit Sequitur is an Apache2 licensed Python module for inferring compositional hierarchies from sequences.
Python
9
star
12

largefile

Python large file utilities inspired by GNU Coreutils and functional programming.
Python
7
star
13

django-modelqueue

Task queue based on Django models.
Python
7
star
14

django-replay

Django application that records and replays web requests.
Python
4
star
15

django-rrweb

Django application to record and replay browser sessions.
Python
3
star
16

prioritydict

PriorityDict is an Apache2 licensed implementation of a dictionary which maintains key-value pairs in value sort order.
Python
3
star
17

advent-of-code

Advent of Code https://adventofcode.com/
Python
2
star
18

python-ivenv

Interactive virtual environments for Python.
Python
2
star
19

syntaxforest

Python
2
star
20

django-dblog

Django Database Logs
Python
2
star
21

dotemacs

Emacs Lisp
2
star
22

python-kmp

Python implementation of Knuth-Morris-Pratt algorithm for sequence search.
Python
2
star
23

python-appstore

User-oriented front-end for pip.
Python
2
star
24

python-fount

Python
2
star
25

emacs-starbuck

Emacs Lisp
1
star
26

csvcompare

CSV comparison and diff tools.
Python
1
star
27

python-shims

Shims is an Apache2 licensed Python module with patching and mocking utilities.
Python
1
star
28

python-templates

Python templating library with templates included.
Python
1
star
29

python-qemu-python

C
1
star
30

SynDiff

Syntactic differencing tool.
1
star
31

python-prique

Python
1
star
32

django-codemirror6

Django CodeMirror 6
JavaScript
1
star
33

Sequitur

Sequitur is a program for identifying structure in long sequences.
1
star
34

jupyter-nbconvert-blue

Use "blue" to format Python cells in Jupyter notebooks.
1
star