artifact-lint-py documentation

A python framework for developing artifact linters

Quick example

 1 from lint.rule import LintRule
 2 from lint.result import LintResult
 3 from lint.status import LintStatus
 4
 5 class IntegerIsEven(LintRule[int]):
 6     def lint(self, artifact: int) -> LintResult:
 7         if artifact % 2 == 0:
 8             return LintResult(
 9                 status=LintStatus.INFO,
10                 message=f"({self.name()}) Integer was even: {artifact}"
11             )
12         return LintResult(
13             status=LintStatus.ERROR,
14             message=f"({self.name()}) Integer was odd: {artifact}"
15         )
16 integer_is_even = IntegerIsEven()
17
18 # Lint an even integer
19 even_result = integer_is_even.lint(2)
20 print(even_result)
21
22 # Lint an odd integer
23 odd_result = integer_is_even.lint(337)
24 print(odd_result)

Installation

Using Pip

Run the following command to install the latest version of this package using pip

pip install artifact-lint-py

Local Install

  1. Clone the source repository

  2. Build the project from source following the build instructions

  3. Locate the .whl (wheel) file in the dist folder. It should be named something like so: artifact_lint_py-1.0.1-py3-none-any.whl

  4. Run the following command from the root of the repository, replacing the name of the .whl file if necessary

pip install dist/artifact_lint_py-1.0.1-py3-none-any.whl

Build

From the root of the source repository, execute

make build

Under the hood, this will execute python3 -m build and produce a .whl (wheel) and .tgz (TAR-GZip archive) file in the dist subdirectory.

Indices and Tables