refactor(reporters): remove cancel_event from progress reporters

Thread cancel_event explicitly through the parameter chain
(sync_run closure → download_book() → streaming calls) instead of
stashing it on reporter objects as shared state. Remove the
cancel_event attribute from both PlainTextReporter and
ProgressReporter — cancellation is not a reporting concern.

Closes #39

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
AlexKuceraandClaude Opus 4.6 committed 2026-06-05 18:45:27 +02:00
1 parent caca930c7c
commit 2930d163b2
9 files changed
+154 -9

No files matched your search

+25
View File
@@ -1401,4 +1401,29 @@ class TestBoundCallableFromStartDownload:
sig = inspect.signature(reporter.update)
assert "task_id" not in sig.parameters, (
"update() should not expose task_id; use bound callable from start_download()"
)
class TestReporterNoCancelEvent:
"""Issue #39: Reporters must not carry cancellation state.
cancel_event flows through explicit parameters (sync_run → download_book →
streaming calls), NOT through reporter attributes.
"""
@pytest.mark.parametrize("reporter_cls", [PlainTextReporter, ProgressReporter])
def test_reporter_has_no_cancel_event_attribute(self, reporter_cls):
"""Neither reporter class exposes cancel_event on its public interface."""
reporter = reporter_cls()
assert not hasattr(reporter, "cancel_event"), (
f"{reporter_cls.__name__} must not have cancel_event attribute (Issue #39)"
)
@pytest.mark.parametrize("reporter_cls", [PlainTextReporter, ProgressReporter])
def test_reporter_init_signature_has_no_cancel_event(self, reporter_cls):
"""cancel_event is not a constructor parameter."""
import inspect
sig = inspect.signature(reporter_cls.__init__)
assert "cancel_event" not in sig.parameters, (
f"{reporter_cls.__name__}.__init__ must not accept cancel_event (Issue #39)"
)