{"id":2824,"library":"types-colorama","title":"Colorama Typing Stubs","description":"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.","status":"active","version":"0.4.15.20260408","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","colorama","terminal","console","typeshed"],"install":[{"cmd":"pip install types-colorama","lang":"bash","label":"Install"}],"dependencies":[{"reason":"Runtime library for which these are type stubs.","package":"colorama","optional":false}],"imports":[{"symbol":"init","correct":"from colorama import init"},{"symbol":"Fore","correct":"from colorama import Fore"},{"symbol":"Back","correct":"from colorama import Back"},{"note":"types-colorama is a stub-only package; its symbols are provided for type checkers when importing from the runtime 'colorama' package.","wrong":"from types_colorama import Style","symbol":"Style","correct":"from colorama import Style"}],"quickstart":{"code":"import sys\nfrom colorama import init, Fore, Style\n\n# Initialize Colorama. For Windows, this is essential for ANSI escape codes.\n# autoreset=True means that colors are automatically reset after each print statement.\ninit(autoreset=True)\n\nprint(Fore.RED + \"This text is red!\")\nprint(Fore.GREEN + \"This text is green and will reset.\")\nprint(\"This text is back to normal.\")\n\n# You can also use Style.RESET_ALL explicitly for fine-grained control\nprint(Fore.YELLOW + \"Yellow text \" + Style.BRIGHT + \"and bright, then \" + Style.RESET_ALL + \"normal again.\")\n\n# To verify type checking, you could run mypy on this file:\n# $ pip install mypy\n# $ mypy your_script_name.py","lang":"python","description":"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`."},"warnings":[{"fix":"Always try to keep the installed `colorama` library version compatible with the `types-colorama` stub version. Review `types-colorama` release notes for targeted `colorama` versions.","message":"The `types-colorama` package aims to provide accurate type annotations for `colorama==0.4.*`. Using it with significantly different major or minor versions of the `colorama` runtime library may result in incorrect type checking errors or missed type issues due to API discrepancies.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your code imports directly from the `colorama` package (e.g., `from colorama import Fore`), not from `types_colorama`.","message":"`types-colorama` is a stub-only package and provides no runtime functionality. It should not be imported or used directly in your application's code. Its sole purpose is to provide type hints for static analysis tools like MyPy or Pyright when you import and use the actual `colorama` library.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Include `from colorama import init; init()` or `from colorama import just_fix_windows_console; just_fix_windows_console()` in your application's entry point, particularly if targeting Windows.","message":"For `colorama` to function correctly and display colored output on Windows terminals, `colorama.init()` (or `colorama.just_fix_windows_console()` for `colorama >= 0.4.6`) must be called at the start of your program. While `types-colorama` will correctly type check these calls, its omission in your runtime code will lead to plain text output on Windows, not a type error.","severity":"gotcha","affected_versions":"All versions of colorama, especially on Windows"},{"fix":"To ensure stability in type checking results, consider pinning `types-colorama` to a specific version (e.g., `types-colorama==0.4.15.20260408`) in your project's dependencies.","message":"Stubs are maintained in the typeshed repository and released frequently. While this generally means up-to-date types, occasional breaking changes in type definitions may occur between stub package versions, even if the runtime library's API has not changed. This can cause your type checker to report new errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}