From 7b2b46d95af7e9b563460dde9d0a05fcb42df4b5 Mon Sep 17 00:00:00 2001 From: Menelaos Date: Sun, 17 Dec 2023 23:58:20 +0200 Subject: [PATCH 1/6] Accept GitHub issues numbered only 32426 or above --- blurb/blurb.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/blurb/blurb.py b/blurb/blurb.py index 7557c23..63d80c3 100755 --- a/blurb/blurb.py +++ b/blurb/blurb.py @@ -956,9 +956,13 @@ def init_tmp_with_template(): failure = str(e) if not failure: - assert len(blurb) # if parse_blurb succeeds, we should always have a body - if len(blurb) > 1: - failure = "Too many entries! Don't specify '..' on a line by itself." + with open(tmp_path, "rt", encoding="utf-8") as file: + for line in file: + if line.startswith(".. gh-issue:"): + issue_number = line.split(":")[1].strip() + if issue_number.isdigit() and int(issue_number) < 32426: + failure = "The gh-issue number should be 32426 or above." + break if failure: print() From f864c05abd807622bb273a03b8e7bdfb67c0dd76 Mon Sep 17 00:00:00 2001 From: Menelaos Date: Mon, 18 Dec 2023 19:23:50 +0200 Subject: [PATCH 2/6] Distinqush if gh-issue is number or < 32426 errors --- blurb/blurb.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/blurb/blurb.py b/blurb/blurb.py index 63d80c3..f5d60fb 100755 --- a/blurb/blurb.py +++ b/blurb/blurb.py @@ -956,13 +956,14 @@ def init_tmp_with_template(): failure = str(e) if not failure: - with open(tmp_path, "rt", encoding="utf-8") as file: - for line in file: - if line.startswith(".. gh-issue:"): - issue_number = line.split(":")[1].strip() - if issue_number.isdigit() and int(issue_number) < 32426: - failure = "The gh-issue number should be 32426 or above." - break + assert len(blurb) # if parse_blurb succeeds, we should always have a body + if len(blurb) > 1: + failure = "Too many entries! Don't specify '..' on a line by itself." + gh_issue_number = blurb[0][0]["gh-issue"] + if not gh_issue_number.isdigit(): + failure = "The gh-issue number must be a number." + if int(gh_issue_number) < 32426: + failure = "The gh-issue number should be 32426 or above." if failure: print() From 724fefb23e4a6ec7d8bffd766c74d6167580f204 Mon Sep 17 00:00:00 2001 From: Menelaos Date: Tue, 19 Dec 2023 01:37:52 +0200 Subject: [PATCH 3/6] Fix old test cases to comply with GH issue number range --- blurb/blurb.py | 8 +++----- blurb/tests/fail/small-gh-number.rst | 4 ++++ blurb/tests/pass/basic.rst | 2 +- blurb/tests/pass/basic.rst.res | 2 +- blurb/tests/pass/case-insensitive.rst | 2 +- blurb/tests/pass/case-insensitive.rst.res | 2 +- blurb/tests/pass/no-break-long-words.rst | 2 +- blurb/tests/pass/no-break-long-words.rst.res | 2 +- blurb/tests/pass/no-break-on-hyphens.rst | 2 +- blurb/tests/pass/no-break-on-hyphens.rst.res | 2 +- 10 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 blurb/tests/fail/small-gh-number.rst diff --git a/blurb/blurb.py b/blurb/blurb.py index f5d60fb..3257a53 100755 --- a/blurb/blurb.py +++ b/blurb/blurb.py @@ -486,6 +486,9 @@ def finish_entry(): # we'll complain about the *first* error # we see in the blurb file, which is a # better user experience. + if key == "gh-issue" and int(value) < 32426: + throw("The gh-issue number should be 32426 or above.") + if key in issue_keys: try: int(value) @@ -959,11 +962,6 @@ def init_tmp_with_template(): assert len(blurb) # if parse_blurb succeeds, we should always have a body if len(blurb) > 1: failure = "Too many entries! Don't specify '..' on a line by itself." - gh_issue_number = blurb[0][0]["gh-issue"] - if not gh_issue_number.isdigit(): - failure = "The gh-issue number must be a number." - if int(gh_issue_number) < 32426: - failure = "The gh-issue number should be 32426 or above." if failure: print() diff --git a/blurb/tests/fail/small-gh-number.rst b/blurb/tests/fail/small-gh-number.rst new file mode 100644 index 0000000..9e702fb --- /dev/null +++ b/blurb/tests/fail/small-gh-number.rst @@ -0,0 +1,4 @@ +.. gh-issue: 100 +.. section: Library + +This is an invalid blurb. GitHub issues should be 32426 or above. \ No newline at end of file diff --git a/blurb/tests/pass/basic.rst b/blurb/tests/pass/basic.rst index 9667423..e6b0b75 100644 --- a/blurb/tests/pass/basic.rst +++ b/blurb/tests/pass/basic.rst @@ -1,5 +1,5 @@ .. date: 2017-05-02 -.. gh-issue: 0 +.. gh-issue: 40000 .. nonce: xyz .. section: Library diff --git a/blurb/tests/pass/basic.rst.res b/blurb/tests/pass/basic.rst.res index 9667423..e6b0b75 100644 --- a/blurb/tests/pass/basic.rst.res +++ b/blurb/tests/pass/basic.rst.res @@ -1,5 +1,5 @@ .. date: 2017-05-02 -.. gh-issue: 0 +.. gh-issue: 40000 .. nonce: xyz .. section: Library diff --git a/blurb/tests/pass/case-insensitive.rst b/blurb/tests/pass/case-insensitive.rst index 8148b68..ca1cbd5 100644 --- a/blurb/tests/pass/case-insensitive.rst +++ b/blurb/tests/pass/case-insensitive.rst @@ -1,5 +1,5 @@ .. date: 2017-05-02 -.. GH-Issue: 0 +.. GH-Issue: 35000 .. nonce: xyz .. section: Library diff --git a/blurb/tests/pass/case-insensitive.rst.res b/blurb/tests/pass/case-insensitive.rst.res index 9667423..4f1aad5 100644 --- a/blurb/tests/pass/case-insensitive.rst.res +++ b/blurb/tests/pass/case-insensitive.rst.res @@ -1,5 +1,5 @@ .. date: 2017-05-02 -.. gh-issue: 0 +.. gh-issue: 35000 .. nonce: xyz .. section: Library diff --git a/blurb/tests/pass/no-break-long-words.rst b/blurb/tests/pass/no-break-long-words.rst index 334f913..10f5d9e 100644 --- a/blurb/tests/pass/no-break-long-words.rst +++ b/blurb/tests/pass/no-break-long-words.rst @@ -1,5 +1,5 @@ .. date: 1234 -.. gh-issue: 0 +.. gh-issue: 35000 .. nonce: xyz .. section: Library diff --git a/blurb/tests/pass/no-break-long-words.rst.res b/blurb/tests/pass/no-break-long-words.rst.res index 334f913..10f5d9e 100644 --- a/blurb/tests/pass/no-break-long-words.rst.res +++ b/blurb/tests/pass/no-break-long-words.rst.res @@ -1,5 +1,5 @@ .. date: 1234 -.. gh-issue: 0 +.. gh-issue: 35000 .. nonce: xyz .. section: Library diff --git a/blurb/tests/pass/no-break-on-hyphens.rst b/blurb/tests/pass/no-break-on-hyphens.rst index 4b46c52..48bd427 100644 --- a/blurb/tests/pass/no-break-on-hyphens.rst +++ b/blurb/tests/pass/no-break-on-hyphens.rst @@ -1,5 +1,5 @@ .. date: 7333 -.. gh-issue: 21121 +.. gh-issue: 41121 .. nonce: ZLsRil .. section: Library diff --git a/blurb/tests/pass/no-break-on-hyphens.rst.res b/blurb/tests/pass/no-break-on-hyphens.rst.res index 0b6e892..cb76b62 100644 --- a/blurb/tests/pass/no-break-on-hyphens.rst.res +++ b/blurb/tests/pass/no-break-on-hyphens.rst.res @@ -1,5 +1,5 @@ .. date: 7333 -.. gh-issue: 21121 +.. gh-issue: 41121 .. nonce: ZLsRil .. section: Library From 9a323763a7ea7eec199d77f74d12560716009411 Mon Sep 17 00:00:00 2001 From: Menelaos Date: Wed, 20 Dec 2023 17:08:28 +0200 Subject: [PATCH 4/6] Add GH issue magic number in a variable --- blurb/blurb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blurb/blurb.py b/blurb/blurb.py index 3257a53..366827d 100755 --- a/blurb/blurb.py +++ b/blurb/blurb.py @@ -473,6 +473,8 @@ def finish_entry(): no_changes = metadata.get('no changes') + lowest_possible_gh_issue_number = 32426 + issue_keys = { 'gh-issue': 'GitHub', 'bpo': 'bpo', @@ -486,7 +488,7 @@ def finish_entry(): # we'll complain about the *first* error # we see in the blurb file, which is a # better user experience. - if key == "gh-issue" and int(value) < 32426: + if key == "gh-issue" and int(value) < lowest_possible_gh_issue_number: throw("The gh-issue number should be 32426 or above.") if key in issue_keys: @@ -959,7 +961,7 @@ def init_tmp_with_template(): failure = str(e) if not failure: - assert len(blurb) # if parse_blurb succeeds, we should always have a body + assert len(blurb) # if parse_blurb succeeds, we should always have a body if len(blurb) > 1: failure = "Too many entries! Don't specify '..' on a line by itself." From 5980c9ade496de9b3fa8172f49843f3de8d54be6 Mon Sep 17 00:00:00 2001 From: Menelaos Kotoglou Date: Wed, 20 Dec 2023 17:20:41 +0200 Subject: [PATCH 5/6] Update blurb error message Co-authored-by: Hugo van Kemenade --- blurb/blurb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blurb/blurb.py b/blurb/blurb.py index 366827d..1d82125 100755 --- a/blurb/blurb.py +++ b/blurb/blurb.py @@ -489,7 +489,7 @@ def finish_entry(): # we see in the blurb file, which is a # better user experience. if key == "gh-issue" and int(value) < lowest_possible_gh_issue_number: - throw("The gh-issue number should be 32426 or above.") + throw("The gh-issue number must be 32426 or above, not a PR number.") if key in issue_keys: try: From 0fcfb9982f4e835fafbcdc82b1870b722d07c28e Mon Sep 17 00:00:00 2001 From: Menelaos Kotoglou Date: Wed, 20 Dec 2023 17:31:41 +0200 Subject: [PATCH 6/6] Use magic number in exception Co-authored-by: Pradyun Gedam --- blurb/blurb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blurb/blurb.py b/blurb/blurb.py index 1d82125..14f2a7f 100755 --- a/blurb/blurb.py +++ b/blurb/blurb.py @@ -489,7 +489,7 @@ def finish_entry(): # we see in the blurb file, which is a # better user experience. if key == "gh-issue" and int(value) < lowest_possible_gh_issue_number: - throw("The gh-issue number must be 32426 or above, not a PR number.") + throw(f"The gh-issue number must be {lowest_possible_gh_issue_number} or above, not a PR number.") if key in issue_keys: try: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy