Skip to content

Conversation

@tony
Copy link
Member

@tony tony commented Jun 19, 2024

Changes

Dev deps: Add pytest-asyncio

See also: https://github.com/pytest-dev/pytest-asyncio

Summary by Sourcery

Tests:

  • Add pytest-asyncio for testing asynchronous code.

@tony
Copy link
Member Author

tony commented Jan 11, 2025

@sourcery-ai review

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 11, 2025

Reviewer's Guide by Sourcery

This pull request adds pytest-asyncio to the development dependencies.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Added pytest-asyncio dependency
  • Added pytest-asyncio to the pyproject.toml file.
  • Updated poetry.lock file to reflect the new dependency
pyproject.toml
poetry.lock

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

@tony tony force-pushed the asyncio-experiment branch from 55536e9 to 5322218 Compare January 11, 2025 20:56
@tony tony force-pushed the asyncio-experiment branch 3 times, most recently from 76dbac5 to a133af8 Compare February 22, 2025 23:46
@codecov
Copy link

codecov bot commented Feb 22, 2025

Codecov Report

❌ Patch coverage is 66.58304% with 666 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.72%. Comparing base (371fd80) to head (d06acda).

Files with missing lines Patch % Lines
src/libvcs/cmd/_async/git.py 38.39% 134 Missing and 81 partials ⚠️
src/libvcs/sync/_async/git.py 51.69% 94 Missing and 20 partials ⚠️
tests/sync/_async/test_svn.py 0.00% 97 Missing ⚠️
src/libvcs/cmd/_async/hg.py 23.46% 50 Missing and 25 partials ⚠️
tests/cmd/_async/test_svn.py 0.00% 73 Missing ⚠️
src/libvcs/sync/_async/base.py 33.92% 30 Missing and 7 partials ⚠️
src/libvcs/_internal/async_run.py 69.33% 22 Missing and 1 partial ⚠️
src/libvcs/sync/_async/hg.py 48.14% 14 Missing ⚠️
src/libvcs/pytest_plugin.py 29.41% 12 Missing ⚠️
src/libvcs/_internal/async_subprocess.py 96.20% 3 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #467      +/-   ##
==========================================
+ Coverage   53.22%   56.72%   +3.49%     
==========================================
  Files          38       53      +15     
  Lines        5676     7669    +1993     
  Branches     1063     1293     +230     
==========================================
+ Hits         3021     4350    +1329     
- Misses       2144     2672     +528     
- Partials      511      647     +136     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tony tony force-pushed the asyncio-experiment branch from a133af8 to bbaaf11 Compare December 29, 2025 11:36
tony added 3 commits December 29, 2025 05:36
why: Document design decisions and implementation strategy for async support
what:
- Study sources from CPython asyncio, pytest, pytest-asyncio
- DOs and DON'Ts for subprocess, API design, testing, typing
- 5-phase implementation plan (subprocess → run → cmd → sync → fixtures)
- Test strategy with 100% coverage goal and NamedTuple parametrization
- File structure for _async/ subpackages
why: Document patterns and conventions for async support implementation
what:
- Architecture section showing _async/ subpackage structure
- Subprocess patterns (communicate, timeout, BrokenPipeError)
- API conventions (Async prefix, async-only callbacks, shared logic)
- Testing patterns (strict mode, function-scoped loops, NamedTuple)
- Anti-patterns to avoid (polling, blocking calls, loop closure)
@tony
Copy link
Member Author

tony commented Dec 29, 2025

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@tony tony force-pushed the asyncio-experiment branch from 0d94194 to b4b2226 Compare December 29, 2025 16:03
tony added 9 commits December 29, 2025 10:04
why: Foundation for asyncio support - async equivalent of SubprocessCommand
what:
- Add AsyncSubprocessCommand dataclass with run(), check_output(), wait() methods
- Add AsyncCompletedProcess result type mirroring subprocess.CompletedProcess
- Use asyncio.create_subprocess_exec for secure non-shell execution
- Use asyncio.wait_for for timeout handling (Python 3.10+ compatible)
- Configure pytest-asyncio strict mode in pyproject.toml
- Add comprehensive tests with 100% coverage (22 tests, all passing)
why: Ensure code quality before commits and phase completion
what:
- Add "Verification Before Commit" section
- Document required pipeline: ruff check, ruff format, mypy, pytest
- All checks must pass before committing
why: Ensure Phase 1 passes full verification pipeline
what:
- Add None checks before .strip() calls on result.stdout in tests
- Apply ruff formatting to list comprehension in _args_as_list()
…acks

why: Phase 2 of asyncio support - async_run() enables non-blocking command
execution with real-time progress callbacks for VCS operations.

what:
- Add AsyncProgressCallbackProtocol for type-safe async callbacks
- Add wrap_sync_callback() helper for users with existing sync callbacks
- Add async_run() function matching sync run() API with:
  - StreamReader.readline() for line-by-line stderr streaming
  - Timeout support via asyncio.wait_for()
  - CommandError/CommandTimeoutError on failures
- Add comprehensive tests (19 tests) with NamedTuple parametrization
why: Phase 3 of asyncio support - AsyncGit enables non-blocking git
operations for concurrent workflows.

what:
- Add AsyncGit class with core git commands:
  - run(), clone(), fetch(), checkout(), status()
  - rev_parse(), symbolic_ref(), rev_list(), show_ref()
  - reset(), rebase(), version()
- Add AsyncGitSubmoduleCmd for submodule init/update
- Add AsyncGitRemoteManager for remote ls/show/add/remove/get_url
- Add AsyncGitStashCmd for stash ls/save/pop/drop/clear
- Add comprehensive tests (26 tests) with concurrency tests
- All methods support timeout parameter for cancellation
why: Phase 4 of asyncio support - AsyncGitSync enables non-blocking
repository clone and update operations.

what:
- Add AsyncBaseSync base class with async run() and ensure_dir()
- Add AsyncGitSync with full sync API:
  - obtain(): Clone repository and init submodules
  - update_repo(): Fetch, checkout, rebase with stash handling
  - set_remotes(), remote(), remotes_get(): Remote management
  - get_revision(), status(), get_git_version(): Status queries
- Reuse GitRemote, GitStatus, exceptions from sync.git module
- Add comprehensive tests (15 tests) including concurrency tests
- 659 total tests pass (17 new)
why: Provide async fixture for testing with AsyncGitSync.
what:
- Add async_git_repo fixture using @pytest_asyncio.fixture
- Conditional import for backward compatibility without pytest-asyncio
why: Verify the new fixture works correctly.
what:
- Test fixture provides initialized repo
- Test status() and remotes_get() work
why: Warning appears despite config being set (timing issue).
tony added 24 commits December 29, 2025 10:04
why: Provide async Mercurial command wrapper.
what:
- Async run(), clone(), update(), pull() methods
- Uses async_run() from _internal/async_run.py
why: Provide async Mercurial repository synchronization.
what:
- Async obtain(), get_revision(), update_repo() methods
- Uses AsyncHg command class
why: Make new Hg async classes importable.
why: Verify AsyncHg functionality.
what:
- Test run, clone, update, pull methods
- 10 test cases
why: Verify AsyncHgSync functionality.
what:
- Test obtain, get_revision, update_repo methods
- 6 test cases
why: Enable async SVN operations for Phase 7 of asyncio support
what:
- Add AsyncSvn class with async run(), checkout(), update(), info()
- Include SVN-specific auth: username, password, trust_server_cert
- Default non_interactive=True for automation
why: Complete Phase 7 asyncio support with repository synchronization
what:
- Add AsyncSvnSync inheriting from AsyncBaseSync
- Implement async obtain(), update_repo(), get_revision()
- Support SVN auth credentials (username, password, svn_trust_cert)
why: Make new async classes available via package imports
what:
- Add AsyncSvn to cmd/_async/__init__.py
- Add AsyncSvnSync to sync/_async/__init__.py
why: Verify async SVN command operations
what:
- Add TestAsyncSvn for init, repr, run tests
- Add TestAsyncSvnCheckout for checkout operations
- Add TestAsyncSvnUpdate and TestAsyncSvnInfo tests
why: Verify async SVN repository synchronization
what:
- Add TestAsyncSvnSync for init, repr, auth tests
- Add TestAsyncSvnSyncObtain for checkout operations
- Add TestAsyncSvnSyncUpdateRepo and get_revision tests
why: Document AsyncSvn and AsyncSvnSync completion
what:
- Add Phase 7 row to implementation status table
why: Enable async doctests to use asyncio.run()
what:
- Import asyncio module
- Add asyncio to doctest_namespace in add_doctest_fixtures
why: Doctests were commented out and never executed
what:
- async_subprocess.py: Uncomment asyncio.run() calls, fix expected bytes output
- async_run.py: Uncomment asyncio.run() call, convert callback example to code-block
why: Prevent workarounds that bypass doctest execution
what:
- All functions/methods MUST have working doctests
- Never comment out asyncio.run() or similar calls
- Never convert to code-blocks (they don't run)
- Stop and ask for help if doctests can't be made to work
- Document available doctest_namespace fixtures
- Add async doctest pattern examples
why: +SKIP is just another workaround that doesn't test anything
what:
- Remove +SKIP from available tools
- Explicitly state +SKIP is not permitted
- Reference skip_if_binaries_missing for VCS availability
why: Doctests were commented out and never executed
what:
- cmd/_async/git.py: Use tmp_path and create_git_remote_repo fixtures
- cmd/_async/hg.py: Use create_hg_remote_repo fixture
- cmd/_async/svn.py: Use create_svn_remote_repo fixture
- sync/_async/git.py: Use create_git_remote_repo fixture
- sync/_async/hg.py: Use create_hg_remote_repo fixture
- sync/_async/svn.py: Use create_svn_remote_repo fixture

All doctests now actually run and test real functionality.
why: Success criterion #4 - "Documentation updated with async examples"
what:
- Add comprehensive async topic guide with working doctests
- Cover: why async, basic usage, concurrent operations, callbacks
- Include comparison tables, error handling, API reference
- Add to topics toctree
why: Make async APIs discoverable from project landing page
what:
- Add "Async Support" section with examples
- Show basic AsyncGitSync usage
- Show concurrent clone pattern with asyncio.gather
why: New users need to see async option in getting started docs
what:
- quickstart.md: Add "Async Usage" section with AsyncGit, AsyncGitSync
- pytest-plugin.md: Add "Async Fixtures" section documenting
  async_git_repo, pytest-asyncio configuration, usage examples
why: Document internal async APIs alongside sync equivalents
what:
- Create async_run.md with automodule reference
- Create async_subprocess.md with automodule reference
- Update internals/index.md toctree
why: Help users discover async equivalents from sync API docs
what:
- cmd/index.md: Add "Async Variants" section listing AsyncGit, AsyncHg, AsyncSvn
- sync/index.md: Add "Async Variants" section listing AsyncGitSync, AsyncHgSync, AsyncSvnSync
@tony tony force-pushed the asyncio-experiment branch from b4b2226 to c4e14a5 Compare December 29, 2025 16:04
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.

2 participants