Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
diwire: type-driven dependency injection for Python
diwire: type-driven dependency injection for Python
v1.3.1 GitHub

Learn

  • Quick start (FastAPI)
  • Dependency injection (DI)
  • Learning paths
  • Why diwire
  • Tutorial (runnable examples)
    • Quickstart
    • Registration methods
    • Autoregistration
    • Lifetimes
    • Scopes & cleanup
    • Scope context values
    • Function injection
    • Named components
    • Annotation normalization
    • Providers
    • Compilation
    • Open generics
    • ResolverContext
    • Lock modes
    • Async
    • Errors & troubleshooting
    • Resolve all components
    • Maybe
    • Supported frameworks
    • Pydantic settings
    • Pytest plugin
    • FastAPI
  • Core concepts
    • Container
    • Registration
    • Lifetimes
    • Scopes & cleanup
    • Function injection
    • Components (named registrations)
    • Open generics
    • Async
    • resolver_context
    • Compilation
    • Errors
    • Integrations
  • How-to guides
    • Web frameworks
      • FastAPI
      • Litestar
      • aiohttp
      • Celery
      • Starlette (and other ASGI frameworks)
      • Flask (WSGI)
      • Django
      • django-modern-rest
    • Testing
      • Overrides
      • pytest
    • Patterns
      • Request scope
      • Unit of work
      • Resources (cleanup)
      • Decorators
      • Interfaces (Protocol/ABC)
      • Handler classes (methods)
    • Advanced
      • Auto-registration tuning
      • Performance
      • Concurrency
  • API reference
    • Container
    • ResolverContext
    • resolver_context
    • Types
    • Exceptions
Back to top
View this page
Edit this page

Web frameworksΒΆ

diwire is intentionally framework-agnostic.

The common pattern is:

  1. Build a diwire.Container at app startup.

  2. Create a request/job scope per incoming request.

  3. Register request/job-specific objects (like the current request or current task data) via factories/contextvars.

  4. Use function injection (Injected[T]) or resolver_context to keep handlers clean.

  • FastAPI
  • Litestar
  • aiohttp
  • Celery
  • Starlette (and other ASGI frameworks)
  • Flask (WSGI)
  • Django
  • django-modern-rest
Next
FastAPI
Previous
How-to guides
Copyright ©
Made with Sphinx and @pradyunsg's Furo