From a9a2906b11af1bdceab4ae54dec14e3279cc2962 Mon Sep 17 00:00:00 2001 From: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:26:52 -0400 Subject: [PATCH 1/2] unpack anonymous callable --- src/tqdm_publisher/_progress_subscriber.py | 14 ++++++++++++++ src/tqdm_publisher/_subscriber.py | 7 ------- 2 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 src/tqdm_publisher/_progress_subscriber.py delete mode 100644 src/tqdm_publisher/_subscriber.py diff --git a/src/tqdm_publisher/_progress_subscriber.py b/src/tqdm_publisher/_progress_subscriber.py new file mode 100644 index 0000000..cfb6524 --- /dev/null +++ b/src/tqdm_publisher/_progress_subscriber.py @@ -0,0 +1,14 @@ +from ._publisher import TQDMPublisher + + +class TQDMProgressSubscriber(TQDMPublisher): + def __init__(self, iterable, *, announcer: "?", request_id: str, message: dict, **tqdm_kwargs): + super().__init__(iterable, **tqdm_kwargs) + + def on_progress_update(format_dict) -> None: + """ + Describe what this announcer is all about... + """ + announcer.announce(dict(request_id=request_id, **message)) + + self.subscribe(callback=on_progress_update) diff --git a/src/tqdm_publisher/_subscriber.py b/src/tqdm_publisher/_subscriber.py deleted file mode 100644 index 289d3d6..0000000 --- a/src/tqdm_publisher/_subscriber.py +++ /dev/null @@ -1,7 +0,0 @@ -from ._publisher import TQDMPublisher - - -class TQDMProgressSubscriber(TQDMPublisher): - def __init__(self, iterable, on_progress_update: callable, **tqdm_kwargs): - super().__init__(iterable, **tqdm_kwargs) - self.subscribe(lambda format_dict: on_progress_update(dict(progress_bar_id=self.id, format_dict=format_dict))) From 0e2f8ca67423ec41bec1e51eb1610aabc174d860 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:26:57 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/tqdm_publisher/_progress_subscriber.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tqdm_publisher/_progress_subscriber.py b/src/tqdm_publisher/_progress_subscriber.py index cfb6524..b892f4e 100644 --- a/src/tqdm_publisher/_progress_subscriber.py +++ b/src/tqdm_publisher/_progress_subscriber.py @@ -2,13 +2,13 @@ class TQDMProgressSubscriber(TQDMPublisher): - def __init__(self, iterable, *, announcer: "?", request_id: str, message: dict, **tqdm_kwargs): + def __init__(self, iterable, *, announcer: "?", request_id: str, message: dict, **tqdm_kwargs): super().__init__(iterable, **tqdm_kwargs) def on_progress_update(format_dict) -> None: - """ - Describe what this announcer is all about... - """ - announcer.announce(dict(request_id=request_id, **message)) - + """ + Describe what this announcer is all about... + """ + announcer.announce(dict(request_id=request_id, **message)) + self.subscribe(callback=on_progress_update)