Skip to content

Commit 0cf3f77

Browse files
chore: auto fixes from pre-commit.com hooks
1 parent 388b0b1 commit 0cf3f77

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

main.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,16 @@ def run_pr_message_checks(pr_messages: list[str], result_file: TextIO) -> int:
156156
total_messages = len(pr_messages)
157157
for index, msg in enumerate(pr_messages, start=1):
158158
subject = msg.splitlines()[0] if msg else "<empty commit message>"
159-
has_failure = run_check_command(
160-
["--message"],
161-
result_file,
162-
input_text=msg,
163-
output_prefix=f"\n--- Commit {index}/{total_messages}: {subject}\n",
164-
) != 0 or has_failure
159+
has_failure = (
160+
run_check_command(
161+
["--message"],
162+
result_file,
163+
input_text=msg,
164+
output_prefix=f"\n--- Commit {index}/{total_messages}: {subject}\n",
165+
)
166+
!= 0
167+
or has_failure
168+
)
165169
return 1 if has_failure else 0
166170

167171

main_test.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,19 @@ def test_falls_back_to_base_ref_when_merge_ref_is_unavailable(self):
191191
def test_exception_returns_empty(self):
192192
with (
193193
patch.dict(os.environ, {"GITHUB_EVENT_NAME": "pull_request"}),
194-
patch("main.get_messages_from_merge_ref", side_effect=Exception("git failed")),
194+
patch(
195+
"main.get_messages_from_merge_ref", side_effect=Exception("git failed")
196+
),
195197
):
196198
result = main.get_pr_commit_messages()
197199
self.assertEqual(result, [])
198200

199201

200202
class TestGitMessageReaders(unittest.TestCase):
201203
def test_get_messages_from_merge_ref(self):
202-
mock_result = MagicMock(returncode=0, stdout="fix: first\n\x00feat: second\n\x00")
204+
mock_result = MagicMock(
205+
returncode=0, stdout="fix: first\n\x00feat: second\n\x00"
206+
)
203207
with patch("main.subprocess.run", return_value=mock_result) as mock_run:
204208
result = main.get_messages_from_merge_ref()
205209
self.assertEqual(result, ["fix: first", "feat: second"])
@@ -426,7 +430,9 @@ def test_same_repo_not_fork(self):
426430
"base": {"repo": {"full_name": "owner/repo"}},
427431
}
428432
}
429-
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as file_obj:
433+
with tempfile.NamedTemporaryFile(
434+
mode="w", suffix=".json", delete=False
435+
) as file_obj:
430436
json.dump(event, file_obj)
431437
event_path = file_obj.name
432438
with patch.dict(os.environ, {"GITHUB_EVENT_PATH": event_path}):
@@ -443,7 +449,9 @@ def test_different_repo_is_fork(self):
443449
"base": {"repo": {"full_name": "owner/repo"}},
444450
}
445451
}
446-
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as file_obj:
452+
with tempfile.NamedTemporaryFile(
453+
mode="w", suffix=".json", delete=False
454+
) as file_obj:
447455
json.dump(event, file_obj)
448456
event_path = file_obj.name
449457
with patch.dict(os.environ, {"GITHUB_EVENT_PATH": event_path}):

0 commit comments

Comments
 (0)