squabble.reporter module

exception squabble.reporter.UnknownReporterException(name)[source]

Bases: squabble.SquabbleException

Raised when a configuration references a reporter that doesn’t exist.


Decorator to register function as a callback when the config sets the "reporter" config value to name.

The wrapped function will be called with each squabble.lint.LintIssue and the contents of the file being linted. Each reporter should return a list of lines of output which will be printed to stderr.

>>> from squabble.lint import LintIssue
>>> @reporter('no_info')
... def no_info(issue, file_contents):
...     return ['something happened']
>>> no_info(LintIssue(), file_contents='')
['something happened']
squabble.reporter.report(reporter_name, issues, files)[source]

Call the named reporter function for every issue in the list of issues. All lines of output returned will be printed to stderr.

  • reporter_name (str) – Issue reporter format to use.
  • issues (list) – List of generated squabble.lint.LintIssue.
  • files (dict) – Map of file name to contents of file.
>>> import sys; sys.stderr = sys.stdout  # for doctest.
>>> from squabble.lint import LintIssue
>>> @reporter('message_and_severity')
... def message_and_severity_reporter(issue, contents):
...     return ['%s:%s' % (issue.severity.name, issue.message_text)]
>>> issue = LintIssue(severity=Severity.CRITICAL,
...                   message_text='bad things!')
>>> report('message_and_severity', [issue], files={})
CRITICAL:bad things!
squabble.reporter.plain_text_reporter(issue, file_contents)[source]

Simple single-line output format that is easily parsed by editors.

squabble.reporter.color_reporter(issue, file_contents)[source]

Extension of squabble.reporter.plain_text_reporter(), uses ANSI color and shows error location.

squabble.reporter.json_reporter(issue, _file_contents)[source]

Dump each issue as a JSON dictionary

squabble.reporter.sqlint_reporter(issue, file_contents)[source]

Format compatible with sqlint, which is already integrated into Flycheck and other editor linting frameworks.

Main difference is really just that there are only two severity levels: ERROR and WARNING.