8000 Check gh-issue- is int before checking range for better error · python/blurb@8e590fc · GitHub
[go: up one dir, main page]

Skip to content

Commit 8e590fc

Browse files
committed
Check gh-issue- is int before checking range for better error
Invalid GitHub issue number! ('one-two') instead of: ValueError: invalid literal for int() with base 10: 'one-two'
1 parent 4cb4857 commit 8e590fc

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/blurb/blurb.py

Lines changed: 3 additions & 3 deletions
< 8000 th scope="col">Diff line change
Original file line numberDiff line number
@@ -482,15 +482,15 @@ def finish_entry():
482482
# we'll complain about the *first* error
483483
# we see in the blurb file, which is a
484484
# better user experience.
485-
if key == "gh-issue" and int(value) < lowest_possible_gh_issue_number:
486-
throw(f"The gh-issue number must be {lowest_possible_gh_issue_number} or above, not a PR number.")
487-
488485
if key in issue_keys:
489486
try:
490487
int(value)
491488
except (TypeError, ValueError):
492489
throw(f"Invalid {issue_keys[key]} issue number! ({value!r})")
493490

491+
if key == "gh-issue" and int(value) < lowest_possible_gh_issue_number:
492+
throw(f"The gh-issue number must be {lowest_possible_gh_issue_number} or above, not a PR number.")
493+
494494
if key == "section":
495495
if no_changes:
496496
continue

tests/test_blurb.py

Lines changed: 4 additi 7B9F ons & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ def test_parse():
224224
"..bpo: one-two\n..section: IDLE\nHello world!",
225225
r"Invalid bpo issue number! \('one-two'\)",
226226
),
227+
(
228+
"..gh-issue: one-two\n..section: IDLE\nHello world!",
229+
r"Invalid GitHub issue number! \('one-two'\)",
230+
),
227231
(
228232
"..gh-issue: 123456\n..section: Funky Kong\nHello world!",
229233
r"Invalid section 'Funky Kong'! You must use one of the predefined sections",

0 commit comments

Comments
 (0)
0