Skip to content

Commit

Permalink
Fix: union_lists for python < 3.9.
Browse files Browse the repository at this point in the history
  • Loading branch information
Labbeti committed Apr 17, 2024
1 parent 561c96d commit f887423
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/aac_datasets/utils/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
# -*- coding: utf-8 -*-

from typing import (
Any,
Dict,
Iterable,
List,
Literal,
Mapping,
Sequence,
TypeVar,
Union,
overload,
)

from typing_extensions import Literal

K = TypeVar("K")
T = TypeVar("T")
V = TypeVar("V")
Expand All @@ -26,7 +28,7 @@
def list_dict_to_dict_list(
lst: Sequence[Mapping[K, V]],
key_mode: Literal["intersect", "same"],
default_val: W = None,
default_val: Any = None,
) -> Dict[K, List[V]]:
...

Expand Down Expand Up @@ -90,6 +92,6 @@ def union_lists(lst_of_lst: Iterable[Iterable[T]]) -> List[T]:
"""Performs union of elements in lists (like set union), but keep their original order."""
out = {}
for lst_i in lst_of_lst:
out |= dict.fromkeys(lst_i)
out.update(dict.fromkeys(lst_i))
out = list(out)
return out

0 comments on commit f887423

Please sign in to comment.