Coverage for src/pullapprove/trust/labels.py: 100%
22 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-07-28 14:54 -0500
« prev ^ index » next coverage.py v7.14.1, created at 2026-07-28 14:54 -0500
1"""The closed vocabulary of trust labels.
3Every label is `family:specific`. Rules return a `Trust` member, which *is* a
4string everywhere it's used — display, counting, comparison, `--hide` matching —
5so callers can treat it as the `family:specific` token it spells, while the enum
6gives one place to see every label and catches typos at the source.
7"""
9from __future__ import annotations
11from enum import StrEnum
14class Trust(StrEnum):
15 LOCKFILE = "generated:lockfile"
16 EMPTY_FILE = "file:added-empty"
17 FILE_RENAMED = "file:renamed"
18 WHITESPACE = "formatting:whitespace"
19 LINE_LENGTH = "formatting:line-length"
20 STYLE = "formatting:style"
21 SPACING = "formatting:spacing"
22 COMMENTS_ADDED = "comments:added"
23 COMMENTS_REMOVED = "comments:removed"
24 COMMENTS_MODIFIED = "comments:modified"
25 IMPORTS_ADDED = "imports:added"
26 IMPORTS_REMOVED = "imports:removed"
27 IMPORTS_MODIFIED = "imports:modified"
28 IMPORTS_REORDERED = "imports:reordered"
29 TYPE_ANNOTATIONS_MODIFIED = "type-annotations:modified"
31 @property
32 def family(self) -> str:
33 """The part before the colon, e.g. `formatting` for `formatting:style`."""
34 return self.value.split(":", 1)[0]
37# Every family a `--hide` filter can name.
38TRUST_FAMILIES = frozenset(label.family for label in Trust)