summaryrefslogtreecommitdiff
path: root/pylint/test/functional/unexpected_special_method_signature.py
blob: 41f02e536b01c6bf3fd9f6164fc95ba4dddcef02 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
"""Test for special methods implemented incorrectly."""

# pylint: disable=missing-docstring, unused-argument, too-few-public-methods
# pylint: disable=invalid-name,too-many-arguments,bad-staticmethod-argument

class Invalid(object):

    def __enter__(self, other): # [unexpected-special-method-signature]
        pass

    def __del__(self, other): # [unexpected-special-method-signature]
        pass

    def __format__(self, other, other2): # [unexpected-special-method-signature]
        pass

    def __setattr__(self): # [unexpected-special-method-signature]
        pass

    def __round__(self, invalid, args): # [unexpected-special-method-signature]
        pass

    def __deepcopy__(self, memo, other): # [unexpected-special-method-signature]
        pass

    def __iter__(): # [no-method-argument]
        pass

    @staticmethod
    def __getattr__(self, nanana): # [unexpected-special-method-signature]
        pass


class FirstBadContextManager(object):
    def __enter__(self):
        return self
    def __exit__(self, exc_type): # [unexpected-special-method-signature]
        pass

class SecondBadContextManager(object):
    def __enter__(self):
        return self
    def __exit__(self, exc_type, value, tb, stack): # [unexpected-special-method-signature]
        pass

class ThirdBadContextManager(object):
    def __enter__(self):
        return self

    # +1: [unexpected-special-method-signature]
    def __exit__(self, exc_type, value, tb, stack, *args):
        pass


class Async(object):

    def __aiter__(self, extra): # [unexpected-special-method-signature]
        pass
    def __anext__(self, extra, argument): # [unexpected-special-method-signature]
        pass
    def __await__(self, param): # [unexpected-special-method-signature]
        pass
    def __aenter__(self, first): # [unexpected-special-method-signature]
        pass
    def __aexit__(self): # [unexpected-special-method-signature]
        pass


class Valid(object):

    def __new__(cls, test, multiple, args):
        pass

    def __init__(self, this, can, have, multiple, args, as_well):
        pass

    def __call__(self, also, trv, for_this):
        pass

    def __round__(self, n):
        pass

    def __index__(self, n=42):
        """Expects 0 args, but we are taking in account arguments with defaults."""

    def __deepcopy__(self, memo):
        pass

    def __format__(self, format_specification=''):
        pass

    def __copy__(self, this=None, is_not=None, necessary=None):
        pass

    @staticmethod
    def __enter__():
        pass

    @staticmethod
    def __getitem__(index):
        pass


class FirstGoodContextManager(object):
    def __enter__(self):
        return self
    def __exit__(self, exc_type, value, tb):
        pass

class SecondGoodContextManager(object):
    def __enter__(self):
        return self
    def __exit__(self, exc_type=None, value=None, tb=None):
        pass

class ThirdGoodContextManager(object):
    def __enter__(self):
        return self
    def __exit__(self, exc_type, *args):
        pass