Repository: python/bedevere
Pull request #595 (2023-10-12 15:09:44)

Revert "Add logging to debug bedevere label staging (#594)"
This reverts commit 72090a4a0e960f307b37e6064bf7b71e36fa1414.


Patch:
diff --git a/bedevere/__main__.py b/bedevere/__main__.py
index 10a866a..55c7208 100644
--- a/bedevere/__main__.py
+++ b/bedevere/__main__.py
@@ -15,8 +15,6 @@ from gidgethub import apps
 from . import backport, gh_issue, close_pr, filepaths, news, stage
 
 import sentry_sdk
-import logging
-
 
 router = routing.Router(backport.router, gh_issue.router, close_pr.router,
                         filepaths.router, news.router,
@@ -26,7 +24,6 @@ cache = cachetools.LRUCache(maxsize=500)
 sentry_sdk.init(os.environ.get("SENTRY_DSN"))
 
 async def main(request):
-    logging.basicConfig(level=logging.DEBUG)
     try:
         body = await request.read()
         secret = os.environ.get("GH_SECRET")
diff --git a/bedevere/stage.py b/bedevere/stage.py
index 181bbb0..bf366ba 100644
--- a/bedevere/stage.py
+++ b/bedevere/stage.py
@@ -9,7 +9,6 @@
 
 import enum
 import random
-import logging
 
 import gidgethub.routing
 
@@ -94,7 +93,6 @@ async def _remove_stage_labels(gh, issue):
 
 async def stage(gh, issue, blocked_on):
     """Remove any "awaiting" labels and apply the specified one."""
-    logging.info("Staging: issue %s, Issue labels: %s, blocked on: %s", issue["number"], issue["labels"], blocked_on.value)
     label_name = blocked_on.value
     if any(label_name == label["name"] for label in issue["labels"]):
         return
@@ -190,7 +188,6 @@ async def new_review(event, gh, *args, **kwargs):
     review = event.data["review"]
     reviewer = util.user_login(review)
     state = review["state"].lower()
-    logging.info("PR# %s Review submitted by %s", pull_request["number"], reviewer, )
     if state == "commented":
         # Don't care about comment reviews.
         return
@@ -202,13 +199,11 @@ async def new_review(event, gh, *args, **kwargs):
             return
         else:
             # Waiting for a core developer to leave a review.
-            logging.info("PR# %s, Review by non core developer, adding awaiting core review %s", pull_request["number"], reviewer )
             await stage(
                 gh, await util.issue_for_PR(gh, pull_request), Blocker.core_review
             )
     else:
         if state == "approved":
-            logging.info("PR# %s approved by core dev: %s", pull_request["number"], reviewer)
             if pull_request["state"] == "open":
                 await stage(
                     gh, await util.issue_for_PR(gh, pull_request), Blocker.merge


Test patch:
diff --git a/tests/test_stage.py b/tests/test_stage.py
index 9e32ab3..9d2b483 100644
--- a/tests/test_stage.py
+++ b/tests/test_stage.py
@@ -50,7 +50,7 @@ class FakeGH:
 
 async def test_stage():
     # Skip changing labels if the label is already set.
-    issue = {"number": 123, "labels": [{"name": "awaiting merge"}, {"name": "skip issue"}]}
+    issue = {"labels": [{"name": "awaiting merge"}, {"name": "skip issue"}]}
     issue_url = "https://api.github.com/some/issue"
     gh = FakeGH()
     await awaiting.stage(gh, issue, awaiting.Blocker.merge)
@@ -59,7 +59,6 @@ async def test_stage():
 
     # Test deleting an old label and adding a new one.
     issue = {
-        "number": 123,
         "labels": [{"name": "awaiting review"}, {"name": "skip issue"}],
         "labels_url": "https://api.github.com/repos/python/cpython/issues/42/labels{/name}",
     }
@@ -82,7 +81,6 @@ async def test_opened_draft_pr():
     data = {
         "action": "opened",
         "pull_request": {
-            "number": 123,
             "user": {
                 "login": username,
             },
@@ -94,7 +92,7 @@ async def test_opened_draft_pr():
     teams = [{"name": "python core", "id": 6}]
     items = {
         f"https://api.github.com/teams/6/memberships/{username}": "OK",
-        issue_url: {"number": 123, "labels": [], "labels_url": "https://api.github.com/labels"},
+        issue_url: {"labels": [], "labels_url": "https://api.github.com/labels"},
     }
     gh = FakeGH(
         getiter={"https://api.github.com/orgs/python/teams": teams}, getitem=items
@@ -120,7 +118,6 @@ async def test_opened_draft_pr():
     data["pull_request"]["draft"] = True
     encoded_label = "awaiting%20core%20review"
     items[issue_url] = {
-        "number": 123,
         "labels": [
             {
                 "url": f"https://api.github.com/repos/python/cpython/labels/{encoded_label}",
@@ -200,7 +197,6 @@ async def test_opened_pr():
     data = {
         "action": "opened",
         "pull_request": {
-            "number": 123,
             "user": {
                 "login": username,
             },
@@ -211,7 +207,7 @@ async def test_opened_pr():
     teams = [{"name": "python core", "id": 6}]
     items = {
         f"https://api.github.com/teams/6/memberships/{username}": "OK",
-        issue_url: {"number": 123, "labels": [], "labels_url": "https://api.github.com/labels"},
+        issue_url: {"labels": [], "labels_url": "https://api.github.com/labels"},
     }
     gh = FakeGH(
         getiter={"https://api.github.com/orgs/python/teams": teams}, getitem=items
@@ -228,7 +224,6 @@ async def test_opened_pr():
     data = {
         "action": "opened",
         "pull_request": {
-            "number": 123,
             "user": {
                 "login": username,
             },
@@ -242,7 +237,7 @@ async def test_opened_pr():
         f"https://api.github.com/teams/6/memberships/{username}": gidgethub.BadRequest(
             status_code=http.HTTPStatus(404)
         ),
-        issue_url: {"number": 123, "labels": [], "labels_url": "https://api.github.com/labels"},
+        issue_url: {"labels": [], "labels_url": "https://api.github.com/labels"},
     }
     gh = FakeGH(
         getiter={"https://api.github.com/orgs/python/teams": teams}, getitem=items
@@ -266,7 +261,6 @@ async def test_new_review():
             },
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
             "state": "open",
@@ -280,7 +274,6 @@ async def test_new_review():
         ),
         "https://api.github.com/teams/6/memberships/brettcannon": True,
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -305,7 +298,6 @@ async def test_new_review():
         ),
         "https://api.github.com/teams/6/memberships/brettcannon": True,
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -330,7 +322,6 @@ async def test_new_review():
             },
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
             "state": "open",
@@ -343,7 +334,6 @@ async def test_new_review():
         ),
         "https://api.github.com/teams/6/memberships/brettcannon": True,
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -369,7 +359,6 @@ async def test_new_review():
             "state": "APPROVED",
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
             "state": "open",
@@ -380,7 +369,6 @@ async def test_new_review():
     items = {
         f"https://api.github.com/teams/6/memberships/{username}": True,
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [{"name": awaiting.Blocker.changes.value}],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -407,7 +395,6 @@ async def test_new_review():
             "state": "APPROVED",
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
             "state": "closed",
@@ -418,7 +405,6 @@ async def test_new_review():
     items = {
         f"https://api.github.com/teams/6/memberships/{username}": True,
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [{"name": awaiting.Blocker.changes.value}],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -441,7 +427,6 @@ async def test_new_review():
             "state": "changes_requested".upper(),
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
             "comments_url": "https://api.github.com/comment/42",
@@ -456,7 +441,6 @@ async def test_new_review():
             status_code=http.HTTPStatus(404)
         ),
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -481,7 +465,6 @@ async def test_new_review():
             "state": "commented".upper(),
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
             "comments_url": "https://api.github.com/comment/42",
@@ -503,7 +486,6 @@ async def test_new_review():
             "state": "changes_requested".upper(),
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
             "comments_url": "https://api.github.com/comment/42",
@@ -514,7 +496,6 @@ async def test_new_review():
     items = {
         f"https://api.github.com/teams/6/memberships/{username}": True,
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [{"name": awaiting.Blocker.changes.value}],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -535,7 +516,6 @@ async def test_dismissed_review():
             },
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
         },
@@ -548,7 +528,6 @@ async def test_dismissed_review():
         ),
         "https://api.github.com/teams/6/memberships/brettcannon": True,
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [{"name": awaiting.Blocker.core_review.value}],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -576,7 +555,6 @@ async def test_dismissed_review():
             },
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
         },
@@ -589,7 +567,6 @@ async def test_dismissed_review():
         ),
         "https://api.github.com/teams/6/memberships/brettcannon": True,
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [{"name": awaiting.Blocker.merge.value}],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -614,7 +591,6 @@ async def test_dismissed_review():
             },
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
         },
@@ -629,7 +605,6 @@ async def test_dismissed_review():
             status_code=http.HTTPStatus(404)
         ),
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [{"name": awaiting.Blocker.core_review.value}],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -654,7 +629,6 @@ async def test_dismissed_review():
             },
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
         },
@@ -667,7 +641,6 @@ async def test_dismissed_review():
             status_code=http.HTTPStatus(404)
         ),
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [{"name": awaiting.Blocker.merge.value}],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -695,7 +668,6 @@ async def test_dismissed_review():
             },
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
         },
@@ -708,7 +680,6 @@ async def test_dismissed_review():
             status_code=http.HTTPStatus(404)
         ),
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [{"name": awaiting.Blocker.merge.value}],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -736,7 +707,6 @@ async def test_dismissed_review():
             },
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
         },
@@ -747,7 +717,6 @@ async def test_dismissed_review():
         f"https://api.github.com/teams/6/memberships/{username}": True,
         f"https://api.github.com/teams/6/memberships/brettcannonalias": True,
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [{"name": awaiting.Blocker.merge.value}],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -773,7 +742,6 @@ async def test_non_core_dev_does_not_downgrade():
         ),
         f"https://api.github.com/teams/6/memberships/{core_dev}": True,
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -789,7 +757,6 @@ async def test_non_core_dev_does_not_downgrade():
             },
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
             "state": "open",
@@ -819,7 +786,6 @@ async def test_non_core_dev_does_not_downgrade():
             },
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
             "state": "open",
@@ -871,7 +837,6 @@ async def test_new_comment():
     data = {
         "action": "created",
         "issue": {
-            "number": 42,
             "user": {"login": "andreamcinnes"},
             "labels": [],
             "labels_url": "https://api.github.com/labels/42",
@@ -921,7 +886,6 @@ async def test_new_comment():
     data = {
         "action": "created",
         "issue": {
-            "number": 42,
             "user": {"login": "andreamcinnes"},
             "labels": [],
             "labels_url": "https://api.github.com/labels/42",
@@ -963,7 +927,6 @@ async def test_change_requested_for_core_dev():
             "state": "changes_requested".upper(),
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
             "comments_url": "https://api.github.com/comment/42",
@@ -976,7 +939,6 @@ async def test_change_requested_for_core_dev():
         f"https://api.github.com/teams/6/memberships/gvanrossum": True,
         "https://api.github.com/teams/6/memberships/brettcannon": True,
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -1013,7 +975,6 @@ async def test_change_requested_for_non_core_dev():
             "state": "changes_requested".upper(),
         },
         "pull_request": {
-            "number": 42,
             "url": "https://api.github.com/pr/42",
             "issue_url": "https://api.github.com/issue/42",
             "comments_url": "https://api.github.com/comment/42",
@@ -1028,7 +989,6 @@ async def test_change_requested_for_non_core_dev():
             status_code=http.HTTPStatus(404)
         ),
         "https://api.github.com/issue/42": {
-            "number": 42,
             "labels": [],
             "labels_url": "https://api.github.com/labels/42",
         },
@@ -1173,7 +1133,6 @@ async def test_new_commit_pushed_to_approved_pr(issue_url_key, repo_full_name):
             ],
         },
         "https://api.github.com/repos/python/cpython/issues/5547": {
-            "number": 42,
             "labels": [{"name": "awaiting merge"}],
             "labels_url": "https://api.github.com/repos/python/cpython/issues/5547/labels{/name}",
             "pull_request": {