2323
2424from __future__ import annotations
2525
26- import collections
27- import datetime
2826import logging
2927import os
28+ import time
29+
3030from scripts import install_third_party_libs
3131
3232import requests
33- from typing import Dict , List , Optional , Set , TypedDict , Any
34- import time
33+ from typing import Any , Dict , List , Optional
3534
3635# Global configuration.
3736GITHUB_TOKEN = os .getenv ('GITHUB_TOKEN' )
@@ -75,9 +74,7 @@ def list_open_prs(self) -> List[Dict[str, Any]]:
7574 prs : List [Dict [str , Any ]] = []
7675 page = 1
7776 while True :
78- url = (
79- f'{ self .base_url } /pulls?state=open&page={ page } &per_page=100'
80- )
77+ url = f'{ self .base_url } /pulls?state=open&page={ page } &per_page=100'
8178 response = requests .get (url , headers = self .rest_headers , timeout = TIMEOUT )
8279 response .raise_for_status ()
8380 current_prs = response .json ()
@@ -94,8 +91,7 @@ def fetch_pr_details(self, pr_number: int) -> Optional[Dict[str, Any]]:
9491 pr_number: The number of the pull request.
9592
9693 Returns:
97- A dictionary with PR details if the mergeable state is determined;
98- otherwise, None.
94+ A dictionary with PR details if the mergeable state is determined; otherwise, None.
9995 """
10096 pr_details_url = f'{ self .base_url } /pulls/{ pr_number } '
10197 for attempt in range (RETRY_COUNT ):
@@ -128,7 +124,9 @@ def assign_pr_author(self, pr_number: int, pr_author: str) -> bool:
128124 """
129125 assign_url = f'{ self .base_url } /issues/{ pr_number } '
130126 assign_payload = {'assignees' : [pr_author ]}
131- response = requests .patch (assign_url , json = assign_payload , headers = self .rest_headers , timeout = TIMEOUT )
127+ response = requests .patch (
128+ assign_url , json = assign_payload , headers = self .rest_headers , timeout = TIMEOUT
129+ )
132130 if response .ok :
133131 return True
134132 logging .error (
@@ -157,7 +155,9 @@ def notify_pr_author(self, pr_number: int, pr_author: str) -> bool:
157155 'if you need help resolving the conflict so that the PR can be merged. Thanks!'
158156 )
159157 comment_payload = {'body' : message }
160- response = requests .post (comment_url , json = comment_payload , headers = self .rest_headers , timeout = TIMEOUT )
158+ response = requests .post (
159+ comment_url , json = comment_payload , headers = self .rest_headers , timeout = TIMEOUT
160+ )
161161 if response .ok :
162162 return True
163163 logging .error (
@@ -225,9 +225,7 @@ def main() -> None:
225225 logging .error ('Error encountered: %s' , e )
226226
227227
228- if __name__ == '__main__' : # pragma: no cover
229- # This installs third party libraries (requests) before
230- # importing other files or importing libraries that use
231- # the builtins python module (e.g. build, utils).
228+ if __name__ == '__main__' : # pragma: no cover
229+ # Ensure third-party libraries are installed before executing the main logic.
232230 install_third_party_libs .main ()
233231 main ()
0 commit comments