from typing import List
from typing import Union


def dedup_list(li: list):
    """
    Deduplicates list while preserving order.

    Note:
        Not the same as `list(set(li))`.
        Copied from https://stackoverflow.com/questions/31479188/quickest-way-to-dedupe-list-in-dict

    Args:
        li (list): list of elements. Can be empty.

    Returns:
        list: The deduplicated list.

    Examples:
        >>> dedup_list([1, 1, 'a'])
        [1, 'a']

        >>> dedup_list([])
        []
    """
    assert isinstance(
        li, list
    ), f"Input argument should be a list. Value passed was: {li}."
    new_list: List[Union[int, str, list]] = []
    for val in li:
        if val not in new_list:
            new_list.append(val)
    return new_list