Pylint: False positive invalid-sequence-index on Tuple[...] on python 3.4

Created on 14 Dec 2016  路  5Comments  路  Source: PyCQA/pylint

Steps to reproduce

Originally discussed in the aftermath of #867.

$ mkvirtualenv --python /usr/bin/python3 py3
...
$ python --version
Python 3.4.3
$ pip install pylint mypy-lang
...
$ pip list
astroid (1.4.8)
isort (4.2.5)
lazy-object-proxy (1.2.2)
mccabe (0.5.2)
mypy-lang (0.4.6)
pip (1.5.4)
pylint (1.6.4)
setuptools (2.2)
six (1.10.0)
wrapt (1.10.8)
$ echo -e "from typing import Tuple\n\ndef my_list() -> Tuple[str, int]:\n    return 'str', 1" > foobar.py

Current behavior

$ pylint --reports=no foobar.py
************* Module foobar
foobar.py:4: [E1126(invalid-sequence-index), my_list] Sequence index is not an int, slice, or instance with __index__

Expected behavior

$ pylint --reports=no foobar.py
************* Module foobar

So, pylint shouldn't raise the error.

pylint --version output

pylint 1.6.4, 
astroid 1.4.8
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4]

Most helpful comment

Still have that problem with Python 3.5.3, maybe that is because some of the typing module internals changed with 3.5.3.

$pylint --reports=no foobar.py
No config file found, using default configuration
************* Module foobar
C:  1, 0: Missing module docstring (missing-docstring)
C:  3, 0: Missing function docstring (missing-docstring)
E:  3, 0: Sequence index is not an int, slice, or instance with __index__ (invalid-sequence-index)

pylint --version output

pylint 1.6.5,
astroid 1.4.9
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)]

All 5 comments

I tested this on python 3.4.5 and it still fails. However 3.5+ works as expected. Since this case is specific to 3.4 I think it should be reopened.

Still have that problem with Python 3.5.3, maybe that is because some of the typing module internals changed with 3.5.3.

$pylint --reports=no foobar.py
No config file found, using default configuration
************* Module foobar
C:  1, 0: Missing module docstring (missing-docstring)
C:  3, 0: Missing function docstring (missing-docstring)
E:  3, 0: Sequence index is not an int, slice, or instance with __index__ (invalid-sequence-index)

pylint --version output

pylint 1.6.5,
astroid 1.4.9
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)]

The problem is still here

def func(self)->Tuple[int, str]:
        '''docstring'''
        return (1, 'xx')
E:  9, 0: Sequence index is not an int, slice, or instance with __index__ (invalid-sequence-index)

pylint 1.6.5
astroid 1.4.9
Python 3.6.0

It's a dupe of #1295 which was fixed in PyCQA/astroid@563031aaf13a44adc8db4f8d0ab8020d550aae00

Was this page helpful?
0 / 5 - 0 ratings