summaryrefslogtreecommitdiff
path: root/test/input/func_non_iterator_returned_py30.py
blob: 69157680ccf84f9d9fd99f8233b0b1af5ba3be25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""Check non-iterators returned by __iter__ """

# pylint: disable=too-few-public-methods

__revision__ = 0

class FirstGoodIterator(object):
    """ yields in iterator. """

    def __iter__(self):
        for index in range(10):
            yield index

class SecondGoodIterator(object):
    """ __iter__ and next """

    def __iter__(self):
        return self

    def __next__(self): # pylint: disable=no-self-use
        """ Infinite iterator, but still an iterator """
        return 1

class ThirdGoodIterator(object):
    """ Returns other iterator, not the current instance """

    def __iter__(self):
        return SecondGoodIterator()

class FourthGoodIterator(object):
    """ __iter__ returns iter(...) """

    def __iter__(self):
        return iter(range(10))

class FirstBadIterator(object):
    """ __iter__ returns a list """

    def __iter__(self):
        return []

class SecondBadIterator(object):
    """ __iter__ without next """

    def __iter__(self):
        return self

class ThirdBadIterator(object):
    """ __iter__ returns an instance of another non-iterator """

    def __iter__(self):
        return SecondBadIterator()