Skip to content

Commit 97cca51

Browse files
chore: auto fixes from pre-commit.com hooks
1 parent 3222c3c commit 97cca51

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

‎main.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ def get_pr_title() -> str | None:
6868
event = json.load(f)
6969
return event.get("pull_request", {}).get("title")
7070
except Exception as e:
71-
print(
72-
f"::warning::Failed to read PR title from event: {e}", file=sys.stderr
73-
)
71+
print(f"::warning::Failed to read PR title from event: {e}", file=sys.stderr)
7472
return None
7573

7674

‎main_test.py‎

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,14 @@ def test_pr_event_returns_title(self):
7878
event = {
7979
"pull_request": {"title": "feat: add login page"},
8080
}
81-
with tempfile.NamedTemporaryFile(
82-
mode="w", suffix=".json", delete=False
83-
) as f:
81+
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as f:
8482
json.dump(event, f)
8583
event_path = f.name
8684
with (
87-
patch.dict(os.environ, {"GITHUB_EVENT_NAME": "pull_request", "GITHUB_EVENT_PATH": event_path}),
85+
patch.dict(
86+
os.environ,
87+
{"GITHUB_EVENT_NAME": "pull_request", "GITHUB_EVENT_PATH": event_path},
88+
),
8889
):
8990
self.assertEqual(main.get_pr_title(), "feat: add login page")
9091
os.unlink(event_path)
@@ -95,13 +96,17 @@ def test_pull_request_target_event(self):
9596
event = {
9697
"pull_request": {"title": "fix: resolve timeout"},
9798
}
98-
with tempfile.NamedTemporaryFile(
99-
mode="w", suffix=".json", delete=False
100-
) as f:
99+
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as f:
101100
json.dump(event, f)
102101
event_path = f.name
103102
with (
104-
patch.dict(os.environ, {"GITHUB_EVENT_NAME": "pull_request_target", "GITHUB_EVENT_PATH": event_path}),
103+
patch.dict(
104+
os.environ,
105+
{
106+
"GITHUB_EVENT_NAME": "pull_request_target",
107+
"GITHUB_EVENT_PATH": event_path,
108+
},
109+
),
105110
):
106111
self.assertEqual(main.get_pr_title(), "fix: resolve timeout")
107112
os.unlink(event_path)
@@ -118,13 +123,14 @@ def test_missing_event_path_returns_none(self):
118123
def test_invalid_json_returns_none(self):
119124
import tempfile
120125

121-
with tempfile.NamedTemporaryFile(
122-
mode="w", suffix=".json", delete=False
123-
) as f:
126+
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as f:
124127
f.write("not valid json")
125128
event_path = f.name
126129
with (
127-
patch.dict(os.environ, {"GITHUB_EVENT_NAME": "pull_request", "GITHUB_EVENT_PATH": event_path}),
130+
patch.dict(
131+
os.environ,
132+
{"GITHUB_EVENT_NAME": "pull_request", "GITHUB_EVENT_PATH": event_path},
133+
),
128134
patch("builtins.print"),
129135
):
130136
self.assertIsNone(main.get_pr_title())
@@ -427,7 +433,8 @@ def test_pr_title_check_runs_when_enabled(self):
427433
rc = main.run_commit_check()
428434
self.assertEqual(rc, 0)
429435
self.assertEqual(
430-
mock_cmd.call_args[0][0], ["--message"],
436+
mock_cmd.call_args[0][0],
437+
["--message"],
431438
)
432439
self.assertEqual(mock_cmd.call_args[1]["input_text"], "feat: a feature")
433440

@@ -471,7 +478,10 @@ def test_pr_title_and_message_both_run(self):
471478
patch("main.AUTHOR_EMAIL_ENABLED", False),
472479
patch("main.is_pr_event", return_value=True),
473480
patch("main.get_pr_title", return_value="feat: nice pr"),
474-
patch("main.get_pr_commit_messages", return_value=["fix: first", "feat: second"]),
481+
patch(
482+
"main.get_pr_commit_messages",
483+
return_value=["fix: first", "feat: second"],
484+
),
475485
patch("main.run_check_command", return_value=0) as mock_cmd,
476486
patch("main.run_pr_message_checks", return_value=0) as mock_pr,
477487
patch("main.run_other_checks", return_value=0),

0 commit comments

Comments
 (0)