Anaconda Linter is a utility to validate that a recipe for a conda package will render correctly.
The package is currently a very rough draft of a pure Python linter specifically to make sure that packages' meta.yaml files adhere to certain Anaconda standards.
conda
(into your current environment)$ conda install -c distro-tooling anaconda-linter
$ cd anaconda-linter
$ make environment
$ conda activate anaconda-linter
$ cd anaconda-linter
$ make dev
$ conda activate anaconda-linter
usage: conda-lint [-h] [-V] [-m VARIANT_CONFIG_FILES] [-e EXCLUSIVE_CONFIG_FILES] [-s SUBDIRS] [--severity {INFO,WARNING,ERROR}] [-v] [-f] RECIPE_PATH
positional arguments:
RECIPE_PATH Path to recipe directory.
options:
-h, --help show this help message and exit
-V, --version The version of anaconda-linter
-m VARIANT_CONFIG_FILES, --variant-config-files VARIANT_CONFIG_FILES
Additional variant config files to add. These yaml files can contain keys such as `c_compiler` and `target_platform` to form a
build matrix.
-e EXCLUSIVE_CONFIG_FILES, --exclusive-config-files EXCLUSIVE_CONFIG_FILES, --exclusive-config-file EXCLUSIVE_CONFIG_FILES
Exclusive variant config files to add. Providing files here disables searching in your home directory and in cwd. The files
specified here come at the start of the order, as opposed to the end with --variant-config-files. Any config files in recipes and
any config files specified with --variant-config-files will override values from these files.
-s SUBDIRS, --subdirs SUBDIRS
List subdir to lint. Example: linux-64, win-64...
--severity {INFO,WARNING,ERROR}
The minimum severity level displayed in the output.
-v, --verbose Enable verbose output. This displays all of the checks that the linter is running.
-f, --fix Attempt to fix issues.
The usage is similar to conda-build.
conda_build_config.yaml
file: cd <path/to/aggregate/>
conda-lint
with: conda-lint <path_to_feedstock>
Concrete example:
cd ~/work/recipes/aggregate/
conda-lint -v ../wip/airflow-feedstock
Full usage details can be found under the help menu (conda-lint -h
). New users may find it easier to run the script with the verbose flag, -v
which will provide additional context for linting errors.
In order to force the linter to ignore a certain type of lint, you can use the top-level extra
key in a meta.yaml file
. To skip lints individually, add lints from this list of current lints to the extra
key as a list with a skip-lints
key. For example:
extra:
skip-lints:
- unknown_selector
- invalid_url
You can also do the opposite of this, and skip all other lints except the lints you want, with only-lint
. For example:
extra:
only-lint:
- missing_license
- incorrect_license
Note: if you have both skip-lints
and only-lint
, any lints in skip-lint
will override identical lints in only-lint
.
Make sure that your anaconda-linter
environment is activated, then:
make test
We welcome contributions for bug fixes, enhancements, or new tests. For a list of projects, please see the Issues page
Before submitting a PR, please make sure to:
make test-cov
.make pre-commit
to format your code using isort
and black
and validate your code with our automated checks.If you would like to develop in a hosted linux environment, a gitpod instance is available to test linter changes with real life packages, without having to download them to your own machine.
To get started as a developer:
$ make dev
$ conda activate anaconda-linter
This will automatically configure pre-commit
for the anaconda-linter
environment. Our automated tooling will run
when you make a commit in this environment. Running make dev
will also blow away any existing environments for a
clean install, every time.
Running make help
will show all of the available commands. Here are some that may be immediately useful:
make test
: Runs all the unit testsmake test-cov
: Reports the current test coverage percentage and indicates
which lines are currently untested.make lint
: Runs our pylint
configuration, based on Google's Python
standards.make format
: Automatically formats codemake analyze
: Runs the static analyzer, mypy
.make pre-commit
: Runs all the pre-commit
checksHere is a rough outline of how to conduct a release of this project:
CHANGELOG.md
anaconda_linter/__init__.py
environment.yaml
aligns with recipe/meta.yaml
found in the feedstockdistro-tooling
This package is inspired by bioconda's linter.
Some of the code for suggesting hints comes from Peter Norvig.