1- from logging import getLogger
1+ """Middleware to build and apply CQL2 filters."""
2+
23import json
34from dataclasses import dataclass
5+ from logging import getLogger
46from typing import Callable , Optional
57
68from cql2 import Expr
7- from starlette .types import ASGIApp , Message , Receive , Scope , Send
89from starlette .requests import Request
10+ from starlette .types import ASGIApp , Message , Receive , Scope , Send
911
1012from ..utils import filters , requests
1113
@@ -25,6 +27,7 @@ class BuildCql2FilterMiddleware:
2527 state_key : str = "cql2_filter"
2628
2729 async def __call__ (self , scope : Scope , receive : Receive , send : Send ) -> None :
30+ """Build the CQL2 filter, place on the request state."""
2831 if scope ["type" ] != "http" :
2932 return await self .app (scope , receive , send )
3033
@@ -35,6 +38,7 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
3538 return await self .app (scope , receive , send )
3639
3740 async def set_filter (body : Optional [dict ] = None ) -> None :
41+ assert filter_builder is not None
3842 cql2_filter = await filter_builder (
3943 {
4044 "req" : {
0 commit comments