From d8cc600aa0cd9996a2b42df1c799bd22806f4d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Wed, 4 Oct 2023 14:29:19 -0400 Subject: [PATCH] Correctly handle message when there is *not* a milestone to remove --- move_issue.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/move_issue.py b/move_issue.py index 8c585e2..6cc1eb3 100644 --- a/move_issue.py +++ b/move_issue.py @@ -22,9 +22,10 @@ def move_issue(source_owner, source_repo, issue_number, destination_owner, desti if message: print(message) - if json_response and 'milestone' in json_response: - print(f"We have removed the milestone {json_response['milestone']['title']} from this issue (milestones are specific to repositories).") - del json_response['milestone'] + milestone = json_response.pop('milestone', {}) + if milestone: + print(f"We have removed the milestone {milestone['title']} from this issue (milestones are specific to repositories).") + # Note that pop has already thrown out the milestone from json_response print(f"Creating issue {json_response['title']} now…")