diff --git a/.github/actions/ensure_backporting/add_labels.py b/.github/actions/ensure_backporting/add_labels.py index 8d1145a..e241e58 100644 --- a/.github/actions/ensure_backporting/add_labels.py +++ b/.github/actions/ensure_backporting/add_labels.py @@ -13,12 +13,8 @@ class RequestError(Exception): def main(): - parser = argparse.ArgumentParser( - description="Ensure an issue contains the backport labels." - ) - parser.add_argument( - "--issue-id", type=int, required=True, help="The pull request number." - ) + parser = argparse.ArgumentParser(description="Ensure an issue contains the backport labels.") + parser.add_argument("--issue-id", type=int, required=True, help="The pull request number.") parser.add_argument( "--repository", type=str, @@ -29,7 +25,7 @@ def main(): # Get list of labels attached to the pull requests headers = { "Accept": "application/vnd.github+json", - "Authorization": "Bearer {0}".format(os.environ.get("GITHUB_TOKEN")), + "Authorization": "Bearer {}".format(os.environ.get("GITHUB_TOKEN")), "X-GitHub-Api-Version": "2022-11-28", } @@ -40,7 +36,9 @@ def main(): ) if not response.ok: raise RequestError(response.reason) - issue_backport_labels = [i['name'] for i in response.json() if re.match("^backport-[0-9]*$", i["name"])] + issue_backport_labels = [ + i["name"] for i in response.json() if re.match("^backport-[0-9]*$", i["name"]) + ] # Get Repository Labels response = requests.get( @@ -49,10 +47,14 @@ def main(): ) if not response.ok: raise RequestError(response.reason) - repository_backport_labels = [i['name'] for i in response.json() if re.match("^backport-[0-9]*$", i["name"])] + repository_backport_labels = [ + i["name"] for i in response.json() if re.match("^backport-[0-9]*$", i["name"]) + ] labels_to_add = list(set(repository_backport_labels) - set(issue_backport_labels)) - print(f"issue_backport_labels = {issue_backport_labels} - repository_backport_labels = {repository_backport_labels} - labels_to_add = {labels_to_add}") + print( + f"issue_backport_labels = {issue_backport_labels} - repository_backport_labels = {repository_backport_labels} - labels_to_add = {labels_to_add}" + ) if labels_to_add: data = {"labels": labels_to_add} response = requests.post( @@ -65,4 +67,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main()