-
Notifications
You must be signed in to change notification settings - Fork 11
Asyncio testing #467
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
base: master
Are you sure you want to change the base?
Asyncio testing #467
Conversation
7f69eab to
c480bb4
Compare
|
@sourcery-ai review |
Reviewer's Guide by SourceryThis 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
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
55536e9 to
5322218
Compare
76dbac5 to
a133af8
Compare
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
a133af8 to
bbaaf11
Compare
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)
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
0d94194 to
b4b2226
Compare
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).
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
b4b2226 to
c4e14a5
Compare
Changes
Dev deps: Add pytest-asyncio
See also: https://github.com/pytest-dev/pytest-asyncio
Summary by Sourcery
Tests: