Skip to content

Commit 3d1b42e

Browse files
committed
revert bandit.yaml, move script to tools
1 parent 9bc1d95 commit 3d1b42e

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
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: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +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
2-
import locale
3-
import os
47
import re
5-
import sys
6-
import argparse
78
import subprocess
89
from collections import namedtuple
910
from os.path import expanduser
11+
from pathlib import Path
1012

1113
import requests
1214

15+
ROOT_DIR = Path(__file__).parent.resolve()
16+
1317
Features = namedtuple(
1418
"Features",
1519
[
@@ -59,11 +63,12 @@ def get_ghstack_token():
5963

6064

6165
def run_query(query):
62-
request = requests.post("https://api.github.com/graphql", json={"query": query}, headers=headers)
63-
if request.status_code == 200:
64-
return request.json()
65-
else:
66-
raise Exception("Query failed to run by returning code of {}. {}".format(request.status_code, query))
66+
response = requests.post("https://api.github.com/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)
6772

6873

6974
def gh_labels(pr_number):
@@ -111,7 +116,10 @@ def get_commits_between(base_version, new_version):
111116

112117

113118
def _parse_args(args):
114-
parser = argparse.ArgumentParser()
119+
parser = argparse.ArgumentParser(
120+
description=__doc__,
121+
formatter_class=argparse.RawTextHelpFormatter,
122+
)
115123
parser.add_argument("base_version", type=str, help="starting tag or commit (exclusive)")
116124
parser.add_argument("new_version", type=str, help="final tag or commit (inclusive)")
117125
parser.add_argument("--file", type=str, default="data.json", help="output json file")
@@ -127,12 +135,10 @@ def _main(args):
127135
if idx % 10 == 0:
128136
print(f"{idx} / {len(hashes)}")
129137

130-
data = {commit: features._asdict() for commit, features in data.items()}
138+
data = {commit: features._asdict() for commit, features in data.items()}
131139
with open(args.file, "w") as f:
132140
json.dump(data, f)
133141

134142

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

0 commit comments

Comments
 (0)