Skip to content

Using functools.lru_cache decorator without parentheses only possible in >= Python 3.8 #67

Closed
@tobbez

Description

@tobbez

Using the functools.lru_cache decorator without parentheses is only possible in Python 3.8 and later.

# a.py
from functools import lru_cache

@lru_cache
def a():
    pass
$ vermin --version
1.1.0
$ vermin a.py
Minimum required versions: 3.2
Incompatible versions:     2
$ python3.7 a.py
Traceback (most recent call last):
  File "a.py", line 4, in <module>
    @lru_cache
  File ".../lib/python3.7/functools.py", line 490, in lru_cache
    raise TypeError('Expected maxsize to be an integer or None')
TypeError: Expected maxsize to be an integer or None
$ python3.8 a.py
$

Relevant quote from the documentation:

@functools.lru_cache(user_function)
@functools.lru_cache(maxsize=128, typed=False)
[...]
If user_function is specified, it must be a callable. This allows the lru_cache decorator to be applied directly to a user function, leaving the maxsize at its default value of 128:
[...}
Changed in version 3.8: Added the user_function option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions