summaryrefslogtreecommitdiff
path: root/tests/functional/i/invalid/invalid_name.py
blob: 527064c44c8aced47a3f58bf1cbbb9c7e00b4113 (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
""" Tests for invalid-name checker. """
# pylint: disable=unused-import, wrong-import-position, import-outside-toplevel, missing-class-docstring,missing-function-docstring
# pylint: disable=too-few-public-methods


AAA = 24
try:
    import collections
except ImportError:
    collections = None

aaa = 42 # [invalid-name]
try:
    import time
except ValueError:
    time = None # [invalid-name]

try:
    from sys import argv, executable as python
except ImportError:
    argv = 42
    python = 24

def test():
    """ Shouldn't emit an invalid-name here. """
    try:
        import re
    except ImportError:
        re = None
    return re

def a(): # [invalid-name]
    """yo"""


def _generate_cmdline_tests():
    TestCase = collections.namedtuple('TestCase', 'cmd, valid')
    valid = ['leave-mode', 'hint all']
    # Valid command only -> valid
    for item in valid:
        yield TestCase(''.join(item), True)


# We should emit for the loop variable.
for i in range(10):
    Foocapfor = 2  # [invalid-name]


def dummy_decorator(aaabc, bbbcd):
    """Some"""
    def real_decorator(fff):
        """pieces of"""
        def wrapper(*args, **kwargs):
            """docstring"""
            print(aaabc, bbbcd)
            fff(*args, **kwargs)
        return wrapper
    return real_decorator


@dummy_decorator(1, [
    0  # Fixing #119 should make this go away
# C0103 always points here - line 61  # [invalid-name]


])
def a_very_very_very_long_function_name_WithCamelCase_to_make_it_sad():  # Should be line 65
    """Docstring"""
    print('LOL')

a_very_very_very_long_function_name_WithCamelCase_to_make_it_sad()


class FooBar:
    def __init__(self, fooBar) -> None:  # [invalid-name]
        self.foo_bar = fooBar
        self.foo_bar2 = None

    def func1(
        self,
        fooBar,  # [invalid-name]
    ):
        self.foo_bar = fooBar

    # Test disable invalid-name
    def test_disable1(self, fooBar):  # pylint: disable=invalid-name
        self.foo_bar = fooBar

    def test_disable2(
        self,
        fooBar,  # pylint: disable=invalid-name
    ):
        self.foo_bar = fooBar

    def test_disable3(self, fooBar):  # pylint: disable=invalid-name
        self.foo_bar = fooBar

    def test_disable_mixed(
        self,
        fooBar,  # pylint: disable=invalid-name
        fooBar2,  # [invalid-name]
    ):
        """Invalid-name will still be raised for other arguments."""
        self.foo_bar = fooBar
        self.foo_bar2 = fooBar2