Registry / type-stubs / types-termcolor

types-termcolor

JSON →
library1.1.6.2pypypiunverified

This is a PEP 561 type stub package for the 'termcolor' library, providing external type annotations for static analysis tools like mypy, pyright, and PyCharm. The current version is 1.1.6.2, released on March 27, 2023. These stub packages are automatically generated and released by the typeshed internal machinery, typically on a daily cadence, ensuring up-to-date type information for various Python libraries.

pip install types-termcolor
INSTALL
IMPORT
SIG · TYPES-TERMCOLOR
T
types-termcolor
type-stubspythonv1.1.6.2
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.6.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

colored
from termcolor_stubs import colored
from termcolor-stubs import colored

This quickstart demonstrates how to use the `colored` function and `cprint` from the `termcolor` library to output text with foreground colors, background highlights, and text attributes to the terminal. When `types-termcolor` is installed, it enables type checkers to provide hints and validate the usage of these functions, improving code quality and readability.

from termcolor import colored, cprint import sys # Basic usage of 'colored' print(colored('Hello, World!', 'red')) # Using 'colored' with background color and multiple attributes text_with_attributes = colored( "Hello, beautifully colored World!", "green", "on_red", attrs=["bold", "underline"] ) print(text_with_attributes) # Using 'cprint' for direct printing cprint("This is a blue and bold message.", "blue", attrs=["bold"]) # Example with error handling, printing to stderr in red try: raise ValueError("Something went wrong during processing!") except ValueError as e: cprint(f"Error: {e}", "white", "on_red", attrs=["bold"], file=sys.stderr)
Debug
Known issues
breakingIf you are using `termcolor` version 2.0.0 or newer, you should uninstall `types-termcolor`. As of version 2.0.0, the `termcolor` package includes its own inline type annotations, making this stub package redundant and potentially causing conflicts or issues with type checkers.
fix
Uninstall `types-termcolor` by running `pip uninstall types-termcolor`. Ensure your type checker is configured to use the inline types from `termcolor`.
affects: termcolor>=2.0.0
gotchaThe `types-termcolor` package provides *only* type stubs; it does not contain the runtime code for the `termcolor` library itself. Your program will not execute correctly without the actual `termcolor` library installed.
fix
Ensure the `termcolor` library is installed alongside `types-termcolor` by running `pip install termcolor`.
affects: all
gotcha`termcolor` relies on ANSI escape codes to produce colored output in the terminal. Not all terminals (e.g., older Windows Command Prompt or when piping output to certain tools) support these codes, which can result in raw escape sequences being printed instead of the intended colored text.
fix
Use a modern terminal emulator (e.g., Windows Terminal, most Linux/macOS terminals, VS Code integrated terminal). When piping output, some tools like `less` may require a `-r` flag to interpret raw ANSI escape sequences (e.g., `python script.py | less -r`).
affects: all
gotchaTypeshed stub packages, including `types-termcolor`, use a versioning scheme where parts of the version number correlate to the runtime package's version. While this aims for compatibility, aggressively pinning stub package versions might lead to incompatibilities if the runtime `termcolor` package updates independently, or cause you to miss valuable type stub improvements.
fix
Consider using flexible version specifiers for stub packages (e.g., `types-termcolor>=1.1,<1.2` if `termcolor>=1.1,<1.2` is used). Regularly review and update pinned stub versions to leverage improvements and maintain compatibility.
affects: all
Upgrade
Version history
1.1.6.2latest on PyPI · released Mar 28, 2023
Audit
Dependencies
termcolorrequired`types-termcolor` provides type stubs for the `termcolor` package; it does not offer runtime functionality itself. It is only beneficial if the `termcolor` library is also installed in your environment.
Agent activity
43 hits · last 30 days
node
36
OpenAI (training)
1
Resources