# TypeError: 'Middleware' object is not callable

- **ID:** `python/starlette-middleware-type-error`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A middleware class is not instantiated or not used as a callable.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **Instantiate the middleware before adding it to the app.** (90% success)
   ```
   from starlette.middleware import Middleware
middleware = Middleware(SomeMiddleware)
app.add_middleware(middleware)
   ```
2. **Use the middleware class directly with app.add_middleware.** (95% success)
   ```
   app.add_middleware(SomeMiddleware)
   ```

## Dead Ends

- **Passing the middleware class directly without instantiation.** — The middleware must be an instance or a callable; a class is not callable in this context. (80% fail)
- **Importing the middleware incorrectly from a wrong module.** — The imported object may not be a middleware at all. (60% fail)
