mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Make it possible to use __getitem__ in interpreter
This commit is contained in:
@@ -599,6 +599,19 @@ def test_dict_getitem(code, types):
|
||||
assert [c.name for c in comps] == types
|
||||
|
||||
|
||||
@pytest.mark.parametrize('class_is_findable', [False, True])
|
||||
def test__getitem__(class_is_findable):
|
||||
class GetitemCls:
|
||||
def __getitem__(self, key) -> int:
|
||||
pass
|
||||
|
||||
if not class_is_findable:
|
||||
GetitemCls.__name__ = 'asdf'
|
||||
|
||||
n, = jedi.Interpreter('GetitemCls()[0]', [locals()]).infer()
|
||||
assert n.name == 'int'
|
||||
|
||||
|
||||
def foo():
|
||||
raise KeyError
|
||||
|
||||
|
||||
Reference in New Issue
Block a user