Skip to content

Commit 7033441

Browse files
authored
fix: support object structure in schema (#231)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 1bb0212 commit 7033441

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

src/repo_review/resources/repo-review.schema.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,18 @@
99
"$ref": "#/$defs/checks"
1010
},
1111
"ignore": {
12-
"$ref": "#/$defs/checks"
12+
"oneOf": [
13+
{
14+
"$ref": "#/$defs/checks"
15+
},
16+
{
17+
"type": "object",
18+
"patternProperties": {
19+
"^[A-Z]+[0-9]*$": { "type": "string" }
20+
},
21+
"additionalProperties": false
22+
}
23+
]
1324
}
1425
},
1526
"$defs": {

tests/test_package.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,45 @@ def test_broken_validate_pyproject(tmp_path: Path) -> None:
4343
results = process(tmp_path)
4444

4545
(result,) = (r for r in results.results if r.name == "VPP001")
46-
assert "must match pattern" in result.err_msg
46+
assert "must be valid exactly by one definition" in result.err_msg
4747
assert not result.result
4848

4949

50+
def test_broken_validate_pyproject_object(tmp_path: Path) -> None:
51+
pytest.importorskip("validate_pyproject")
52+
tmp_path.joinpath("pyproject.toml").write_text(
53+
textwrap.dedent(
54+
"""\
55+
[tool.repo-review.ignore]
56+
a2 = "some message"
57+
"""
58+
)
59+
)
60+
61+
results = process(tmp_path)
62+
63+
(result,) = (r for r in results.results if r.name == "VPP001")
64+
assert "must be valid exactly by one definition" in result.err_msg
65+
assert not result.result
66+
67+
68+
def test_working_validate_pyproject_object(tmp_path: Path) -> None:
69+
pytest.importorskip("validate_pyproject")
70+
tmp_path.joinpath("pyproject.toml").write_text(
71+
textwrap.dedent(
72+
"""\
73+
[tool.repo-review.ignore]
74+
PP102 = "some message"
75+
"""
76+
)
77+
)
78+
79+
results = process(tmp_path)
80+
81+
(result,) = (r for r in results.results if r.name == "VPP001")
82+
assert result.result
83+
84+
5085
def test_testing_function():
5186
pytest.importorskip("sp_repo_review")
5287

0 commit comments

Comments
 (0)