python / python/mypy

MYPY_FORCE_COLOR only colours output on Windows, not macOS/Ubuntu

Open
#13,817 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-configuration
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Bug Report

When using MYPY_FORCE_COLOR (or FORCE_COLOR with master) on GitHub Actions (which is not a tty), colour only shows up for Windows, and not for Ubuntu or macOS.

To Reproduce

Test with a worklflow something like this:

name: Test

on: [push, pull_request, workflow_dispatch]

env:
  MYPY_FORCE_COLOR: 1

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        python-version: [
          "3.7",
          "3.10",
        ]
        os: [
          windows-latest,
          macOS-latest,
          ubuntu-latest,
        ]

    steps:
      - uses: actions/checkout@v3

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          python -m pip install -U pip
          python -m pip install mypy

      - name: Test
        run: |
          mypy test.py

Expected Behavior

Colour output for all three operating systems.

Actual Behavior

Colour output only for Windows:

image

And not for Ubuntu:

image

Nor macOS:

image

For example: https://github.com/hugovk/test/actions/runs/3185917456

Your Environment

  • Mypy version used: 0.982
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.7 and 3.10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided GitHub Actions workflow with MYPY_FORCE_COLOR set across Windows, macOS, and Ubuntu, then trace the command-line color handling used by mypy. Done means forced color output appears consistently on all three operating systems, including when the command is not running in a TTY.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.