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

Incorrect 'unsubscriptable-object' reported #3139

Closed
atilag opened this issue Sep 25, 2019 · 11 comments
Closed

Incorrect 'unsubscriptable-object' reported #3139

atilag opened this issue Sep 25, 2019 · 11 comments
Assignees
Labels
Astroid Related to astroid Bug 🪲

Comments

@atilag
Copy link

atilag commented Sep 25, 2019

Steps to reproduce

Running pylint 2.4.1 to this code will want about incorrect 'unsubscriptable-object':

import numpy as np

arr = np.array([1, 2, 3])
shape = arr.shape
print(shape[0])

Current behavior

Running pylint warns:

...
example.py:5:6: E1136: Value 'shape' is unsubscriptable (unsubscriptable-object)

Expected behavior

No warn

pylint --version output

pylint 2.4.1
astroid 2.3.0
Python 3.7.2 (default, Dec 29 2018, 00:00:04)
[Clang 4.0.1 (tags/RELEASE_401/final)]

Maybe related to: #3129 ?

@inducer
Copy link

inducer commented Sep 25, 2019

Downgrading to pylint<2.4 and astroid<2.3 appears to resolve this. Notably, downgrading only pylint does not help.

x-ref: https://gitlab.tiker.net/inducer/pytential/merge_requests/182

@PCManticore
Copy link
Contributor

Thank you for reporting the issue, I can reproduce it as well.

@hippo91
Copy link
Contributor

hippo91 commented Dec 11, 2019

@atilag, the PR pylint-dev/astroid#732 should fix this issue.

@yoonghm
Copy link

yoonghm commented Apr 26, 2020

I am using pylint 2.4.4. It still shows the error.

@bersbersbers
Copy link

This should be fixed with the release of astroid==2.4.0.

@isohrab
Copy link

isohrab commented May 31, 2020

Astroid 2.4.1 and pylint 2.5.2

My error raise from pymongo db e.g db[collection_name].insert_one(...)

soxofaan added a commit to Open-EO/openeo-python-driver that referenced this issue Jun 19, 2020
Oleksii-Kutsenko added a commit to Oleksii-Kutsenko/PersonalAssistantBackend that referenced this issue Sep 27, 2020
@acxz
Copy link

acxz commented Oct 15, 2020

I can reproduce the original issue as well. I don't believe this issue has been fixed or it momentarily was and the issue resurfaced with newer versions.

pylint 2.6.0
astroid 2.4.2
Python 3.8.6

@hippo91
Copy link
Contributor

hippo91 commented Nov 24, 2020

@acxz thanks for your report. However i can not reproduce the original issue. For example linting the following code:

import numpy as np

arr = np.array([1, 2, 3])
shape = arr.shape
print(shape[0])

gives:

************* Module bug_pylint_3139
bug_pylint_3139.py:1:0: C0114: Missing module docstring (missing-module-docstring)

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

with:

pylint 2.6.0
astroid 2.4.3
Python 3.8.2 (default, Sep 28 2020, 21:24:28) 
[GCC 8.3.

@acxz
Copy link

acxz commented Nov 24, 2020

Thanks for looking into this, @hippo91! I cannot reproduce the issue with the original script either.
The following script, however, does give me the unsubscriptable-object

"""."""
import numpy as np

x_vec_list = [None] * 2
x_vec_list[0] = np.zeros(2)
x_vec_list[1] = np.zeros(2)

x1_vec = [x_vec[0] for x_vec in x_vec_list]

print(x1_vec)

gives:

************* Module test
test.py:8:10: E1136: Value 'x_vec' is unsubscriptable (unsubscriptable-object)

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

with

pylint 2.6.0
astroid 2.4.2
Python 3.8.6 (default, Sep 30 2020, 04:00:38) 
[GCC 10.2.0]

Should I instead make a new issue for this snippet?

We can just track this over at #3637
sorry for kinda necro-bumping this issue, was the first one I found 😜

@hippo91
Copy link
Contributor

hippo91 commented Nov 26, 2020

@acxz yes please open a different issue. In fact #3637 is probably not related to your issue but linked to panda support in astroid and pylint.

@acxz
Copy link

acxz commented Nov 26, 2020

Sounds good, I deleted my comment on #3637 and opened a new issue at #3956

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

No branches or pull requests

8 participants