Skip to content

Fix stop_server coverage gap, add return types, unify console output#41

Open
tschm wants to merge 1 commit into
alihaskar:masterfrom
tschm:fix-stop-server-coverage
Open

Fix stop_server coverage gap, add return types, unify console output#41
tschm wants to merge 1 commit into
alihaskar:masterfrom
tschm:fix-stop-server-coverage

Conversation

@tschm

@tschm tschm commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses three quality findings from a Rhiza quality assessment. All changes are confined to src/pycharting/api/interface.py and tests/test_interface.py.

Tracked in the fork at tschm#7, tschm#8, tschm#9.

Changes

7 — Test-isolation / coverage gap (interface.py:285)
The cleanup_globals fixture used global _active_server, which only rebinds the test module's imported copy and never touches interface._active_server. The running server therefore leaked across tests, leaving the no-server branch of stop_server() uncovered and making test_status_when_no_server intermittently fail. The fixture now resets the live module global (stop + set None) before and after each test; test_stop_server_when_not_running forces the no-server branch and asserts on the message. Coverage is back to 100% and deterministic across repeated runs.

8 — Return-type annotations
Added stop_server() -> None and _repr_html_() -> str, matching the rest of the public API surface.

9 — Unified console output
Routed all user-facing console output through a single _notify() helper instead of scattered bare print() calls. No bare print() remains in src/pycharting/; visible stdout behavior is preserved.

Verification

Gate Result
make fmt
make typecheck ✅ All checks passed
make docs-coverage ✅ 100%
make deptry ✅ No issues
make test ✅ 143 passed, 100.00% coverage (×3 consecutive runs)

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 25, 2026 16:53
Tracked in the fork at #7, #8,
#9.

#7 Test-isolation/coverage gap (interface.py:285): the cleanup_globals
fixture used `global _active_server`, which rebinds the test module's
imported copy and never touches `interface._active_server`. The running
server leaked across tests, leaving the no-server branch of stop_server()
uncovered and `test_status_when_no_server` intermittently failing. The
fixture now resets the live module global (stop + None); the no-server
test forces the branch and asserts on the message. Coverage is back to
100% and deterministic across runs.

#8 Add explicit return annotations: stop_server() -> None and
_repr_html_() -> str, matching the rest of the public API surface.

#9 Route all user-facing console output through a single _notify() helper
instead of scattered bare print() calls. No bare print() remains in
src/pycharting/; stdout behavior is preserved.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the stability and quality of the pycharting public API interface by fixing test isolation around the module-level server global, adding missing return type annotations, and centralizing user-facing console output.

Changes:

  • Fixes test isolation by resetting pycharting.api.interface._active_server (the live module global) before/after each test and adds a deterministic no-server branch test for stop_server().
  • Adds return type annotations for stop_server() -> None and _repr_html_() -> str.
  • Introduces _notify() and routes user-facing stdout messages through it (replacing scattered direct print() calls).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/test_interface.py Fixes global state cleanup to target the live interface module and adds deterministic coverage for the stop_server() no-op branch.
src/pycharting/api/interface.py Adds _notify() for centralized console output and adds missing return type annotations for public/Jupyter-facing functions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tschm tschm force-pushed the fix-stop-server-coverage branch from 096b0e5 to 49b90bf Compare June 25, 2026 16:55
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