# fastapi.exceptions.FastAPIError: Invalid dependency: 'get_db' is not a callable or a class.

- **ID:** `python/fastapi-dependency-error`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Dependencies in FastAPI must be callables (functions or classes) that return the required value.

## Version Compatibility

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

## Workarounds

1. **Define a proper dependency function** (100% success)
   ```
   def get_db():
    return db_session

@app.get('/items')
def read_items(db=Depends(get_db)):
    ...
   ```
2. **Use a class as a dependency with __call__** (90% success)
   ```
   class DBSession:
    def __call__(self):
        return db_session

app.dependency_overrides[get_db] = DBSession()
   ```

## Dead Ends

- **Passing a string or integer as a dependency** — Must be a callable. (100% fail)
- **Using a class without __call__** — Classes must be instantiable or have __call__. (80% fail)
