bpo-36772 Allow lru_cache to be used as decorator without making a function call by rhettinger · Pull Request #13048 · python/cpython

To avoid misuse of the decorator, lru_cache should be treated as a decorator itself only if it is called with a single positional argument.

def lru_cache(*args, **kwargs):
    if not kwargs and len(args) == 1 and callable(args[0]):
        return lru_cache_impl()(args[0])
    return lru_cache_impl(*args, **kwargs)

lru_cache.__text_signature__ = '(maxsize=128, typed=False)'

def lru_cache_impl(maxsize=128, typed=False):
    ... # the current implementation