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 E1101 (no-member) on overridden class property setters #3480

Closed
akkeluukkonen opened this issue Apr 11, 2020 · 1 comment · Fixed by pylint-dev/astroid#890 or PennyDreadfulMTG/Penny-Dreadful-Tools#8447
Labels
Bug 🪲 Checkers Related to a checker

Comments

@akkeluukkonen
Copy link

Steps to reproduce

class Parent:
    def __init__(self):
        self._attr = 0

    @property
    def attr(self):
        return self._attr

    @attr.setter
    def attr(self, value):
        self._attr = value

class Child(Parent):

    @Parent.attr.setter
    def attr(self, value):
        # Perform "pre-hook" actions
        Parent.attr.fset(self, value)
        # Perform "post-hook" actions

Current behavior

issue.py:14:5: E1101: Method 'attr' has no 'setter' member (no-member)
issue.py:17:8: E1101: Method 'attr' has no 'fset' member (no-member)

Expected behavior

No E1101 errors.

The described code example functions as expected, even though it is a quite niche use case. This is closely related to #2221 where a similar issue is observed with getters. However, with setters the situation is somewhat different. You cannot define @attr.setter if you have not defined the property itself in the Child class. However, you can define it by using the described @Parent.attr.setter.

The actual use case here is that I'm inheriting a class from another library that I wish to extend. It has a quite complex @attr.setter function that I don't want to directly copy in case it receives an update later. However, in my case I need to run additional "post-hook" actions directly after the Parent setter in order to synchronize some data only existing in the Child class.

pylint --version output

pylint 2.4.4
astroid 2.3.3
Python 3.8.2 (default, Mar  7 2020, 19:36:55) 
[GCC 7.4.0]
@PCManticore
Copy link
Contributor

Thanks for the report, I believe this makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Checkers Related to a checker
Projects
None yet
2 participants