Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Used "is" for comparisons with None.

  • Loading branch information...
commit cec11a3336c730e6dc2f1966fee749cc830e97c0 1 parent ff9e8ec
Tim Graham authored October 10, 2013
3  django/core/mail/message.py
@@ -292,7 +292,8 @@ def attach(self, filename=None, content=None, mimetype=None):
292 292
         into the resulting message attachments.
293 293
         """
294 294
         if isinstance(filename, MIMEBase):
295  
-            assert content == mimetype == None
  295
+            assert content is None
  296
+            assert mimetype is None
296 297
             self.attachments.append(filename)
297 298
         else:
298 299
             assert content is not None
2  django/forms/widgets.py
@@ -508,7 +508,7 @@ def render(self, name, value, attrs=None, choices=()):
508 508
         return mark_safe('\n'.join(output))
509 509
 
510 510
     def render_option(self, selected_choices, option_value, option_label):
511  
-        if option_value == None:
  511
+        if option_value is None:
512 512
             option_value = ''
513 513
         option_value = force_text(option_value)
514 514
         if option_value in selected_choices:
2  django/middleware/cache.py
@@ -96,7 +96,7 @@ def process_response(self, request, response):
96 96
         # Control" header before reverting to using the default cache_timeout
97 97
         # length.
98 98
         timeout = get_max_age(response)
99  
-        if timeout == None:
  99
+        if timeout is None:
100 100
             timeout = self.cache_timeout
101 101
         elif timeout == 0:
102 102
             # max-age was set to 0, don't bother caching.
2  django/template/defaulttags.py
@@ -315,7 +315,7 @@ def resolve_expression(self, obj, context):
315 315
 
316 316
     def render(self, context):
317 317
         obj_list = self.target.resolve(context, True)
318  
-        if obj_list == None:
  318
+        if obj_list is None:
319 319
             # target variable wasn't found in context; fail silently.
320 320
             context[self.var_name] = []
321 321
             return ''
2  django/test/_doctest.py
@@ -1345,7 +1345,7 @@ def py3_displayhook(value):
1345 1345
                     # exception message will be in group(2)
1346 1346
                     m = re.match(r'(.*)\.(\w+:.+\s)', exc_msg)
1347 1347
                     # make sure there's a match
1348  
-                    if m != None:
  1348
+                    if m is not None:
1349 1349
                         f_name = m.group(1)
1350 1350
                         # check to see if m.group(1) contains the module name
1351 1351
                         if f_name == exception[0].__module__:
4  tests/basic/tests.py
@@ -33,7 +33,7 @@ def test_lookup(self):
33 33
         a.save()
34 34
 
35 35
         # Now it has an ID.
36  
-        self.assertTrue(a.id != None)
  36
+        self.assertTrue(a.id is not None)
37 37
 
38 38
         # Models have a pk property that is an alias for the primary key
39 39
         # attribute (by default, the 'id' attribute).
@@ -585,7 +585,7 @@ def test_field_ordering(self):
585 585
         f3 = Field()
586 586
         self.assertTrue(f2 < f1)
587 587
         self.assertTrue(f3 > f1)
588  
-        self.assertFalse(f1 == None)
  588
+        self.assertFalse(f1 is None)
589 589
         self.assertFalse(f2 in (None, 1, ''))
590 590
 
591 591
     def test_extra_method_select_argument_with_dashes_and_values(self):
14  tests/comment_tests/tests/test_comment_view.py
@@ -243,21 +243,21 @@ def testCommentNext(self):
243 243
         response = self.client.post("/post/", data)
244 244
         location = response["Location"]
245 245
         match = post_redirect_re.match(location)
246  
-        self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
  246
+        self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
247 247
 
248 248
         data["next"] = "/somewhere/else/"
249 249
         data["comment"] = "This is another comment"
250 250
         response = self.client.post("/post/", data)
251 251
         location = response["Location"]
252 252
         match = re.search(r"^http://testserver/somewhere/else/\?c=\d+$", location)
253  
-        self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
  253
+        self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
254 254
 
255 255
         data["next"] = "http://badserver/somewhere/else/"
256 256
         data["comment"] = "This is another comment with an unsafe next url"
257 257
         response = self.client.post("/post/", data)
258 258
         location = response["Location"]
259 259
         match = post_redirect_re.match(location)
260  
-        self.assertTrue(match != None, "Unsafe redirection to: %s" % location)
  260
+        self.assertTrue(match is not None, "Unsafe redirection to: %s" % location)
261 261
 
262 262
     def testCommentDoneView(self):
263 263
         a = Article.objects.get(pk=1)
@@ -265,7 +265,7 @@ def testCommentDoneView(self):
265 265
         response = self.client.post("/post/", data)
266 266
         location = response["Location"]
267 267
         match = post_redirect_re.match(location)
268  
-        self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
  268
+        self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
269 269
         pk = int(match.group('pk'))
270 270
         response = self.client.get(location)
271 271
         self.assertTemplateUsed(response, "comments/posted.html")
@@ -282,7 +282,7 @@ def testCommentNextWithQueryString(self):
282 282
         response = self.client.post("/post/", data)
283 283
         location = response["Location"]
284 284
         match = re.search(r"^http://testserver/somewhere/else/\?foo=bar&c=\d+$", location)
285  
-        self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
  285
+        self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
286 286
 
287 287
     def testCommentPostRedirectWithInvalidIntegerPK(self):
288 288
         """
@@ -311,7 +311,7 @@ def testCommentNextWithQueryStringAndAnchor(self):
311 311
         response = self.client.post("/post/", data)
312 312
         location = response["Location"]
313 313
         match = re.search(r"^http://testserver/somewhere/else/\?foo=bar&c=\d+#baz$", location)
314  
-        self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
  314
+        self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
315 315
 
316 316
         # Without a query string
317 317
         a = Article.objects.get(pk=1)
@@ -321,4 +321,4 @@ def testCommentNextWithQueryStringAndAnchor(self):
321 321
         response = self.client.post("/post/", data)
322 322
         location = response["Location"]
323 323
         match = re.search(r"^http://testserver/somewhere/else/\?c=\d+#baz$", location)
324  
-        self.assertTrue(match != None, "Unexpected redirect location: %s" % location)
  324
+        self.assertTrue(match is not None, "Unexpected redirect location: %s" % location)
4  tests/signals_regress/tests.py
@@ -34,11 +34,11 @@ def post_save_test(self, signal, sender, instance, **kwargs):
34 34
 
35 35
     def pre_delete_test(self, signal, sender, instance, **kwargs):
36 36
         self.signal_output.append('pre_save signal, %s' % instance)
37  
-        self.signal_output.append('instance.id is not None: %s' % (instance.id != None))
  37
+        self.signal_output.append('instance.id is not None: %s' % (instance.id is not None))
38 38
 
39 39
     def post_delete_test(self, signal, sender, instance, **kwargs):
40 40
         self.signal_output.append('post_delete signal, %s' % instance)
41  
-        self.signal_output.append('instance.id is not None: %s' % (instance.id != None))
  41
+        self.signal_output.append('instance.id is not None: %s' % (instance.id is not None))
42 42
 
43 43
     def setUp(self):
44 44
         self.signal_output = []

0 notes on commit cec11a3

Please sign in to comment.
Something went wrong with that request. Please try again.