Skip to content

Commit 87a01bc

Browse files
Typing and black issues
1 parent 138366b commit 87a01bc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

docassemble/GithubFeedbackForm/github_issue.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,12 @@ def make_github_issue(
370370
title: the title for the GitHub issue
371371
body: the body of the GitHub issue
372372
label: optional label to add *if* we can verify or create it
373-
373+
374374
Returns:
375375
str, the URL for the label if it exists, or None if the issue could not be created
376376
"""
377377
make_issue_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/issues"
378378

379-
380379
# Abort early if the configuration or repo owner is invalid
381380
if not valid_github_issue_config():
382381
log(
@@ -414,7 +413,9 @@ def make_github_issue(
414413
apply_label = False # only set to True when we're sure it exists
415414

416415
if label:
417-
labels_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/labels/{label}"
416+
labels_url = (
417+
f"https://api.github.com/repos/{repo_owner}/{repo_name}/labels/{label}"
418+
)
418419
has_label_resp = requests.get(labels_url, headers=headers)
419420

420421
if has_label_resp.status_code == 200:
@@ -454,10 +455,16 @@ def make_github_issue(
454455
# ------------------------------------------------------------------
455456
# 2. Derive title/body from a template, if supplied
456457
# ------------------------------------------------------------------
457-
if template:
458+
if template and not (title and body):
458459
title = template.subject
459460
body = template.content
460461

462+
if not body:
463+
return None
464+
465+
if not title:
466+
title = "User feedback"
467+
461468
# Reject obvious spam before calling GitHub
462469
if is_likely_spam(body):
463470
log("Error creating issue: the body of the issue was classified as spam")
@@ -470,7 +477,7 @@ def make_github_issue(
470477
"title": title,
471478
"body": body,
472479
}
473-
if apply_label: # only include when we *know* the label exists
480+
if apply_label and label is not None:
474481
data["labels"] = [label]
475482

476483
response = requests.post(make_issue_url, data=json.dumps(data), headers=headers)

0 commit comments

Comments
 (0)