Skip to content

mypy audit silently passes when FORCE_COLOR is set: ANSI output parses as zero findings; pr_gates skips env -i when versions match #4551

Closed

Description

@squid-protocol

Problem

The local mypy audit can silently pass on code that CI rejects. Found on PR #4550, and the likely cause of the earlier local-pass/CI-fail on #4500 and #4529.

  1. pr_gates.pinned_mypy_audit() uses the clean env -i pinned venv only when the local mypy version differs from tests/requirements-mypy.txt. When it matches (the shared selfscan venv has mypy 2.4.0), the audit runs in the caller's full environment.
  2. With FORCE_COLOR=3 and TERM=xterm-256color in that environment, mypy writes ANSI colour codes even into a pipe. tests/mypy_audit.py's _ERROR_LINE regex then matches nothing, parses zero findings and prints "no NEW type errors". This is a silent false pass (confirmed by bisecting the environment).
  3. "mypy used: …" is printed only on the pinned path, so the log does not show which mypy ran.

Acceptance criteria

  • mypy_audit.py makes colour impossible: pass --no-color-output (and/or set NO_COLOR=1, unset FORCE_COLOR/MYPY_FORCE_COLOR), and strip ANSI escapes before parsing.
  • The audit fails loudly (non-zero) when mypy produced output but zero lines parsed, or when mypy's own exit status contradicts the parsed result.
  • pr_gates always runs the audit in a clean environment (env -i plus the needed vars), whether or not the local version matches, and always prints "mypy used: ()".
  • Apply the same three checks to the ruff audit.
  • Regression test: with FORCE_COLOR=3 TERM=xterm-256color, a known type error is reported.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    ci-cd
    testing
    priority: high
    on Oct 6, 2026
  2. added
    scope:infra
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugci-cdpriority: highscope:infratesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions