Configuration

formate is configured using the formate.toml file in the root of your project (alongside setup.py, tox.ini etc.). The file uses the TOML syntax, built around a top-level mapping of two keys. The -c / --config-file option can be used to point to a file with a different name, but at this time the file must be TOML and must have the same layout.

The two top-level keys are hooks and config.

hooks

This is a mapping of hook names to their settings. The values can be either:

  • an integer, representing the priority of the hook.

  • a mapping of the following:

    • priority – an integer, representing the priority of the hook.

    • args – a list of positional arguments to pass to the hook function. Optional. Default ().

    • kwargs – a mapping of keyword arguments to pass to the hook. Optional. Default {}.


The TOML syntax allows for the mapping to spread over multiple tables, like so:

[hooks]
reformat-generics = 40
collections-import-rewrite = 20
noqa-reformat = 60
ellipsis-reformat = 70

[hooks.isort]
priority = 50

[hooks.isort.kwargs]
multi_line_output = 8
use_parentheses = true
remove_redundant_aliases = true

config

This is a mapping of general configuration settings, which hooks can use as they please. Common keys include indent, indicating the type of indent to use, and line_length, indicating how long lines may be.

Example:

[config]
indent = "\t"
line_length = 115

Alternatively the configuration may be placed in the pyproject.toml file defined in PEP 518. The only difference is that hooks and config become tool.formate.hooks and tool.formate.config. You must also pass --config-file pyproject.toml on the command line.