def qualified_name(t):
    # type: (type) -> str
    """
    >>> print(qualified_name(qualified_name))
    qualified_name

    >>> from serial import model
    >>> print(qualified_name(model.marshal))
    serial.model.marshal
    """
    if hasattr(t, '__qualname__'):
        tn = t.__qualname__
    else:
        tn = t.__name__
    if t.__module__ not in ('builtins', '__builtin__', '__main__'):
        tn = t.__module__ + '.' + tn
    return tn