Releases: JasperSui/fastapi-injectable
v1.1.0
Changes
- bump: from 1.0.0 to 1.1.0 (#116) @JasperSui
- fix: add support for FastAPI's dependency override (#115) @GerardSoleCa
- Thank @GerardSoleCa for resolving #80!
📦 Dev Dependencies
- build(deps): bump codecov/codecov-action from 5.4.2 to 5.4.3 (#109) @dependabot[bot]
- build(deps-dev): bump charset-normalizer from 3.4.1 to 3.4.2 (#110) @dependabot[bot]
- build(deps-dev): bump click from 8.1.8 to 8.2.1 (#111) @dependabot[bot]
- build(deps-dev): bump watchfiles from 1.0.4 to 1.0.5 (#112) @dependabot[bot]
- build(deps-dev): bump decorator from 5.1.1 to 5.2.1 (#113) @dependabot[bot]
- build(deps-dev): bump urllib3 from 2.3.0 to 2.4.0 (#114) @dependabot[bot]
v1.0.0
FastAPI Injectable 1.0.0
This major release introduces comprehensive type checking support with a custom MyPy plugin, resolving the long-standing issue where static type checkers would complain about missing dependency parameters. This enhancement makes the library production-ready and marks our transition to stable 1.0.0.
Key Improvements
Full MyPy Type Checking Support
- Custom MyPy Plugin: Introduces
fastapi_injectable.mypy
plugin that makes dependency-injected parameters optional from the caller's perspective - Enhanced Type Safety: Static type checkers now understand that
Annotated[Type, Depends(...)]
parameters are automatically injected - Runtime Signature Modification: Decorator now modifies function signatures at runtime to support various tools and frameworks
- Seamless Integration: Enable type checking support by simply adding the plugin to your MyPy configuration
Developer Experience Improvements
- No More Type Checker Complaints: Eliminates
call-arg
errors when calling injectable functions without explicitly providing dependency parameters - Better IDE Support: Improved autocomplete and type inference in IDEs that use MyPy
- Production Ready: With full type checking support, the library is now ready for production use
Code Changes
- feat: add mypy plugin for enhanced type checking support (#106) @JasperSui
- fix: makes mypy plugin work even if the func_node is from deserialization (#108) @JasperSui
- bump: from 0.7.2 to 1.0.0 (#107) @JasperSui
Breaking Changes
None - this release maintains full backward compatibility while adding new functionality.
Getting Started with Type Checking
Add the plugin to your MyPy configuration:
[tool.mypy]
plugins = ["fastapi_injectable.mypy"]
Now your injectable functions work seamlessly with static type checkers:
@injectable
def get_country(capital: Annotated[Capital, Depends(get_capital)]) -> Country:
return Country(capital)
country = get_country() # No more MyPy complaints!
Full Changelog: v0.7.2...v1.0.0
v0.7.2
To resolve #103.
Changes
- bump: from 0.7.1 to 0.7.2 (#105) @JasperSui
- fix: prevent "Future attached to different loop" error in AsyncExitStackManager cleanup (#104) @JasperSui
v0.7.1
FastAPI Injectable 0.7.1
This release fixes an important issue with the event loop management system introduced in v0.7.0, enhancing compatibility with various awaitable types.
Thank @jtfidje for raising this issue (#100).
Key Improvements
Enhanced Awaitable Support
- Fixed
run_in_loop
function: Now properly handles all awaitable types, not just coroutines and futures - Support for
asyncio.gather()
: The loop management system now works correctly with tasks created viaasyncio.gather()
Code Changes
- fix: support non-coroutine awaitables in run_in_loop (#101) @JasperSui
- bump: from 0.7.0 to 0.7.1 (#102) @JasperSui
Dependencies
- build(deps-dev): bump mypy from 1.14.0 to 1.15.0 (#90) @dependabot[bot]
- build(deps-dev): bump h11 from 0.14.0 to 0.16.0 in the pip group (#94) @dependabot[bot]
- build(deps): bump actions/download-artifact from 4.2.1 to 4.3.0 (#95) @dependabot[bot]
- build(deps): bump codecov/codecov-action from 5.4.0 to 5.4.2 (#96) @dependabot[bot]
- build(deps-dev): bump mypy-extensions from 1.0.0 to 1.1.0 (#97) @dependabot[bot]
- build(deps-dev): bump websockets from 14.1 to 15.0.1 (#98) @dependabot[bot]
- build(deps-dev): bump prompt-toolkit from 3.0.50 to 3.0.51 (#99) @dependabot[bot]
- build(deps-dev): bump coverage from 7.6.10 to 7.8.0 (#86) @dependabot[bot]
- build(deps-dev): bump iniconfig from 2.0.0 to 2.1.0 (#87) @dependabot[bot]
- build(deps-dev): bump pytest from 8.3.4 to 8.3.5 (#88) @dependabot[bot]
- build(deps-dev): bump beautifulsoup4 from 4.12.3 to 4.13.3 (#89) @dependabot[bot]
- build(deps): bump crazy-max/ghaction-github-labeler from 5.2.0 to 5.3.0 (#91) @dependabot[bot]
- build(deps): bump actions/download-artifact from 4.1.9 to 4.2.1 (#92) @dependabot[bot]
- build(deps): bump actions/upload-artifact from 4.6.1 to 4.6.2 (#93) @dependabot[bot]
Full Changelog: v0.7.0...v0.7.1
v0.7.0
FastAPI Injectable 0.7.0
This release introduces a comprehensive event loop management system, providing flexible strategies for handling asynchronous code in different contexts.
Major Features
Loop Management Strategies
Three different strategies are now available:
current
(default): Uses the current thread's event loopisolated
: Creates a separate isolated loopbackground_thread
: Runs a dedicated background thread with its own event loop
API Enhancements
- Added
loop_manager
central object for controlling loop strategy and execution - Enhanced
run_coroutine_sync
function to work with the loop manager - Updated
AsyncExitStackManager
to work with the loop manager for proper resource cleanup
Benefits
- Flexibility: Run async code from any context (sync functions, background threads, etc.)
- Reliability: Ensure resources are properly cleaned up regardless of execution context
- Compatibility: Work with libraries like
aiohttp
that require specific loop handling
Code Changes
- bump: from 0.6.0 to 0.7.0 (#85) @JasperSui
- feat: add event loop management system (#84) @JasperSui
Full Changelog: v0.6.0...v0.7.0
v0.6.0
FastAPI Injectable 0.6.0
This release significantly simplifies the event loop management approach, with breaking changes to how asynchronous code is handled.
BREAKING CHANGES
- Removed
LoopManager
class and daemon thread approach - Simplified
run_coroutine_sync
function - now relies on the application's main event loop - Removed
RunCoroutineSyncMaxRetriesError
exception class - Removed timeout and retry parameters from
run_coroutine_sync
function
These changes simplify the concurrency model but require updates to code that relies on custom event loop management.
Major Changes
Event Loop Management Improvements
- Refactored to use the application's main event loop instead of managing a separate loop
- Simplified
AsyncExitStackManager
to directly await coroutines without loop management - Converted async tests to sync tests using the simplified
run_coroutine_sync
- Removed daemon thread approach for running a separate event loop
Compatibility Improvements
- Resolved compatibility issues with libraries like aiohttp where injected objects were attached to the wrong event loop
- Simplified stack cleanup by removing multi-loop considerations
- Made the library more predictable by using a single event loop model
- Reduced complexity and potential threading issues
Code Changes
- bump: from 0.5.0 to 0.6.0 (#82) @JasperSui
- refactor: simplify event loop management to use application's main loop (#81) @JasperSui
Full Changelog: v0.5.0...v0.6.0
v0.5.0
FastAPI Injectable 0.5.0
This release includes significant changes to error handling and dependency resolution, with breaking changes to the API.
BREAKING CHANGES
- Removed
DependencyResolveError
exception class - Removed
raise_exception
parameter from:injectable
decoratorresolve_dependencies
functionget_injected_obj
function
These changes simplify the error handling model but require updates to code that relies on these features.
Major Changes
Dependency Resolution Improvements
- Refactored to ignore FastAPI route-specific errors during dependency resolution
- Enhanced stability when working with FastAPI's dependency injection system
- Simplified error handling approach throughout the library
Package Structure Fixes
- Correctly placed
py.typed
marker file under thefastapi_injectable
folder - Improved MyPy integration and type checking capabilities
Code Changes
- fix: correctly place py.typed file under fastapi_injectable folder (#76) @JasperSui
- refactor(dependencies): ignore FastAPI route-specific errors during dependency resolution (#77) @JasperSui
- docs: remove FAQ redundant toc (#58) @JasperSui
- bump: from 0.4.1 to 0.5.0 (#78) @JasperSui
📦 Dependencies
Core Dependencies
Development Dependencies
- build(deps): bump myst-parser from 4.0.0 to 4.0.1 (#68) @dependabot
- build(deps-dev): bump watchfiles from 1.0.3 to 1.0.4 (#69) @dependabot
- build(deps-dev): bump babel from 2.16.0 to 2.17.0 (#67) @dependabot
- build(deps-dev): bump ruff from 0.8.4 to 0.8.6 (#66) @dependabot
- build(deps-dev): bump executing from 2.1.0 to 2.2.0 (#65) @dependabot
GitHub Actions
- build(deps): bump actions/upload-artifact from 4.6.0 to 4.6.1 (#73) @dependabot
- build(deps): bump codecov/codecov-action from 5.3.1 to 5.4.0 (#72) @dependabot
- build(deps): bump crazy-max/ghaction-github-labeler from 5.0.0 to 5.2.0 (#71) @dependabot
- build(deps): bump actions/download-artifact from 4.1.8 to 4.1.9 (#70) @dependabot
Full Changelog: v0.4.1...v0.5.0
v0.4.1
Changes
- bump: from 0.4.0 to 0.4.1 (#52) @JasperSui
- chore: make register_app public (#51) @JasperSui
v0.4.0
FastAPI Injectable 0.4.0
Major update introducing concurrency improvements and enhanced request context handling.
Major Changes
Concurrency Refactor
- Implemented dedicated event loop manager for coroutine execution
- Improved async task handling reliability
- Reduced potential race conditions in concurrent operations
Request Context Enhancements
- Added ability to register and retrieve real app instance during request resolution (thanks to @lokhman's issue)
- Enabled deeper integration with FastAPI's request lifecycle
Code Changes
- bump: from 0.3.0 to 0.4.0 (#50) @JasperSui
- refactor(concurrency): implement dedicated event loop manager for coroutine execution (#49) @JasperSui
- feat: allow registration to get real app from request when resolving depedencies (#48) @JasperSui
v0.3.0
FastAPI Injectable 0.3.0
Major update adding args/kwargs support to dependency injection and improving type hints throughout the codebase.
Major Changes
Enhanced Dependency Injection
- Added support for passing positional and keyword arguments to
get_injected_obj
- Improved flexibility in dependency instantiation
- Enhanced type safety for argument passing
Type System Improvements
- Added
py.typed
marker file for better MyPy integration - Added comprehensive
@overload
type hints forinjectable
decorator andget_injected_obj
- Improved type hints throughout the codebase
- Removed unnecessary type ignores in tests
Testing Enhancements
- Added extensive test coverage for new args/kwargs functionality:
- Basic args/kwargs usage
- Args/kwargs with sync functions
- Args/kwargs with async functions
- Args/kwargs with sync/async generators
- Combined args and kwargs usage
- Maintained 100% code coverage
Code Changes
- bump: from 0.2.0 to 0.3.0 (#46) @JasperSui
- feat: add args/kwargs support to get_injected_obj and improve type hints (#45) @JasperSui
- docs: correct readme faq toc (#38) @JasperSui
- chore(dev): update pre commit config and fix md by it (#37) @JasperSui
- docs: add FAQ (#36) @JasperSui
- chore(README): update logo url (#35) @JasperSui
📦 Dependencies
- build(deps-dev): bump jinja2 from 3.1.4 to 3.1.5 (#40) @dependabot
- build(deps-dev): bump coverage from 7.6.9 to 7.6.10 (#41) @dependabot
- build(deps-dev): bump charset-normalizer from 3.4.0 to 3.4.1 (#42) @dependabot
- build(deps-dev): bump urllib3 from 2.2.3 to 2.3.0 (#43) @dependabot
- build(deps-dev): bump click from 8.1.7 to 8.1.8 (#39) @dependabot