python
type_error
ai_generated
true
TypeError: __call__() takes 1 positional argument but 2 were given
ID: python/starlette-middleware-error
80%Fix Rate
84%Confidence
0Evidence
2025-09-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
中间件类未正确实现 __call__ 方法。
generic中文
中间件类未正确实现 __call__ 方法。
Workarounds
-
95% success
class MyMiddleware:\n def __init__(self, app):\n self.app = app\n async def __call__(self, scope, receive, send):\n await self.app(scope, receive, send)
-
85% success
async def simple_middleware(request, call_next):\n response = await call_next(request)\n return response
Dead Ends
Common approaches that don't work:
-
70% fail
签名不匹配。
-
90% fail
导致中间件无法工作。