pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.28k stars 1.13k forks source link

Spurious error about 'str' not having a member #1862

Closed tjanez closed 6 years ago

tjanez commented 6 years ago

Steps to reproduce

Using Fedora 27 Docker image:

docker run --rm -it registry.fedoraproject.org/fedora:27 /bin/bash
dnf install -y tox git-core
git clone https://github.com/genialis/resolwe-bio-py
cd resolwe-bio-py/
git checkout pylint-issue
tox -e linters

I was also successful in reproducing this with the latest Ubuntu 17.10 and CentOS 7 Docker images.

Current behavior

Pylint reports:

Using config file /resolwe-bio-py/.pylintrc
************* Module resdk.tests.unit.test_base
C: 60, 8: Attribute name "WRITABLE_FIELDS" doesn't conform to u'[a-z_][a-z0-9_]{2,30}$' pattern (invalid-name)
C: 46, 8: Attribute name "UPDATE_PROTECTED_FIELDS" doesn't conform to u'[a-z_][a-z0-9_]{2,30}$' pattern (invalid-name)
C: 29, 8: Attribute name "READ_ONLY_FIELDS" doesn't conform to u'[a-z_][a-z0-9_]{2,30}$' pattern (invalid-name)
************* Module resdk.resources.relation
E:136,46: Instance of 'str' has no 'name' member (no-member)

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

Expected behavior

Pylint would report:

Using config file /resolwe-bio-py/.pylintrc

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

pylint --version output

Using config file /resolwe-bio-py/.pylintrc
pylint 1.8.2, 
astroid 1.6.1
Python 3.6.2 (default, Sep  1 2017, 12:03:48) 
[GCC 7.1.1 20170802 (Red Hat 7.1.1-7)]

Code that is flagged

https://github.com/genialis/resolwe-bio-py/blob/pylint-issue/resdk/resources/relation.py#L136

tjanez commented 6 years ago

Note, the other issue that Pylint reports has been filed as #1861 .

PCManticore commented 6 years ago

I can't reproduce this using your instructions, I'm getting:

linters runtests: commands[1] | pylint --version
Using config file /resolwe-bio-py/.pylintrc
pylint 1.8.2,
astroid 1.6.1
Python 3.6.2 (default, Sep  1 2017, 12:03:48)
[GCC 7.1.1 20170802 (Red Hat 7.1.1-7)]
linters runtests: commands[2] | pylint resdk
Using config file /resolwe-bio-py/.pylintrc

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

linters runtests: commands[3] | pycodestyle resdk