nitpick.plugins.ini module
INI files.
- class nitpick.plugins.ini.IniPlugin(info: FileInfo, expected_config: JsonDict, autofix=False)[source]
Bases:
NitpickPlugin
Enforce configurations and autofix INI files.
Examples of
.ini
files handled by this plugin:Style examples enforcing values on INI files: flake8 configuration.
- add_options_before_space(section: str, options: dict) None [source]
Add new options before a blank line in the end of the section.
- compare_different_keys(section, key, raw_actual: Any, raw_expected: Any) Iterator[Fuss] [source]
Compare different keys, with special treatment when they are lists or numeric.
- static contents_without_top_section(multiline_text: str) str [source]
Remove the temporary top section from multiline text, and keep the newline at the end of the file.
- enforce_comma_separated_values(section, key, raw_actual: Any, raw_expected: Any) Iterator[Fuss] [source]
Enforce sections and keys with comma-separated values. The values might contain spaces.
- enforce_rules() Iterator[Fuss] [source]
Enforce rules on missing sections and missing key/value pairs in an INI file.
- expected_config: JsonDict
- file_path: Path
- filename = ''
- static get_example_cfg(parser: ConfigParser) str [source]
Print an example of a config parser in a string instead of a file.
- get_missing_output() str [source]
Get a missing output string example from the missing sections in an INI file.
- identify_tags: set[str] = {'editorconfig', 'ini'}
Which
identify
tags thisnitpick.plugins.base.NitpickPlugin
child recognises.
- property needs_top_section: bool
Return True if this .ini file needs a top section (e.g.: .editorconfig).
- property nitpick_file_dict: Dict[str, Any]
Nitpick configuration for this file as a TOML dict, taken from the style file.
- predefined_special_config() SpecialConfig
Create a predefined special configuration for this plugin. Each plugin can override this method.
- show_missing_keys(section: str, values: list[tuple[str, Any]]) Iterator[Fuss] [source]
Show the keys that are not present in a section.
- skip_empty_suggestion = False
- updater: ConfigUpdater
- validation_schema: Schema | None = 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
).
- class nitpick.plugins.ini.Violations(value)[source]
Bases:
ViolationEnum
Violations for this plugin.
- INVALID_COMMA_SEPARATED_VALUES_SECTION = (325, ': invalid sections on comma_separated_values:')
- MISSING_OPTION = (324, ': section [{section}] has some missing key/value pairs. Use this:')
- MISSING_SECTIONS = (321, ' has some missing sections. Use this:')
- MISSING_VALUES_IN_LIST = (322, ' has missing values in the {key!r} key. Include those values:')
- OPTION_HAS_DIFFERENT_VALUE = (323, ': [{section}]{key} is {actual} but it should be like this:')
- PARSING_ERROR = (326, ': parsing error ({cls}): {msg}')
- TOP_SECTION_HAS_DIFFERENT_VALUE = (327, ': {key} is {actual} but it should be:')
- TOP_SECTION_MISSING_OPTION = (328, ': top section has missing options. Use this:')
- nitpick.plugins.ini.can_handle(info: FileInfo) type[NitpickPlugin] | None [source]
Handle INI files.
- nitpick.plugins.ini.plugin_class() type[NitpickPlugin] [source]
Handle INI files.