-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed as not planned
Labels
Bug 🪲Control flowRequires control flow understandingRequires control flow understandingMinor 💅Polishing pylint is always nicePolishing pylint is always niceNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Description
The following code:
N = 10
order = [0] * N
j = None
for i in range(N):
if j is not None:
order[j] += 1 # <--- E1126 for this line
else:
j = i
gives:
test.py:6:0: E1126: Sequence index is not an int, slice, or instance with __index__ (invalid-sequence-index)
I can see that this is because j was initially set to None
, which would not be a valid index. However the code is actually correct, as a human can see, since it checks for None
before using the index.
I'm not sure if there's anything pylint can do abut this, since I'm not sure how sophisticated it aims to be in checking this sort of thing. But reporting this anyway for what it's worth - feel free to close if this is outside the scope of pylint.
pylint 2.2.2
astroid 2.1.0
Python 3.7.3 (default, Mar 26 2019, 21:43:19)
[GCC 8.2.1 20181127]
Metadata
Metadata
Assignees
Labels
Bug 🪲Control flowRequires control flow understandingRequires control flow understandingMinor 💅Polishing pylint is always nicePolishing pylint is always niceNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation