diff --git a/spinn_utilities/progress_bar.py b/spinn_utilities/progress_bar.py index 3b4e3ebe..7c062bcd 100644 --- a/spinn_utilities/progress_bar.py +++ b/spinn_utilities/progress_bar.py @@ -13,12 +13,13 @@ # limitations under the License. from collections import defaultdict +from collections.abc import Sized from datetime import date import logging import math import os import sys -from typing import Dict, Iterable, List, TypeVar +from typing import Dict, Iterable, List, TypeVar, Union from spinn_utilities.config_holder import get_config_bool from spinn_utilities.log import FormatAdapter from spinn_utilities.overrides import overrides @@ -46,15 +47,14 @@ class ProgressBar(object): "_step_character", "_end_character", "_in_bad_terminal", ) - def __init__(self, total_number_of_things_to_do, + def __init__(self, total_number_of_things_to_do: Union[int, Sized], string_describing_what_being_progressed, step_character="=", end_character="|"): try: self._number_of_things = int(total_number_of_things_to_do) except TypeError: - # Might be dealing with general iterable; better not be infinite - self._number_of_things = len(list(total_number_of_things_to_do)) + self._number_of_things = len(total_number_of_things_to_do) self._currently_completed = 0 self._chars_per_thing = None