Typing Stubs for TQDM

4.67.3.20260408 · active · verified Thu Apr 09

This package provides machine-readable type hints (stubs) for the popular `tqdm` progress bar library. It enables static type checkers like MyPy, Pyright, or Pylance to validate `tqdm` usage in Python code, catching potential type errors before runtime. As part of the `typeshed` project, `types-tqdm` versions are frequently released, often daily, to track changes and updates in the upstream `tqdm` library.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic `tqdm` usage. Installing `types-tqdm` allows static type checkers (like MyPy, Pyright, or Pylance) to validate the type correctness of your interactions with `tqdm`'s functions and methods, for example, ensuring you pass an iterable to `tqdm` or correctly use its return values. The stubs themselves have no runtime effect; they are purely for static analysis.

from tqdm import tqdm
import time

def process_items(items):
    for item in tqdm(items, desc='Processing'):
        time.sleep(0.01) # Simulate work
        # Add type-sensitive operations here
        # For example, if item is expected to be a string:
        _ = item.upper()

if __name__ == '__main__':
    my_list = list(range(100))
    process_items(my_list)

    # To check types, run a type checker like MyPy:
    # pip install mypy
    # mypy your_script_name.py
    # The 'types-tqdm' package provides the necessary type definitions for 'tqdm'.

view raw JSON →