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

next release v4.66.4 #1578

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .meta/.readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ Additional ``bar_format`` parameters may also be defined by overriding
"""Provides a `total_time` format parameter"""
@property
def format_dict(self):
d = super(TqdmExtraFormat, self).format_dict
d = super().format_dict
total_time = d["elapsed"] * (d["total"] or 0) / max(d["n"], 1)
d.update(total_time=self.format_interval(total_time) + " in total")
return d
Expand Down Expand Up @@ -765,7 +765,7 @@ custom callback take advantage of this, simply use the return value of

class TqdmExt(std_tqdm):
def update(self, n=1):
displayed = super(TqdmExt, self).update(n)
displayed = super().update(n)
if displayed:
external_callback(**self.format_dict)
return displayed
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down
2 changes: 1 addition & 1 deletion DEMO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@
" \"\"\"Provides a `total_time` format parameter\"\"\"\n",
" @property\n",
" def format_dict(self):\n",
" d = super(TqdmExtraFormat, self).format_dict\n",
" d = super().format_dict\n",
" total_time = d[\"elapsed\"] * (d[\"total\"] or 0) / max(d[\"n\"], 1)\n",
" d.update(total_time=self.format_interval(total_time) + \" in total\")\n",
" return d\n",
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ Additional ``bar_format`` parameters may also be defined by overriding
"""Provides a `total_time` format parameter"""
@property
def format_dict(self):
d = super(TqdmExtraFormat, self).format_dict
d = super().format_dict
total_time = d["elapsed"] * (d["total"] or 0) / max(d["n"], 1)
d.update(total_time=self.format_interval(total_time) + " in total")
return d
Expand Down Expand Up @@ -982,7 +982,7 @@ custom callback take advantage of this, simply use the return value of

