pre_commit

Configuration for pre-commit.

Data:

GITHUB_COM

Instance of apeye.url.URL that points to the GitHub website.

Classes:

Hook

Represents a pre-commit hook.

Repo(repo, rev, hooks)

Represents a repository providing a pre-commit hooks.

Functions:

make_github_url(username, repository)

Construct a URL to a GitHub repository from a username and repository name.

make_pre_commit(repo_path, templates)

Add configuration for pre-commit.

GITHUB_COM = URL('https://github.com')

Type:    URL

Instance of apeye.url.URL that points to the GitHub website.

typeddict Hook[source]

Bases: dict

Represents a pre-commit hook.

Required Keys
  • id (str) – Which hook from the repository to use.

Optional Keys
  • alias (str) – Allows the hook to be referenced using an additional id when using pre-commit run <hookid>.

  • name (str) – Override the name of the hook - shown during hook execution.

  • language_version (str) – Override the language version for the hook. See https://pre-commit.com/#overriding-language-version

  • files (str) – Override the default pattern for files to run on.

  • exclude (str) – File exclude pattern.

  • types (List[str]) – Override the default file types to run on. See https://pre-commit.com/#filtering-files-with-types.

  • exclude_types (List[str]) – File types to exclude.

  • args (List[str]) – List of additional parameters to pass to the hook.

  • stages (List[Literal['commit', 'merge-commit', 'push', 'prepare-commit-msg', 'commit-msg', 'manual']]) – Confines the hook to the commit, merge-commit, push, prepare-commit-msg, commit-msg, post-checkout, or manual stage. See https://pre-commit.com/#confining-hooks-to-run-at-certain-stages.

  • additional_dependencies (List[str]) – A list of dependencies that will be installed in the environment where this hook gets run. One useful application is to install plugins for hooks such as eslint.

  • always_run (bool) – If True, this hook will run even if there are no matching files.

  • verbose (bool) – If True, forces the output of the hook to be printed even when the hook passes.

  • log_file (str) – If present, the hook output will additionally be written to a file.

class Repo(repo, rev, hooks)[source]

Bases: object

Represents a repository providing a pre-commit hooks.

Methods:

__eq__(other)

Method generated by attrs for class Repo.

__ge__(other)

Method generated by attrs for class Repo.

__gt__(other)

Method generated by attrs for class Repo.

__le__(other)

Method generated by attrs for class Repo.

__lt__(other)

Method generated by attrs for class Repo.

__ne__(other)

Method generated by attrs for class Repo.

__repr__()

Method generated by attrs for class Repo.

to_dict()

Returns a dictionary representation of the Repo.

Attributes:

repo

The repository url to git clone from.

rev

The revision or tag to clone at.

__eq__(other)

Method generated by attrs for class Repo.

__ge__(other)

Method generated by attrs for class Repo.

__gt__(other)

Method generated by attrs for class Repo.

__le__(other)

Method generated by attrs for class Repo.

__lt__(other)

Method generated by attrs for class Repo.

__ne__(other)

Method generated by attrs for class Repo.

__repr__()

Method generated by attrs for class Repo.

repo

Type:    URL

The repository url to git clone from.

rev

Type:    str

The revision or tag to clone at.

to_dict()[source]

Returns a dictionary representation of the Repo.

Return type

MutableMapping[str, Union[str, List[Hook]]]

make_github_url(username, repository)[source]

Construct a URL to a GitHub repository from a username and repository name.

Parameters
  • username (str) – The username of the GitHub account that owns the repository.

  • repository (str) – The name of the repository.

Return type

URL

make_pre_commit(repo_path, templates)[source]

Add configuration for pre-commit.

https://github.com/pre-commit/pre-commit

# See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks

Parameters
  • repo_path (Path) – Path to the repository root.

  • templates (Environment)

Return type

List[str]