diff --git a/dvc/progress.py b/dvc/progress.py index fcfb1ddf8..98728e51d 100644 --- a/dvc/progress.py +++ b/dvc/progress.py @@ -51,7 +51,7 @@ class Tqdm(tqdm): file=None, total=None, postfix=None, - **kwargs + **kwargs, ): """ bytes : shortcut for @@ -90,7 +90,7 @@ class Tqdm(tqdm): bar_format="!", lock_args=(False,), total=total, - **kwargs + **kwargs, ) self.postfix = postfix or {"info": ""} if bar_format is None: @@ -106,13 +106,16 @@ class Tqdm(tqdm): self.bar_format = bar_format self.refresh() - def update_msg(self, msg, n=1): + def update_msg(self, msg: str, n: int = 1) -> None: """ Sets `msg` as a postfix and calls `update(n)`. """ - self.postfix["info"] = " %s |" % msg + self.set_msg(msg) self.update(n) + def set_msg(self, msg: str) -> None: + self.postfix["info"] = f" {msg} |" + def update_to(self, current, total=None): if total: self.total = total diff --git a/dvc/repo/add.py b/dvc/repo/add.py index 93e044a96..eb3007e64 100644 --- a/dvc/repo/add.py +++ b/dvc/repo/add.py @@ -94,14 +94,16 @@ def translate_graph_error(stages: Stages) -> Iterator[None]: def progress_iter(stages: Stages) -> Iterator["Stage"]: total = len(stages) desc = "Adding..." - with ui.progress(total=total, desc=desc, unit="file", leave=True) as pbar: + with ui.progress( + stages, total=total, desc=desc, unit="file", leave=True + ) as pbar: if total == 1: pbar.bar_format = desc pbar.refresh() - for stage in stages: + for stage in pbar: if total > 1: - pbar.update_msg(f"{stage.outs[0]}") + pbar.set_msg(f"{stage.outs[0]}") yield stage if total == 1: # restore bar format for stats # pylint: disable=no-member