nitpick.plugins.toml module

TOML files.

class nitpick.plugins.toml.TomlPlugin(info: nitpick.plugins.info.FileInfo, expected_config: Dict[str, Any], fix=False)[source]

Bases: nitpick.plugins.base.NitpickPlugin

Enforce config on TOML files.

E.g.: pyproject.toml (PEP 518).

See also the [tool.poetry] section of the pyproject.toml file.

Style example: Python 3.8 version constraint. There are many other examples here.

can_fix: bool = True

Can this plugin modify files directly?

dirty: bool
enforce_rules() Iterator[nitpick.violations.Fuss][source]

Enforce rules for missing key/value pairs in the TOML file.

entry_point() Iterator[nitpick.violations.Fuss]

Entry point of the Nitpick plugin.

expected_config: JsonDict
file_path: Path
filename = ''
classmethod get_compiled_jmespath_filenames()

Return a compiled JMESPath expression for file names, using the class name as part of the key.

identify_tags: Set[str] = {'toml'}

Which identify tags this nitpick.plugins.base.NitpickPlugin child recognises.

init()

Hook for plugin initialization after the instance was created.

property initial_contents: str

Suggest the initial content for this missing file.

property nitpick_file_dict: Dict[str, Any]

Nitpick configuration for this file as a TOML dict, taken from the style file.

report(violation: nitpick.violations.ViolationEnum, document: Optional[tomlkit.toml_document.TOMLDocument], change_dict: Optional[nitpick.formats.BaseFormat])[source]

Report a violation while optionally modifying the TOML document.

skip_empty_suggestion = False
validation_schema: Optional[marshmallow.schema.Schema] = None

Nested validation field for this file, to be applied in runtime when the validation schema is rebuilt. Useful when you have a strict configuration for a file type (e.g. nitpick.plugins.json.JSONPlugin).

violation_base_code: int = 310
warn_missing_different(comparison: nitpick.formats.Comparison, prefix: str = '') Iterator[nitpick.violations.Fuss]

Warn about missing and different keys.

write_file(file_exists: bool) Optional[nitpick.violations.Fuss]

Hook to write the new file when fix mode is on. Should be used by inherited classes.

nitpick.plugins.toml.can_handle(info: nitpick.plugins.info.FileInfo) Optional[Type[nitpick.plugins.base.NitpickPlugin]][source]

Handle TOML files.

nitpick.plugins.toml.change_toml(document: tomlkit.toml_document.TOMLDocument, dictionary)[source]

Traverse a TOML document recursively and change values, keeping its formatting and comments.

nitpick.plugins.toml.plugin_class() Type[nitpick.plugins.base.NitpickPlugin][source]

Handle TOML files.