Releases: ZechCodes/Bevy
Bevy 3.1.0-beta.12
Bevy 3.1.0-beta.12
This release includes improvements to the Bevy dependency injection framework.
Installation
pip install bevy==3.1.0-beta.12What's Changed
See the commit history for detailed changes in this release.
Full Changelog: v3.1.0-beta.11...v3.1.0-beta.12
Bevy 3.1.0-beta.11
Bevy 3.1.0-beta.11
This release includes improvements to the Bevy dependency injection framework.
Installation
pip install bevy==3.1.0-beta.11What's Changed
See the commit history for detailed changes in this release.
Full Changelog: v3.1.0-beta.10...v3.1.0-beta.11
Bevy 3.1.0-beta.10
Bevy 3.1.0-beta.10 Release 🚀
🌟 Major Features
Async-Native Dependency Resolution with find() and Result
- New
container.find()method: Returns aResult[T]type that can be resolved in sync or async contexts Resulttype: Deferred dependency resolution with.get()(sync) and.get_async()(async) methods- Benefit: Truly async-native dependency resolution with no thread overhead in async code
Async Function Injection
- Automatic async detection:
@injectableasync functions work seamlessly withcontainer.call() - Async-native injection: Dependencies are resolved using
await container.find()automatically - Benefit: Write async functions with dependency injection just like sync functions
Async-Native Hook Architecture
- Removed sync wrappers: Hooks now execute in native async context when using
find() - Real async work: Async hooks can perform I/O, delays, and other async operations efficiently
- Benefit: No unnecessary thread spawning when working in async contexts
🔧 Technical Improvements
Hook System
- Async-first execution:
HookManager.handle()andHookManager.filter()are now purely async - Sync compatibility: Sync hooks still work - automatically called within async context
- Pattern matching: Use match/case instead of isinstance for Optional checks
Container API
- Read-only
parentproperty: Clean API for accessing parent containers - Removed dead code: Cleaned up unused
_create_instanceand_call_post_injection_hookmethods
📚 Documentation Updates
- New Section: "Async-Native Dependency Resolution" in usage guide with best practices
- API Reference: Complete documentation for
Resulttype andfind()method - Hook Reference: Updated to clarify which hooks work in async-native architecture
- Best Practices: Added guidance on using
await container.find(T)instead ofcontainer.get(T)in async code
🧪 Testing & Quality
Test Coverage
- 7 new async function injection tests: Covering async functions with hooks, qualifiers, and factories
- Async hook verification: Tests confirm async hooks run in same async context (no thread overhead)
- Total: 179 tests passing (up from 172)
💡 Usage Examples
Async-Native Dependency Resolution:
from bevy import injectable, Inject, get_container
# In async code - truly async with no thread overhead
async def process_order(order_id: str):
container = get_container()
db = await container.find(Database)
cache = await container.find(Cache, qualifier="redis")
user = await db.get_user(order_id)
await cache.set(f"user:{order_id}", user)
# Async function injection
@injectable
async def send_notification(
user_id: str,
email: Inject[EmailService],
db: Inject[Database]
):
user = await db.get_user(user_id)
await email.send(user.email, "Welcome!")
# Call it - returns a coroutine
container = get_container()
await container.call(send_notification, user_id="123")Result Type:
# Get a Result for deferred resolution
result = container.find(Service)
# Resolve in async context - no thread overhead
instance = await result # Uses __await__
# OR
instance = await result.get_async()
# Resolve in sync context - runs async in thread
instance = result.get()⚠️ Breaking Changes
Injection Lifecycle Hooks (Minor Impact)
The following hooks are no longer called from sync container.call() in the async-native architecture:
INJECTION_REQUESTINJECTION_RESPONSEPOST_INJECTION_CALLMISSING_INJECTABLEFACTORY_MISSING_TYPE
Migration: Use dependency resolution hooks instead (GET_INSTANCE, GOT_INSTANCE, CREATE_INSTANCE, CREATED_INSTANCE, HANDLE_UNSUPPORTED_DEPENDENCY), which work in both sync and async contexts.
Impact: Low - these hooks were primarily used for observability, and most users don't use them.
🙏 Acknowledgments
Thank you to all contributors who made this release possible!
Full Changelog: View on GitHub
Installation: pip install bevy==3.1.0-beta.10
Feedback: Please report any issues or feedback on our GitHub Issues page.
Bevy 3.1.0-beta.9
Bevy 3.1.0-beta.9
Highlights
- Republished the async-aware injection system introduced in beta.8 to guarantee PyPI now ships the latest code.
- Keeps the streamlined
InjectableCallableflow so containers consistently orchestrate dependency resolution. - Retains expanded auto-injection coverage across instance, class, and static methods for parity with the docs.
Upgrading
Install or upgrade with:
pip install --upgrade bevy==3.1.0-beta.9Contributors
Bevy 3.1.0-beta.8
Bevy 3.1.0-beta.8
Highlights
- Reworked dependency-injection flow around a new
InjectableCallablewrapper so injection metadata and execution live in one place. - Simplified
Container.callto delegate toInjectableCallable, ensuring the invoking container always drives injection. - Fixed global-container handling when registries are used via context managers and documented the double-injection edge case with extra decorators.
- Added comprehensive tests covering auto-injection for instance, class, and static methods plus updated documentation to reflect the new behaviour.
Upgrading
Install or upgrade with:
pip install --upgrade bevy==3.1.0-beta.8Contributors
Bevy 3.1.0-beta.7
Bevy 3.1.0-beta.7
This release includes improvements to the Bevy dependency injection framework.
Installation
pip install bevy==3.1.0-beta.7What's Changed
See the commit history for detailed changes in this release.
Full Changelog: v3.1.0-beta.6...v3.1.0-beta.7
Bevy 3.1.0-beta.6
Bevy 3.1.0-beta.6
This release includes improvements to the Bevy dependency injection framework.
Installation
pip install bevy==3.1.0-beta.6What's Changed
See the commit history for detailed changes in this release.
Full Changelog: v3.1.0-beta.5...v3.1.0-beta.6
Bevy 3.1.0-beta.5
Bevy 3.1.0-beta.5
This release includes improvements to the Bevy dependency injection framework.
Installation
pip install bevy==3.1.0-beta.5What's Changed
See the commit history for detailed changes in this release.
Full Changelog: v3.1.0b4...v3.1.0-beta.5
Bevy 3.1.0b4
Bevy 3.1.0b4
This release includes improvements to the Bevy dependency injection framework.
Installation
pip install bevy==3.1.0b4What's Changed
See the commit history for detailed changes in this release.
What's Changed
- feat: Complete dependency injection system overhaul with type-safe Inject[T] syntax by @ZechCodes in #10
- Fix injection precedence and qualified dependency error handling by @ZechCodes in #12
- Add comprehensive container branching documentation by @ZechCodes in #13
Full Changelog: v3.0.0b9...v3.1.0b4
v3.1.0b1
Bevy 3.1.0-beta.1 Release 🚀
We're excited to announce the release of Bevy 3.1.0-beta.1, featuring a major overhaul of the dependency injection system with modern Python 3.12+ features and significant new functionality!
🌟 Major Features
Factory-Based Caching System
- Intelligent Caching: Factory functions now serve as cache keys, ensuring same factory = same instance
- Configurable Behavior: Control caching with
cache_factory_resultparameter inOptionsclass - Performance Optimization: Eliminates redundant factory calls while maintaining flexibility for testing scenarios
- Unified Architecture: Merged factory cache into main instances cache for simplified container management
Modern Type System Overhaul
- Python 3.12+ Type Alias: Replaced
dependency()with cleanInject[T]syntax - Rich Options Support: Enhanced
Optionsclass with factory caching controls - Type-Safe Annotations: Full IDE support with modern Python type hints
- Qualified Dependencies: Support for multiple implementations with string qualifiers
🔧 Technical Improvements
Enhanced Container System
- Unified Cache Architecture: Single instances cache supporting Type, (Type, qualifier), and Callable keys
- Parent Container Inheritance: Factory cache properly inherited across container branches
- Improved Error Handling: Better error messages with proper context and parameter names
- Thread Safety Improvements: Enhanced concurrent access patterns
Developer Experience
- Comprehensive Documentation: Updated API docs, guides, and quickstart for 3.1 features
- Rich Hook Context: Enhanced injection hooks with detailed execution context
- Better Debugging: Improved debug logging and error reporting
- Modern Syntax: Clean, readable dependency injection patterns
📚 Documentation Updates
- Complete API Documentation: Updated for all new 3.1 features
- Enhanced Quickstart Guide: Added factory caching examples and best practices
- Migration Examples: Clear examples showing 3.0 → 3.1 syntax changes
- Comprehensive Guides: Updated index and navigation structure
💡 Usage Examples
Before (3.0):
from bevy import dependency, inject
@inject
def process_data(
service: UserService = dependency(),
logger: Logger = dependency(lambda: Logger("app"))
):
return service.process()After (3.1):
from bevy import injectable, auto_inject, Inject
from bevy.injection_types import Options
@auto_inject
@injectable
def process_data(
service: Inject[UserService],
logger: Inject[Logger, Options(default_factory=lambda: Logger("app"))]
):
return service.process()Factory Caching:
@injectable
def create_expensive_service() -> DatabaseService:
return DatabaseService(connect_to_database())
@injectable
def handler_a(service: Inject[DatabaseService, Options(default_factory=create_expensive_service)]):
return service.query("SELECT * FROM users")
@injectable
def handler_b(service: Inject[DatabaseService, Options(default_factory=create_expensive_service)]):
return service.query("SELECT * FROM products")
# Both handlers share the same DatabaseService instance!Qualified Dependencies:
container.add(Database, DatabaseConnection("primary"), qualifier="primary")
container.add(Database, DatabaseConnection("backup"), qualifier="backup")
@injectable
def data_processor(
primary_db: Inject[Database, Options(qualifier="primary")],
backup_db: Inject[Database, Options(qualifier="backup")]
):
return f"Using {primary_db.name} with {backup_db.name} backup"🔄 Migration Guide
- Update Imports: Replace
dependency()imports withInjectandOptions - Update Syntax: Convert
param: Type = dependency()toparam: Inject[Type] - Factory Options: Use
param: Inject[Type, Options(default_factory=func)]instead ofparam: Type = dependency(func) - Decorator Order: Ensure
@injectablecomes after@auto_injectif using both
⚠️ Breaking Changes
- Removed:
dependency()function (replaced withInject[T]syntax) - Changed: Decorator configuration now uses modern
@injectabledecorator - Required: Python 3.12+ for full type alias support
🙏 Acknowledgments
This release represents a significant modernization of Bevy's dependency injection system, bringing it in line with current Python best practices while maintaining the simplicity and power that makes Bevy great.
Full Changelog: View on GitHub
Installation: pip install bevy==3.1.0b1
Feedback: Please report any issues or feedback on our GitHub Issues page.