summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Gordon <jogo@cloudscaling.com>2013-02-12 17:46:23 -0800
committerJoe Gordon <jogo@cloudscaling.com>2013-02-12 17:46:23 -0800
commit339dd992b497519446a1e80fe5d317342b33967d (patch)
treef5b215b171ece60ed0dd507bba1155a22dac2153
parent9994a9161d0acac216b3441233eae1f7238db889 (diff)
downloadnova-339dd992b497519446a1e80fe5d317342b33967d.tar.gz
nova-339dd992b497519446a1e80fe5d317342b33967d.tar.xz
nova-339dd992b497519446a1e80fe5d317342b33967d.zip
Add "is not" test to hacking.py
HACKING.rst was updated in I7534ef73e6fd525fd8f4bee594a4b37524699c08. This adds hacking.py enforcement. Change-Id: I5d75d536762449d0a7ae38213addd02aeceede0b
-rwxr-xr-xtools/hacking.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/tools/hacking.py b/tools/hacking.py
index 42a644e7d..d75595cc2 100755
--- a/tools/hacking.py
+++ b/tools/hacking.py
@@ -495,20 +495,34 @@ def nova_localization_strings(logical_line, tokens):
#TODO(jogo) Dict and list objects
+def nova_is_not(logical_line):
+ r"""Check localization in line.
+
+ Okay: if x is not y
+ N901: if not X is Y
+ N901: if not X.B is Y
+ """
+ split_line = logical_line.split()
+ if (len(split_line) == 5 and split_line[0] == 'if' and
+ split_line[1] == 'not' and split_line[3] == 'is'):
+ yield (logical_line.find('not'), "N901: Use the 'is not' "
+ "operator for when testing for unequal identities")
+
+
def nova_not_in(logical_line):
r"""Check localization in line.
Okay: if x not in y
Okay: if not (X in Y or X is Z)
Okay: if not (X in Y)
- N901: if not X in Y
- N901: if not X.B in Y
+ N902: if not X in Y
+ N902: if not X.B in Y
"""
split_line = logical_line.split()
if (len(split_line) == 5 and split_line[0] == 'if' and
split_line[1] == 'not' and split_line[3] == 'in' and not
split_line[2].startswith('(')):
- yield (logical_line.find('not'), "N901: Use the 'not in' "
+ yield (logical_line.find('not'), "N902: Use the 'not in' "
"operator for collection membership evaluation")
current_file = ""