Skip to content

Releases: JasperSui/fastapi-injectable

v1.1.0

06 Jun 11:08
305643d
Compare
Choose a tag to compare

Changes

📦 Dev Dependencies

v1.0.0

01 Jun 09:53
3f1b7b4
Compare
Choose a tag to compare

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

03 May 04:40
dd9c1cb
Compare
Choose a tag to compare

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

02 May 15:47
a4c68e4
Compare
Choose a tag to compare

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 via asyncio.gather()

Code Changes

Dependencies

Full Changelog: v0.7.0...v0.7.1

v0.7.0

19 Mar 17:07
7eedca9
Compare
Choose a tag to compare

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 loop
  • isolated: Creates a separate isolated loop
  • background_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

Full Changelog: v0.6.0...v0.7.0

v0.6.0

17 Mar 16:10
5da8a60
Compare
Choose a tag to compare

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

06 Mar 09:07
a096383
Compare
Choose a tag to compare

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 decorator
    • resolve_dependencies function
    • get_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 the fastapi_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

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

01 Feb 18:40
c919a23
Compare
Choose a tag to compare

Changes

v0.4.0

01 Feb 18:10
dde51a7
Compare
Choose a tag to compare

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

12 Jan 12:44
ed61249
Compare
Choose a tag to compare

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 for injectable decorator and get_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

📦 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