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