From 2068275e7affa79096d78eacd1c1fa47dbb1b7c6 Mon Sep 17 00:00:00 2001 From: Diskuss <360374399+Diskuss@users.noreply.github.com> Date: Tue, 24 Nov 2026 19:38:49 +0100 Subject: [PATCH 1/2] Scripts: pr_check accepts markdown headings and any case for the sections The PR description check found a section only as the template's bold `**Tested**`, case-sensitively. Descriptions written with markdown headings (`## Tested`, `## Not Tested`, `## AI Use`) were refused with "the **Tested** section is missing or empty" though the sections were there and filled; about 20 open PRs fail only on this. A section heading is now `**Name**` as before, or a markdown heading `#`..`######` on a line of its own (optionally with the name in bold), with the name in any case. The same heading form starts the **AI use** text the banned-model check reads, so a model named under `## AI use` is still refused. Empty sections and template placeholders still fail. Co-Authored-By: Claude Opus 5.5 --- scripts/pr_check.py | 19 +++++++++++-------- scripts/test_pr_check.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/scripts/pr_check.py b/scripts/pr_check.py index cb0ef3ef9e..66e23f4068 100644 --- a/scripts/pr_check.py +++ b/scripts/pr_check.py @@ -82,14 +82,17 @@ def builds_runtime(path): return path.startswith("crates/xcl/data/") or path in RUNTIME_BUILD +def heading(names): + """A heading of one of `names`, in either case: `**Tested**` as in the template, or a markdown + heading on a line of its own (`## Tested`, `### **Tested**`).""" + alt = "|".join(re.escape(n) for n in names) + return (r"(?im:\*\*(?:" + alt + r")\*\*|^[ \t]*#{1,6}[ \t]+(?:\*\*)?(?:" + alt + + r")(?:\*\*)?[ \t]*#*[ \t]*$)") + + def section_has_content(body, section): - """True when `**section**` exists and has at least one non-placeholder line.""" - next_heading = "|".join(re.escape(h) for h in HEADINGS) - m = re.search( - r"\*\*" + re.escape(section) + r"\*\*[ \t]*\n(.*?)(?=\n\*\*(?:" + next_heading + r")\*\*|\Z)", - body, - re.S, - ) + """True when the `**section**` heading exists and has at least one non-placeholder line.""" + m = re.search(heading([section]) + r"[ \t]*\n(.*?)(?=\n" + heading(HEADINGS) + r"|\Z)", body, re.S) if not m: return False text = re.sub(r"", "", m.group(1), flags=re.S) @@ -110,7 +113,7 @@ def check(body, head, files, is_main_ancestor, *, test_only=False): if not section_has_content(body, section): problems.append(f"the **{section}** section is missing or empty") - ai = re.search(r"\*\*AI use\*\*(.*?)(\n\*\*|\Z)", body, re.S) + ai = re.search(heading(["AI use"]) + r"(.*?)(\n\*\*|\n#{1,6}[ \t]|\Z)", body, re.S) banned = re.findall(BANNED_MODELS, ai.group(1), re.I) if ai else [] if banned: problems.append("**AI use** names a model this repository does not accept for code (" diff --git a/scripts/test_pr_check.py b/scripts/test_pr_check.py index 8cc45d5d06..b10b12a542 100644 --- a/scripts/test_pr_check.py +++ b/scripts/test_pr_check.py @@ -136,5 +136,38 @@ def test_bare_bullets_and_html_comments_only_fail(self): self.assertEqual(3, len(problems)) +class HeadingFormTests(unittest.TestCase): + """Markdown headings and other cases of the section names count as the template's bold ones.""" + + def problems(self, body): + return check(body, HEAD, [changed("README.md")], lambda _: True) + + def test_markdown_headings_and_any_case_pass(self): + for tested, not_tested, ai in (("## Tested", "## Not Tested", "## AI Use"), + ("### **Tested**", "# not tested #", "###### AI use"), + ("**TESTED**", "**Not Tested**", "**AI Use**")): + with self.subTest(heading=tested): + body = f"## What is in it\n- x\n{tested}\nSynthetic fixtures\n{not_tested}\nRetail titles\n{ai}\nNone\n" + self.assertEqual([], self.problems(body)) + + def test_empty_markdown_sections_still_fail(self): + body = "## Tested\n-\n## Not tested\n\n## AI use\n" + self.assertEqual(3, len(self.problems(body))) + + def test_markdown_heading_ends_the_section_before_it(self): + body = "## Tested\n\n## Not tested\nRetail titles\n## AI use\nNone\n" + self.assertEqual(["the **Tested** section is missing or empty"], self.problems(body)) + + def test_heading_words_in_a_sentence_are_not_headings(self): + body = "## Tested things\nok\n## Not tested\nRetail titles\n## AI use\nNone\n" + self.assertEqual(["the **Tested** section is missing or empty"], self.problems(body)) + + def test_banned_model_under_a_markdown_heading_is_refused(self): + body = "## Tested\nSynthetic fixtures\n## Not tested\nRetail titles\n## AI Use\n- Qwen 3\n" + problems = self.problems(body) + self.assertEqual(1, len(problems), problems) + self.assertIn("does not accept", problems[0]) + + if __name__ == "__main__": unittest.main() From e0682e179b8f42a200bee31b374550eb09728355 Mon Sep 17 00:00:00 2001 From: Diskuss <360374399+Diskuss@users.noreply.github.com> Date: Wed, 25 Nov 2026 08:56:48 +0100 Subject: [PATCH 2/2] Scripts: pr_check ignores headings in code fences and reads all of AI use Two descriptions that main's checker refused passed with the markdown headings (RobertAndreiGit on #1645): - A sub-heading inside **AI use** (`### Tools`) ended its text, so a banned model named below it was not seen. The **AI use** text now runs to the next section of the template, in either heading form. - A description quoted whole in a code fence counted as one. Lines in a ``` or ~~~ fence are no headings now; the fence still counts as the text of the section it sits in, and the banned-model check still reads it. Co-Authored-By: Claude Opus 5.5 --- scripts/pr_check.py | 30 +++++++++++++++++++++++++++--- scripts/test_pr_check.py | 23 +++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/scripts/pr_check.py b/scripts/pr_check.py index 66e23f4068..5d349d3726 100644 --- a/scripts/pr_check.py +++ b/scripts/pr_check.py @@ -90,6 +90,25 @@ def heading(names): + r")(?:\*\*)?[ \t]*#*[ \t]*$)") +def mask_fences(body): + """`body` with each line inside a fenced code block (``` or ~~~) replaced by as many backticks, + so a heading quoted in a fence is no heading, while the fence still counts as a section's text + and every offset stays where it was.""" + out, fence = [], None + for line in body.split("\n"): + m = re.match(r"[ ]{0,3}(`{3,}|~{3,})", line) + if fence is None: + if m and not (m.group(1)[0] == "`" and "`" in line[m.end():]): + fence = m.group(1) + out.append(line) + elif m and m.group(1)[0] == fence[0] and len(m.group(1)) >= len(fence) and not line[m.end():].strip(): + fence = None + out.append(line) + else: + out.append("`" * len(line)) + return "\n".join(out) + + def section_has_content(body, section): """True when the `**section**` heading exists and has at least one non-placeholder line.""" m = re.search(heading([section]) + r"[ \t]*\n(.*?)(?=\n" + heading(HEADINGS) + r"|\Z)", body, re.S) @@ -108,13 +127,18 @@ def check(body, head, files, is_main_ancestor, *, test_only=False): size) with `size` a function giving the file's bytes; `is_main_ancestor(sha)`: whether the commit is on main.""" body = body.replace("\r\n", "\n") + masked = mask_fences(body) problems = [] for section in SECTIONS: - if not section_has_content(body, section): + if not section_has_content(masked, section): problems.append(f"the **{section}** section is missing or empty") - ai = re.search(heading(["AI use"]) + r"(.*?)(\n\*\*|\n#{1,6}[ \t]|\Z)", body, re.S) - banned = re.findall(BANNED_MODELS, ai.group(1), re.I) if ai else [] + # the **AI use** text runs to the next section of the template, not to a sub-heading of its own + # (`### Tools`); a fence in it is read as written + banned = [] + for ai in re.finditer(heading(["AI use"]), masked): + end = re.compile(r"\n" + heading(HEADINGS)).search(masked, ai.end()) + banned += re.findall(BANNED_MODELS, body[ai.end():end.start() if end else len(body)], re.I) if banned: problems.append("**AI use** names a model this repository does not accept for code (" + ", ".join(sorted({b.lower() for b in banned})) + "): see CONTRIBUTING.md") diff --git a/scripts/test_pr_check.py b/scripts/test_pr_check.py index b10b12a542..0c3ff5c2e2 100644 --- a/scripts/test_pr_check.py +++ b/scripts/test_pr_check.py @@ -168,6 +168,29 @@ def test_banned_model_under_a_markdown_heading_is_refused(self): self.assertEqual(1, len(problems), problems) self.assertIn("does not accept", problems[0]) + def test_banned_model_under_a_sub_heading_of_ai_use_is_refused(self): + # RobertAndreiGit on #1645: a `### Tools` heading in **AI use** hid the model from the check + for ai in ("**AI use**", "## AI use"): + with self.subTest(heading=ai): + body = f"**Tested**\nSynthetic fixtures\n**Not tested**\nRetail titles\n{ai}\n### Tools\nQwen\n" + problems = self.problems(body) + self.assertEqual(1, len(problems), problems) + self.assertIn("qwen", problems[0]) + + def test_headings_inside_a_code_fence_are_not_sections(self): + # RobertAndreiGit on #1645: a fenced example of a description passed as the description + example = "## Tested\nSynthetic fixtures\n## Not tested\nRetail titles\n## AI use\nNone\n" + for opening, closing in (("```", "```"), ("~~~", "~~~"), ("````markdown", "````")): + with self.subTest(fence=opening): + body = f"An example:\n{opening}\n{example}{closing}\n" + self.assertEqual(3, len(self.problems(body))) + + def test_a_fence_in_a_section_is_its_text(self): + body = "## Tested\n```\n## Not tested\n18 passed\n```\n## Not tested\nRetail titles\n## AI use\nNone\n" + self.assertEqual([], self.problems(body)) + body = "## Tested\nok\n## Not tested\nRetail titles\n## AI use\n```\nqwen\n```\n" + self.assertEqual(1, len(self.problems(body))) + if __name__ == "__main__": unittest.main()