mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-19 06:49:38 +08:00
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:
@@ -13,7 +13,8 @@ except ImportError:
|
|||||||
def factory(typing_name, indextypes):
|
def factory(typing_name, indextypes):
|
||||||
class Iterable(abc.Iterable):
|
class Iterable(abc.Iterable):
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
yield indextypes[0]()
|
while True:
|
||||||
|
yield indextypes[0]()
|
||||||
|
|
||||||
class Iterator(Iterable, abc.Iterator):
|
class Iterator(Iterable, abc.Iterator):
|
||||||
def next(self):
|
def next(self):
|
||||||
@@ -23,10 +24,14 @@ def factory(typing_name, indextypes):
|
|||||||
def __next__(self):
|
def __next__(self):
|
||||||
return indextypes[0]()
|
return indextypes[0]()
|
||||||
|
|
||||||
class Sequence(Iterable, abc.Sequence):
|
class Sequence(abc.Sequence):
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
return indextypes[0]()
|
return indextypes[0]()
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
import sys
|
||||||
|
return sys.maxint
|
||||||
|
|
||||||
class MutableSequence(Sequence, abc.MutableSequence):
|
class MutableSequence(Sequence, abc.MutableSequence):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -42,6 +47,13 @@ def factory(typing_name, indextypes):
|
|||||||
else:
|
else:
|
||||||
return indextypes[index]()
|
return indextypes[index]()
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
if indextypes[1] == ...:
|
||||||
|
import sys
|
||||||
|
return sys.maxint
|
||||||
|
else:
|
||||||
|
return len(indextypes)
|
||||||
|
|
||||||
class AbstractSet(Iterable, abc.Set):
|
class AbstractSet(Iterable, abc.Set):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -53,11 +65,13 @@ def factory(typing_name, indextypes):
|
|||||||
|
|
||||||
class ValuesView(abc.ValuesView):
|
class ValuesView(abc.ValuesView):
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
yield indextypes[1]()
|
while True:
|
||||||
|
yield indextypes[1]()
|
||||||
|
|
||||||
class ItemsView(abc.ItemsView):
|
class ItemsView(abc.ItemsView):
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
yield Tuple()
|
while True:
|
||||||
|
yield Tuple()
|
||||||
|
|
||||||
class Mapping(Iterable, abc.Mapping):
|
class Mapping(Iterable, abc.Mapping):
|
||||||
def __getitem__(self, item):
|
def __getitem__(self, item):
|
||||||
|
|||||||
@@ -47,6 +47,16 @@ def iterators(
|
|||||||
p
|
p
|
||||||
#?
|
#?
|
||||||
next(ps)
|
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:
|
for q in qs:
|
||||||
#? str()
|
#? str()
|
||||||
q
|
q
|
||||||
@@ -93,8 +103,12 @@ def tuple(
|
|||||||
#? int()
|
#? int()
|
||||||
i
|
i
|
||||||
##? str() --- TODO fix support for tuple assignment
|
##? str() --- TODO fix support for tuple assignment
|
||||||
|
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
|
||||||
|
#?
|
||||||
s
|
s
|
||||||
##? float() --- TODO fix support for tuple assignment
|
##? float() --- TODO fix support for tuple assignment
|
||||||
|
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
|
||||||
|
#?
|
||||||
f
|
f
|
||||||
|
|
||||||
class Key:
|
class Key:
|
||||||
@@ -136,11 +150,15 @@ def mapping(
|
|||||||
#? Key()
|
#? Key()
|
||||||
key
|
key
|
||||||
##? Value() --- TODO fix support for tuple assignment
|
##? Value() --- TODO fix support for tuple assignment
|
||||||
|
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
|
||||||
|
#?
|
||||||
value
|
value
|
||||||
for key, value in p.items():
|
for key, value in p.items():
|
||||||
#? Key()
|
#? Key()
|
||||||
key
|
key
|
||||||
##? Value() --- TODO fix support for tuple assignment
|
##? Value() --- TODO fix support for tuple assignment
|
||||||
|
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
|
||||||
|
#?
|
||||||
value
|
value
|
||||||
for key in r:
|
for key in r:
|
||||||
#? Key()
|
#? Key()
|
||||||
@@ -152,6 +170,8 @@ def mapping(
|
|||||||
#? Key()
|
#? Key()
|
||||||
key
|
key
|
||||||
##? Value() --- TODO fix support for tuple assignment
|
##? Value() --- TODO fix support for tuple assignment
|
||||||
|
# https://github.com/davidhalter/jedi/pull/663#issuecomment-172317854
|
||||||
|
#?
|
||||||
value
|
value
|
||||||
|
|
||||||
def union(
|
def union(
|
||||||
|
|||||||
Reference in New Issue
Block a user