Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mdegat01 opened this issue Apr 4, 2022 · 0 comments · Fixed by #6181
Closed

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

mdegat01 opened this issue Apr 4, 2022 · 0 comments · Fixed by #6181
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@mdegat01
Copy link

mdegat01 commented Apr 4, 2022

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

@mdegat01 mdegat01 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Apr 4, 2022
@jacobtylerwalls jacobtylerwalls added Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 4, 2022
@jacobtylerwalls jacobtylerwalls added this to the 2.13.5 milestone Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants