import typing


def type_hints(f):
    """Same as `typing.get_type_hints` but returns `{}` if not allowed type."""
    allowed_types = typing._allowed_types  # type:ignore
    return typing.get_type_hints(f) if isinstance(f, allowed_types) else {}