summaryrefslogtreecommitdiff
path: root/doc/message-control.rst
blob: 203229d1f8d4b316884893bb7047a9ecbd060482 (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

Messages control
----------------

An example available from the examples directory:

.. sourcecode:: python

    """pylint option block-disable"""

    __revision__ = None

    class Foo(object):
        """block-disable test"""

        def __init__(self):
            pass

        def meth1(self, arg):
            """this issues a message"""
            print self

        def meth2(self, arg):
            """and this one not"""
            # pylint: disable=unused-argument
            print self\
                  + "foo"

        def meth3(self):
            """test one line disabling"""
            # no error
            print self.bla # pylint: disable=no-member
            # error
            print self.blop

        def meth4(self):
            """test re-enabling"""
            # pylint: disable=no-member
            # no error
            print self.bla
            print self.blop
            # pylint: enable=no-member
            # error
            print self.blip

        def meth5(self):
            """test IF sub-block re-enabling"""
            # pylint: disable=no-member
            # no error
            print self.bla
            if self.blop:
                # pylint: enable=no-member
                # error
                print self.blip
            else:
                # no error
                print self.blip
            # no error
            print self.blip

        def meth6(self):
            """test TRY/EXCEPT sub-block re-enabling"""
            # pylint: disable=no-member
            # no error
            print self.bla
            try:
                # pylint: enable=no-member
                # error
                print self.blip
            except UndefinedName: # pylint: disable=undefined-variable
                # no error
                print self.blip
            # no error
            print self.blip

        def meth7(self):
            """test one line block opening disabling"""
            if self.blop: # pylint: disable=no-member
                # error
                print self.blip
            else:
                # error
                print self.blip
            # error
            print self.blip


        def meth8(self):
            """test late disabling"""
            # error
            print self.blip
            # pylint: disable=no-member
            # no error
            print self.bla
            print self.blop