Skip to main content

Black for Databricks notebooks

Project description

PyPI version PyPI downloads License Code style: Black

Blackbricks

A formatting tool for your Databricks notebooks.

  • Python cells are formatted with black
  • SQL cells are formatted with sqlparse

Installation and Usage

Install:

$ pip install blackbricks

Usage:

$ blackbricks --help
usage: blackbricks [-h] [--line-length LINE_LENGTH]
                   [--sql-upper | --sql-lower] [--check | --diff]
                   [--indent-with-two-spaces] [--version]
                   [filenames [filenames ...]]

Formatting tool for Databricks python notebooks. Python cells are formatted
using `black`, and SQL cells are formatted by `sqlparse`.

positional arguments:
  filenames             Path to the notebook(s) to format

optional arguments:
  -h, --help            show this help message and exit
  --line-length LINE_LENGTH
                        How many characters per line to allow. [default: ask
                        black]
  --sql-upper           SQL keywords should be uppercase
  --sql-lower           SQL keywords should be lowercase
  --check               Don't write the files back, just return the status.
                        Return code 0 means nothing would change.
  --diff                Don't write the files back, just output a diff for
                        each file on stdout
  --indent-with-two-spaces
                        Use two spaces for indentation in Python cells instead
                        of Black's default of four.
  --version             Display version information and exit.

Version control integration

Use pre-commit. Add a .pre-commit-config.yaml file to your repo with the following content (changing/removing the args as you wish):

repos:
-   repo: https://github.com/bsamseth/blackbricks
    rev: 0.3.5
    hooks:
    - id: blackbricks
      args: [--line-length=120, --indent-with-two-spaces]

Set the rev attribute to the most recent version of blackbricks. The args are optional and can be used to set any of blackbricks options.

Contributing

If you find blackbricks useful or utterly broken, you are more than welcome to contribute improvements. Please open an issue first to discuss what you want added/fixed. Unless you are just adding tests. In that case your pull request is extremely likely to be merged right away.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

blackbricks-0.3.6-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

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