Skip to content

pylint reports false positive error for lru_cache with maxsize omitted #6180

@mdegat01

Description

@mdegat01

Bug description

Starting in v2.13.0 pylint reports warning if you decorate a method with lru_cache but do not provide a value for maxsize (#5670) . It does this even if you omit a value for maxsize and just use @lru_cache or @lru_cache().

This is incorrect, the lru_cache decorator defaults maxsize to 128 if omitted so it should not warn about this. It should only warn if maxsize is explicitly set to None by doing @lru_cache(maxsize=None) as that is what can create memory leaks.

Configuration

No response

Command used

pylint supervisor/host/manager.py

Pylint output

************* Module supervisor.host.manager
supervisor/host/manager.py:71:5: W1516: 'lru_cache' without 'maxsize' will keep all method args alive indefinitely, including 'self' (lru-cache-decorating-method)

Expected behavior

No warning since we are using the default maxsize of 128.

Pylint version

pylint 2.13.4

OS / Environment

macOS 12.2.1
Python 3.10.2
pip 22.0.4

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🪲False Positive 🦟A message is emitted but nothing is wrong with the code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions