Skip to main content

More Black! Denser Black formatting

Project description

More Black! - Denser Black formatting

This is s a fork of the Black code formatter


I love Black formatting because I agree with its formatting choices, but it does have one pathology: Excessive indenting on data structures

schema = {
    "mappings": {
        "test": {
            "properties": {
                "one_value": {
                    "type": "keyword",
                    "store": True,

The pathology looks even worse for singleton lists; many lines can be wasted on lonely brackets:

            "name": "a",
            "value": 42

Solution: More Black!

When there is only one property (or list item, or parameter), then do not make a new line.

schema = {"mappings": {"test": {"properties": {"one_value": {
    "type": "keyword", 
    "store": True,

Singleton lists are especially dense.

    "name": "a",
    "value": 42


Please read the official Black documentation at time of fork


Be sure you are in the mo-black main directory

Setup virtual environment

python -m venv .venv
source .venv/bin/activate

Install requirements

pip install -r requirements.txt
pip install -r tests/requirements.txt

Set some environment variables

export PYTHONPATH=src:.
export SKIP_AST_PRINT=true

Run the tests

python -m unittest tests/

Here is the same for Windows...

c:\Python38\python -m pip install virtualenv
c:\Python38\python -m virtualenv .venv             
pip install -r requirements.txt
pip install -r tests\requirements.txt
set PYTHONPATH=src;.
python -m unittest tests\

Upgrade requirements.txt

The file is for humans to update. Use pip-compile to update the locked requirements.txt file:

pip install -r tests\requirements.txt
pip-compile --upgrade --generate-hashes --output-file requirements.txt
pip install -r requirements.txt

Development Installation

You can install mo-black from the main directory

python.exe -m pip install .

Project details

Download files

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

Files for mo-black, version 3.90.20218
Filename, size File type Python version Upload date Hashes
Filename, size mo-black-3.90.20218.tar.gz (91.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page