Coverage for src/pullapprove/trust/labels.py: 100%
21 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-07-17 11:30 -0500
« prev ^ index » next coverage.py v7.14.1, created at 2026-07-17 11:30 -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 WHITESPACE = "formatting:whitespace"
18 LINE_LENGTH = "formatting:line-length"
19 STYLE = "formatting:style"
20 SPACING = "formatting:spacing"
21 COMMENTS_ADDED = "comments:added"
22 COMMENTS_REMOVED = "comments:removed"
23 COMMENTS_MODIFIED = "comments:modified"
24 IMPORTS_ADDED = "imports:added"
25 IMPORTS_REMOVED = "imports:removed"
26 IMPORTS_MODIFIED = "imports:modified"
27 IMPORTS_REORDERED = "imports:reordered"
28 TYPE_ANNOTATIONS_MODIFIED = "type-annotations:modified"
30 @property
31 def family(self) -> str:
32 """The part before the colon, e.g. `formatting` for `formatting:style`."""
33 return self.value.split(":", 1)[0]
36# Every family a `--hide` filter can name.
37TRUST_FAMILIES = frozenset(label.family for label in Trust)