from typing import Type


def _extract_origin_collection(collection: Type) -> Type:
    """
    Takes a type like List[Foo], where `Foo` may be something like:

        class Foo(NamedTuple):
            a: int

    and extracts the 'origin' collection type, which will be one of the
    stdlib collection types: list, dict, tuple, etc.
    """
    try:
        return collection.__extra__
    except AttributeError:
        return collection.__origin__