Skip to content

Commit 600ba7c

Browse files
author
github-actions
committed
[github-actions] Apply auto-formatting using ruff
1 parent 68f558b commit 600ba7c

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

undo_init/download.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
from exercise_utils.file import create_or_update_file
33
from exercise_utils.git import init
44

5+
56
def setup(verbose: bool = False):
67
create_or_update_file(
78
"todo.txt",
89
"""
910
My tasks
10-
"""
11+
""",
1112
)
1213

1314
os.makedirs("private")
@@ -16,7 +17,7 @@ def setup(verbose: bool = False):
1617
"contacts.txt",
1718
"""
1819
My contacts
19-
"""
20+
""",
2021
)
2122

2223
os.chdir("..")

undo_init/tests/test_verify.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
from git_autograder import GitAutograderStatus, GitAutograderTestLoader, assert_output
33

44
from ..verify import (
5-
INIT_NOT_UNDONE,
5+
INIT_NOT_UNDONE,
66
TODO_FILE_MISSING,
77
CONTACTS_FILE_MISSING,
8-
PRIVATE_FOLDER_MISSING,
9-
verify
8+
PRIVATE_FOLDER_MISSING,
9+
verify,
1010
)
1111

1212
REPOSITORY_NAME = "undo-init"
@@ -16,11 +16,13 @@
1616

1717
def test_base():
1818
# We patch the ExerciseRepoConfig to return "ignore" instead of "local"
19-
with mock.patch("git_autograder.exercise_config.ExerciseConfig.ExerciseRepoConfig") as mock_config:
19+
with mock.patch(
20+
"git_autograder.exercise_config.ExerciseConfig.ExerciseRepoConfig"
21+
) as mock_config:
2022
# Configure the mock to return "ignore" when the loader accesses it
2123
instance = mock_config.return_value
2224
instance.repo_type = "ignore"
23-
instance.repo_name = "repo" # Match the loader's hardcoded name
25+
instance.repo_name = "repo" # Match the loader's hardcoded name
2426
instance.init = False
2527

2628
with loader.load("specs/base.yml") as output:
@@ -33,7 +35,9 @@ def test_init_not_undone():
3335

3436

3537
def test_todo_file_missing():
36-
with mock.patch("git_autograder.exercise_config.ExerciseConfig.ExerciseRepoConfig") as mock_config:
38+
with mock.patch(
39+
"git_autograder.exercise_config.ExerciseConfig.ExerciseRepoConfig"
40+
) as mock_config:
3741
instance = mock_config.return_value
3842
instance.repo_type = "ignore"
3943
instance.repo_name = "repo"
@@ -44,25 +48,32 @@ def test_todo_file_missing():
4448

4549

4650
def test_private_dir_missing():
47-
with mock.patch("git_autograder.exercise_config.ExerciseConfig.ExerciseRepoConfig") as mock_config:
51+
with mock.patch(
52+
"git_autograder.exercise_config.ExerciseConfig.ExerciseRepoConfig"
53+
) as mock_config:
4854
instance = mock_config.return_value
4955
instance.repo_type = "ignore"
5056
instance.repo_name = "repo"
5157
instance.init = False
5258

5359
with loader.load("specs/private_dir_missing.yml") as output:
54-
assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [
55-
PRIVATE_FOLDER_MISSING,
56-
CONTACTS_FILE_MISSING
57-
])
60+
assert_output(
61+
output,
62+
GitAutograderStatus.UNSUCCESSFUL,
63+
[PRIVATE_FOLDER_MISSING, CONTACTS_FILE_MISSING],
64+
)
5865

5966

6067
def test_contacts_file_missing():
61-
with mock.patch("git_autograder.exercise_config.ExerciseConfig.ExerciseRepoConfig") as mock_config:
68+
with mock.patch(
69+
"git_autograder.exercise_config.ExerciseConfig.ExerciseRepoConfig"
70+
) as mock_config:
6271
instance = mock_config.return_value
6372
instance.repo_type = "ignore"
6473
instance.repo_name = "repo"
6574
instance.init = False
6675

6776
with loader.load("specs/contacts_file_missing.yml") as output:
68-
assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [CONTACTS_FILE_MISSING])
77+
assert_output(
78+
output, GitAutograderStatus.UNSUCCESSFUL, [CONTACTS_FILE_MISSING]
79+
)

undo_init/verify.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
PRIVATE_FOLDER_MISSING = "The private folder should not be deleted."
1212
SUCCESS_MESSAGE = "You have successfully undone the init operation!"
1313

14+
1415
def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
1516
repo_root = exercise.exercise_path
1617
repo_folder = exercise.config.exercise_repo.repo_name
@@ -20,19 +21,19 @@ def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
2021
dot_git_dir_path = os.path.join(work_dir, ".git")
2122
if os.path.exists(dot_git_dir_path):
2223
comments.append(INIT_NOT_UNDONE)
23-
24+
2425
todo_file_path = os.path.join(work_dir, "todo.txt")
2526
if not os.path.exists(todo_file_path):
2627
comments.append(TODO_FILE_MISSING)
27-
28+
2829
private_dir_path = os.path.join(work_dir, "private")
2930
if not os.path.exists(private_dir_path):
3031
comments.append(PRIVATE_FOLDER_MISSING)
3132

3233
contacts_file_path = os.path.join(private_dir_path, "contacts.txt")
3334
if not os.path.exists(contacts_file_path):
3435
comments.append(CONTACTS_FILE_MISSING)
35-
36+
3637
if comments:
3738
raise exercise.wrong_answer(comments)
3839

0 commit comments

Comments
 (0)