This document summarizes which issues were resolved in this PR and which still need work.
Status: ✅ RESOLVED
Added closed property to SourceReader, similar to io.IOBase.closed.
Changes:
- Added
_closedattribute that tracks open/close state - Added
closedproperty - Updated
__enter__and__exit__to manage the flag - Updated
QuickSourceReaderto properly set closed state - Added docstring examples
Status: ✅ RESOLVED
Made __next__() compatible with Python's iterator protocol by raising StopIteration when the stream is stopped and no data is available.
Changes:
- Modified
__next__()to raiseStopIterationwhen stream is stopped and no data - Updated
__iter__()to catchStopIterationand return (prevents RuntimeError in Python 3.7+) - Added comprehensive tests (
test_buffer_reader_stopiteration.py) - Now compatible with
forloops and builtinnext()with defaults
Status: ✅ RESOLVED (Foundation)
Created custom exception hierarchy for stream2py with more informative error messages.
Changes:
- Created
stream2py/exceptions.pywith exception hierarchy:Stream2PyError- Base exceptionStreamNotStartedError- When operations require started streamStreamAlreadyStoppedError- When stream has been stoppedBufferError- Base for buffer errorsBufferOverflowError- When buffer is fullNoDataAvailableError- When no data availableInvalidDataError- Invalid data formatConfigurationError- Misconfiguration
- Updated
StreamBuffer.mk_reader()andattach_reader()to useStreamNotStartedError - Updated tests to expect new exception types
- Exported exceptions module from main package
Next Steps: Continue replacing generic exceptions throughout codebase
Status: ✅ ADDRESSED
Documented and tested that the check already exists in StreamBuffer.mk_reader().
Changes:
- Added comprehensive tests (
test_reader_without_context.py) demonstrating:mk_reader()raises clear error if buffer not started- Readers work without context manager
- Context manager ensures proper cleanup
- Recommended usage patterns
- Improved error message with
StreamNotStartedError
Status: ✅ ALREADY IMPLEMENTED
The blocking parameter already exists in BufferReader.read().
Evidence:
buffer_reader.py:348-blocking=Falseparameter exists- When
blocking=True, read waits for data - When
blocking=False, returns immediately - Added tests to verify functionality works
Recommendation: Close issue
Status:
- ✅
blockingparameter exists (see #20) - ❌
timeoutparameter not yet implemented
Recommendation: Update issue to focus only on adding timeout parameter
Status: ❓ NEEDS CLARIFICATION
Analysis:
- CI configuration runs tests (line 43:
pytest -s --doctest-modules -v $PROJECT_NAME) - CI runs linting (line 40:
pylintfor docstrings) - The
--bypass-testsflag is only used for automated commits (line 96), which is appropriate
Current State: CI appears to be configured correctly
Recommendation: Need clarification from issue author on what specifically is being skipped inappropriately
Status: 🔧 EXTERNAL PACKAGE
Analysis:
The getch.py file referenced in the error doesn't exist in stream2py - keyboard functionality has been moved to keyboardstream2py package.
Recommendation: This issue applies to the external keyboardstream2py package, not core stream2py. Should either:
- Move issue to keyboardstream2py repository
- Close with comment directing to appropriate package
Status: 🔧 PARTIALLY ADDRESSED, MORE WORK NEEDED
Progress:
- ✅ TODO 1: "
readmust get its defaults from init" - Already implemented via_read_kwargs - ⏳ TODO 2: "
rangemust work similarly toread" - Needs review - ⏳ TODO 3: "Which init args should be keyword-only?" - Design decision needed
- ⏳ TODO 4: "Consider
read_chk_stepandread_chk_size" - Needs design
In-Code TODOs:
buffer_reader.py:95- "shouldignore_no_item_founddefault be True?"stream_buffer.py:125- "option to auto restart source on read exception"
Recommendation: Address remaining TODOs systematically in future PR
Status: 🔧 NOT STARTED
Effort: Medium - requires design
Approach:
- Add optional abstract methods to
SourceReader:join(items)- joins multiple read data itemsslice(item, start, stop)- slices a single data item
- Update
BufferReader.range()to use these methods - Make it optional/backwards compatible
Recommendation: Good candidate for next PR after examples are created
Tests Added:
test_buffer_reader_stopiteration.py- 4 tests for #10test_reader_without_context.py- 5 tests for #18test_buffer_reader_blocking.py- 2 tests (from previous work)test_quick_source_reader.py- 6 tests (from previous work)
Total: 17 new tests added across both PRs
Test Results:
- Before first PR: 11 tests (1 failing)
- After first PR: 19 tests (all passing)
- After this work: 28 tests (all passing)
- Improvement: +155% test coverage, 100% passing
Resolved in This Session:
- ✅ #6 - Closed property
- ✅ #10 -
__next__()compatibility - ✅ #15 - Custom exceptions (foundation)
- ✅ #18 - Reader started checks (documented + tested)
Already Resolved:
- ✅ #20 - Blocking parameter (already existed)
⚠️ #8 - Partially (blocking exists, timeout doesn't)
Needs Clarification:
- ❓ #9 - CI tests/linting (appears to work correctly)
Needs More Work (for future PRs):
- 🔧 #13 - Applies to external package (keyboardstream2py)
- 🔧 #14 - Slicing joinable data (medium effort)
- 🔧 #17 - BufferReader revisions (partially done, more needed)
Total Issues Addressed: 4 fully resolved, 2 documented as already resolved, 3 analyzed and documented