Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FORCE_COLOR in addition to MYPY_FORCE_COLOR #13806

Closed
hugovk opened this issue Oct 4, 2022 · 0 comments · Fixed by #13814
Closed

Support FORCE_COLOR in addition to MYPY_FORCE_COLOR #13806

hugovk opened this issue Oct 4, 2022 · 0 comments · Fixed by #13814
Assignees
Labels
feature topic-configuration Configuration files and flags

Comments

@hugovk
Copy link
Member

hugovk commented Oct 4, 2022

Feature

Force colour when the FORCE_COLOR environment variable is set.

Pitch

Mypy automatically adds colour to output for TTYs, or if the env var MYPY_FORCE_COLOR is set.

For example, GitHub Actions is not a tty but it's good to add colour to help read the logs.

FORCE_COLOR is used by many CLI tools and libraries.

It would be good if mypy forced colour output if either FORCE_COLOR or MYPY_FORCE_COLOR is set.

This helps avoid adding lots of separate env vars for each tool/CLI, for example:

env:
  FORCE_COLOR: 1 # Request colored output from CLI tools supporting it
  MYPY_FORCE_COLOR: 1 # MyPy's color enforcement
  PIP_DISABLE_PIP_VERSION_CHECK: 1
  PIP_NO_PYTHON_VERSION_WARNING: 1
  PIP_NO_WARN_SCRIPT_LOCATION: 1
  PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest`
  TOX_PARALLEL_NO_SPINNER: 1
  TOX_TESTENV_PASSENV: >-
    FORCE_COLOR
    MYPY_FORCE_COLOR
    NO_COLOR
    PY_COLORS
    PYTEST_THEME
    PYTEST_THEME_MODE

For reference:

@hugovk hugovk added the feature label Oct 4, 2022
@AlexWaygood AlexWaygood added the topic-configuration Configuration files and flags label Oct 4, 2022
@AlexWaygood AlexWaygood self-assigned this Oct 4, 2022
hauntsaninja pushed a commit that referenced this issue Oct 4, 2022
…not present (#13814)

Fixes #13806

This PR adds support for a FORCE_COLOR environment variable. If both
MYPY_FORCE_COLOR and FORCE_COLOR are present, mypy will continue to use
MYPY_FORCE_COLOR over FORCE_COLOR. However, if only FORCE_COLOR is set,
mypy will use that environment variable in much the same way it
currently uses MYPY_FORCE_COLOR.

MYPY_FORCE_COLOR appears to be undocumented and untested currently, so
this PR doesn't add any tests. However, @hugovk has tested this change
manually and using GitHub Actions, and reports that it appears to work
as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature topic-configuration Configuration files and flags
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants