Skip to content

Commit

Permalink
rich: expose options kwargs
Browse files Browse the repository at this point in the history
- replaces/closes tqdm#1282
  • Loading branch information
casperdcl committed Mar 26, 2022
1 parent fb0844f commit 96fe8c5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tqdm/rich.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ def __init__(self, *args, **kwargs):
----------
progress : tuple, optional
arguments for `rich.progress.Progress()`.
options : dict, optional
keyword arguments for `rich.progress.Progress()`.
"""
kwargs = kwargs.copy()
kwargs['gui'] = True
# convert disable = None to False
kwargs['disable'] = bool(kwargs.get('disable', False))
progress = kwargs.pop('progress', None)
options = kwargs.pop('options', {}).copy()
super(tqdm_rich, self).__init__(*args, **kwargs)

if self.disable:
Expand All @@ -108,7 +111,8 @@ def __init__(self, *args, **kwargs):
",", RateColumn(unit=d['unit'], unit_scale=d['unit_scale'],
unit_divisor=d['unit_divisor']), "]"
)
self._prog = Progress(*progress, transient=not self.leave)
options.setdefault('transient', not self.leave)
self._prog = Progress(*progress, **options)
self._prog.__enter__()
self._task_id = self._prog.add_task(self.desc or "", **d)

Expand Down

0 comments on commit 96fe8c5

Please sign in to comment.