Skip to content

Commit f870625

Browse files
committed
general cleanup and linting fixes
Signed-off-by: Zack Koppert <[email protected]>
1 parent 5b59baf commit f870625

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ lint:
1111
# stop the build if there are Python syntax errors or undefined names
1212
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
1313
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
14-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
14+
flake8 . --count --exit-zero --max-complexity=15 --max-line-length=127 --statistics
1515
pylint --rcfile=.pylintrc --fail-under=9.0 *.py

issue_metrics.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
Searches for issues in a GitHub repository that match the given search query.
1414
auth_to_github() -> github3.GitHub: Connect to GitHub API with token authentication.
1515
get_per_issue_metrics(issues: Union[List[dict], List[github3.issues.Issue]],
16-
discussions: bool = False), labels: Union[List[str], None] = None, ignore_users: List[str] = [] -> tuple[List, int, int]:
16+
discussions: bool = False), labels: Union[List[str], None] = None,
17+
ignore_users: List[str] = [] -> tuple[List, int, int]:
1718
Calculate the metrics for each issue in a list of GitHub issues.
1819
get_owner(search_query: str) -> Union[str, None]]:
1920
Get the owner from the search query.
@@ -123,10 +124,12 @@ def auth_to_github() -> github3.GitHub:
123124
if token := os.getenv("GH_TOKEN"):
124125
if not os.getenv("GITHUB_SERVER_URL"):
125126
github_connection = github3.login(token=token)
126-
elif os.getenv("GITHUB_SERVER_URL") == 'https://github.com':
127+
elif os.getenv("GITHUB_SERVER_URL") == "https://github.com":
127128
github_connection = github3.login(token=token)
128129
else:
129-
github_connection = github3.GitHubEnterprise(os.getenv("GITHUB_SERVER_URL"),token=token)
130+
github_connection = github3.GitHubEnterprise(
131+
os.getenv("GITHUB_SERVER_URL"), token=token
132+
)
130133
else:
131134
raise ValueError("GH_TOKEN environment variable not set")
132135

@@ -137,7 +140,7 @@ def get_per_issue_metrics(
137140
issues: Union[List[dict], List[github3.search.IssueSearchResult]], # type: ignore
138141
discussions: bool = False,
139142
labels: Union[List[str], None] = None,
140-
ignore_users: List[str] = [],
143+
ignore_users: List[str] = None,
141144
) -> tuple[List, int, int]:
142145
"""
143146
Calculate the metrics for each issue/pr/discussion in a list provided.
@@ -159,6 +162,8 @@ def get_per_issue_metrics(
159162
issues_with_metrics = []
160163
num_issues_open = 0
161164
num_issues_closed = 0
165+
if ignore_users is None:
166+
ignore_users = []
162167

163168
for issue in issues:
164169
if discussions:
@@ -320,6 +325,7 @@ def main():
320325
average_time_in_labels,
321326
num_issues_open,
322327
num_issues_closed,
328+
search_query,
323329
)
324330
write_to_markdown(
325331
issues_with_metrics,
@@ -330,6 +336,7 @@ def main():
330336
num_issues_open,
331337
num_issues_closed,
332338
labels,
339+
search_query,
333340
)
334341

335342

labels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_label_events(
2929
return label_events
3030

3131

32-
def get_label_metrics(issue: github3.issues.Issue, labels: List[str]) -> dict: # type: ignore
32+
def get_label_metrics(issue: github3.issues.Issue, labels: List[str]) -> dict:
3333
"""
3434
Calculate the time spent with the given labels on a given issue.
3535

time_to_first_response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
def measure_time_to_first_response(
2828
issue: Union[github3.issues.Issue, None], # type: ignore
2929
discussion: Union[dict, None],
30-
ignore_users: List[str] = [],
30+
ignore_users: List[str] = None,
3131
) -> Union[timedelta, None]:
3232
"""Measure the time to first response for a single issue or a discussion.
3333
@@ -44,6 +44,8 @@ def measure_time_to_first_response(
4444
first_comment_time = None
4545
earliest_response = None
4646
issue_time = None
47+
if ignore_users is None:
48+
ignore_users = []
4749

4850
# Get the first comment time
4951
if issue:

0 commit comments

Comments
 (0)