class TqdmExt(std_tqdm):
def update(self, n=1):
displayed = super(TqdmExt, self).update(n)
displayed = super().update(n)
if displayed:
external_callback(**self.format_dict)
return displayed
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_tqdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def cpu_timify(t, timer=None):
class UnicodeIO(IOBase):
"""Unicode version of StringIO"""
def __init__(self, *args, **kwargs):
super(UnicodeIO, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.encoding = 'U8' # io.StringIO supports unicode, but no encoding
self.text = ''
self.cursor = 0
Expand Down Expand Up @@ -342,7 +342,7 @@ def test_all_defaults():
class WriteTypeChecker(BytesIO):
"""File-like to assert the expected type is written"""
def __init__(self, expected_type):
super(WriteTypeChecker, self).__init__()
super().__init__()
self.expected_type = expected_type

def write(self, s):
Expand Down Expand Up @@ -1095,7 +1095,7 @@ class TqdmExtraFormat(tqdm):
"""Provides a `total_time` format parameter"""
@property
def format_dict(self):
d = super(TqdmExtraFormat, self).format_dict
d = super().format_dict
total_time = d["elapsed"] * (d["total"] or 0) / max(d["n"], 1)
d.update(total_time=self.format_interval(total_time) + " in total")
return d
Expand Down
2 changes: 1 addition & 1 deletion tqdm/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class tqdm_asyncio(std_tqdm):
Asynchronous-friendly version of tqdm.
"""
def __init__(self, iterable=None, *args, **kwargs):
super(tqdm_asyncio, self).__init__(iterable, *args, **kwargs)
super().__init__(iterable, *args, **kwargs)
self.iterable_awaitable = False
if iterable is not None:
if hasattr(iterable, "__anext__"):
Expand Down
2 changes: 1 addition & 1 deletion tqdm/contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DummyTqdmFile(ObjectWrapper):
"""Dummy file-like that will write to tqdm"""

def __init__(self, wrapped):
super(DummyTqdmFile, self).__init__(wrapped)
super().__init__(wrapped)
self._buf = []

def write(self, x, nolock=False):
Expand Down
8 changes: 4 additions & 4 deletions tqdm/contrib/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DiscordIO(MonoWorker):
"""Non-blocking file-like IO using a Discord Bot."""
def __init__(self, token, channel_id):
"""Creates a new message in the given `channel_id`."""
super(DiscordIO, self).__init__()
super().__init__()
config = ClientConfig()
config.token = token
client = Client(config)
Expand Down Expand Up @@ -91,10 +91,10 @@ def __init__(self, *args, **kwargs):
kwargs.pop('token', getenv("TQDM_DISCORD_TOKEN")),
kwargs.pop('channel_id', getenv("TQDM_DISCORD_CHANNEL_ID")))
kwargs['mininterval'] = max(1.5, kwargs.get('mininterval', 1.5))
super(tqdm_discord, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def display(self, **kwargs):
super(tqdm_discord, self).display(**kwargs)
super().display(**kwargs)
fmt = self.format_dict
if fmt.get('bar_format', None):
fmt['bar_format'] = fmt['bar_format'].replace(
Expand All @@ -104,7 +104,7 @@ def display(self, **kwargs):
self.dio.write(self.format_meter(**fmt))

def clear(self, *args, **kwargs):
super(tqdm_discord, self).clear(*args, **kwargs)
super().clear(*args, **kwargs)
if not self.disable:
self.dio.write("")

Expand Down
2 changes: 1 addition & 1 deletion tqdm/contrib/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(
self,
tqdm_class=std_tqdm # type: Type[std_tqdm]
):
super(_TqdmLoggingHandler, self).__init__()
super().__init__()
self.tqdm_class = tqdm_class

def emit(self, record):
Expand Down
8 changes: 4 additions & 4 deletions tqdm/contrib/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SlackIO(MonoWorker):
"""Non-blocking file-like IO using a Slack app."""
def __init__(self, token, channel):
"""Creates a new message in the given `channel`."""
super(SlackIO, self).__init__()
super().__init__()
self.client = WebClient(token=token)
self.text = self.__class__.__name__
try:
Expand Down Expand Up @@ -88,10 +88,10 @@ def __init__(self, *args, **kwargs):
kwargs.pop('token', getenv("TQDM_SLACK_TOKEN")),
kwargs.pop('channel', getenv("TQDM_SLACK_CHANNEL")))
kwargs['mininterval'] = max(1.5, kwargs.get('mininterval', 1.5))
super(tqdm_slack, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def display(self, **kwargs):
super(tqdm_slack, self).display(**kwargs)
super().display(**kwargs)
fmt = self.format_dict
if fmt.get('bar_format', None):
fmt['bar_format'] = fmt['bar_format'].replace(
Expand All @@ -105,7 +105,7 @@ def display(self, **kwargs):
self.sio.write(self.format_meter(**fmt))

def clear(self, *args, **kwargs):
super(tqdm_slack, self).clear(*args, **kwargs)
super().clear(*args, **kwargs)
if not self.disable:
self.sio.write("")

Expand Down
10 changes: 5 additions & 5 deletions tqdm/contrib/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TelegramIO(MonoWorker):

def __init__(self, token, chat_id):
"""Creates a new message in the given `chat_id`."""
super(TelegramIO, self).__init__()
super().__init__()
self.token = token
self.chat_id = chat_id
self.session = Session()
Expand Down Expand Up @@ -118,10 +118,10 @@ def __init__(self, *args, **kwargs):
self.tgio = TelegramIO(
kwargs.pop('token', getenv('TQDM_TELEGRAM_TOKEN')),
kwargs.pop('chat_id', getenv('TQDM_TELEGRAM_CHAT_ID')))
super(tqdm_telegram, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def display(self, **kwargs):
super(tqdm_telegram, self).display(**kwargs)
super().display(**kwargs)
fmt = self.format_dict
if fmt.get('bar_format', None):
fmt['bar_format'] = fmt['bar_format'].replace(
Expand All @@ -131,14 +131,14 @@ def display(self, **kwargs):
self.tgio.write(self.format_meter(**fmt))

def clear(self, *args, **kwargs):
super(tqdm_telegram, self).clear(*args, **kwargs)
super().clear(*args, **kwargs)
if not self.disable:
self.tgio.write("")

def close(self):
if self.disable:
return
super(tqdm_telegram, self).close()
super().close()
if not (self.leave or (self.leave is None and self.pos == 0)):
self.tgio.delete()

Expand Down
2 changes: 1 addition & 1 deletion tqdm/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, start=None, pretask=None, tqdm_class=tqdm_auto,
tqdm_kwargs : optional
Any other arguments used for all bars.
"""
super(TqdmCallback, self).__init__(start=start, pretask=pretask)
super().__init__(start=start, pretask=pretask)
if tqdm_kwargs:
tqdm_class = partial(tqdm_class, **tqdm_kwargs)
self.tqdm_class = tqdm_class
Expand Down
2 changes: 1 addition & 1 deletion tqdm/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, *args, **kwargs):
kwargs = kwargs.copy()
kwargs['gui'] = True
colour = kwargs.pop('colour', 'g')
super(tqdm_gui, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

if self.disable:
return
Expand Down
14 changes: 7 additions & 7 deletions tqdm/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _json_(self, pretty=None):
def __repr__(self, pretty=False):
pbar = getattr(self, 'pbar', None)
if pbar is None:
return super(TqdmHBox, self).__repr__()
return super().__repr__()
return pbar.format_meter(**self._json_(pretty))

def _repr_pretty_(self, pp, *_, **__):
Expand Down Expand Up @@ -220,7 +220,7 @@ def __init__(self, *args, **kwargs):
kwargs['disable'] = bool(kwargs.get('disable', False))
colour = kwargs.pop('colour', None)
display_here = kwargs.pop('display', True)
super(tqdm_notebook, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
if self.disable or not kwargs['gui']:
self.disp = lambda *_, **__: None
return
Expand All @@ -246,7 +246,7 @@ def __init__(self, *args, **kwargs):

def __iter__(self):
try:
it = super(tqdm_notebook, self).__iter__()
it = super().__iter__()
for obj in it:
# return super(tqdm...) will not catch exception
yield obj
Expand All @@ -259,7 +259,7 @@ def __iter__(self):

def update(self, n=1):
try:
return super(tqdm_notebook, self).update(n=n)
return super().update(n=n)
# NB: except ... [ as ...] breaks IPython async KeyboardInterrupt
except: # NOQA
# cannot catch KeyboardInterrupt when using manual tqdm
Expand All @@ -272,7 +272,7 @@ def update(self, n=1):
def close(self):
if self.disable:
return
super(tqdm_notebook, self).close()
super().close()
# Try to detect if there was an error or KeyboardInterrupt
# in manual mode: if n < total, things probably got wrong
if self.total and self.n < self.total:
Expand All @@ -297,14 +297,14 @@ def reset(self, total=None):
total : int or float, optional. Total to use for the new bar.
"""
if self.disable:
return super(tqdm_notebook, self).reset(total=total)
return super().reset(total=total)
_, pbar, _ = self.container.children
pbar.bar_style = ''
if total is not None:
pbar.max = total
if not self.total and self.ncols is None: # no longer unknown total
pbar.layout.width = None # reset width
return super(tqdm_notebook, self).reset(total=total)
return super().reset(total=total)


def tnrange(*args, **kwargs):
Expand Down
7 changes: 4 additions & 3 deletions tqdm/rich.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, *args, **kwargs):
kwargs['disable'] = bool(kwargs.get('disable', False))
progress = kwargs.pop('progress', None)
options = kwargs.pop('options', {}).copy()
super(tqdm_rich, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

if self.disable:
return
Expand All @@ -116,7 +116,8 @@ def __init__(self, *args, **kwargs):
def close(self):
if self.disable:
return
super(tqdm_rich, self).close()
self.display() # print 100%, vis #1306
super().close()
self._prog.__exit__(None, None, None)

def clear(self, *_, **__):
Expand All @@ -137,7 +138,7 @@ def reset(self, total=None):
"""
if hasattr(self, '_prog'):
self._prog.reset(total=total)
super(tqdm_rich, self).reset(total=total)
super().reset(total=total)


def trrange(*args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion tqdm/std.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, msg, fp_write=None, *a, **k):
if fp_write is not None:
fp_write("\n" + self.__class__.__name__ + ": " + str(msg).rstrip() + '\n')
else:
super(TqdmWarning, self).__init__(msg, *a, **k)
super().__init__(msg, *a, **k)


class TqdmExperimentalWarning(TqdmWarning, FutureWarning):
Expand Down
4 changes: 2 additions & 2 deletions tqdm/tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, *args, **kwargs):
grab = kwargs.pop('grab', False)
tk_parent = kwargs.pop('tk_parent', None)
self._cancel_callback = kwargs.pop('cancel_callback', None)
super(tqdm_tk, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

if self.disable:
return
Expand Down Expand Up @@ -172,7 +172,7 @@ def reset(self, total=None):
self._tk_pbar.configure(maximum=100, mode="indeterminate")
else:
self._tk_pbar.configure(maximum=total, mode="determinate")
super(tqdm_tk, self).reset(total=total)
super().reset(total=total)

@staticmethod
def _tk_dispatching_helper():
Expand Down
6 changes: 3 additions & 3 deletions tqdm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class SimpleTextIOWrapper(ObjectWrapper):
"""
# pylint: disable=too-few-public-methods
def __init__(self, wrapped, encoding):
super(SimpleTextIOWrapper, self).__init__(wrapped)
super().__init__(wrapped)
self.wrapper_setattr('encoding', encoding)

def write(self, s):
Expand Down Expand Up @@ -211,7 +211,7 @@ def inner(*args, **kwargs):
return inner

def __init__(self, wrapped, tqdm_instance):
super(DisableOnWriteError, self).__init__(wrapped)
super().__init__(wrapped)
if hasattr(wrapped, 'write'):
self.wrapper_setattr(
'write', self.disable_on_exception(tqdm_instance, wrapped.write))
Expand All @@ -229,7 +229,7 @@ def __init__(self, callback, stream, method="read"):
Wrap a given `file`-like object's `read()` or `write()` to report
lengths to the given `callback`
"""
super(CallbackIOWrapper, self).__init__(stream)
super().__init__(stream)
func = getattr(stream, method)
if method == "write":
@wraps(func)
Expand Down
Loading