icontract_lint

Lint contracts defined with icontract library.

class icontract_lint.Error(identifier, description, filename, lineno)

Represent a linter error.

as_mapping()

Transform the error to a mapping that can be converted to JSON and similar formats.

Return type:ErrorMapping
description = None

verbose description of the error including details about the cause (e.g., the name of the invalid argument)

filename = None

file name of the linted module

identifier = None

identifier of the error

lineno = None

line number of the offending decorator

class icontract_lint.ErrorID

Enumerate error identifiers.

INVALID_SYNTAX = 'invalid-syntax'
INV_INVALID_ARG = 'inv-invalid-arg'
NO_CONDITION = 'no-condition'
POST_INVALID_ARG = 'post-invalid-arg'
POST_OLD_CONFLICT = 'post-old-conflict'
POST_RESULT_CONFLICT = 'post-result-conflict'
POST_RESULT_NONE = 'post-result-none'
PRE_INVALID_ARG = 'pre-invalid-arg'
SNAPSHOT_INVALID_ARG = 'snapshot-invalid-arg'
SNAPSHOT_WO_CAPTURE = 'snapshot-wo-capture'
SNAPSHOT_WO_NAME = 'snapshot-wo-name'
SNAPSHOT_WO_POST = 'snapshot-wo-post'
UNREADABLE = 'unreadable'
class icontract_lint.ErrorMapping

Represent an error given as a mapping.

icontract_lint.check_file(path)

Parse the given file as Python code and lint its contracts.

Parameters:path (Path) – path to the file
Return type:List[Error]
Returns:list of lint errors
icontract_lint.check_paths(paths)

Lint the given paths.

The directories are recursively linted for *.py files.

Parameters:paths (List[Path]) – paths to lint
Return type:List[Error]
Returns:list of lint errors
icontract_lint.check_recursively(path)

Lint all *.py files beneath the directory (including subdirectories).

Parameters:path (Path) – path to the directory.
Return type:List[Error]
Returns:list of lint errors
icontract_lint.output_json(errors, stream)

Output errors in a JSON format to the stream.

Parameters:
  • errors (List[Error]) – list of lint errors
  • stream (Textio) – output stream
Return type:

None

Returns:

icontract_lint.output_verbose(errors, stream)

Output errors in a verbose, human-readable format to the stream.

Parameters:
  • errors (List[Error]) – list of lint errors
  • stream (Textio) – output stream
Return type:

None

Returns: