Skip to content
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

Fix nonclearing output when nothing is outputed #60

Merged
merged 2 commits into from
Sep 23, 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: 3 additions & 1 deletion src/scwidgets/check/_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ def check_function(self) -> ChecksResult:
if self._fingerprint is not None:
try:
output = self._fingerprint(*output)
except Exception as exception:
except ( # we do not raise here since it is passed to widget output # noqa B040
Exception
) as exception:
if python_version() >= "3.11":
exception.add_note(
"An error was raised in fingerprint function, "
Expand Down
5 changes: 5 additions & 0 deletions src/scwidgets/exercise/_widget_code_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,11 @@ def _on_click_update_action(self) -> bool:
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 (raised_error)

def run_update(self):
Expand Down
Loading