auto.py 871 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. """
  2. Enables multiple commonly used features.
  3. Method resolution order:
  4. - `tqdm.autonotebook` without import warnings
  5. - `tqdm.asyncio`
  6. - `tqdm.std` base class
  7. Usage:
  8. >>> from tqdm.auto import trange, tqdm
  9. >>> for i in trange(10):
  10. ... ...
  11. """
  12. import warnings
  13. from .std import TqdmExperimentalWarning
  14. with warnings.catch_warnings():
  15. warnings.simplefilter("ignore", category=TqdmExperimentalWarning)
  16. from .autonotebook import tqdm as notebook_tqdm
  17. from .asyncio import tqdm as asyncio_tqdm
  18. from .std import tqdm as std_tqdm
  19. if notebook_tqdm != std_tqdm:
  20. class tqdm(notebook_tqdm, asyncio_tqdm): # pylint: disable=inconsistent-mro
  21. pass
  22. else:
  23. tqdm = asyncio_tqdm
  24. def trange(*args, **kwargs):
  25. """
  26. A shortcut for `tqdm.auto.tqdm(range(*args), **kwargs)`.
  27. """
  28. return tqdm(range(*args), **kwargs)
  29. __all__ = ["tqdm", "trange"]