Skip to main content

A wrapper for black to connect with other python configuration files such as setup.cfg and tox.ini

Project description

configparser-black

A module to parse configuration for black from common python config files such as setup.cfg, tox.ini, etc

Install

pip install configparser-black

Run

cblack

or

python -m cblack

Configuration

Black supports pyproject.toml and global configuration natively.

This module ignores setup.cfg and tox.ini black related configurations if there is a [tool.black] section in your pyproject.toml This module will pass the configuration to black as command line arguments, meaning that it will override any configuration you have in your global black files in

  • Windows ~\.black
  • Linux/MacOS: $XDG_CONFIG_HOME/black (~/.config/black if the XDG_CONFIG_HOME environment variable is not set)

If there is no pyproject.toml it will lookup for configuration in

  1. setup.cfg: as [tool:black]
  2. tox.ini: as [black]

with the higher number superseeding lower numbers (i.e tox.ini overrides any black configuration found in setup.cfg)

setup.cfg

Example configuration in setup.cfg

[tool:black]
line-length = 100
quiet = true
target-version = py37
include = \.pyi?|somerandomfilename$
extend-exclude = ^/foo.py

Running

cblack --check ./

black will run with

black --quiet --line-length 100 --target-version py37 --include '\.pyi?|somerandomfilename' --check ./

tox.ini

Same configuration in tox.ini

[black]
line-length = 79
target-version = ['py37', 'py38']
; Note single and double quotes at the start/end are stripped
include = "\.pyi?$"
extend-exclude = ^/foo.py

Running

cblack ./

Similarly black will run with

black will run with

black --line-length 79 --target-version py36 --target-version py37 --include '\.pyi?$' --extend-exclude '^/foo.py' ./

Notes

Quotes

Quotes will be stripped from values from start and end. Also there is no need to escape quotes in the middle of a string.

e.g

include = "somerandomfile"

Will be

black --include "somerandomfile"
# Equivalently in bash
black --include somerandomfile

and not

black --include "\"somerandomfile\""

If you want to include quotes you can wrap in single if you want double or double if you want single i.e

include = '"somerandomfile"'
extend-exclude = "'somerandomfile'"

will be

black --include "\"somerandomfile\"" --extend-exclude "'somerandomfile'"

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

configparser-black-0.2.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

configparser_black-0.2.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file configparser-black-0.2.0.tar.gz.

File metadata

  • Download URL: configparser-black-0.2.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.8.10 Linux/5.8.0-63-generic

File hashes

Hashes for configparser-black-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3d12f214fff47ad5e12711df1acee2ddac7e58fab0c90c2b86fd94d596b3f571
MD5 05dab542eb98f809f3f1ba5cc3d6eab8
BLAKE2b-256 f73c1c4985309e43a4ebbb33f1e630a72b48a2f660715d57271b44c3cc12f36c

See more details on using hashes here.

File details

Details for the file configparser_black-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: configparser_black-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.8.10 Linux/5.8.0-63-generic

File hashes

Hashes for configparser_black-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eacd8e980c1a1e477e8ea045a3a4ae2210c17b327becf1c67c115bf7b8dc6a8e
MD5 0128d3bf2803ffc3051ab7619f60b8be
BLAKE2b-256 8d9b68462d6dbd749c1caf3172b6826e3444ee2b8111d0ed72202949264b195b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page