3.1.3. Black

The tool is located in tools/waf-tools.

3.1.3.1. Tool Documentation

Implements a waf tool to run black.

Listing 3.10 shows how to use this tool.

Listing 3.10 f_black.py
1def options(opt):
2    opt.load("black")
3
4def configure(conf):
5    conf.load("black")
6
7def build:
8    files = bld.path.ant_glob("\*\*/\*.py")
9    bld(features="black", files=files)
class f_black.black(*args: Any, **kwargs: Any)

Bases: waflib.Task.Task

Class to implement running the black formatting tool on Python files

color = 'BLUE'

color in which the command line is displayed in the terminal

Type

str

keyword()

displayed keyword when black is run

f_black.configure(conf)

configuration step of the black tool

  • searches for the program black

  • applies configured options

f_black.options(opt)

Passing options to black

f_black.process_black(self)

creates black tasks for each input file