github3_utils.check_labels

Helpers for creating labels to mark pull requests with which tests are failing.

New in version 0.4.0.

Classes:

Checks(successful, failing, running, …)

Represents the sets of status checks returned by get_checks_for_pr().

Label(name, color[, description])

Represents an issue or pull request label.

Data:

check_status_labels

Labels corresponding to failing pull request checks.

Functions:

get_checks_for_pr(pull)

Returns a Checks object containing sets of check names grouped by their status.

label_pr_failures(pull)

Labels the given pull request to indicate which checks are failing.

namedtuple Checks(successful, failing, running, skipped, neutral)[source]

Bases: NamedTuple

Represents the sets of status checks returned by get_checks_for_pr().

Fields
  1.  successful (Set[str]) – Alias for field number 0

  2.  failing (Set[str]) – Alias for field number 1

  3.  running (Set[str]) – Alias for field number 2

  4.  skipped (Set[str]) – Alias for field number 3

  5.  neutral (Set[str]) – Alias for field number 4

__repr__()

Return a nicely formatted representation string

class Label(name, color, description=None)[source]

Bases: object

Represents an issue or pull request label.

Parameters
  • name (str) – The text of the label.

  • color (str) – The background colour of the label.

  • description (Optional[str]) – A short description of the label. Default None.

Methods:

__repr__()

Return a string representation of the Label.

__str__()

Return str(self).

create(repo)

Create this label on the given repository.

to_dict()

Return the Label as a dictionary.

Attributes:

color

The background colour of the label.

description

A short description of the label.

name

The text of the label.

__repr__()

Return a string representation of the Label.

Return type

str

__str__()[source]

Return str(self).

Return type

str

color

Type:    str

The background colour of the label.

create(repo)[source]

Create this label on the given repository.

Parameters

repo (Repository)

Return type

Label

description

Type:    str

A short description of the label.

name

Type:    str

The text of the label.

to_dict()[source]

Return the Label as a dictionary.

Return type

Dict[str, str]

check_status_labels = {'failure: Linux': Label(name='failure: Linux', color='#F6BDC0', description='The Linux tests are failing.'), 'failure: Windows': Label(name='failure: Windows', color='#F07470', description='The Windows tests are failing.'), 'failure: docs': Label(name='failure: docs', color='#EA4C46', description='The docs check is failing.'), 'failure: flake8': Label(name='failure: flake8', color='#B60205', description='The Flake8 check is failing.'), 'failure: mypy': Label(name='failure: mypy', color='#DC1C13', description='The mypy check is failing.')}

Type:    Dict[str, Label]

Labels corresponding to failing pull request checks.

get_checks_for_pr(pull)[source]

Returns a Checks object containing sets of check names grouped by their status.

Parameters

pull (Union[PullRequest, ShortPullRequest]) – The pull request to obtain checks for.

Return type

Checks

label_pr_failures(pull)[source]

Labels the given pull request to indicate which checks are failing.

Parameters

pull (Union[PullRequest, ShortPullRequest])

Return type

Set[str]

Returns

The new labels set for the pull request.