1
0
forked from VimPlug/jedi

fix for iterators -- should start working when py__iter__ gets fixed: https://github.com/davidhalter/jedi/pull/663\#issuecomment-172317854

This commit is contained in:
Claude
2016-01-17 16:45:12 +01:00
parent b499906398
commit 885f7cb068
2 changed files with 38 additions and 4 deletions

View File

@@ -13,7 +13,8 @@ except ImportError:
def factory(typing_name, indextypes):
class Iterable(abc.Iterable):
def __iter__(self):
yield indextypes[0]()
while True:
yield indextypes[0]()
class Iterator(Iterable, abc.Iterator):
def next(self):
@@ -23,10 +24,14 @@ def factory(typing_name, indextypes):
def __next__(self):
return indextypes[0]()
class Sequence(Iterable, abc.Sequence):
class Sequence(abc.Sequence):
def __getitem__(self, index):
return indextypes[0]()
def __len__(self):
import sys
return sys.maxint
class MutableSequence(Sequence, abc.MutableSequence):
pass
@@ -42,6 +47,13 @@ def factory(typing_name, indextypes):
else:
return indextypes[index]()
def __len__(self):
if indextypes[1] == ...:
import sys
return sys.maxint
else:
return len(indextypes)
class AbstractSet(Iterable, abc.Set):
pass
@@ -53,11 +65,13 @@ def factory(typing_name, indextypes):
class ValuesView(abc.ValuesView):
def __iter__(self):
yield indextypes[1]()
while True:
yield indextypes[1]()
class ItemsView(abc.ItemsView):
def __iter__(self):
yield Tuple()
while True:
yield Tuple()
class Mapping(Iterable, abc.Mapping):
def __getitem__(self, item):

View File

@@ -47,6 +47,16 @@ def iterators(
p
#?
next(ps)
a, b = ps
#? int()
a
##? int() --- TODO fix support for tuple assignment
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
# test below is just to make sure that in case it gets fixed by accident
# these tests will be fixed as well the way they should be
#?
b
for q in qs:
#? str()
q
@@ -93,8 +103,12 @@ def tuple(
#? int()
i
##? str() --- TODO fix support for tuple assignment
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
#?
s
##? float() --- TODO fix support for tuple assignment
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
#?
f
class Key:
@@ -136,11 +150,15 @@ def mapping(
#? Key()
key
##? Value() --- TODO fix support for tuple assignment
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
#?
value
for key, value in p.items():
#? Key()
key
##? Value() --- TODO fix support for tuple assignment
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
#?
value
for key in r:
#? Key()
@@ -152,6 +170,8 @@ def mapping(
#? Key()
key
##? Value() --- TODO fix support for tuple assignment
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
#?
value
def union(