Skip to content

Commit 14094b5

Browse files
authored
refactor: delete the unused CheckResult type and the descriptor-gate script entry (#84)
1 parent 696aea3 commit 14094b5

3 files changed

Lines changed: 2 additions & 51 deletions

File tree

‎semvertag/_types.py‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,3 @@ class Commit:
3737
class Tag:
3838
name: str
3939
commit_sha: str
40-
41-
42-
@dataclasses.dataclass(frozen=True, slots=True, kw_only=True)
43-
class CheckResult:
44-
name: str
45-
status: typing.Literal["passed", "failed", "skipped"]
46-
cause: str

‎tests/_descriptor_gate.py‎

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
"""Structural validator for templates/semvertag.yml.
2-
3-
Shared between the `.github/workflows/ci.yml` lint step and the
4-
regression test fixtures in test_ci_descriptor_gate.py so the gate
5-
and its tests cannot drift.
6-
"""
1+
"""Structural validator for templates/semvertag.yml, run by test_ci_descriptor_gate.py."""
72

83
import pathlib
9-
import sys
104
import typing
115

126
import yaml
@@ -17,7 +11,6 @@
1711
_SUBSTITUTION_LITERAL: typing.Final = "$[[ inputs.strategy ]]"
1812
_EXPECTED_OPTIONS: typing.Final = {"branch-prefix", "conventional-commits"}
1913
_EXPECTED_DOC_COUNT: typing.Final = 2
20-
_EXPECTED_ARGV_LEN: typing.Final = 2
2114

2215

2316
class DescriptorGateError(SystemExit):
@@ -106,15 +99,3 @@ def validate(path: str) -> None:
10699
">=" in first or "==" in first or _VERSION_MARKER in first,
107100
f"job.script[0] must pin the semvertag version (contain '>=', '==', or '{_VERSION_MARKER}'), got {first!r}",
108101
)
109-
110-
111-
def main(argv: list[str]) -> None:
112-
if len(argv) != _EXPECTED_ARGV_LEN:
113-
msg = f"usage: python -m tests._descriptor_gate <path>; got {argv!r}"
114-
raise DescriptorGateError(msg)
115-
validate(argv[1])
116-
sys.stdout.write(f"{argv[1]} shape OK\n")
117-
118-
119-
if __name__ == "__main__":
120-
main(sys.argv)

‎tests/test_ci_descriptor_gate.py‎

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
"""
88

99
import pathlib
10-
import runpy
11-
import sys
1210
import typing
1311

1412
import pytest
1513
import yaml
1614

17-
from tests._descriptor_gate import DescriptorGateError, main, validate
15+
from tests._descriptor_gate import DescriptorGateError, validate
1816

1917

2018
_REPO_ROOT: typing.Final = pathlib.Path(__file__).parent.parent
@@ -123,24 +121,3 @@ def test_unpinned_semvertag_fails(tmp_path: pathlib.Path, shipped_descriptor_doc
123121
bad = _write_descriptor(tmp_path, [spec, body])
124122
with pytest.raises(DescriptorGateError, match=r"script.* must pin the semvertag version"):
125123
validate(str(bad))
126-
127-
128-
def test_main_prints_shape_ok_for_valid_descriptor(capsys: pytest.CaptureFixture[str]) -> None:
129-
main(["_descriptor_gate", str(_DESCRIPTOR_PATH)])
130-
captured: typing.Final = capsys.readouterr()
131-
assert captured.out == f"{_DESCRIPTOR_PATH} shape OK\n"
132-
133-
134-
def test_module_run_as_script_validates_argv_path(
135-
monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
136-
) -> None:
137-
monkeypatch.setattr(sys, "argv", ["_descriptor_gate", str(_DESCRIPTOR_PATH)])
138-
monkeypatch.delitem(sys.modules, "tests._descriptor_gate")
139-
runpy.run_module("tests._descriptor_gate", run_name="__main__")
140-
captured: typing.Final = capsys.readouterr()
141-
assert captured.out == f"{_DESCRIPTOR_PATH} shape OK\n"
142-
143-
144-
def test_main_raises_when_argv_length_wrong() -> None:
145-
with pytest.raises(DescriptorGateError, match=r"usage: python -m tests\._descriptor_gate"):
146-
main(["_descriptor_gate"])

0 commit comments

Comments
 (0)