from typing import Union
from typing import Callable


def format_fully_qualified_type_name(
        type_object: Union[Callable, type]) -> str:
    """Formats a fully qualified name of any type."""
    module: str = type_object.__module__
    type_name: str = type_object.__qualname__
    if module is None or module == object.__module__:
        return type_name
    return f'{module}.{type_name}'