Fix stop_server coverage gap, add return types, unify console output#41
Open
tschm wants to merge 1 commit into
Open
Fix stop_server coverage gap, add return types, unify console output#41tschm wants to merge 1 commit into
tschm wants to merge 1 commit into
Conversation
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>
There was a problem hiding this comment.
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 forstop_server(). - Adds return type annotations for
stop_server() -> Noneand_repr_html_() -> str. - Introduces
_notify()and routes user-facing stdout messages through it (replacing scattered directprint()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.
096b0e5 to
49b90bf
Compare
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
Addresses three quality findings from a Rhiza quality assessment. All changes are confined to
src/pycharting/api/interface.pyandtests/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_globalsfixture usedglobal _active_server, which only rebinds the test module's imported copy and never touchesinterface._active_server. The running server therefore leaked across tests, leaving the no-server branch ofstop_server()uncovered and makingtest_status_when_no_serverintermittently fail. The fixture now resets the live module global (stop + setNone) before and after each test;test_stop_server_when_not_runningforces 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() -> Noneand_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 bareprint()calls. No bareprint()remains insrc/pycharting/; visible stdout behavior is preserved.Verification
make fmtmake typecheckmake docs-coveragemake deptrymake test🤖 Generated with Claude Code