Skip to content

fix: update stale interactive-loop snippets in implementation.md (#1167)#1168

Open
microsasa wants to merge 1 commit intomainfrom
fix/stale-interactive-loop-snippets-1167-1f114a4c63c0bc0a
Open

fix: update stale interactive-loop snippets in implementation.md (#1167)#1168
microsasa wants to merge 1 commit intomainfrom
fix/stale-interactive-loop-snippets-1167-1f114a4c63c0bc0a

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Closes #1167

Changes

Documentation (src/copilot_usage/docs/implementation.md)

  1. _read_line_nonblocking snippet — Updated to match the actual implementation that checks for empty readline() and raises EOFError("stdin closed") to prevent infinite polling.

  2. Fallback reader snippet — Added the except EOFError: break clause before except (ValueError, OSError): to reflect the actual control flow in _interactive_loop.

  3. Prose updates — Updated the "Non-blocking input with select()" subsection to mention that _read_line_nonblocking raises EOFError when stdin is closed, and updated the fallback section to explain that EOFError causes an immediate loop break rather than starting the fallback reader.

Tests (tests/test_docs.py)

Added test_read_line_nonblocking_doc_snippet_matches_implementation which:

  • Asserts EOFError appears in _read_line_nonblocking's source via inspect.getsource
  • Asserts except EOFError appears in _interactive_loop's source
  • Asserts EOFError appears in implementation.md

This prevents the docs from silently diverging from the implementation again.

Warning

⚠️ Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • astral.sh
  • pypi.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "astral.sh"
    - "pypi.org"

See Network Configuration for more information.

Generated by Issue Implementer · ● 7.4M ·

Update _read_line_nonblocking snippet to include EOFError raise on
closed stdin. Add 'except EOFError: break' clause to the fallback
reader snippet. Update surrounding prose to document the EOFError
early-exit path.

Add test_read_line_nonblocking_doc_snippet_matches_implementation to
tests/test_docs.py to prevent future drift between docs and code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 3, 2026 06:03
@microsasa microsasa added the aw Created by agentic workflow label May 3, 2026
@microsasa microsasa enabled auto-merge May 3, 2026 06:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the interactive-loop documentation to match the current copilot_usage.cli EOF handling behavior, and adds regression tests to prevent future doc/implementation drift.

Changes:

  • Refreshes implementation.md snippets/prose to include _read_line_nonblocking raising EOFError("stdin closed") and _interactive_loop breaking on EOFError.
  • Adds a new docs regression test that checks the implementation and documentation mention EOFError handling.
  • Imports inspect to enable source-based assertions in the new test.

Reviewed changes

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

File Description
tests/test_docs.py Adds a regression test using inspect.getsource to ensure EOFError handling remains reflected in both code and docs.
src/copilot_usage/docs/implementation.md Updates interactive-loop snippets and prose to accurately document EOFError behavior and fallback reader control flow.

Comment thread tests/test_docs.py
Comment on lines +317 to +320
# _read_line_nonblocking must mention EOFError (source or docstring)
read_src = inspect.getsource(cli_mod._read_line_nonblocking)
assert "EOFError" in read_src, (
"_read_line_nonblocking source must reference EOFError — "
Comment thread tests/test_docs.py
Comment on lines +324 to +329
# _interactive_loop must have 'except EOFError' near the
# ValueError/OSError fallback logic
loop_src = inspect.getsource(cli_mod._interactive_loop)
assert "except EOFError" in loop_src, (
"_interactive_loop source must contain 'except EOFError' — "
"the loop breaks immediately when stdin is closed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow

Projects

None yet

2 participants