Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Oct 11, 2024
1 parent 075448b commit 8253adf
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions spinn_utilities/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class ProgressBar(object):
)

def __init__(self, total_number_of_things_to_do: Union[int, Sized],
string_describing_what_being_progressed,
step_character="=", end_character="|"):
string_describing_what_being_progressed: str,
step_character: str = "=", end_character: str = "|"):
if isinstance(total_number_of_things_to_do, Sized):
self._number_of_things = len(total_number_of_things_to_do)
else:
Expand All @@ -80,7 +80,7 @@ def __init__(self, total_number_of_things_to_do: Union[int, Sized],
self._create_initial_progress_bar(
string_describing_what_being_progressed)

def update(self, amount_to_add=1):
def update(self, amount_to_add: int = 1) -> None:
"""
Update the progress bar by a given amount.
Expand All @@ -92,10 +92,10 @@ def update(self, amount_to_add=1):
self._currently_completed += amount_to_add
self._check_differences()

def _print_overwritten_line(self, string: str):
def _print_overwritten_line(self, string: str) -> None:
print("\r" + string, end="", file=self._destination)

def _print_distance_indicator(self, description: str):
def _print_distance_indicator(self, description: str) -> None:
if description is not None:
print(description, file=self._destination)

Expand All @@ -116,12 +116,13 @@ def _print_distance_indicator(self, description: str):
print("", file=self._destination)
print(" ", end="", file=self._destination)

def _print_distance_line(self, first_space, second_space):
def _print_distance_line(
self, first_space: int, second_space: int) -> None:
line = f"{self._end_character}0%{' ' * first_space}50%" \
f"{' ' * second_space}100%{self._end_character}"
print(line, end="", file=self._destination)

def _print_progress(self, length: int):
def _print_progress(self, length: int) -> None:
chars_to_print = length
if not self._in_bad_terminal:
self._print_overwritten_line(self._end_character)
Expand Down

0 comments on commit 8253adf

Please sign in to comment.