You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parameters:
sequence (Iterable[ProgressType]) – A sequence (must support “len”) you wish to iterate over.
In fact, the sequence parameter is not a sequence, it is an iterable (which is correctly detected by a documentation builder, btw), so it doesn't have to support len.
My suggestions:
add a parameter named iterable with the same meaning as sequence,
of course, keep sequence for backward compatibility,
maybe change the type in the source code from Sequence | Iterable to just Iterable.
Sample program to play with (as you see, concurrent.futures.as_completed() is not a sequence—it is a generator—so it does not have len, and despite of that the code works correctly):
#! /usr/bin/env --split-string=uv run --script# /// script# requires-python = ">=3.13"# dependencies = [# "rich",# ]# ///importconcurrent.futuresimportrandomimporttimeimportrich.progressimportrich.tracebackdefmain() ->None:
"""Top-level logic."""rich.traceback.install(show_locals=True)
withconcurrent.futures.ProcessPoolExecutor() asexecutor:
futures= { executor.submit(simulate_job) foriinrange(15) }
forfutureinrich.progress.track(
concurrent.futures.as_completed(futures),
description='Working…',
# total=len(futures),
):
print('Something is done!')
defsimulate_job() ->None:
"""Job simulator — sleep for a random amount of time."""time.sleep(
random.uniform(0.1, 1.3),
)
if__name__=='__main__':
main()
The text was updated successfully, but these errors were encountered:
https://rich.readthedocs.io/en/latest/reference/progress.html#rich.progress.track reads:
In fact, the
sequence
parameter is not a sequence, it is an iterable (which is correctly detected by a documentation builder, btw), so it doesn't have to supportlen
.My suggestions:
iterable
with the same meaning assequence
,sequence
for backward compatibility,Sequence | Iterable
to justIterable
.Sample program to play with (as you see,
concurrent.futures.as_completed()
is not a sequence—it is a generator—so it does not havelen
, and despite of that the code works correctly):The text was updated successfully, but these errors were encountered: