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

False positive cache_clear no member with lru_cache decorator without parenthesis #8868

Closed
vinsonlee opened this issue Jul 20, 2023 · 0 comments · Fixed by pylint-dev/astroid#2259
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@vinsonlee
Copy link

Bug description

pylint issues a false positive on cache_clear method when the class method is decoratored with lru_cache without parenthesis.

"""Module docstring"""
import functools

class TestObject:
    """class docstring"""

    def method(self) -> None:
        """method docstring"""

    @functools.lru_cache
    def cached_method(self) -> None:
        """method docstring"""


t = TestObject()
t.cached_method.cache_clear()

Configuration

No response

Command used

pylint a.py

Pylint output

************* Module a
a.py:16:0: E1101: Method 'cached_method' has no 'cache_clear' member (no-member)

Expected behavior

With parenthesis on lru_cache decorator.

"""Module docstring"""
import functools

class TestObject:
    """class docstring"""

    def method(self) -> None:
        """method docstring"""

    @functools.lru_cache()
    def cached_method(self) -> None:
        """method docstring"""


t = TestObject()
t.cached_method.cache_clear()
% pylint a.py

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Pylint version

pylint 2.17.4
astroid 2.15.4
Python 3.11.4 (main, Jun 20 2023, 16:59:59) [Clang 14.0.3 (clang-1403.0.22.14.1)]

OS / Environment

No response

Additional dependencies

No response

@vinsonlee vinsonlee added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jul 20, 2023
@jacobtylerwalls jacobtylerwalls added False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jul 21, 2023
@jacobtylerwalls jacobtylerwalls self-assigned this Jul 21, 2023
@jacobtylerwalls jacobtylerwalls modified the milestones: 2.17.5, 2.17.6 Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid update Needs an astroid update (probably a release too) before being mergable Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants