nitpick.violations module

Violation codes.

Name inspired by flake8’s violations.

class nitpick.violations.Fuss(fixed: bool, filename: str, code: int, message: str, suggestion: str = '', lineno: int = 1)[source]

Bases: object

Nitpick makes a fuss when configuration doesn’t match.

Fields inspired on SyntaxError and pyflakes.messages.Message.

code: int
property colored_suggestion: str

Suggestion with color.

filename: str
fixed: bool
lineno: int = 1
message: str
property pretty: str

Message to be used on the CLI.

suggestion: str = ''
class nitpick.violations.ProjectViolations(value)[source]

Bases: ViolationEnum

Project initialization violations.

FILE_SHOULD_BE_DELETED = (104, ' should be deleted{extra}')
MINIMUM_VERSION = (203, "The style file you're using requires {project}>={expected} (you have {actual}). Please upgrade")
MISSING_FILE = (103, ' should exist{extra}')
NO_PYTHON_FILE = (102, 'No Python file was found on the root dir and subdir of {root!r}')
NO_ROOT_DIR = (101, "No root directory detected. Create a configuration file (.nitpick.toml, pyproject.toml) manually, or run 'nitpick init'. See https://nitpick.rtfd.io/en/latest/configuration.html")
class nitpick.violations.Reporter(info: FileInfo | None = None, violation_base_code: int = 0)[source]

Bases: object

Error reporter.

fixed: int = 0
classmethod get_counts() str[source]

String representation with error counts and emojis.

classmethod increment(fixed=False)[source]

Increment the fixed ou manual count.

make_fuss(violation: ViolationEnum, suggestion: str = '', fixed=False, **kwargs) Fuss[source]

Make a fuss.

manual: int = 0
classmethod reset()[source]

Reset the counters.

class nitpick.violations.SharedViolations(value)[source]

Bases: ViolationEnum

Shared violations used by all plugins.

CREATE_FILE = (1, ' was not found', True)
CREATE_FILE_WITH_SUGGESTION = (1, ' was not found. Create it with this content:', True)
DELETE_FILE = (2, ' should be deleted', True)
DIFFERENT_VALUES = (9, '{prefix} has different values. Use this:', True)
MISSING_VALUES = (8, '{prefix} has missing values:', True)
class nitpick.violations.StyleViolations(value)[source]

Bases: ViolationEnum

Style violations.

INVALID_CONFIG = (1, ' has an incorrect style. Invalid config:')
INVALID_DATA_TOOL_NITPICK = (1, ' has an incorrect style. Invalid data in [{section}]:')
INVALID_TOML = (1, ' has an incorrect style. Invalid TOML{exception}')
class nitpick.violations.ViolationEnum(value)[source]

Bases: Enum

Base enum with violation codes and messages.