Infra: Make check-peps’ _validate_post_history crash less (#3511)

Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
This commit is contained in:
Philipp A 2023-10-29 01:23:55 +02:00 committed by GitHub
parent 1d09abe701
commit 39d050b5e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -414,12 +414,15 @@ def _validate_post_history(line_num: int, body: str) -> MessageIterator:
for offset, line in enumerate(body.removesuffix(",").split("\n"), start=line_num):
for post in line.removesuffix(",").strip().split(", "):
if not post.startswith("`") and not post.endswith(">`__"):
prefix, postfix = (post.startswith("`"), post.endswith(">`__"))
if not prefix and not postfix:
yield from _date(offset, post, "Post-History")
else:
elif prefix and postfix:
post_date, post_url = post[1:-4].split(" <")
yield from _date(offset, post_date, "Post-History")
yield from _thread(offset, post_url, "Post-History")
else:
yield offset, f"post line must be a date or both start with “`” and end with “>`__”"
def _validate_resolution(line_num: int, line: str) -> MessageIterator: