Fix delete comments (#657)

Signed-off-by: Glenn Jocher <[email protected]>
Co-authored-by: UltralyticsAssistant <[email protected]>
This commit is contained in:
Glenn Jocher
2025-11-16 15:00:02 +01:00
committed by GitHub
co-authored by UltralyticsAssistant
parent 65e6445fbe
commit 650540c276
2 changed files with 6 additions and 5 deletions
+3 -3
View File
@@ -371,13 +371,13 @@ def dismiss_previous_reviews(event: Action) -> int:
event.put(f"{reviews_base}/{review_id}/dismissals", json={"message": "Superseded by new review"})
# Delete previous inline comments
comments_base = f"{GITHUB_API_URL}/repos/{event.repository}/pulls/{pr_number}/comments"
comments_url = f"{comments_base}?per_page=100"
comments_url = f"{GITHUB_API_URL}/repos/{event.repository}/pulls/{pr_number}/comments?per_page=100"
delete_base = f"{GITHUB_API_URL}/repos/{event.repository}/pulls/comments"
if (response := event.get(comments_url)).status_code == 200:
for comment in response.json():
if comment.get("user", {}).get("login") == bot_username and (comment_id := comment.get("id")):
event.delete(
f"{comments_base}/{comment_id}",
f"{delete_base}/{comment_id}",
expected_status=[200, 204, 404],
)
+3 -2
View File
@@ -133,7 +133,8 @@ class Action:
"""Unified request handler with error checking."""
r = getattr(requests, method)(url, headers=headers or self.headers, **kwargs)
expected = expected_status or self._default_status[method]
success = r.status_code in expected
status_expected = r.status_code in expected
success = status_expected and r.status_code < 400
if self.verbose:
elapsed = r.elapsed.total_seconds()
@@ -147,7 +148,7 @@ class Action:
except Exception:
print(f" ❌ Error: {r.text[:1000]}")
if not success and hard:
if not status_expected and hard:
r.raise_for_status()
return r