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 wrongly detects alias properties in slotted classes #2439

Closed
mathieui opened this issue Aug 22, 2018 · 1 comment
Closed

Pylint wrongly detects alias properties in slotted classes #2439

mathieui opened this issue Aug 22, 2018 · 1 comment
Labels

Comments

@mathieui
Copy link

Hi, we encountered the issue in our CI which runs a pylint -E.
The issue does not happen in non-slotted classes, as far as I am aware.

Steps to reproduce

Run pylint -E on the following file:

class TestClass:
    __slots__ = ['_i']
    def __init__(self):
        self._i = 0

    @property
    def i(self):
        return self._i

    @i.setter
    def i(self, v):
        self._i = v

    other = i

instance = TestClass()
instance.other = 42
print(instance.i)

Current behavior

************* Module test
test.py:17:0: E0237: Assigning to attribute 'other' not defined in class slots (assigning-non-slot)

(and other errors in the code using that class)

Expected behavior

No error

pylint --version output

pylint 2.1.1
astroid 2.0.4
Python 3.7.0 (default, Jul 15 2018, 10:44:58) 
[GCC 8.1.1 20180531]
@PCManticore
Copy link
Contributor

Thanks for reporting this issue! I can confirm the bug, pylint in this case is not taking in account the class level other attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants