# 类型错误：'Depends' 对象不可调用

- **ID:** `python/fastapi-dependency-error-callable`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

错误地将Depends用作函数而不是依赖注入。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **Use Depends as a parameter without calling it.** (95% 成功率)
   ```
   from fastapi import Depends
async def read_items(db: Session = Depends(get_db)):
   ```
2. **If using a callable dependency, define it as a function and pass it to Depends.** (90% 成功率)
   ```
   def common_parameters(q: str = None):
    return {'q': q}

@app.get('/items')
async def read_items(commons: dict = Depends(common_parameters)):
   ```

## 无效尝试

- **Calling Depends() with parentheses inside a function parameter.** — Depends should be used without calling it; it's a class. (80% 失败率)
- **Importing Depends from the wrong module.** — Depends is from fastapi, not from fastapi.params. (60% 失败率)
