

























#ODASA-4519
#OK as we are using identity tests for unique objects
V2 = "v2"
V3 = "v3"

class C:
    def __init__(self, c):
        if c:
            self.version = V2
        else:
            self.version = V3

    def meth(self):
        if self.version is V2:    #FP here.
            pass


#Using 'is' when should be using '=='
s = "Hello " + "World"
if "Hello World" is s:
    print ("OK")

#This is OK in CPython, but may not be portable
s = str(7)
if "7" is s:
    print ("OK")

#And some data flow
CONSTANT = 20
if x is CONSTANT:
    print ("OK")

#This is OK
x = object()
y = object()
if x is y:
    print ("Very surprising!")

#This is also OK
if s is None:
    print ("Also surprising")

#Portable is comparisons
def f(arg):
    arg is ()
    arg is 0

class C(object):
    def __eq__(self, other):
        '''
        'is' must be fine here.
        '''
        return self is other

#Was FP -- https://github.com/lgtmhq/lgtm-queries/issues/13
def both_sides_known(zero_based="auto", query_id=False):
    if query_id and zero_based == "auto":
        zero_based = True
    if zero_based is False: # False positive here
        pass


@@ -23,19 +23,8 @@
 %0A%0A%0A%0A
-#ODASA-4519
 %0A#OK
@@ -1142,20 +1142,344 @@
  here%0A        pass%0A%0A
+#Avoid depending on enum back port for Python 2 tests:%0Aclass Enum(object):%0A    pass%0A%0Aclass MyEnum(Enum):%0A%0A    memberA = None%0A    memberB = 10%0A    memberC = (%22Hello%22, %22World%22)%0A%0Adef comp_enum(x):%0A    if x is MyEnum.memberA:%0A        return%0A    if x is MyEnum.memberB:%0A        return%0A    if x is MyEnum.memberC:%0A        return%0A%0A

add failing test for comparison using 'is' and enum members.