From 8b2515a450ef376b9205029090af0a79c8341bd7 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Thu, 7 Sep 2017 17:10:49 +0500 Subject: [PATCH] Removed unneeded __init__() methods. --- django/contrib/auth/base_user.py | 10 ++++----- django/contrib/auth/models.py | 3 --- .../gis/db/backends/postgis/operations.py | 21 +++++++------------ django/core/files/uploadhandler.py | 3 --- django/core/handlers/base.py | 14 ++++++------- django/core/management/commands/test.py | 5 +---- django/db/backends/oracle/operations.py | 5 +---- django/db/models/functions/base.py | 3 --- django/db/models/sql/compiler.py | 5 +---- 9 files changed, 21 insertions(+), 48 deletions(-) diff --git a/django/contrib/auth/base_user.py b/django/contrib/auth/base_user.py index 8865b671c9..0f8d5d87e2 100644 --- a/django/contrib/auth/base_user.py +++ b/django/contrib/auth/base_user.py @@ -52,6 +52,10 @@ class AbstractBaseUser(models.Model): REQUIRED_FIELDS = [] + # Stores the raw password if set_password() is called so that it can + # be passed to password_changed() after the model is saved. + _password = None + class Meta: abstract = True @@ -59,12 +63,6 @@ class AbstractBaseUser(models.Model): "Return the identifying username for this User" return getattr(self, self.USERNAME_FIELD) - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - # Stores the raw password if set_password() is called so that it can - # be passed to password_changed() after the model is saved. - self._password = None - def __str__(self): return self.get_username() diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index d931277c66..3ad2e84e17 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -374,9 +374,6 @@ class AnonymousUser: _groups = EmptyManager(Group) _user_permissions = EmptyManager(Permission) - def __init__(self): - pass - def __str__(self): return 'AnonymousUser' diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index 85e1f35fe1..a535b49849 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -103,6 +103,14 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations): Adapter = PostGISAdapter + collect = geom_func_prefix + 'Collect' + extent = geom_func_prefix + 'Extent' + extent3d = geom_func_prefix + '3DExtent' + length3d = geom_func_prefix + '3DLength' + makeline = geom_func_prefix + 'MakeLine' + perimeter3d = geom_func_prefix + '3DPerimeter' + unionagg = geom_func_prefix + 'Union' + gis_operators = { 'bbcontains': PostGISOperator(op='~', raster=True), 'bboverlaps': PostGISOperator(op='&&', geography=True, raster=True), @@ -137,19 +145,6 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations): select = '%s::bytea' select_extent = None - def __init__(self, connection): - super().__init__(connection) - - prefix = self.geom_func_prefix - - self.collect = prefix + 'Collect' - self.extent = prefix + 'Extent' - self.extent3d = prefix + '3DExtent' - self.length3d = prefix + '3DLength' - self.makeline = prefix + 'MakeLine' - self.perimeter3d = prefix + '3DPerimeter' - self.unionagg = prefix + 'Union' - @cached_property def function_names(self): function_names = { diff --git a/django/core/files/uploadhandler.py b/django/core/files/uploadhandler.py index 5e993d13e2..a0f34b741c 100644 --- a/django/core/files/uploadhandler.py +++ b/django/core/files/uploadhandler.py @@ -132,9 +132,6 @@ class TemporaryFileUploadHandler(FileUploadHandler): """ Upload handler that streams data into a temporary file. """ - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - def new_file(self, *args, **kwargs): """ Create the file object to append to as data is coming in. diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py index 9b79439569..80cc8b3281 100644 --- a/django/core/handlers/base.py +++ b/django/core/handlers/base.py @@ -13,14 +13,12 @@ logger = logging.getLogger('django.request') class BaseHandler: - - def __init__(self): - self._request_middleware = None - self._view_middleware = None - self._template_response_middleware = None - self._response_middleware = None - self._exception_middleware = None - self._middleware_chain = None + _request_middleware = None + _view_middleware = None + _template_response_middleware = None + _response_middleware = None + _exception_middleware = None + _middleware_chain = None def load_middleware(self): """ diff --git a/django/core/management/commands/test.py b/django/core/management/commands/test.py index 21d763c33e..4e4016ed06 100644 --- a/django/core/management/commands/test.py +++ b/django/core/management/commands/test.py @@ -10,10 +10,7 @@ class Command(BaseCommand): # DiscoverRunner runs the checks after databases are set up. requires_system_checks = False - - def __init__(self): - self.test_runner = None - super().__init__() + test_runner = None def run_from_argv(self, argv): """ diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py index bf54755c5e..4377bd59ec 100644 --- a/django/db/backends/oracle/operations.py +++ b/django/db/backends/oracle/operations.py @@ -23,6 +23,7 @@ class DatabaseOperations(BaseDatabaseOperations): 'PositiveSmallIntegerField': (0, 99999999999), 'PositiveIntegerField': (0, 99999999999), } + set_operators = dict(BaseDatabaseOperations.set_operators, difference='MINUS') # TODO: colorize this SQL code with style.SQL_KEYWORD(), etc. _sequence_reset_sql = """ @@ -52,10 +53,6 @@ END; # Oracle doesn't support string without precision; use the max string size. cast_char_field_without_max_length = 'NVARCHAR2(2000)' - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.set_operators['difference'] = 'MINUS' - def cache_key_culling_sql(self): return """ SELECT cache_key diff --git a/django/db/models/functions/base.py b/django/db/models/functions/base.py index 378a9504d2..e1d7938eac 100644 --- a/django/db/models/functions/base.py +++ b/django/db/models/functions/base.py @@ -52,9 +52,6 @@ class ConcatPair(Func): """ function = 'CONCAT' - def __init__(self, left, right, **extra): - super().__init__(left, right, **extra) - def as_sqlite(self, compiler, connection): coalesced = self.coalesce() return super(ConcatPair, coalesced).as_sql( diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 743803338b..37f5cce37a 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -1056,10 +1056,7 @@ class SQLCompiler: class SQLInsertCompiler(SQLCompiler): - - def __init__(self, *args, **kwargs): - self.return_id = False - super().__init__(*args, **kwargs) + return_id = False def field_as_sql(self, field, val): """