-
Notifications
You must be signed in to change notification settings - Fork 3
Add support for sync functions and context managers in Depends
#172
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
Conversation
Enable dependency injection for both sync and async code to simplify testing and allow integration with existing synchronous libraries. Dependencies now support: - Sync functions returning values - Sync context managers (@contextmanager) - Async functions (existing) - Async context managers (existing) All dependency types work seamlessly together with automatic detection and proper resource cleanup. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @desertaxle's task —— View job Code Review: Add support for sync functions and context managers in
|
|
📚 Documentation has been built for this PR! You can download the documentation directly here: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #172 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 34 34
Lines 4834 5047 +213
Branches 265 267 +2
==========================================
+ Hits 4834 5047 +213
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Replace examples showing blocking operations (file I/O, locks) with non-blocking patterns: - Pure computations (config merging, param building) - In-memory operations (dict/set access) - Quick transformations Add clear guidance that sync dependencies should NEVER include blocking I/O operations. All I/O must use async dependencies. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Depends
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.
Beautiful!
Summary
Enables dependency injection for both synchronous and asynchronous code, making it easier to:
Important: Sync dependencies should NOT include blocking I/O. Use async dependencies for any I/O operations.
Changes
Depends()now accepts sync functions, sync context managers (@contextmanager), async functions, and async context managers (@asynccontextmanager)Examples
Sync dependency - pure computation
Async dependency - I/O operations
What NOT to do
Use Cases
Best for sync dependencies:
Use async dependencies for:
awaitTesting
test_dependencies.pycovering all sync scenariostest_fundamentals.pyto document the feature🤖 Generated with Claude Code