squabble.reporter module¶
-
exception
squabble.reporter.UnknownReporterException(name)[source]¶ Bases:
squabble.SquabbleExceptionRaised when a configuration references a reporter that doesn’t exist.
-
squabble.reporter.reporter(name)[source]¶ Decorator to register function as a callback when the config sets the
"reporter"config value toname.The wrapped function will be called with each
squabble.lint.LintIssueand 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.
Parameters: - 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.