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

Add numpy-style docstrings #12

Merged
merged 9 commits into from
Jan 21, 2024
Merged
12 changes: 7 additions & 5 deletions src/tqdm_publisher/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from tqdm import tqdm as base_tqdm
from uuid import uuid4

from typing import Union

# This class is a subclass of tqdm that allows for an arbitary number of callbacks to be registered
class TQDMPublisher(base_tqdm):

Expand All @@ -11,12 +13,12 @@ def __init__(self, *args, **kwargs):


# Override the update method to call callbacks
def update(self, n=1):
def update(self, n: int=1) -> Union[bool, None]:
displayed = super().update(n)
for id in list(self.callbacks):
callback = self.callbacks.get(id)
if callback:
callback(self.format_dict)

for callback in self.callbacks.values():
callback(self.format_dict)

return displayed


Expand Down