mirror of
https://github.com/Textualize/rich.git
synced 2025-12-23 07:08:35 +00:00
Implements a runtime adapter that replaces tqdm imports with Rich's progress bars via install_tqdm(). The shim preserves common tqdm APIs (iteration, len(), postfix, write, wrapattr) while routing rendering through rich.progress.Progress. Features: - Opt-in monkeypatching of tqdm/trange and notebook variants - Shared global Progress instance for performance - Render throttling via mininterval/miniters/maxinterval - Simplified text backend for file outputs (partial mode) - Postfix value caching to avoid redundant formatting Includes runnable examples demonstrating basic replacement and aggressive reference overwriting, plus comprehensive unit tests covering adapter installation, throttling, and postfix handling. Updates README and contributor list.
15 lines
327 B
Python
15 lines
327 B
Python
"""Simulated third-party module that hides a tqdm reference internally.
|
|
|
|
Imported by tqdm_adapter_hidden.py to demonstrate aggressive replacement.
|
|
"""
|
|
|
|
import time
|
|
|
|
import tqdm as _tqdm
|
|
|
|
_hidden_tqdm = _tqdm.tqdm
|
|
|
|
|
|
def run_hidden_loop() -> None:
|
|
for _ in _hidden_tqdm(range(5), desc="hidden-lib"):
|
|
time.sleep(0.05)
|