Skip to content

Various cleanups and fixes #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/scwidgets/check/_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ def __init__(
self._stop_on_assert_error_raised = stop_on_assert_error_raised

@property
def function_to_check(self):
def function_to_check(self) -> Callable[..., FunOutParamsT]:
return self._function_to_check

@function_to_check.setter
def function_to_check(self, function_to_check):
def function_to_check(self, function_to_check: Callable[..., FunOutParamsT]):
self._function_to_check = function_to_check

@property
Expand Down
8 changes: 4 additions & 4 deletions src/scwidgets/exercise/_widget_code_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ def outputs(self) -> List[CueOutput]:

def _on_click_update_action(self) -> bool:
self._output.clear_output(wait=True)
self._raised_error = False
raised_error = False
# runs code and displays output
with self._output:
try:
Expand All @@ -708,18 +708,18 @@ def _on_click_update_action(self) -> bool:
cue_output.draw_display()

except CodeValidationError as e:
self._raised_error = True
raised_error = True
raise e
except Exception as e:
self._raised_error = True
raised_error = True
raise e

# The clear_output command at the beginning of the function waits till
# something is printed. If nothing is printed, it is not cleared. We
# enforce it to be invoked by printing an empty string
print("", end="")

return not (self._raised_error)
return not (raised_error)

def run_update(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def print_success(code_ex: CodeExercise | None):
parameters={"parameter": fixed(5)},
exercise_registry=exercise_registry,
exercise_key="test_save_registry_ex",
cue_outputs=[cue_output],
outputs=[cue_output],
update_func=print_success,
)

Expand Down
Loading