17
17
18
18
import asyncio
19
19
import os
20
- from typing import Any , AsyncIterator , Dict , Mapping , Sequence
20
+ from typing import Any , AsyncIterator , Dict , Mapping , Sequence , cast
21
21
22
22
from elasticsearch .helpers import async_bulk
23
23
24
24
from elasticsearch_dsl import Agg , AsyncSearch , Response , aggs , async_connections
25
+ from elasticsearch_dsl .types import CompositeAggregate
25
26
from tests .test_integration .test_data import DATA , GIT_INDEX
26
27
27
28
@@ -30,7 +31,7 @@ async def scan_aggs(
30
31
source_aggs : Sequence [Mapping [str , Agg ]],
31
32
inner_aggs : Dict [str , Agg ] = {},
32
33
size : int = 10 ,
33
- ) -> AsyncIterator [Any ]:
34
+ ) -> AsyncIterator [CompositeAggregate ]:
34
35
"""
35
36
Helper function used to iterate over all possible bucket combinations of
36
37
``source_aggs``, returning results of ``inner_aggs`` for each. Uses the
@@ -54,7 +55,7 @@ async def run_search(**kwargs: Any) -> Response:
54
55
response = await run_search ()
55
56
while response .aggregations ["comp" ].buckets :
56
57
for b in response .aggregations ["comp" ].buckets :
57
- yield b
58
+ yield cast ( CompositeAggregate , b )
58
59
if "after_key" in response .aggregations ["comp" ]:
59
60
after = response .aggregations ["comp" ].after_key
60
61
else :
0 commit comments