3.1.1. Waf Tool Black

The tool is located in tools/waf-tools.

3.1.1.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
1
2
3
4
5
6
7
8
9
def options(opt):
    opt.load("black")

def configure(conf):
    conf.load("black")

def build:
    files = bld.path.ant_glob("\*\*/\*.py")
    bld(features="black", files=files)
class f_black.black(*args: Any, **kwargs: Any)

Bases: waflib.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