X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=dict_utils.py;h=292b933886d7b6b5cc80ec98f358ad1f29ae9abf;hb=a838c154135b2420d9047a101caf24a2c9f593c2;hp=2362749b12c91b7f2d2b6519d3c9db1506a12fe8;hpb=3bc4daf1edc121cd633429187392227f2fa61885;p=python_utils.git diff --git a/dict_utils.py b/dict_utils.py index 2362749..292b933 100644 --- a/dict_utils.py +++ b/dict_utils.py @@ -3,9 +3,6 @@ from itertools import islice from typing import Any, Callable, Dict, Iterator, Tuple -import list_utils - - def init_or_inc( d: Dict[Any, Any], key: Any, @@ -27,7 +24,8 @@ def shard(d: Dict[Any, Any], size: int) -> Iterator[Dict[Any, Any]]: def coalesce_by_creating_list(key, v1, v2): - return list_utils.flatten([v1, v2]) + from list_utils import flatten + return flatten([v1, v2]) def coalesce_by_creating_set(key, v1, v2): @@ -41,9 +39,9 @@ def raise_on_duplicated_keys(key, v1, v2): def coalesce( inputs: Iterator[Dict[Any, Any]], *, - aggregation_function: Callable[[Any, Any, Any], Any] = coalesce_by_creating_list + aggregation_function: Callable[[Any, Any], Any] = coalesce_by_creating_list ) -> Dict[Any, Any]: - out = {} + out: Dict[Any, Any] = {} for d in inputs: for key in d: if key in out: