Skip to content

Commit 39d050b

Browse files
Infra: Make check-peps’ _validate_post_history crash less (python#3511)
Co-authored-by: Pradyun Gedam <[email protected]>
1 parent 1d09abe commit 39d050b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

check-peps.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,15 @@ def _validate_post_history(line_num: int, body: str) -> MessageIterator:
414414

415415
for offset, line in enumerate(body.removesuffix(",").split("\n"), start=line_num):
416416
for post in line.removesuffix(",").strip().split(", "):
417-
if not post.startswith("`") and not post.endswith(">`__"):
417+
prefix, postfix = (post.startswith("`"), post.endswith(">`__"))
418+
if not prefix and not postfix:
418419
yield from _date(offset, post, "Post-History")
419-
else:
420+
elif prefix and postfix:
420421
post_date, post_url = post[1:-4].split(" <")
421422
yield from _date(offset, post_date, "Post-History")
422423
yield from _thread(offset, post_url, "Post-History")
424+
else:
425+
yield offset, f"post line must be a date or both start with “`” and end with “>`__”"
423426

424427

425428
def _validate_resolution(line_num: int, line: str) -> MessageIterator:

0 commit comments

Comments
 (0)