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/blackif theXDG_CONFIG_HOMEenvironment variable is not set)
If there is no pyproject.toml it will lookup for configuration in
setup.cfg: as[tool:black]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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d12f214fff47ad5e12711df1acee2ddac7e58fab0c90c2b86fd94d596b3f571
|
|
| MD5 |
05dab542eb98f809f3f1ba5cc3d6eab8
|
|
| BLAKE2b-256 |
f73c1c4985309e43a4ebbb33f1e630a72b48a2f660715d57271b44c3cc12f36c
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eacd8e980c1a1e477e8ea045a3a4ae2210c17b327becf1c67c115bf7b8dc6a8e
|
|
| MD5 |
0128d3bf2803ffc3051ab7619f60b8be
|
|
| BLAKE2b-256 |
8d9b68462d6dbd749c1caf3172b6826e3444ee2b8111d0ed72202949264b195b
|