This should be `getattr(obj, '__qualname__', None) or obj.__name__` as that ensures that `obj.__name__` is not called unless qualname is missing.