nitpick.plugins.base module

Base class for file checkers.

class nitpick.plugins.base.NitpickPlugin(info:, expected_config: Dict[str, Any], fix=False)[source]

Bases: object

Base class for Nitpick plugins.

  • data – File information (project, path, tags).

  • expected_config – Expected configuration for the file

  • fix – Flag to modify files, if the plugin supports it (default: True).

can_fix: bool = False

Can this plugin modify files directly?

abstract enforce_rules() Iterator[nitpick.violations.Fuss][source]

Enforce rules for this file. It must be overridden by inherited classes if needed.

entry_point() Iterator[nitpick.violations.Fuss][source]

Entry point of the Nitpick plugin.

filename = ''
classmethod get_compiled_jmespath_filenames()[source]

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

identify_tags: Set[str] = {}

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


Hook for plugin initialization after the instance was created.

abstract property initial_contents: str

Suggested initial content when the file doesn’t exist.

property nitpick_file_dict: Dict[str, Any]

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

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 = 0
warn_missing_different(comparison: nitpick.formats.Comparison, prefix: str = '') Iterator[nitpick.violations.Fuss][source]

Warn about missing and different keys.

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

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