Skip to content

Unexpected E1126: Sequence index is not an int, slice, or instance with __index__  #3214

@miko989

Description

@miko989

Steps to reproduce

test.py:

def print_info_from_list(some_list):
    msg=''
    msg+=('  ' + '{:<27}'.format('') + ''.join('{:>10}|'.format(
        cntrs['id']) for cntrs in some_list) + '\n') # pylint says this is not ok
    for k in ['a', 'b', 'c']:
        msg+=('  ' + '{:<27}'.format(k) + ''.join('{:>10}|'.format(
            cntrs['bla'][k]) for cntrs in some_list) + '\n') # but this is ok
$ pylint test.py --errors-only

Current behavior

************* Module test
plint.py:4:0: E1126: Sequence index is not an int, slice, or instance with __index__ (invalid-sequence-index)

Expected behavior

I don't expect any error here.

pylint --version output

pylint 2.3.1
astroid 2.2.5
Python 3.6.8 (default, Jul 11 2019, 15:00:19)
[GCC 7.3.0]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions