1717
1818import asyncio
1919import os
20- from typing import Any , AsyncIterator , Dict , Mapping , Sequence
20+ from typing import Any , AsyncIterator , Dict , Mapping , Sequence , cast
2121
2222from elasticsearch .helpers import async_bulk
2323
2424from elasticsearch_dsl import Agg , AsyncSearch , Response , aggs , async_connections
25+ from elasticsearch_dsl .types import CompositeAggregate
2526from tests .test_integration .test_data import DATA , GIT_INDEX
2627
2728
@@ -30,7 +31,7 @@ async def scan_aggs(
3031 source_aggs : Sequence [Mapping [str , Agg ]],
3132 inner_aggs : Dict [str , Agg ] = {},
3233 size : int = 10 ,
33- ) -> AsyncIterator [Any ]:
34+ ) -> AsyncIterator [CompositeAggregate ]:
3435 """
3536 Helper function used to iterate over all possible bucket combinations of
3637 ``source_aggs``, returning results of ``inner_aggs`` for each. Uses the
@@ -54,7 +55,7 @@ async def run_search(**kwargs: Any) -> Response:
5455 response = await run_search ()
5556 while response .aggregations ["comp" ].buckets :
5657 for b in response .aggregations ["comp" ].buckets :
57- yield b
58+ yield cast ( CompositeAggregate , b )
5859 if "after_key" in response .aggregations ["comp" ]:
5960 after = response .aggregations ["comp" ].after_key
6061 else :
0 commit comments