fix(tools): read multi-line Depends on lists in pr_overlap #819

Merged
ebosido444-ai merged 2 commits from upstream-pr/819 into main 2026-10-07 20:03:33 +00:00
ebosido444-ai commented 2026-10-06 06:37:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-06T06:37:17Z.


What

The capture continues over consecutive - #N / * #N list items only (dashes or asterisks), so - PR #12, 1. #12, or a paragraph break before the list are not read — matching the template's list form.

Tested

Windows 11, Python 3.14 (no build). Assert checks: list form Depends on:\n- #12\n- #13 yields {12, 13} (was {}), single-line form unchanged, the Depends on: none template row and Depends on: <!-- #PR, or none --> yield no dependencies (no false #N from the #PR placeholder). Exact reproducer (run at 6a42906; on main without the fix asserts 1–2 fail — both lists read as {}):

git checkout 6a42906
python - <<'PYEOF'
import re, sys
sys.path.insert(0, 'tools')
import pr_overlap
def deps(body):
    m = pr_overlap.DEPENDS.search(body)
    return {int(n) for n in re.findall(r"#(\d+)", m.group(1))} if m else set()
def old_deps(body):
    m = re.compile(r"Depends on:(.*)").search(body)
    return {int(n) for n in re.findall(r"#(\d+)", m.group(1))} if m else set()
tmpl = '### Checklist\n- [x] Depends on: <!-- #PR, or none -->\n- #12\n- #13\n\nother'
lst = 'Depends on:\n- #12\n- #13\n\nother text #77'
one = 'Depends on: #12, #13'
assert deps(tmpl) == {12, 13} and old_deps(tmpl) == set()
assert deps(lst) == {12, 13} and old_deps(lst) == set()
assert deps(one) == {12, 13} and old_deps(one) == {12, 13}
assert deps('Depends on: none') == set()
assert deps('Depends on: <!-- #PR, or none -->') == set()
print('assert 1 template row + following list: {12, 13} (was {}) -- the template line was eating the list')
print('assert 2 markdown list form: {12, 13} (was {})')
print('assert 3 single-line form unchanged: {12, 13}')
print('assert 4 `none` and bare placeholder rows: no dependencies, no phantom #PR')
print('PASS 4/4')
PYEOF

Assert results:

assert 1 template row + following list: {12, 13} (was {}) -- the template line was eating the list
assert 2 markdown list form: {12, 13} (was {})
assert 3 single-line form unchanged: {12, 13}
assert 4 `none` and bare placeholder rows: no dependencies, no phantom #PR
PASS 4/4

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (n/a, tooling)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (n/a)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4755099509 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/819). Originally posted by [ebosido444-ai](https://github.com/ebosido444-ai) on 2026-10-06T06:37:17Z. --- ### What The capture continues over consecutive `- #N` / `* #N` list items only (dashes or asterisks), so `- PR #12`, `1. #12`, or a paragraph break before the list are not read — matching the template's list form. ### Tested Windows 11, Python 3.14 (no build). Assert checks: list form `Depends on:\n- #12\n- #13` yields `{12, 13}` (was `{}`), single-line form unchanged, the `Depends on: none` template row and `Depends on: <!-- #PR, or none -->` yield no dependencies (no false `#N` from the `#PR` placeholder). Exact reproducer (run at `6a42906`; on `main` without the fix asserts 1–2 fail — both lists read as `{}`): git checkout 6a42906 python - <<'PYEOF' import re, sys sys.path.insert(0, 'tools') import pr_overlap def deps(body): m = pr_overlap.DEPENDS.search(body) return {int(n) for n in re.findall(r"#(\d+)", m.group(1))} if m else set() def old_deps(body): m = re.compile(r"Depends on:(.*)").search(body) return {int(n) for n in re.findall(r"#(\d+)", m.group(1))} if m else set() tmpl = '### Checklist\n- [x] Depends on: <!-- #PR, or none -->\n- #12\n- #13\n\nother' lst = 'Depends on:\n- #12\n- #13\n\nother text #77' one = 'Depends on: #12, #13' assert deps(tmpl) == {12, 13} and old_deps(tmpl) == set() assert deps(lst) == {12, 13} and old_deps(lst) == set() assert deps(one) == {12, 13} and old_deps(one) == {12, 13} assert deps('Depends on: none') == set() assert deps('Depends on: <!-- #PR, or none -->') == set() print('assert 1 template row + following list: {12, 13} (was {}) -- the template line was eating the list') print('assert 2 markdown list form: {12, 13} (was {})') print('assert 3 single-line form unchanged: {12, 13}') print('assert 4 `none` and bare placeholder rows: no dependencies, no phantom #PR') print('PASS 4/4') PYEOF Assert results: assert 1 template row + following list: {12, 13} (was {}) -- the template line was eating the list assert 2 markdown list form: {12, 13} (was {}) assert 3 single-line form unchanged: {12, 13} assert 4 `none` and bare placeholder rows: no dependencies, no phantom #PR PASS 4/4 ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (n/a, tooling) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (n/a) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
oneandonlydean commented 2026-10-06 09:27:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-06T09:27:41Z.


Good catch on the list form. There's one problem with the new pattern: PR bodies written in the GitHub web editor are stored with CRLF line endings. 31 of the 106 open PRs have them. For those bodies \n\n never matches \r\n\r\n, so the capture runs to the end of the body. Any #N written after the checklist then counts as a dependency and hides the overlap row for that pair. #811's body is an example: the capture continues into the paragraph after its checklist. No open PR's dependency set changes today, so the bug is latent for now, but a hidden overlap is the failure the tool exists to catch.

Capturing the line plus any following list items that start with #N handles both forms without touching the rest of the body:

DEPENDS = re.compile(r"Depends on:([^\r\n]*(?:\r?\n[ \t]*[-*][ \t]*#\d+[^\r\n]*)*)")

That pattern gives {12, 13} for Depends on:\n- #12\n- #13, for the CRLF and indented checklist variants, and for Depends on: #12, #13. It gives nothing for none, the template's "#PR, or none" placeholder comment, or a #700 in a later paragraph. On the current open PRs it gives the same sets as main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6013351994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/819#issuecomment-6013351994). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-06T09:27:41Z. --- Good catch on the list form. There's one problem with the new pattern: PR bodies written in the GitHub web editor are stored with CRLF line endings. 31 of the 106 open PRs have them. For those bodies `\n\n` never matches `\r\n\r\n`, so the capture runs to the end of the body. Any `#N` written after the checklist then counts as a dependency and hides the overlap row for that pair. #811's body is an example: the capture continues into the paragraph after its checklist. No open PR's dependency set changes today, so the bug is latent for now, but a hidden overlap is the failure the tool exists to catch. Capturing the line plus any following list items that start with `#N` handles both forms without touching the rest of the body: ```python DEPENDS = re.compile(r"Depends on:([^\r\n]*(?:\r?\n[ \t]*[-*][ \t]*#\d+[^\r\n]*)*)") ``` That pattern gives `{12, 13}` for `Depends on:\n- #12\n- #13`, for the CRLF and indented checklist variants, and for `Depends on: #12, #13`. It gives nothing for `none`, the template's "#PR, or none" placeholder comment, or a `#700` in a later paragraph. On the current open PRs it gives the same sets as `main`.
ebosido444-ai commented 2026-10-06 09:50:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-06T09:50:31Z.


Applied your CRLF-safe pattern verbatim (999da59a). Behaviour matrix re-run against the file line on the branch, samples built with explicit CR/LF so no escape can lie: list form LF {12,13}, list form CRLF with a later #700 paragraph {12,13}, indented star form {12}, single-line {12,13}, none {}, template placeholder {}, later-paragraph #700 ignored {}. 7/7. Thanks for catching the CRLF class — 31/106 bodies would have been poisoned quietly.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6013713927 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/819#issuecomment-6013713927). Originally posted by [ebosido444-ai](https://github.com/ebosido444-ai) on 2026-10-06T09:50:31Z. --- Applied your CRLF-safe pattern verbatim (999da59a). Behaviour matrix re-run against the file line on the branch, samples built with explicit CR/LF so no escape can lie: list form LF {12,13}, list form CRLF with a later #700 paragraph {12,13}, indented star form {12}, single-line {12,13}, none {}, template placeholder {}, later-paragraph #700 ignored {}. 7/7. Thanks for catching the CRLF class — 31/106 bodies would have been poisoned quietly.
adriadam10 commented 2026-10-07 16:08:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T16:08:18Z.

Review: CHANGES_REQUESTED


Checked the new DEPENDS pattern against LF and CRLF bodies (template row + list, bare list, single line, none, #PR placeholder, later #N paragraph): all read as described. One thing to fix:

  • tools/pr_overlap.py:11: the pattern is now a plain string literal containing \d, which emits SyntaxWarning: invalid escape sequence '\d' (a SyntaxError in future Python versions). Keep it a raw string, as the original was: re.compile(r'Depends on:...').

Minor, optional: the description says the capture runs "until a blank line", but the regex only continues over - #N / * #N items, so - PR #12, 1. #12 or a blank line before the list are not read. Either describe it that way or widen the item pattern.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5445032014 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/819#pullrequestreview-5445032014). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T16:08:18Z. **Review:** CHANGES_REQUESTED --- Checked the new `DEPENDS` pattern against LF and CRLF bodies (template row + list, bare list, single line, `none`, `#PR` placeholder, later `#N` paragraph): all read as described. One thing to fix: - `tools/pr_overlap.py:11`: the pattern is now a plain string literal containing `\d`, which emits `SyntaxWarning: invalid escape sequence '\d'` (a `SyntaxError` in future Python versions). Keep it a raw string, as the original was: `re.compile(r'Depends on:...')`. Minor, optional: the description says the capture runs "until a blank line", but the regex only continues over `- #N` / `* #N` items, so `- PR #12`, `1. #12` or a blank line before the list are not read. Either describe it that way or widen the item pattern.
ebosido444-ai commented 2026-10-07 17:49:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ebosido444-ai on 2026-10-07T17:49:56Z.


Both handled (5a4d8b6f): the pattern is a raw string again (re.compile(r'...')) with the 7-case behaviour matrix re-run green and a warning-trip assertion (any invalid-escape SyntaxWarning fails the check); and the description now says what the regex really does — continuation over consecutive - #N / * #N list items only, not blanket until-a-blank-line. Kept the narrower item pattern rather than widening to - PR #12 forms, per your either/or.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6043592344 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/819#issuecomment-6043592344). Originally posted by [ebosido444-ai](https://github.com/ebosido444-ai) on 2026-10-07T17:49:56Z. --- Both handled (5a4d8b6f): the pattern is a raw string again (`re.compile(r'...')`) with the 7-case behaviour matrix re-run green and a warning-trip assertion (any invalid-escape SyntaxWarning fails the check); and the description now says what the regex really does — continuation over consecutive `- #N` / `* #N` list items only, not blanket until-a-blank-line. Kept the narrower item pattern rather than widening to `- PR #12` forms, per your either/or.
adriadam10 commented 2026-10-07 20:03:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T20:03:29Z.

Review: APPROVED


Checked the new DEPENDS pattern on the PR head (merged onto current main) with python -W error (no SyntaxWarning): LF and CRLF bodies with a later #N paragraph, template row + list, single-line form, none, the #PR placeholder and an indented * list all read as described. CI is green; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5447678534 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/819#pullrequestreview-5447678534). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T20:03:29Z. **Review:** APPROVED --- Checked the new `DEPENDS` pattern on the PR head (merged onto current `main`) with `python -W error` (no `SyntaxWarning`): LF and CRLF bodies with a later `#N` paragraph, template row + list, single-line form, `none`, the `#PR` placeholder and an indented `*` list all read as described. CI is green; merging.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!819
No description provided.