from typing import get_origin
from typing import get_args
import typing


def is_closed_python_set_type(ttype):
    """
    A "closed" generic type has all of its type parameters parameterized
    by other closed or concrete types.

    e.g.

    Returns true for Set[string] but false for Set or set
    """
    origin = get_origin(ttype)
    args = get_args(ttype)

    return (
        origin is set
        and args != ()
        # py3.7 compat
        and type(args[0]) != typing.TypeVar
    )