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

_state: clear the spinner entirely when done #174

Merged
merged 2 commits into from
Dec 3, 2021
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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ All versions prior to 0.0.9 are untracked.

### Changed

* CLI: `pip-audit` now clears its spinner bar from the terminal upon
completion, preventing visual confusion
([#174](https://github.com/trailofbits/pip-audit/pull/174))

### Fixed

### Removed
Expand Down
13 changes: 13 additions & 0 deletions pip_audit/_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ def update(self) -> None:
line = f"{self.phases[i]} {self.message}"
self._writeln_truncated(line)

def finish(self) -> None:
"""
Finish the progress spinner.

This method is overridden from `BaseSpinner` to customize the spinner's termination
behavior: instead of finishing by printing a newline and leaving the last spinner state
on the terminal, we clear the spinner entirely and reset the line's state, leaving
no trace of the spinner at all.
"""
self.writeln("")
self.file.write("\r")
self.file.flush()

def update_state(self, message: str) -> None:
"""
Update the state message for the progress spinner.
Expand Down