Skip to content

Commit 21a89ca

Browse files
committed
revert bandit.yaml, move script to tools
1 parent c995408 commit 21a89ca

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

.github/workflows/bandit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Run Bandit Security Analysis
2121
run: |
2222
python -m pip install bandit
23-
python -m bandit -r . -x ./scripts -lll
23+
python -m bandit -r . -x ./third_party -lll

scripts/retrieve_prs.py renamed to tools/retrieve_prs.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
"""
2+
Usage: python scripts/release_notes/retrieve_prs.py tags/v0.10.0 \
3+
18685a517ae68353b05b9a0ede5343df31525c76 --file data.json
4+
"""
5+
import argparse
16
import json
27
import re
3-
import sys
4-
import argparse
58
import subprocess
69
from collections import namedtuple
710
from os.path import expanduser
11+
from pathlib import Path
812

913
import requests
1014

15+
ROOT_DIR = Path(__file__).parent.resolve()
16+
1117
Features = namedtuple(
1218
"Features",
1319
[
@@ -57,11 +63,12 @@ def get_ghstack_token():
5763

5864

5965
def run_query(query):
60-
request = requests.post("https://github.com/api/graphql", json={"query": query}, headers=headers)
61-
if request.status_code == 200:
62-
return request.json()
63-
else:
64-
raise Exception("Query failed to run by returning code of {}. {}".format(request.status_code, query))
66+
response = requests.post("https://github.com/api/graphql", json={"query": query}, headers=headers)
67+
try:
68+
response.raise_for_status()
69+
return response.json()
70+
except requests.exceptions.HTTPError as e:
71+
print(e)
6572

6673

6774
def gh_labels(pr_number):
@@ -109,7 +116,10 @@ def get_commits_between(base_version, new_version):
109116

110117

111118
def _parse_args(args):
112-
parser = argparse.ArgumentParser()
119+
parser = argparse.ArgumentParser(
120+
description=__doc__,
121+
formatter_class=argparse.RawTextHelpFormatter,
122+
)
113123
parser.add_argument("base_version", type=str, help="starting tag or commit (exclusive)")
114124
parser.add_argument("new_version", type=str, help="final tag or commit (inclusive)")
115125
parser.add_argument("--file", type=str, default="data.json", help="output json file")
@@ -131,6 +141,4 @@ def _main(args):
131141

132142

133143
if __name__ == "__main__":
134-
# Usage: python scripts/release_notes/retrieve_prs.py tags/v0.10.0 \
135-
# 18685a517ae68353b05b9a0ede5343df31525c76 --file data.json
136-
_main(_parse_args(sys.argv[1:]))
144+
_main(_parse_args())

0 commit comments

Comments
 (0)