Skip to content

Commit a325681

Browse files
author
github-actions
committed
[github-actions] Apply auto-formatting using ruff
1 parent ccb5c09 commit a325681

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

branch_previous/download.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
from exercise_utils.file import create_or_update_file, append_to_file
22
from exercise_utils.git import add, commit
33

4+
45
def setup(verbose: bool = False):
56
create_or_update_file(
67
"story.txt",
78
"""
89
It was a dark and stormy night.
9-
"""
10+
""",
1011
)
1112
add(["story.txt"], verbose)
1213
commit("Describe night", verbose)
1314

1415
append_to_file(
15-
"story.txt",
16+
"story.txt",
1617
"""
1718
I was alone in my room.
18-
"""
19+
""",
1920
)
2021
add(["story.txt"], verbose)
2122
commit("Describe location", verbose)
@@ -24,7 +25,7 @@ def setup(verbose: bool = False):
2425
"story.txt",
2526
"""
2627
I heard a strange noise.
27-
"""
28+
""",
2829
)
2930
add(["story.txt"], verbose)
3031
commit("Mention noise", verbose)

branch_previous/verify.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
)
2424

2525

26-
def get_commit_from_message(commits: List[GitAutograderCommit], message: str) -> Optional[GitAutograderCommit]:
26+
def get_commit_from_message(
27+
commits: List[GitAutograderCommit], message: str
28+
) -> Optional[GitAutograderCommit]:
2729
"""Find a commit with the given message from a list of commits."""
2830
for commit in commits:
2931
if message.strip() == commit.commit.message.strip():
@@ -45,22 +47,27 @@ def verify_branch(
4547
branch_helper = exercise.repo.branches
4648
if not branch_helper.has_branch(branch_name):
4749
raise exercise.wrong_answer([MISSING_BRANCH.format(branch_name=branch_name)])
48-
50+
4951
branch = branch_helper.branch(branch_name)
5052
latest_commit = branch.latest_commit
51-
53+
5254
if latest_commit.hexsha == expected_start_commit.hexsha:
5355
raise exercise.wrong_answer([MISSING_COMMIT.format(branch_name=branch_name)])
5456

55-
if expected_start_commit.hexsha not in [parent.hexsha for parent in latest_commit.commit.parents]:
57+
if expected_start_commit.hexsha not in [
58+
parent.hexsha for parent in latest_commit.commit.parents
59+
]:
5660
raise exercise.wrong_answer([WRONG_START.format(branch_name=branch_name)])
57-
61+
5862
with latest_commit.file("story.txt") as content:
5963
if expected_content not in content:
60-
raise exercise.wrong_answer([WRONG_CONTENT.format(
61-
branch_name=branch_name,
62-
expected_content=expected_content
63-
)])
64+
raise exercise.wrong_answer(
65+
[
66+
WRONG_CONTENT.format(
67+
branch_name=branch_name, expected_content=expected_content
68+
)
69+
]
70+
)
6471

6572

6673
def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
@@ -71,14 +78,14 @@ def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
7178
branch_name="visitor-line",
7279
expected_start_commit=describe_location_commit,
7380
expected_content="I heard someone knocking at the door.",
74-
exercise=exercise
81+
exercise=exercise,
7582
)
7683

7784
verify_branch(
7885
branch_name="sleep-line",
7986
expected_start_commit=describe_location_commit,
8087
expected_content="I fell asleep on the couch.",
81-
exercise=exercise
88+
exercise=exercise,
8289
)
8390

8491
return exercise.to_output(

0 commit comments

Comments
 (0)