Browse Source

final fixes

pull/15091/head
svlandeg 4 months ago
parent
commit
ccd6f2fd42
  1. 10
      fastapi/applications.py

10
fastapi/applications.py

@ -1029,13 +1029,13 @@ class FastAPI(Starlette):
exception_handlers[key] = value exception_handlers[key] = value
middleware = ( middleware = (
[Middleware(ServerErrorMiddleware, handler=error_handler, debug=debug)] # type: ignore[invalid-argument-type] [Middleware(ServerErrorMiddleware, handler=error_handler, debug=debug)] # ty: ignore[invalid-argument-type]
+ self.user_middleware + self.user_middleware
+ [ + [
Middleware( Middleware(
ExceptionMiddleware, ExceptionMiddleware, # ty: ignore[invalid-argument-type]
handlers=exception_handlers, handlers=exception_handlers,
debug=debug, # type: ignore[invalid-argument-type] debug=debug,
), ),
# Add FastAPI-specific AsyncExitStackMiddleware for closing files. # Add FastAPI-specific AsyncExitStackMiddleware for closing files.
# Before this was also used for closing dependencies with yield but # Before this was also used for closing dependencies with yield but
@ -1056,7 +1056,7 @@ class FastAPI(Starlette):
# user middlewares, the same context is used. # user middlewares, the same context is used.
# This is currently not needed, only for closing files, but used to be # This is currently not needed, only for closing files, but used to be
# important when dependencies with yield were closed here. # important when dependencies with yield were closed here.
Middleware(AsyncExitStackMiddleware), # type: ignore[invalid-argument-type] Middleware(AsyncExitStackMiddleware), # ty: ignore[invalid-argument-type]
] ]
) )
@ -4638,7 +4638,7 @@ class FastAPI(Starlette):
""" """
def decorator(func: DecoratedCallable) -> DecoratedCallable: def decorator(func: DecoratedCallable) -> DecoratedCallable:
self.add_middleware(BaseHTTPMiddleware, dispatch=func) # type: ignore[arg-type] self.add_middleware(BaseHTTPMiddleware, dispatch=func) # ty: ignore[invalid-argument-type]
return func return func
return decorator return decorator

Loading…
Cancel
Save