Skip to main content
Version: 2.0 (deprecated)

pylint_source_plugin


A Pylint plugin loaded through source code.

To load a source plugin:

1. Write your plugin. See http://pylint.pycqa.org/en/latest/how_tos/plugins.html.
2. Define a `pylint_source_plugin` target with the plugin's Python file(s) included in the
`sources` field.
3. Add the parent directory of your target to the `root_patterns` option in the `[source]`
scope. For example, if your plugin is at `build-support/pylint/custom_plugin.py`, add
'build-support/pylint'. This is necessary for Pants to know how to tell Pylint to
discover your plugin. See https://www.pantsbuild.org/docs/source-roots.
4. Add `load-plugins=$module_name` to your Pylint config file. For example, if your Python
file is called `custom_plugin.py`, set `load-plugins=custom_plugin`. Set the `config`
option in the `[pylint]` scope to point to your Pylint config file.
5. Set the option `source_plugins` in the `[pylint]` scope to include this target's
address, e.g. `source_plugins = ["build-support/pylint:plugin"]`.

To instead load a third-party plugin, set the option extra_requirements in the [pylint] scope (see https://www.pantsbuild.org/docs/python-linters-and-formatters). Set load-plugins in your config file, like you'd do with a source plugin.

This target type is treated similarly to a python_library target. For example, Python linters and formatters will run on this target.

You can include other targets in the dependencies field, so long as those targets are third-party dependencies or are located in the same directory or a subdirectory.

Other targets can depend on this target. This allows you to write a python_tests target for this code or a python_distribution target to distribute the plugin externally.

Backend: ``


sources

Iterable[str]
required

A list of files and globs that belong to this target. Paths are relative to the BUILD file's directory. You can ignore files/globs by prefixing them with !. Example: sources=['example.py', 'test_*.py', '!test_ignore.py'].

compatibility

str | Iterable[str] | None
default: None

A string for Python interpreter constraints on this target. This should be written in Requirement-style format, e.g. CPython==2.7.* or CPython>=3.6,<4. As a shortcut, you can leave off CPython, e.g. >=2.7 will be expanded to CPython>=2.7. If this is left off, this will default to the option interpreter_constraints in the [python-setup] scope. See https://www.pantsbuild.org/docs/python-interpreter-compatibility.

dependencies

Iterable[str] | None
default: None

Addresses to other targets that this plugin depends on. Due to restrictions with Pylint plugins, these targets must either be third-party Python dependencies (https://www.pantsbuild.org/docs/python-third-party-dependencies) or be located within this target's same directory or a subdirectory.

description

str | None
default: None

A human-readable description of the target. Use ./pants list --documented :: to see all targets with descriptions.

tags

Iterable[str] | None
default: None

Arbitrary strings that you can use to describe a target. For example, you may tag some test targets with 'integration_test' so that you could run ./pants --tags='integration_test' test :: to only run on targets with that tag.