fix: apply pre-commit formatting

This commit is contained in:
Peter Double 2025-04-14 12:35:32 -04:00
parent ffb5600ec4
commit ff468d91ce

View file

@ -230,29 +230,23 @@ class TracingMiddleware:
self.app = app self.app = app
self.impls = impls self.impls = impls
# FastAPI built-in paths that should bypass custom routing # FastAPI built-in paths that should bypass custom routing
self.fastapi_paths = ( self.fastapi_paths = ("/docs", "/redoc", "/openapi.json", "/favicon.ico", "/static")
"/docs",
"/redoc",
"/openapi.json",
"/favicon.ico",
"/static"
)
async def __call__(self, scope, receive, send): async def __call__(self, scope, receive, send):
if scope.get("type") == "lifespan": if scope.get("type") == "lifespan":
return await self.app(scope, receive, send) return await self.app(scope, receive, send)
path = scope.get("path", "") path = scope.get("path", "")
# Check if the path is a FastAPI built-in path # Check if the path is a FastAPI built-in path
if path.startswith(self.fastapi_paths): if path.startswith(self.fastapi_paths):
# Pass through to FastAPI's built-in handlers # Pass through to FastAPI's built-in handlers
logger.debug(f"Bypassing custom routing for FastAPI built-in path: {path}") logger.debug(f"Bypassing custom routing for FastAPI built-in path: {path}")
return await self.app(scope, receive, send) return await self.app(scope, receive, send)
if not hasattr(self, "endpoint_impls"): if not hasattr(self, "endpoint_impls"):
self.endpoint_impls = initialize_endpoint_impls(self.impls) self.endpoint_impls = initialize_endpoint_impls(self.impls)
try: try:
_, _, trace_path = find_matching_endpoint(scope.get("method", "GET"), path, self.endpoint_impls) _, _, trace_path = find_matching_endpoint(scope.get("method", "GET"), path, self.endpoint_impls)
except ValueError: except ValueError: