Colorama Typing Stubs

0.4.15.20260408 · active · verified Fri Apr 10

types-colorama provides PEP 561 compliant type stubs for the colorama library, enabling static type checking for colored terminal output. It is part of the typeshed project and aims to provide accurate annotations for colorama==0.4.*. Updates are frequent as it's part of the typeshed project, which releases stub packages to PyPI automatically, sometimes daily.

Warnings

Install

Imports

Quickstart

This example demonstrates basic usage of the colorama library. The `types-colorama` package, once installed, allows type checkers like MyPy or Pyright to validate the types and signatures of `init`, `Fore`, `Back`, and `Style` when imported from `colorama`.

import sys
from colorama import init, Fore, Style

# Initialize Colorama. For Windows, this is essential for ANSI escape codes.
# autoreset=True means that colors are automatically reset after each print statement.
init(autoreset=True)

print(Fore.RED + "This text is red!")
print(Fore.GREEN + "This text is green and will reset.")
print("This text is back to normal.")

# You can also use Style.RESET_ALL explicitly for fine-grained control
print(Fore.YELLOW + "Yellow text " + Style.BRIGHT + "and bright, then " + Style.RESET_ALL + "normal again.")

# To verify type checking, you could run mypy on this file:
# $ pip install mypy
# $ mypy your_script_name.py

view raw JSON →