Cleanup: reduce right-shift in Python scripts

Also place the return type on it's own line as it's easier to identify
when it's in a predictable location instead of the line ending.
This commit is contained in:
Campbell Barton
2024-02-28 11:02:54 +11:00
parent 44e64b8f29
commit 2e6739967e
3 changed files with 90 additions and 58 deletions

View File

@@ -15,7 +15,11 @@ Example usage:
import argparse
import datetime
from gitea_utils import gitea_json_issues_search, gitea_json_issue_events_filter, git_username_detect
from gitea_utils import (
git_username_detect,
gitea_json_issue_events_filter,
gitea_json_issues_search,
)
def print_needing_info_urls(username: str, before: str) -> None:
@@ -23,11 +27,13 @@ def print_needing_info_urls(username: str, before: str) -> None:
print(f"Needs information from user before {before}:")
label = "Status/Needs Information from User"
issues_json = gitea_json_issues_search(type="issues",
state="open",
before=before,
labels=label,
verbose=True)
issues_json = gitea_json_issues_search(
type="issues",
state="open",
before=before,
labels=label,
verbose=True,
)
for issue in issues_json:
fullname = issue["repository"]["full_name"]

View File

@@ -40,7 +40,8 @@ from typing import (
def argparse_create() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
description="Generate Weekly Report",
epilog="This script is typically used to help write weekly reports")
epilog="This script is typically used to help write weekly reports",
)
parser.add_argument(
"--username",
@@ -48,21 +49,26 @@ def argparse_create() -> argparse.ArgumentParser:
metavar='USERNAME',
type=str,
required=False,
help="")
help="",
)
parser.add_argument(
"--weeks-ago",
dest="weeks_ago",
type=int,
default=1,
help="Determine which week the report should be generated for. 0 means the current week. "
"The default is 1, to create a report for the previous week.")
help=(
"Determine which week the report should be generated for. 0 means the current week. "
"The default is 1, to create a report for the previous week."
),
)
parser.add_argument(
"-v",
"--verbose",
action="store_true",
help="increase output verbosity")
help="increase output verbosity",
)
return parser
@@ -160,14 +166,17 @@ def report_personal_weekly_get(username: str, start: datetime.datetime, verbose:
print(f"[{int(100 * (process / len_total))}%] Checking issue {issue} ", end="\r", flush=True)
process += 1
issue_events = gitea_json_issue_events_filter(issue,
date_start=start,
date_end=date_end,
username=username,
labels={
"Status/Confirmed",
"Status/Needs Information from User",
"Status/Needs Info from Developers"})
issue_events = gitea_json_issue_events_filter(
issue,
date_start=start,
date_end=date_end,
username=username,
labels={
"Status/Confirmed",
"Status/Needs Information from User",
"Status/Needs Info from Developers"
}
)
for event in issue_events:
label_name = event["label"]["name"]
@@ -182,12 +191,14 @@ def report_personal_weekly_get(username: str, start: datetime.datetime, verbose:
print(f"[{int(100 * (process / len_total))}%] Checking issue {issue} ", end="\r", flush=True)
process += 1
issue_events = gitea_json_issue_events_filter(issue,
date_start=start,
date_end=date_end,
username=username,
event_type={"close", "commit_ref"},
labels={"Status/Duplicate"})
issue_events = gitea_json_issue_events_filter(
issue,
date_start=start,
date_end=date_end,
username=username,
event_type={"close", "commit_ref"},
labels={"Status/Duplicate"},
)
for event in issue_events:
event_type = event["type"]
@@ -202,11 +213,13 @@ def report_personal_weekly_get(username: str, start: datetime.datetime, verbose:
print(f"[{int(100 * (process / len_total))}%] Checking pull {pull} ", end="\r", flush=True)
process += 1
pull_events = gitea_json_issue_events_filter(pull.replace("pulls", "issues"),
date_start=start,
date_end=date_end,
username=username,
event_type={"comment"})
pull_events = gitea_json_issue_events_filter(
pull.replace("pulls", "issues"),
date_start=start,
date_end=date_end,
username=username,
event_type={"comment"},
)
if pull_events:
pull_data = gitea_json_issue_get_cached(pull)