#923·doctest

Honor FORCE_COLOR and NO_COLOR environment variables

Author: RedBeard0531Created Jun 27, 2025Updated Jul 12, 2026
Labelstype/feature-proposalcategory/CLI

FORCE_COLOR and NO_COLOR are semi-standard ways to forcibly enable and disable colors that work across a number of programs (more than are listed on the page). It would be good if doctest also honored them.

Since there are multiple ways to choose whether to enable colors, I think the right precedence is the following (from strongest to weakest):

  1. The specific --force-colors flag and any other programmatic ways to control colors.
  2. FORCE_COLOR
  3. NO_COLOR (the order of 2 and 3 is debatable, but specifying both is rare and probably user error, so it likely doesn't matter)
  4. fallback to isatty() detection