Pylint: Incorrect 'unsubscriptable-object' reported

Created on 19 May 2020  路  6Comments  路  Source: PyCQA/pylint

Steps to reproduce

Running Pylint on the following code will produce the error on the last line.

import statsmodels.api as sm

data = sm.datasets.longley.load_pandas().data

properties = ['GNP', 'POP']
specificData = data[properties]

Current behavior

Running Pylint gives

example.py|6 col 16 error| E1136: Value 'data' is unsubscriptable (unsubscriptable-object)
example.py|6 col 16 error| unsubscriptable-object: Value 'data' is unsubscriptable

Expected behavior

No errors/warnings should be produced.

pylint --version output

pylint 2.5.2
astroid 2.4.1
Python 3.7.7 (default, Apr 14 2020, 11:51:19)
[Clang 11.0.0 (clang-1100.0.33.12)]

bug false-positive

Most helpful comment

@Cielquan thanks for your report. However your issue is not linked to the original one but it is due to the fact pylint is not yet supporting python3.9. We are working on it.

All 6 comments

Same problem with this:

import numpy as np

ARRAY = np.array([[1, 2, 3]]).T

print(ARRAY[0])

Value 'ARRAY' is unsubscriptable (unsubscriptable-object)
There should be no error.

Have a similar problem with type hints.

This LoC

EnvVarTypes = Union[str, int, float, bool, None]

gives E1136: Value 'Union' is unsubscriptable (unsubscriptable-object).

This LoC

def validate(self, line: str, _: GitCommit) -> List[Optional[RuleViolation]]:

gives E1136: Value 'Optional' is unsubscriptable (unsubscriptable-object).

BUT those errors only occur in with

$ pylint --version
pylint 2.6.0
astroid 2.4.2
Python 3.9.0 (default, Oct  6 2020, 02:47:17) 
[GCC 7.5.0]

and not with

$ pylint --version
pylint 2.6.0
astroid 2.4.2
Python 3.8.6 (default, Oct  6 2020, 03:22:36) 
[GCC 7.5.0]

@beauxq thanks for your comment. It seems your issue is not linked to the original one. Morevoer it should have been fixed through PyCQA/astroid#831.

@Cielquan thanks for your report. However your issue is not linked to the original one but it is due to the fact pylint is not yet supporting python3.9. We are working on it.

To any people thinking adding a comment here, please do only if your problem seems to be linked to panda's support in pylint. Otherwise please open another issue. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sambarluc picture sambarluc  路  3Comments

GergelyKalmar picture GergelyKalmar  路  3Comments

pylint-bot picture pylint-bot  路  3Comments

z4y4ts picture z4y4ts  路  3Comments

PCManticore picture PCManticore  路  3Comments