from typing import Dict
from typing import Any
from typing import Union
from typing import Optional
from typing import List


def acquire_symbols_from(
    name2sym: Dict[str, Any], name: Union[Any, str], never_str: bool = False
) -> Optional[Union[Any, str, List[Union[Any, str]]]]:
    """
    Acquire the symbol(s) from the iterable

    :param name2sym: Dict from symbol name to symbol

    :param name: Name of symbol. All namespace is removed.

    :param never_str: If True, ensure that `getattr` on the module is always called

    :return: The list of symbols acquired from the module
    """
    if isinstance(name, str):
        name = name.rpartition(".")[2] if name.count(".") > 0 else name
        if name in name2sym:
            return name2sym[name]
    if never_str:
        raise KeyError("{!r} not found in {!r}".format(name, ""))
    return name