Skip to content

Route color through the Outputter instead of mutating colorama globals - #369

Merged
danielfromearth merged 3 commits into
nasa:developfrom
sylvesterkaczmarek:feature/issue-366
Oct 1, 2026
Merged

danielfromearth merged 3 commits into
nasa:developfrom
sylvesterkaczmarek:feature/issue-366

Conversation

@sylvesterkaczmarek

@sylvesterkaczmarek sylvesterkaczmarek commented Sep 10, 2026 •

Copy link
Copy Markdown

Closes #366.

Description

Keep colors and ANSI width compensation on each Outputter, route section headings through that palette, and remove global colorama mutation. Use a per-write console wrapper so terminal conversion and redirected-output stripping do not replace the caller's standard streams.

Local test steps

  • pytest: 60 passed, 1 authenticated integration test deselected.
  • Ruff checks and formatting passed for changed Python files; git diff --check passed.
  • New regressions cover interleaved and threaded outputters, explicit ANSI input, exception cleanup, and unchanged standard streams. The five initial color-isolation regressions failed before the fix.

Overview of integration done

Existing CLI pseudo-terminal and alignment tests, text/CSV/Excel golden-file tests, and the offline ATL06 comparison passed unchanged. Live Earthdata and Windows-console testing were not run.

PR Acceptance Checklist

  • Unit tests added/updated and passing.
  • Integration testing with local CLI and committed fixtures.
  • CHANGELOG.md updated.
  • Documentation reviewed; no user-facing API or option change.

📚 Documentation preview 📚: https://ncompare--369.org.readthedocs.build/en/369/

@codecov

codecov Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.08%. Comparing base (900f6cf) to head (c3b1fed).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #369      +/-   ##
===========================================
+ Coverage    96.95%   97.08%   +0.12%     
===========================================
  Files            9        9              
  Lines          592      584       -8     
===========================================
- Hits           574      567       -7     
+ Misses          18       17       -1     
Flag Coverage Δ
python-3.11 97.08% <100.00%> (+0.12%) ⬆️
python-3.12 97.08% <100.00%> (+0.12%) ⬆️
python-3.13 97.08% <100.00%> (+0.12%) ⬆️
python-3.14 97.05% <100.00%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danielfromearth danielfromearth left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this great contribution! This looks good for #366. Two Outputters with opposite no_color do conflict on develop, and don't here.

61 passed, and the txt/CSV/xlsx outputs are byte-identical. The only difference I saw when verifying is three redundant trailing \x1b[0m, from the bare print(total_diff_count) in console.py that used to pick up colorama's global autoreset by accident. The count line seems cleaner without them.

Two small comments but otherwise looks good. Note that I haven't tested on Windows.

Comment thread CHANGELOG.md Outdated
Comment thread ncompare/printing.py Outdated
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
@sylvesterkaczmarek

Copy link
Copy Markdown
Author

Addressed both review comments in signed commit c3b1fed: added the changelog attribution/removed the extra blank line, and expanded the per-write comment to explain why sys.stdout is intentionally re-read for capsys/redirect_stdout. Full suite passes via uv run pytest.

@sylvesterkaczmarek

Copy link
Copy Markdown
Author

Verified the current head against both requested review points: the changelog entry includes the contributor attribution with no extra blank line, and the per-write AnsiToWin32 comment explains the capsys/redirect_stdout requirement. The branch is current with develop (0 behind), and uv run --group dev pytest -q tests/test_printing.py passes 10/10. I resolved the two addressed review threads; ready for re-review when convenient.

@sylvesterkaczmarek

Copy link
Copy Markdown
Author

@danielfromearth Both requested changes are present on current head c3b1fed: changelog attribution/spacing is corrected and the per-write sys.stdout comment documents the capsys/redirect_stdout requirement. The focused printing tests previously pass 10/10, all review threads are resolved, and there are no current failing or pending checks. Could you re-review the current head?

@danielfromearth
danielfromearth merged commit 3a4e8f9 into nasa:develop Oct 1, 2026
10 checks passed
@danielfromearth

Copy link
Copy Markdown
Collaborator

Thanks @sylvesterkaczmarek!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants