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

Instance of 'list' has no 'get_name' member regression in astroid 2.5 #903

Closed
chrisburr opened this issue Feb 18, 2021 · 2 comments
Closed

Comments

@chrisburr
Copy link

Steps to reproduce

Make a file containing:

class A:
    def __init__(self):
        self._data = []

    def add(self, value):
        self._data += [value]

    def exists(self, name):
        for i in self._data:
            if i.get_name() == name:
                return True
        return False


class B:
    name = "my-name"

    def get_name(self):
        return self.name


if __name__ == "__main__":
    j = A()
    j.add(B())
    print(j.exists("my-name"), j.exists("my-name2"))

This runs successfully but linting with pylint gives the error:

$ pylint reproducer.py --disable=invalid-name,missing-module-docstring,missing-function-docstring,missing-class-docstring,too-few-public-methods
************* Module reproducer
reproducer.py:10:15: E1101: Instance of 'list' has no 'get_name' member (no-member)

-----------------------------------
Your code has been rated at 7.22/10

Current behavior

Pylint fails to realise that items within A._data are not lists. This is a new regression in astroid 2.5 and downgrading to 2.4.2 while changing no other packages causes the false positive to go away.

Expected behavior

No error message.

@chrisburr
Copy link
Author

I realised this might actually be the same thing as the other recent issues (#895 and #899) so I tried running with #901 locally and it fixes this issue. Sorry for the duplicated report!

@hippo91
Copy link
Contributor

hippo91 commented Feb 18, 2021

@chrisburr thanks for your report. It is not useless because it confirms that we definitely needs #901

@hippo91 hippo91 closed this as completed Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants