summaryrefslogtreecommitdiff
path: root/pylint/test/functional/no_staticmethod_decorator.py
blob: a64cd7cd9184efdf853e9353d97a19c2e5ecc417 (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
"""Checks static methods are declared with a decorator if within the class
scope and if static method's argument is a member of the class
"""

# pylint: disable=too-few-public-methods, using-constant-test, no-method-argument

class MyClass(object):
    """Some class"""
    def __init__(self):
        pass

    def smethod():
        """static method-to-be"""
    smethod = staticmethod(smethod) # [no-staticmethod-decorator]

    if True:
        smethod = staticmethod(smethod)  # [no-staticmethod-decorator]

    @staticmethod
    def my_second_method():
        """correct static method definition"""

    def other_method():
        """some method"""
    smethod2 = staticmethod(other_method)  # [no-staticmethod-decorator]

def helloworld():
    """says hello"""
    print 'hello world'

MyClass.new_static_method = staticmethod(helloworld)

class MyOtherClass(object):
    """Some other class"""
    _make = staticmethod(tuple.__new__)