formate.config

Read and parse formate configuration.

Data:

_C_str

Invariant TypeVar bound to typing.Callable[…, str].

Functions:

load_toml(filename)

Load the formate configuration mapping from the given TOML file.

parse_global_config(config)

Returns a read-only view on the global configuration mapping, for hooks to do with as they wish.

parse_hooks(config)

Given a mapping parsed from a TOML file (or similar), return a list of hooks selected by the user.

wants_filename(func)

Decorator to indicate to formate that the filename being reformatted should be passed to this hook.

wants_global_config(func)

Decorator to indicate to formate that the global configuration should be passed to this hook.

_C_str = TypeVar(_C_str, bound=typing.Callable[..., str])

Type:    TypeVar

Invariant TypeVar bound to typing.Callable[…, str].

load_toml(filename)[source]

Load the formate configuration mapping from the given TOML file.

Parameters

filename (Union[str, Path, PathLike])

Return type

FormateConfigDict

parse_global_config(config)[source]

Returns a read-only view on the global configuration mapping, for hooks to do with as they wish.

Parameters

config (Mapping) – The formate configuration, parsed from a TOML file (or similar).

Return type

MappingProxyType

parse_hooks(config)[source]

Given a mapping parsed from a TOML file (or similar), return a list of hooks selected by the user.

Parameters

config (Mapping) – The formate configuration, parsed from a TOML file (or similar).

Return type

List[Hook]

wants_filename(func)[source]

Decorator to indicate to formate that the filename being reformatted should be passed to this hook.

The configuration will be provided as the formate_filename: PathLike keyword argument.

New in version 0.2.0.

Parameters

func (~_C_str)

Return type

~_C_str

wants_global_config(func)[source]

Decorator to indicate to formate that the global configuration should be passed to this hook.

The configuration will be provided as the formate_global_config: Mapping keyword argument.

Parameters

func (~_C_str)

Return type

~_C_str