Skip to content

Releases: ZechCodes/Bevy

Bevy 3.1.0-beta.12

03 Oct 17:54
607a345

Choose a tag to compare

Bevy 3.1.0-beta.12 Pre-release
Pre-release

Bevy 3.1.0-beta.12

This release includes improvements to the Bevy dependency injection framework.

Installation

pip install bevy==3.1.0-beta.12

What'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

02 Oct 01:42
1486062

Choose a tag to compare

Bevy 3.1.0-beta.11 Pre-release
Pre-release

Bevy 3.1.0-beta.11

This release includes improvements to the Bevy dependency injection framework.

Installation

pip install bevy==3.1.0-beta.11

What'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

01 Oct 23:15
eb85900

Choose a tag to compare

Bevy 3.1.0-beta.10 Pre-release
Pre-release

Bevy 3.1.0-beta.10 Release 🚀

🌟 Major Features

Async-Native Dependency Resolution with find() and Result

  • New container.find() method: Returns a Result[T] type that can be resolved in sync or async contexts
  • Result type: 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: @injectable async functions work seamlessly with container.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() and HookManager.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 parent property: Clean API for accessing parent containers
  • Removed dead code: Cleaned up unused _create_instance and _call_post_injection_hook methods

📚 Documentation Updates

  • New Section: "Async-Native Dependency Resolution" in usage guide with best practices
  • API Reference: Complete documentation for Result type and find() method
  • Hook Reference: Updated to clarify which hooks work in async-native architecture
  • Best Practices: Added guidance on using await container.find(T) instead of container.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_REQUEST
  • INJECTION_RESPONSE
  • POST_INJECTION_CALL
  • MISSING_INJECTABLE
  • FACTORY_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

19 Sep 21:52
1bb6d80

Choose a tag to compare

Bevy 3.1.0-beta.9 Pre-release
Pre-release

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 InjectableCallable flow 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.9

Contributors

Bevy 3.1.0-beta.8

19 Sep 02:26
d3612c4

Choose a tag to compare

Bevy 3.1.0-beta.8 Pre-release
Pre-release

Bevy 3.1.0-beta.8

Highlights

  • Reworked dependency-injection flow around a new InjectableCallable wrapper so injection metadata and execution live in one place.
  • Simplified Container.call to delegate to InjectableCallable, 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.8

Contributors

Bevy 3.1.0-beta.7

11 Sep 01:12
8cc531c

Choose a tag to compare

Bevy 3.1.0-beta.7 Pre-release
Pre-release

Bevy 3.1.0-beta.7

This release includes improvements to the Bevy dependency injection framework.

Installation

pip install bevy==3.1.0-beta.7

What'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

05 Sep 12:26
15439fa

Choose a tag to compare

Bevy 3.1.0-beta.6 Pre-release
Pre-release

Bevy 3.1.0-beta.6

This release includes improvements to the Bevy dependency injection framework.

Installation

pip install bevy==3.1.0-beta.6

What'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

04 Sep 23:36
e1fbeda

Choose a tag to compare

Bevy 3.1.0-beta.5 Pre-release
Pre-release

Bevy 3.1.0-beta.5

This release includes improvements to the Bevy dependency injection framework.

Installation

pip install bevy==3.1.0-beta.5

What'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

28 Aug 15:12
e084e61

Choose a tag to compare

Bevy 3.1.0b4

This release includes improvements to the Bevy dependency injection framework.

Installation

pip install bevy==3.1.0b4

What'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

03 Jun 00:46

Choose a tag to compare

v3.1.0b1 Pre-release
Pre-release

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_result parameter in Options class
  • 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 clean Inject[T] syntax
  • Rich Options Support: Enhanced Options class 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

  1. Update Imports: Replace dependency() imports with Inject and Options
  2. Update Syntax: Convert param: Type = dependency() to param: Inject[Type]
  3. Factory Options: Use param: Inject[Type, Options(default_factory=func)] instead of param: Type = dependency(func)
  4. Decorator Order: Ensure @injectable comes after @auto_inject if using both

⚠️ Breaking Changes

  • Removed: dependency() function (replaced with Inject[T] syntax)
  • Changed: Decorator configuration now uses modern @injectable decorator
  • 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.