Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Sync progress flushes #492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
Loading
from
Open

Sync progress flushes #492

wants to merge 7 commits into from

Conversation

tony
Copy link
Member

@tony tony commented Jun 20, 2025

Summary by Sourcery

Document TTY limitation for git progress output and introduce tests for the run module

Enhancements:

  • Add comment explaining why git progress outputs newlines instead of carriage returns when stderr is not a TTY

Tests:

  • Introduce tests for the internal run module to validate process polling and progress callbacks

Copy link

sourcery-ai bot commented Jun 20, 2025

Reviewer's Guide

This PR inserts explanatory comments in run.py detailing why Git’s progress output uses new lines when stderr isn’t a TTY (and why switching to a pseudo-TTY would require deeper subprocess changes), and it scaffolds a new test file stub for run.py.

File-Level Changes

Change Details Files
Clarify Git progress output behavior when not on a TTY
  • Added notes on stderr TTY detection and its effect on progress formatting
  • Described that without a pseudo-TTY, Git emits lines instead of carriage returns
  • Explained that supporting proper in-place updates would need substantial subprocess handling changes
src/libvcs/_internal/run.py
Add empty test module for run.py
  • Created new test file stub to support future run module tests
tests/_internal/test_run.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @tony - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

)

# Verify we got multiple chunks
assert len(captured_chunks) > 0, "Should receive progress chunks"
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): Simplify sequence length comparison (simplify-len-comparison)

)

# Check that output is fragmented
assert len(captured_chunks) > 0, "Should capture output"
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Simplify sequence length comparison (simplify-len-comparison)

Suggested change
assert len(captured_chunks) > 0, "Should capture output"
assert captured_chunks, "Should capture output"


# In current implementation, all stderr is read in one chunk
# This demonstrates the buffering issue
assert len(captured_chunks) >= 1, "Should get at least 1 chunk"
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Simplify sequence length comparison (simplify-len-comparison)

Suggested change
assert len(captured_chunks) >= 1, "Should get at least 1 chunk"
assert captured_chunks, "Should get at least 1 chunk"

# Desired behavior: each complete line is one chunk

# For now, just verify we got output
assert len(captured_chunks) > 0, "Should capture output"
Copy link

Choose a reason for hiding this comment

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

suggestion (code-quality): Simplify sequence length comparison (simplify-len-comparison)

Suggested change
assert len(captured_chunks) > 0, "Should capture output"
assert captured_chunks, "Should capture output"

"Output should be fragmented into multiple chunks"
)

assert len(captured_chunks) > 0
Copy link

Choose a reason for hiding this comment

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

issue (code-quality): Simplify sequence length comparison (simplify-len-comparison)

@tony tony force-pushed the sync-progress-flushes branch from b505738 to b0b3cab Compare June 20, 2025 11:54
tony and others added 3 commits June 20, 2025 07:06
… behavior

- Add TestFlushingBehavior class with tests for:
  - Timing verification of immediate flushing
  - Unbuffered subprocess output handling
  - Carriage return overwrites for progress bars
  - ANSI escape sequence preservation
  - Git-style progress simulation
  - Mixed line endings (\n, \r, \r\n)
  - Large output streaming without blocking
  - stderr vs stdout stream separation

- Add TestRealWorldScenarios class covering:
  - npm-style progress with Unicode spinners
  - Long-running processes with periodic updates
  - Multi-line progress bars (Docker-style)
  - Binary/Unicode output handling
  - Interleaved stdout/stderr timing

- Add TestEdgeCases class for:
  - Empty output handling
  - stdout-only processes
  - Very long lines exceeding buffer size
  - Rapid output bursts
  - Callback exception handling

- Enhance existing tests with better type annotations
- Fix linting issues (imports, line length, docstrings)
- Follow libvcs testing conventions and patterns

These tests verify the current behavior of the run() function's
real-time output streaming via callbacks, including the 128-byte
chunking behavior and proper handling of control characters.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@tony tony force-pushed the sync-progress-flushes branch from b0b3cab to 4f85cd7 Compare June 20, 2025 12:06
tony and others added 4 commits June 20, 2025 08:32
…e progress updates

why: Commit 80b480e switched to text=True which interfered with carriage return handling,
causing git progress output to appear on separate lines instead of overwriting the same line.

what:
- Revert subprocess to text=False (bytes mode)
- Restore console_to_str() function for proper bytes-to-string conversion

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
… of broken fragmentation

why: Previous tests were verifying the broken 128-byte fragmentation behavior.
With the fix, we need tests that verify proper in-place progress streaming.

what:
- Update existing tests to verify correct behavior instead of broken fragmentation
- Add comprehensive TestStreamingFix class with tests for:
  * Line-by-line streaming without fragmentation
  * Real-time streaming with timing verification
  * Proper handling of long lines without breaking them

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
why: Fix mypy type errors and improve type safety in subprocess handling.
what:
- Add type annotations for lines and stderr_lines variables
- Add null checks for proc.stdout and proc.stderr before accessing readlines()
- Update ProgressCallbackProtocol to use str instead of t.AnyStr for consistency

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ations

why: Comply with 88-character line length limit for linting requirements.
what:
- Split long assert statement across multiple lines in line 438
- Break long string literal across multiple lines in line 965
- Update CallbackOutput type alias from t.AnyStr to str for consistency

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.