Skip to content

Conversation

@cofin
Copy link
Member

@cofin cofin commented Nov 2, 2025

Adds disable_di boolean flag to Litestar, Starlette/FastAPI, and Flask
extensions. When enabled, disables built-in dependency injection to allow
users to manage database lifecycle with their own DI solutions (e.g., Dishka).

cofin added 3 commits November 2, 2025 01:37
Flask extensions. When enabled, disables built-in dependency injection to allow
users to manage database lifecycle with their own DI solutions (e.g., Dishka).
Adds `disable_di` boolean flag to Litestar, Starlette/FastAPI, and Flask
extensions. When enabled, disables built-in dependency injection to allow
users to manage database lifecycle with their own DI solutions (e.g., Dishka).

## Changes

### Configuration
- Added `disable_di: NotRequired[bool]` to FlaskConfig, LitestarConfig, and
  StarletteConfig TypedDicts in sqlspec/config.py
- Default: False (backward compatible)

### Framework Extensions
- **Litestar**: Conditionally skip DI provider registration when disable_di=True
- **Starlette/FastAPI**: Conditionally skip middleware when disable_di=True
- **Flask**: Conditionally skip request hooks when disable_di=True

### Test Organization
- Reorganized extension integration tests into subdirectories:
  - tests/integration/test_extensions/test_flask/
  - tests/integration/test_extensions/test_starlette/
  - tests/integration/test_extensions/test_fastapi/
  - tests/integration/test_extensions/test_litestar/
- Added comprehensive disable_di tests for all three frameworks
- Verified backward compatibility with default behavior tests

## Testing
- All extension unit tests pass (104 passed, 1 skipped)
- All extension integration tests pass (37 passed, 1 skipped)
- Type checking clean (mypy + pyright: 0 errors)
@cofin cofin merged commit 4a0ba88 into main Nov 2, 2025
10 checks passed
@cofin cofin deleted the feat/external-di-provider-support branch November 2, 2025 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants