forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincomplete_ordering.py
More file actions
40 lines (29 loc) · 826 Bytes
/
incomplete_ordering.py
File metadata and controls
40 lines (29 loc) · 826 Bytes
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
#Incomplete ordering
class LtWithoutLe(object): # $ Alert
def __eq__(self, other):
return self is other
def __ne__(self, other):
return self is not other
def __hash__(self):
return id(self)
def __lt__(self, other):
return False
# Don't alert on subclass
class LtWithoutLeSub(LtWithoutLe):
pass
class LeSub(LtWithoutLe):
def __le__(self, other):
return self < other or self == other
class GeSub(LtWithoutLe):
def __ge__(self, other):
return self > other or self == other
class LendGeNoLt: # $ Alert
def __le__(self, other):
return True
def __ge__(self, other):
return other <= self
from functools import total_ordering
@total_ordering
class Total:
def __le__(self, other):
return True