cki_lint.sh
Runs flake8, pydocstyle and ruff. The
script automatically handles environment preparation including dependency
installation via pip. Ruff checks and sorts import order (see [lint.isort] in
ruff.toml). For pylint, only the packages specified as parameters
will be checked.
Performs linting and link checking for all README.*.md files. It uses the
markdownlint tool to check for markdown errors and a cki_check_links.sh
script to check for broken links.
The experimental --fix parameter can be used to automatically fix some of the
detected issues. At the moment, this will invoke autopep8 and ruff --fix
(which includes import sorting).
For correct editor integration of linters/fixers, the following parameters must be set:
flake8:--max-line-length 100autopep8:--max-line-length 100- Import order is enforced by ruff (see
ruff.toml[lint.isort]).
When run in a GitLab CI/CD pipeline for a merge request, the script tries to
determine the previous code coverage and will fail if code coverage decreased.
This can be skipped by adding [skip coverage check] with an explanation to
the merge request description.
Automatic Preparation
The script automatically sources and executes cki_prepare.sh to handle dependency
installation, version management, and package overrides. This includes automatic
cki-lib version checking in CI/MR environments and support for custom package
overrides via *_pip_url environment variables.
For detailed information about preparation and environment variables, see the cki_prepare documentation.
For a comprehensive overview of the entire linting and testing pipeline, see the cki tox pipeline documentation.
Environment variables
Linting Control
| Environment variable | Description |
|---|---|
CKI_DISABLED_LINTERS |
linters to disable or all |
CKI_IGNORED_LINTERS |
space-separated list of linters where results are ignored, or all |
CKI_PYLINT_ARGS |
Additional arguments for pylint, e.g. to disable certain warnings |
Preparation Control
| Environment variable | Description |
|---|---|
CKI_SKIP_PREPARE |
true if Python package installation should be skipped |
cki_lib_pip_url |
Override cki-lib with custom Git URL (see cki_prepare docs) |
NOTE
CKI_SKIP_PREPARE=true can be useful to run checks without network.
When using tox, you should probably call: tox --skip-pkg-install;
when using podman, you should probably call podman run --net none ...args....
Running Python tests and linting
To run both Python tests and linting, execute the following command:
tox
To run only the linting use the lint tox environment:
tox -e lint
Disabling linters
To skip certain linters, specify them in the CKI_DISABLED_LINTERS variable as a
space-separated list. For example:
TOX_OVERRIDE=testenv.passenv+=CKI_DISABLED_LINTERS \
CKI_DISABLED_LINTERS="markdownlint pylint" \
tox -e lint
The above command skips the markdownlint and pylint linters when running
tox.