Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions scripts/notebook_tools/check_kernel_drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,21 @@ def body_has_derive_exemption(body):
tolerates the unaccented 'derive' (covers authors who type the header
without the accent, a common shortcut when reviewing on a non-French
keyboard layout).

Fix v3 (suffix form, cas vecu #17220): also tolerate a trailing
parenthetical qualifier, e.g. '## Diagnostic derive (C.4)' -- the exact
form used in the PR body of #17220, whose exemption silently failed to
fire because
the strict end-of-line anchor rejected the '(C.4)' suffix (measured
firsthand 2026-09-21: kernel_diffs downgraded nowhere, guard red on a
3.13.7 -> 3.13.15 patch drift that the C.4 section was documenting).
"""
if not body:
return False
# Case-insensitive header, optional whitespace, optional accent on 'e'.
# Case-insensitive header, optional whitespace, optional accent on 'e',
# optional trailing parenthetical qualifier such as '(C.4)'.
pattern = re.compile(
r"^##\s*Diagnostic\s*d[ée]rive\s*$",
r"^##\s*Diagnostic\s*d[ée]rive(?:\s*\([^)]*\))?\s*$",
re.MULTILINE | re.IGNORECASE,
)
return bool(pattern.search(body))
Expand Down
23 changes: 23 additions & 0 deletions scripts/notebook_tools/tests/test_check_kernel_drift_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ def test_body_empty_no_exemption():
assert ckd.body_has_derive_exemption("") is False


def test_body_derive_suffix_parenthetical_exempts():
"""Suffix form '## Diagnostic derive (C.4)' exempts (cas vecu #17220).

The strict end-of-line anchor used to reject the parenthetical
qualifier, so a PR whose C.4 section was properly written but suffixed
with '(C.4)' silently lost the exemption.
"""
body = "## Summary\nFix\n\n## Diagnostic derive (C.4)\nverdict CAUSE_FIXED\n"
assert ckd.body_has_derive_exemption(body) is True


def test_body_derive_suffix_parenthetical_accented_exempts():
"""Accented suffix form '## Diagnostic dérive (C.4)' exempts."""
body = "## Summary\nFix\n\n## Diagnostic dérive (C.4)\nverdict CAUSE_FIXED\n"
assert ckd.body_has_derive_exemption(body) is True


def test_body_derive_trailing_garbage_no_exemption():
"""Arbitrary trailing text (not a single parenthetical) stays rejected."""
body = "## Summary\nFix\n\n## Diagnostic derive and other notes\n"
assert ckd.body_has_derive_exemption(body) is False


# === Defect 5: float_signatures normalization ===

def test_float_signatures_text_plain_list():
Expand Down
Loading