Skip to main content

should-color

github pypi types

Determine if terminal output should be colored, respecting NO_COLOR and CLICOLOR environment variables.

On Unix, ANSI colors are enabled if the output is isatty. On Windows, ANSI colors are assumed to be unsupported unless or colorama is installed and enabled.

Example Usage

import sys
from should_color import should_color, apply_ansi_style

should_color(sys.stdout)
should_color(sys.stderr)
should_color('stdout')  # same as should_color(sys.stdout)
should_color('stderr')  # same as should_color(sys.stdout)
print(
    apply_ansi_style(
        "ERROR:",
        color="red",
        bold=True,
        # implicitly checks should_color('stdout'),
        # both these options are the implicit defaults if unspecified
        enabled='auto',
        file='stdout',
    ),
    "Fatal problem",
)

License

Licensed under either the Apache 2.0 License or MIT License at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Metadata

Release files for should-color 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for should-color 0.2.2
File Size Uploaded
should_color-0.2.2.tar.gz 12.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for should-color 0.2.2
File Interpreter ABI Platform
should_color-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 23.1 kB

Release files / should_color-0.2.2.tar.gz

Download URL should_color-0.2.2.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b56d107645283ddc31fb7dc71e62677c4fe35b980cdc865c8937dde3f64e14d0
BLAKE2b-256 checksum
How to use checksums
af0af29fbd113e793c43feb568028c3c5242739908b8798688a4211c3dea87c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / should_color-0.2.2-py3-none-any.whl

Download URL should_color-0.2.2-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5133dd699d7b08dea7b5e920a42b8cf4f858185247ad78e277aa6761055c4128
BLAKE2b-256 checksum
How to use checksums
050b6a8f3043f58002aa8f692a74015030c1865b11456634dd853a7990049db5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page