##// END OF EJS Templates
code style: prefer 'is' and 'is not' tests with singletons
Martin Geisler -
r13031:3da456d0 default
parent child Browse files
Show More
@@ -150,6 +150,8 b' pypats = ['
150 150 (r'ui\.(status|progress|write|note|warn)\([\'\"]x',
151 151 "warning: unwrapped ui message"),
152 152 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
153 (r' [=!]=\s+(True|False|None)',
154 "comparison with singleton, use 'is' or 'is not' instead"),
153 155 ]
154 156
155 157 pyfilters = [
@@ -137,7 +137,7 b' def bookmark(ui, repo, mark=None, rev=No'
137 137 write(repo)
138 138 return
139 139
140 if mark != None:
140 if mark is not None:
141 141 if "\n" in mark:
142 142 raise util.Abort(_("bookmark name cannot contain newlines"))
143 143 mark = mark.strip()
@@ -181,14 +181,14 b' def revtree(ui, args, repo, full="tree",'
181 181 if i + x >= count:
182 182 l[chunk - x:] = [0] * (chunk - x)
183 183 break
184 if full != None:
184 if full is not None:
185 185 l[x] = repo[i + x]
186 186 l[x].changeset() # force reading
187 187 else:
188 188 l[x] = 1
189 189 for x in xrange(chunk - 1, -1, -1):
190 190 if l[x] != 0:
191 yield (i + x, full != None and l[x] or None)
191 yield (i + x, full is not None and l[x] or None)
192 192 if i == 0:
193 193 break
194 194
@@ -1523,7 +1523,7 b' class queue(object):'
1523 1523 l = line.rstrip()
1524 1524 l = l[10:].split(' ')
1525 1525 qpp = [bin(x) for x in l]
1526 elif datastart != None:
1526 elif datastart is not None:
1527 1527 l = line.rstrip()
1528 1528 n, name = l.split(':', 1)
1529 1529 if n:
@@ -401,7 +401,7 b' class transplanter(object):'
401 401
402 402 def hasnode(repo, node):
403 403 try:
404 return repo.changelog.rev(node) != None
404 return repo.changelog.rev(node) is not None
405 405 except error.RevlogError:
406 406 return False
407 407
@@ -130,7 +130,7 b' class config(object):'
130 130 name = m.group(1)
131 131 if sections and section not in sections:
132 132 continue
133 if self.get(section, name) != None:
133 if self.get(section, name) is not None:
134 134 del self._data[section][name]
135 135 continue
136 136
@@ -179,7 +179,7 b' class changectx(object):'
179 179 """
180 180 # deal with workingctxs
181 181 n2 = c2._node
182 if n2 == None:
182 if n2 is None:
183 183 n2 = c2._parents[0]._node
184 184 n = self._repo.changelog.ancestor(self._node, n2)
185 185 return changectx(self._repo, n)
@@ -171,19 +171,19 b' class manifest(revlog.revlog):'
171 171 raise AssertionError(
172 172 _("failed to remove %s from manifest") % f)
173 173 l = ""
174 if dstart != None and dstart <= start and dend >= start:
174 if dstart is not None and dstart <= start and dend >= start:
175 175 if dend < end:
176 176 dend = end
177 177 if l:
178 178 dline.append(l)
179 179 else:
180 if dstart != None:
180 if dstart is not None:
181 181 delta.append([dstart, dend, "".join(dline)])
182 182 dstart = start
183 183 dend = end
184 184 dline = [l]
185 185
186 if dstart != None:
186 if dstart is not None:
187 187 delta.append([dstart, dend, "".join(dline)])
188 188 # apply the delta to the addlist, and get a delta for addrevision
189 189 cachedelta = (self.rev(p1), addlistdelta(addlist, delta))
@@ -212,7 +212,7 b' class lazyparser(object):'
212 212 return None
213 213 self.mapfind_count += 1
214 214 last = self.l - 1
215 while self.index[last] != None:
215 while self.index[last] is not None:
216 216 if last == 0:
217 217 self.all = 1
218 218 self.allmap = 1
@@ -715,7 +715,7 b' methods = {'
715 715 }
716 716
717 717 def optimize(x, small):
718 if x == None:
718 if x is None:
719 719 return 0, x
720 720
721 721 smallbonus = 1
@@ -589,7 +589,7 b' class ui(object):'
589 589 termination.
590 590 '''
591 591
592 if pos == None or not self.debugflag:
592 if pos is None or not self.debugflag:
593 593 return
594 594
595 595 if unit:
@@ -1054,7 +1054,7 b' def strdate(string, format, defaults=[])'
1054 1054
1055 1055 # NOTE: unixtime = localunixtime + offset
1056 1056 offset, date = timezone(string), string
1057 if offset != None:
1057 if offset is not None:
1058 1058 date = " ".join(string.split()[:-1])
1059 1059
1060 1060 # add missing elements from defaults
@@ -34,7 +34,7 b' def _verify(repo):'
34 34 raise util.Abort(_("cannot verify bundle or remote repos"))
35 35
36 36 def err(linkrev, msg, filename=None):
37 if linkrev != None:
37 if linkrev is not None:
38 38 badrevs.add(linkrev)
39 39 else:
40 40 linkrev = '?'
@@ -594,7 +594,7 b' def run(cmd, options, replacements):'
594 594 tochild.close()
595 595 output = fromchild.read()
596 596 ret = fromchild.close()
597 if ret == None:
597 if ret is None:
598 598 ret = 0
599 599 else:
600 600 proc = Popen4(cmd)
@@ -714,7 +714,7 b' def runone(options, test, skips, fails):'
714 714 # If we're not in --debug mode and reference output file exists,
715 715 # check test output against it.
716 716 if options.debug:
717 refout = None # to match out == None
717 refout = None # to match "out is None"
718 718 elif os.path.exists(ref):
719 719 f = open(ref, "r")
720 720 refout = splitnewlines(f.read())
General Comments 0
You need to be logged in to leave comments. Login now