# -*- coding: utf-8 -*-
from enum import Enum
from typing import TypeVar, Type, List, Iterable, cast

from faker.providers import BaseProvider

TEnum = TypeVar("TEnum", bound=Enum)


class EnumProvider(BaseProvider):
    """
    A Provider for enums.
    """

    def enum(self, enum_cls: Type[TEnum]) -> TEnum:

        members: List[TEnum] = list(cast(Iterable[TEnum], enum_cls))
        return self.random_element(members)

[((7, 8, 7, 36), 'typing.TypeVar', 'TypeVar', (), '', False, 'from typing import TypeVar, Type, List, Iterable, cast\n'), ((17, 36, 17, 67), 'typing.cast', 'cast', ({(17, 41, 17, 56): 'Iterable[TEnum]', (17, 58, 17, 66): 'enum_cls'}, {}), '(Iterable[TEnum], enum_cls)', False, 'from typing import TypeVar, Type, List, Iterable, cast\n')]