Skip to content

Commit 43d0ff2

Browse files
author
github-actions
committed
[github-actions] Apply auto-formatting using ruff
1 parent e61be0b commit 43d0ff2

File tree

3 files changed

+40
-28
lines changed

3 files changed

+40
-28
lines changed

glossary_branch_pull/download.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def setup(verbose: bool = False):
3535
"d.txt",
3636
"""
3737
documentation: Evidence that someone once cared.
38-
""")
38+
""",
39+
)
3940
add(["d.txt"], verbose)
4041
commit("Add 'documentation'", verbose)

glossary_branch_pull/test_verify.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from contextlib import contextmanager
22
from typing import Iterator, Tuple
33

4-
from exercise_utils.test import GitAutograderTest, GitAutograderTestLoader, assert_output
4+
from exercise_utils.test import (
5+
GitAutograderTest,
6+
GitAutograderTestLoader,
7+
assert_output,
8+
)
59
from git_autograder import GitAutograderStatus
610
from repo_smith.repo_smith import RepoSmith
711

@@ -23,7 +27,7 @@ def base_setup() -> Iterator[Tuple[GitAutograderTest, RepoSmith]]:
2327
with loader.start(include_remote_repo=True) as (test, rs, rs_remote):
2428
remote_path = str(rs_remote.repo.git_dir)
2529
rs.git.remote_add("origin", remote_path)
26-
30+
2731
rs.git.commit(allow_empty=True, message="Initial commit")
2832

2933
rs.git.checkout("ABC", branch=True)
@@ -39,6 +43,7 @@ def base_setup() -> Iterator[Tuple[GitAutograderTest, RepoSmith]]:
3943

4044
yield (test, rs)
4145

46+
4247
def test_no_changes():
4348
with base_setup() as (test, rs):
4449
output = test.run()
@@ -49,9 +54,10 @@ def test_no_changes():
4954
BRANCH_MISSING.format(branch="STU"),
5055
BRANCH_MISSING.format(branch="VWX"),
5156
REMOTE_COMMIT_MISSING.format(branch="ABC"),
52-
REMOTE_COMMIT_MISSING.format(branch="DEF")
53-
])
54-
57+
REMOTE_COMMIT_MISSING.format(branch="DEF"),
58+
],
59+
)
60+
5561

5662
def test_branch_not_tracking():
5763
with base_setup() as (test, rs):
@@ -66,9 +72,10 @@ def test_branch_not_tracking():
6672
BRANCH_NOT_TRACKING.format(branch="STU"),
6773
BRANCH_NOT_TRACKING.format(branch="VWX"),
6874
REMOTE_COMMIT_MISSING.format(branch="ABC"),
69-
REMOTE_COMMIT_MISSING.format(branch="DEF")
70-
])
71-
75+
REMOTE_COMMIT_MISSING.format(branch="DEF"),
76+
],
77+
)
78+
7279

7380
def test_def_local_commit_missing():
7481
with base_setup() as (test, rs):
@@ -87,11 +94,8 @@ def test_def_local_commit_missing():
8794
rs.git.merge("origin/DEF")
8895

8996
output = test.run()
90-
assert_output(
91-
output,
92-
GitAutograderStatus.UNSUCCESSFUL,
93-
[LOCAL_COMMIT_MISSING])
94-
97+
assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [LOCAL_COMMIT_MISSING])
98+
9599

96100
def test_successful_changes():
97101
with base_setup() as (test, rs):
@@ -110,4 +114,4 @@ def test_successful_changes():
110114
rs.git.merge("origin/DEF")
111115

112116
output = test.run()
113-
assert_output(output, GitAutograderStatus.SUCCESSFUL)
117+
assert_output(output, GitAutograderStatus.SUCCESSFUL)

glossary_branch_pull/verify.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,34 @@
99
BRANCH_MISSING = "The local {branch} branch is not created."
1010
BRANCH_NOT_TRACKING = "The local {branch} branch does not track origin/{branch}."
1111
REMOTE_COMMIT_MISSING = "New commit in the remote {branch} branch is not pulled to the local {branch} branch."
12-
LOCAL_COMMIT_MISSING = "The original local commit on DEF is missing. " \
13-
"You may have lost your work instead of merging."
12+
LOCAL_COMMIT_MISSING = (
13+
"The original local commit on DEF is missing. "
14+
"You may have lost your work instead of merging."
15+
)
1416

1517

16-
def get_commit_from_message(commits: List[GitAutograderCommit], message: str) \
17-
-> GitAutograderCommit | None:
18+
def get_commit_from_message(
19+
commits: List[GitAutograderCommit], message: str
20+
) -> GitAutograderCommit | None:
1821
"""Find a commit with the given message from a list of commits."""
1922
for commit in commits:
2023
if message.strip() == commit.commit.message.strip():
2124
return commit
2225
return None
2326

24-
def get_commit_from_hexsha(commits: List[GitAutograderCommit], hexsha: str) \
25-
-> GitAutograderCommit | None:
27+
28+
def get_commit_from_hexsha(
29+
commits: List[GitAutograderCommit], hexsha: str
30+
) -> GitAutograderCommit | None:
2631
"""Find a commit with the given hexsha from a list of commits."""
2732
for commit in commits:
2833
if hexsha.strip() == commit.commit.hexsha.strip():
2934
return commit
3035
return None
3136

37+
3238
def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
33-
repo = exercise.repo
39+
repo = exercise.repo
3440
comments = []
3541

3642
if not repo.branches.has_branch("STU"):
@@ -58,8 +64,8 @@ def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
5864
if not remote_abc or remote_abc.name != "origin/ABC":
5965
comments.append(BRANCH_NOT_TRACKING.format(branch="ABC"))
6066
elif not get_commit_from_hexsha(abc_commits, remote_abc.commit.hexsha):
61-
comments.append(REMOTE_COMMIT_MISSING.format(branch="ABC"))
62-
67+
comments.append(REMOTE_COMMIT_MISSING.format(branch="ABC"))
68+
6369
if not repo.branches.has_branch("DEF"):
6470
comments.append(BRANCH_MISSING.format(branch="DEF"))
6571
else:
@@ -71,10 +77,11 @@ def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
7177
if not remote_def or remote_def.name != "origin/DEF":
7278
comments.append(BRANCH_NOT_TRACKING.format(branch="DEF"))
7379
elif not get_commit_from_hexsha(def_commits, remote_def.commit.hexsha):
74-
comments.append(REMOTE_COMMIT_MISSING.format(branch="DEF"))
80+
comments.append(REMOTE_COMMIT_MISSING.format(branch="DEF"))
7581

7682
if comments:
7783
raise exercise.wrong_answer(comments)
78-
return exercise.to_output([
79-
"Great work! All required branches are present and correctly set up."
80-
], GitAutograderStatus.SUCCESSFUL)
84+
return exercise.to_output(
85+
["Great work! All required branches are present and correctly set up."],
86+
GitAutograderStatus.SUCCESSFUL,
87+
)

0 commit comments

Comments
 (0)