Skip to content

Commit 4847314

Browse files
nelfinPierre-Sassoulas
authored andcommitted
Add regression test of invalid-sequence-index on __getitem__
Ref pylint-dev/astroid#927 (comment)
1 parent cd7c012 commit 4847314

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# pylint: disable=missing-docstring,too-few-public-methods
2+
3+
class DynamicGetitem:
4+
def __getitem__(self, key):
5+
if key == 'attributes':
6+
return []
7+
return {'world': 123}
8+
9+
10+
ex = DynamicGetitem()
11+
a = ex['hello']['world'] # [invalid-sequence-index] known false-positive
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
invalid-sequence-index:11:4:11:24::Sequence index is not an int, slice, or instance with __index__:UNDEFINED

0 commit comments

Comments
 (0)