Infra: Make check-peps’ _validate_post_history crash less (#3511)
Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
This commit is contained in:
parent
1d09abe701
commit
39d050b5e0
|
@ -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 offset, line in enumerate(body.removesuffix(",").split("\n"), start=line_num):
|
||||||
for post in line.removesuffix(",").strip().split(", "):
|
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")
|
yield from _date(offset, post, "Post-History")
|
||||||
else:
|
elif prefix and postfix:
|
||||||
post_date, post_url = post[1:-4].split(" <")
|
post_date, post_url = post[1:-4].split(" <")
|
||||||
yield from _date(offset, post_date, "Post-History")
|
yield from _date(offset, post_date, "Post-History")
|
||||||
yield from _thread(offset, post_url, "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:
|
def _validate_resolution(line_num: int, line: str) -> MessageIterator:
|
||||||
|
|
Loading…
Reference in New Issue