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 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.
- Navigate into the folder of your main
conda_build_config.yaml
file:cd <path/to/aggregate/>
- Run
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:
- Add unit tests for new functionality. To print a coverage report, run
make test-cov
. - Run
make pre-commit
to format your code usingisort
andblack
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 ourpylint
configuration, based on Google's Python standards.make format
: Automatically formats codemake analyze
: Runs the static analyzer,mypy
.make pre-commit
: Runs all thepre-commit
checks
Here is a rough outline of how to conduct a release of this project:
- Update
CHANGELOG.md
- Update the version number in
anaconda_linter/__init__.py
- Ensure
environment.yaml
aligns withrecipe/meta.yaml
found in the feedstock - Create a new release on GitHub with a version tag.
- The Anaconda packaging team will need to update
the feedstock
and aggregate and publish to
distro-tooling
This package is inspired by bioconda's linter.
Some of the code for suggesting hints comes from Peter Norvig.