Skip to main content

The customized uncompromising code formatter.

Project description

cblack

Custom Black Code Formatter for Python with 2-space indents

Same rules as Black, only with two-space indents.

Installation

cblack can be installed by running pip3 install cblack.

It requires Python 3.7+ to run but you can reformat Python 2 and Python 3.x code as well (although you should run cblack with a Python 3.7+ interpreter).

NOTE: Running cblack with Python 3.6 is no longer supported since black itself is failing as well.

Usage

python -m cblack {source_file_or_directory}

Options

python -m cblack --help

You can also go to https://github.com/psf/black for the latest options available

Why

After a long discussion about indentation levels it was decided by the main author that:

Two space indents are not distinct enough to be recommended by the Black coding style.

The whole pourpose of this project is to provide an alternative to black, with the exact same rules and behaviour, but using 2 spaces for indentation instead of 4. All other black options are still supported.

Second reason is that Google YAPF is not able to produce same output as black (mostly because of function arguments indentation), otherwise, if it was possible to do it, I would not have created this project.

How

I'm a busy man. I don't want to spend my time pulling latest changes from black regularly, so I've created a small package that depends on black and overrides a method to reindent using two spaces. Shall black developers break this behaviour I might end up cloning the whole project. But the aim of this project would still be the same.

Similar projects

  • YAPF
  • Autopep8
  • pep8ify
  • pyfmt
  • prettier in node
  • gofmt in go
  • rustfmt in rust

Versioning

This project will try to follow the same versioning as black itself, so any changes introduced in black formatting will be reflected in this project as well.

As black project states:

 This is made explicit by the “Beta” trove classifier, as well as by 
 the “b” in the version number. What this means for you is that until
 the formatter becomes stable, you should expect some formatting to change
 in the future.

Credits

All the credit is deserved to the people who created black on the first place.

Please visit black website:

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

cblack-22.6.0.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file cblack-22.6.0.tar.gz.

File metadata

  • Download URL: cblack-22.6.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for cblack-22.6.0.tar.gz
Algorithm Hash digest
SHA256 346ccb573ee592b9f632fee7dfd0f7bb19f386b9a11930027e792dd9c3884d89
MD5 b7f0841c9f9f2e2834cebd7f043831e9
BLAKE2b-256 b4242dfbf8fd488db96feeab8421e50a930f3d54bcd36e37af39d978660f3738

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