Skip to content

False positive about @cache on Enum methods #7857

Closed
@RumovZ

Description

@RumovZ

Bug description

# pylint: disable=missing-docstring
from enum import Enum
from functools import cache

class Class(Enum):
    A = 1

    @cache
    def func(self) -> None:
        pass

Configuration

No response

Command used

pylint demo.py

Pylint output

W1518: 'lru_cache(maxsize=None)' or 'cache' will keep all method args alive indefinitely, including 'self' (method-cache-max-size-none)

Expected behavior

Pylint shouldn't complain about this, the code is perfectly fine.
Repeated calls to Class(1).func() will not grow the cache, nor prevent anything from being garbage collected.

Pylint version

pylint 2.15.6
astroid 2.12.13
Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)]

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Positive 🦟A message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions