invalid-sequence-index / E1126#

Message emitted:

Sequence index is not an int, slice, or instance with __index__

Description:

Used when a sequence type is indexed with an invalid type. Valid types are ints, slices, and objects with an __index__ method.

Correct code:

fruits = ['apple', 'banana', 'orange']
print(fruits[0])

Problematic code:

fruits = ['apple', 'banana', 'orange']
print(fruits['apple'])  # [invalid-sequence-index]

Additional details:

Be careful with [True] or [False] as sequence index, since True and False will respectively be evaluated as 1 and 0 and will bring the second element of the list and the first without erroring.

Created by the typecheck checker.