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

Attributes on functions supplied by decorators trigger no-member #9246

Closed
socketpair opened this issue Nov 19, 2023 · 0 comments · Fixed by #9308
Closed

Attributes on functions supplied by decorators trigger no-member #9246

socketpair opened this issue Nov 19, 2023 · 0 comments · Fixed by #9308
Labels
Decorators False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@socketpair
Copy link

Bug description

from functools import cache


class SomeClass:
    # Yes, the order of decorators is correct.
    @classmethod
    @cache
    def __cached_fun(cls, arg: int) -> str:  # no-member
        return str(arg)

    @classmethod
    def cache_clear(cls):
        cls.__cached_fun.cache_clear()

Configuration

No response

Command used

pylint a.py

Pylint output

a.py:13:8: E1101: Method '__cached_fun' has no 'cache_clear' member (no-member)

Expected behavior

No message above. Actually everything works as expected at runtime.

Pylint version

pylint 2.17.4
astroid 2.15.4
Python 3.11.6 (main, Oct  3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)]

OS / Environment

Fedora 38

Additional dependencies

No response

@socketpair socketpair added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Nov 19, 2023
@socketpair socketpair changed the title @cache + @classmethod + .clear_cache() = bug @cache + @classmethod + .cache_clear() = bug Nov 19, 2023
@jacobtylerwalls jacobtylerwalls added Decorators False Positive 🦟 A message is emitted but nothing is wrong with the code 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 Dec 17, 2023
@jacobtylerwalls jacobtylerwalls added this to the 3.0.4 milestone Dec 17, 2023
@jacobtylerwalls jacobtylerwalls changed the title @cache + @classmethod + .cache_clear() = bug Attributes on functions supplied by decorators trigger no-member Dec 17, 2023
toofar added a commit to qutebrowser/qutebrowser that referenced this issue Feb 26, 2024
The lint ones are:

    linters (pylint): qutebrowser/completion/completionwidget.py#L440
    Consider using 'height = min(height, contents_height)' instead of unnecessary if block

    linters (pylint): qutebrowser/browser/webengine/webview.py#L241
    Useless suppression of 'no-member'

The no-member one might be due to this change: pylint-dev/pylint#9246

For the importlib-resources one, I'm not sure why it's changed to be
underscore instead of a dash now. But at least it's consistent across
all the requirements files now!

I feel like I've seem this in a previous dependancy update too (for a
different package?) but I can't find that now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Decorators False Positive 🦟 A message is emitted but nothing is wrong with the code 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