fix: disable Python 3.14 argparse colorization in tests - #17
Merged
Conversation
Python 3.14's argparse colorizes --help/usage output by default, honoring FORCE_COLOR (which CI sets globally for other tools). This broke test_doc_examples.py's flag-extraction regex, which can't match a flag glued to a preceding ANSI escape code, and baked colorized text into contree_cli.shell.repl.BUILTIN_HELP at import time. Set PYTHON_COLORS=0 in conftest.py before any contree_cli import, mirroring the existing CONTREE_HOME pattern.
The allowance was masking 103 real test failures caused by argparse's new colorized --help output; the prior commit fixes that at the root, so 3.14 gates the build like every other matrix leg.
insomnes
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test Python 3.14 on ubuntu-latestCI job was green only because that matrix leg isallow-failure: true— the actualpytestrun was failing with 103 failed tests (exit code 1), silently masked bycontinue-on-error.--help/usage output by default (stdlib_colorize.can_colorize()), and this repo's CI workflow setsFORCE_COLOR: "1"globally for other tools. Two symptoms:tests/test_doc_examples.py'sflag_lexicon()regex can't match a flag immediately glued to a preceding ANSI escape code (e.g.\x1b[36m--file-excludes), so it silently drops flags from the parsed lexicon.contree_cli.shell.repl.BUILTIN_HELPcallsArgumentParser.format_help()at module import time, baking the colorized (import-time) text into a module-level dict — a per-test fixture can't undo that afterward.PYTHON_COLORS=0intests/conftest.pybefore anycontree_cliimport (same pattern already used forCONTREE_HOME).PYTHON_COLORStakes precedence overFORCE_COLORin the stdlib's own precedence order, so this is a clean override regardless of what CI sets.Test plan
uv run --python 3.14 pytest -qunderFORCE_COLOR=1: 1943 passed, 6 skipped (previously 103 failed)uv run --python 3.10 pytest -qunderFORCE_COLOR=1: unaffected, still passes (confirms no behavior change on versions without argparse colorization)uv run ruff check/ruff format --check/mypy contree_cli: clean