Hey! These docs are for version 2.10, which is no longer officially supported. Click here for the latest version, 2.15!


Lint your code using regex patterns, e.g. to check for copyright headers.

To activate this with the lint goal, you must set [regex-lint].config.

Unlike other linters, this can run on files not owned by targets, such as BUILD files. To run on those, use lint '**' rather than lint ::, for example. Unfortunately, --changed-since=<sha> does not yet cause this linter to run. We are exploring how to improve both these gotchas.

Backend: pants.backend.project_info
Config section: [sourcefile-validation]

Basic options


--sourcefile-validation-config="{'key1': val1, 'key2': val2, ...}"
default: {}

Config schema is as follows:

  'required_matches': {
    'path_pattern1': [content_pattern1, content_pattern2],
    'path_pattern2': [content_pattern1, content_pattern3],
  'path_patterns': [
      'name': path_pattern1',
      'pattern': <path regex pattern>,
      'inverted': True|False (defaults to False),
      'content_encoding': <encoding> (defaults to utf8)
  'content_patterns': [
      'name': 'content_pattern1',
      'pattern': <content regex pattern>,
      'inverted': True|False (defaults to False)

Meaning: if a file matches some path pattern, its content must match all the corresponding content patterns.

It's often helpful to load this config from a JSON or YAML file. To do that, set [regex-lint].config = '@path/to/config.yaml', for example.


one of: none, summary, nonmatching, names, all
default: nonmatching

How much detail to include in the result.

Advanced options


Deprecated options