Backends

How to enable specific functionality.

Pants has some basic, non-language-specific functionality built in to its core. For example, you can count the lines of code under some directory in your repo:

$ ./pants count-loc 'src/**'
───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
Python                      13       155       50        22       83          5
BASH                         2       261       29        22      210         10
JSON                         2        25        0         0       25          0
...

However most Pants functionality, including all language-specific functionality, is provided via backends.

A backend is a Python package that implements some required functionality, and uses hooks to register itself with Pants. You enable a backend by listing it under the backend_packages config key in pants.toml.

For example, to enable Python support:

[GLOBAL]
backend_packages = ["pants.backend.python"]

Available backends

Activate by adding the backend to the option backend_packages in the [GLOBAL] scope in pants.toml.

Backend

What it does

Docs

pants.backend.awslambda.python

Enables generating an AWS Lambda zip file from Python code.

Python support

pants.backend.codegen.protobuf.python

Enables generating Python from Protocol Buffers. Includes gRPC support.

Protobuf and gRPC

pants.backend.python

Core Python support.

Enabling Python support

pants.backend.python.mixed_interpreter_constraints

Adds the py-constraints goal for insights on Python interpreter constraints.

Interpreter compatibility

pants.backend.python.lint.bandit

Enables Bandit, the Python security linter: https://bandit.readthedocs.io/en/latest/.

Linters and formatters

pants.backend.python.lint.black

Enables Black, the Python autoformatter: https://black.readthedocs.io/en/stable/.

Linters and formatters

pants.backend.python.lint.docformatter

Enables Docformatter, the Python docstring autoformatter: https://github.com/myint/docformatter.

Linters and formatters

pants.backend.python.lint.flake8

Enables Flake8, the Python linter: https://flake8.pycqa.org/en/latest/.

Linters and formatters

pants.backend.python.lint.isort

Enables isort, the Python import autoformatter: https://timothycrosley.github.io/isort/.

Linters and formatters

pants.backend.python.lint.pylint

Enables Pylint, the Python linter: https://www.pylint.org.

Linters and formatters

pants.backend.python.typecheck.mypy

Enables MyPy, the Python type checker: https://mypy.readthedocs.io/en/stable/.

typecheck

pants.backend.shell

Core Shell support, including shUnit2 test runner.

Shell overview

pants.backend.shell.lint.shfmt

Enables shfmt, a Shell autoformatter: https://github.com/mvdan/sh.

Shell overview

pants.backend.shell.lint.shellcheck

Enables Shellcheck, a Shell linter: https://www.shellcheck.net/.

Shell overview


Did this page help you?