summaryrefslogtreecommitdiff
path: root/pylint/test/functional/misplaced_comparison_constant.py
blob: fb6e40d7df218b7e0eb0cb1ca543b347540adb43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Check that the constants are on the right side of the comparisons"""

# pylint: disable=singleton-comparison
def bad_comparisons():
    """this is not ok: 5 should be on the right"""
    for i in range(10):
        if 5 <= i:  # [misplaced-comparison-constant]
            print "foo"
        if True == True:  # [misplaced-comparison-constant]
            pass
        if 'bar' != 'foo':  # [misplaced-comparison-constant]
            pass
        if 1 == i:  # [misplaced-comparison-constant]
            print "bar"

def good_comparison():
    """this is ok"""
    for i in range(10):
        if i == 5:
            print "foo"