formate.config¶
Read and parse formate configuration.
Exceptions:
Base exception for errors with hook configuration. |
|
Exception for when no hooks are configured. |
|
|
Exception for when no hooks support the given file type. |
Data:
Invariant |
Functions:
|
Decorator to indicate to |
|
Filters the hooks to those that support the given filetype. |
|
Load the |
|
Returns a read-only view on the global configuration mapping, for hooks to do with as they wish. |
|
Given a mapping parsed from a TOML file (or similar), return a list of hooks selected by the user. |
|
Decorator to indicate to |
|
Decorator to indicate to |
-
exception
HookConfigError[source]¶ Bases:
ValueErrorBase exception for errors with hook configuration.
-
exception
NoHooksError[source]¶ Bases:
formate.config.HookConfigErrorException for when no hooks are configured.
-
exception
NoSupportedHooksError(filetype)[source]¶ Bases:
formate.config.HookConfigErrorException for when no hooks support the given file type.
- Parameters
filetype (
str)
-
_C_str= TypeVar(_C_str, bound=typing.Callable[..., str])¶ Type:
TypeVarInvariant
TypeVarbound totyping.Callable[…,str].
-
formats_filetypes(*filetypes)[source]¶ Decorator to indicate to
formatethat the hook formats the specified filetypes (as extensions, e.g.".js".New in version 1.2.0.
-
get_hooks_for_filetype(filetype, hooks)[source]¶ Filters the hooks to those that support the given filetype.
-
load_toml(filename)[source]¶ Load the
formateconfiguration mapping from the given TOML file.- Parameters
- Return type
-
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) – Theformateconfiguration, parsed from a TOML file (or similar).- Return type
-
parse_hooks(config)[source]¶ Given a mapping parsed from a TOML file (or similar), return a list of hooks selected by the user.