summaryrefslogtreecommitdiff
path: root/test/input/func_bad_slots.py
blob: 16f7a79b61465a2cf593df59ccb10ed7c323efb0 (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
53
54
55
56
57
""" Checks that classes uses valid __slots__ """

# pylint: disable=too-few-public-methods, missing-docstring

from collections import deque

def func():
    if True:
        return ("a", "b", "c")
    else:
        return [str(var) for var in range(3)]

__revision__ = 0

class NotIterable(object):
    def __iter_(self):
        """ do nothing """

class Good(object):
    __slots__ = ()

class SecondGood(object):
    __slots__ = []

class ThirdGood(object):
    __slots__ = ['a']

class FourthGood(object):
    __slots__ = ('a%s' % i for i in range(10))

class FifthGood(object):
    __slots__ = "a"

class SixthGood(object):
    __slots__ = deque(["a", "b", "c"])

class SeventhGood(object):
    __slots__ = {"a": "b", "c": "d"}

class Bad(object):
    __slots__ = list

class SecondBad(object):
    __slots__ = 1

class ThirdBad(object):
    __slots__ = ('a', 2)

class FourthBad(object):
    __slots__ = NotIterable()

class FifthBad(object):
    __slots__ = ("a", "b", "")

class PotentiallyGood(object):
    __slots__ = func()