Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #13827 -- Cleaned up a few unnecessary function calls.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13876 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 1df1378f9e6e71588f45624c4ddf9e5d37cc875a 1 parent d8d38ec
Jannis Leidel authored
2  django/conf/__init__.py
@@ -102,7 +102,7 @@ def __init__(self, settings_module):
102 102
                 new_installed_apps.append(app)
103 103
         self.INSTALLED_APPS = new_installed_apps
104 104
 
105  
-        if hasattr(time, 'tzset') and getattr(self, 'TIME_ZONE'):
  105
+        if hasattr(time, 'tzset') and self.TIME_ZONE:
106 106
             # When we can, attempt to validate the timezone. If we can't find
107 107
             # this file, no check happens and it's harmless.
108 108
             zoneinfo_root = '/usr/share/zoneinfo'
2  django/contrib/admin/validation.py
@@ -170,7 +170,7 @@ def validate_inline(cls, parent, parent_model):
170 170
     fk = _get_foreign_key(parent_model, cls.model, fk_name=cls.fk_name, can_fail=True)
171 171
 
172 172
     # extra = 3
173  
-    if not isinstance(getattr(cls, 'extra'), int):
  173
+    if not isinstance(cls.extra, int):
174 174
         raise ImproperlyConfigured("'%s.extra' should be a integer."
175 175
                 % cls.__name__)
176 176
 
9  django/contrib/auth/__init__.py
@@ -20,15 +20,12 @@ def load_backend(path):
20 20
         cls = getattr(mod, attr)
21 21
     except AttributeError:
22 22
         raise ImproperlyConfigured('Module "%s" does not define a "%s" authentication backend' % (module, attr))
23  
-    try:
24  
-        getattr(cls, 'supports_object_permissions')
25  
-    except AttributeError:
  23
+    if not hasattr(cls, "supports_object_permissions"):
26 24
         warn("Authentication backends without a `supports_object_permissions` attribute are deprecated. Please define it in %s." % cls,
27 25
              PendingDeprecationWarning)
28 26
         cls.supports_object_permissions = False
29  
-    try:
30  
-        getattr(cls, 'supports_anonymous_user')
31  
-    except AttributeError:
  27
+
  28
+    if not hasattr(cls, 'supports_anonymous_user'):
32 29
         warn("Authentication backends without a `supports_anonymous_user` attribute are deprecated. Please define it in %s." % cls,
33 30
              PendingDeprecationWarning)
34 31
         cls.supports_anonymous_user = False
2  django/contrib/gis/sitemaps/views.py
@@ -93,7 +93,7 @@ def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB
93 93
         else:
94 94
             qs = klass._default_manager.using(using).all()
95 95
         for mod in qs:
96  
-            setattr(mod, 'kml', getattr(mod, field_name).kml)
  96
+            mod.kml = getattr(mod, field_name).kml)
97 97
             placemarks.append(mod)
98 98
 
99 99
     # Getting the render function and rendering to the correct.
2  django/core/cache/__init__.py
@@ -63,7 +63,7 @@ def get_cache(backend_uri):
63 63
     else:
64 64
         name = scheme
65 65
     module = importlib.import_module(name)
66  
-    return getattr(module, 'CacheClass')(host, params)
  66
+    return module.CacheClass(host, params)
67 67
 
68 68
 cache = get_cache(settings.CACHE_BACKEND)
69 69
 
2  django/db/models/base.py
@@ -508,7 +508,7 @@ def save_base(self, raw=False, cls=None, origin=None, force_insert=False,
508 508
                     # autopopulate the _order field
509 509
                     field = meta.order_with_respect_to
510 510
                     order_value = manager.using(using).filter(**{field.name: getattr(self, field.attname)}).count()
511  
-                    setattr(self, '_order', order_value)
  511
+                    self._order = order_value
512 512
 
513 513
                 if not pk_set:
514 514
                     if force_update:
6  django/db/models/options.py
@@ -79,14 +79,14 @@ def contribute_to_class(self, cls, name):
79 79
             # unique_together can be either a tuple of tuples, or a single
80 80
             # tuple of two strings. Normalize it to a tuple of tuples, so that
81 81
             # calling code can uniformly expect that.
82  
-            ut = meta_attrs.pop('unique_together', getattr(self, 'unique_together'))
  82
+            ut = meta_attrs.pop('unique_together', self.unique_together)
83 83
             if ut and not isinstance(ut[0], (tuple, list)):
84 84
                 ut = (ut,)
85  
-            setattr(self, 'unique_together', ut)
  85
+            self.unique_together = ut
86 86
 
87 87
             # verbose_name_plural is a special case because it uses a 's'
88 88
             # by default.
89  
-            setattr(self, 'verbose_name_plural', meta_attrs.pop('verbose_name_plural', string_concat(self.verbose_name, 's')))
  89
+            self.verbose_name_plural = meta_attrs.pop('verbose_name_plural', string_concat(self.verbose_name, 's'))
90 90
 
91 91
             # Any leftover attributes must be invalid.
92 92
             if meta_attrs != {}:
5  django/db/models/query_utils.py
@@ -257,9 +257,8 @@ def deferred_class_factory(model, attrs):
257 257
     deferred attributes to a particular instance of the model.
258 258
     """
259 259
     class Meta:
260  
-        pass
261  
-    setattr(Meta, "proxy", True)
262  
-    setattr(Meta, "app_label", model._meta.app_label)
  260
+        proxy = True
  261
+        app_label = model._meta.app_label
263 262
 
264 263
     # The app_cache wants a unique name for each model, otherwise the new class
265 264
     # won't be created (we get an old one back). Therefore, we generate the
2  django/forms/forms.py
@@ -268,7 +268,7 @@ def full_clean(self):
268 268
         self._clean_form()
269 269
         self._post_clean()
270 270
         if self._errors:
271  
-            delattr(self, 'cleaned_data')
  271
+            del self.cleaned_data
272 272
 
273 273
     def _clean_fields(self):
274 274
         for name, field in self.fields.items():
2  django/test/simple.py
@@ -58,7 +58,7 @@ def stoptest(test):
58 58
                 func(test)
59 59
             return stoptest
60 60
 
61  
-        setattr(result, 'stopTest', stoptest_override(result.stopTest))
  61
+        result.stopTest = stoptest_override(result.stopTest)
62 62
         return result
63 63
 
64 64
 def get_tests(app_module):
2  tests/regressiontests/comment_tests/tests/app_api_tests.py
@@ -41,7 +41,7 @@ def tearDown(self):
41 41
         del settings.INSTALLED_APPS[-1]
42 42
         settings.COMMENTS_APP = self.old_comments_app
43 43
         if settings.COMMENTS_APP is None:
44  
-            delattr(settings._wrapped, 'COMMENTS_APP')
  44
+            del settings._wrapped.COMMENTS_APP
45 45
 
46 46
     def testGetCommentApp(self):
47 47
         from regressiontests.comment_tests import custom_comments

0 notes on commit 1df1378

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