from typing import Optional
from typing import Union
from typing import Type
from typing import Any
from typing import Callable


def tname(arg: Optional[Union[Type[Any], Any, Callable]]) -> str:
    """Get name of method or class.

    Args:
        arg: Something get a name for.

    Returns:
        A type name.
    """
    if arg is None:
        return "None"  # pragma: no cover
    if isinstance(arg, type):
        return arg.__name__
    if hasattr(arg, "__class__") and not callable(arg):
        return arg.__class__.__name__

    return arg.__name__ if hasattr(arg, "__name__") else arg.__class__.__name__