From eb422e476f3c0070dbf200bd62d97d12150c6fd9 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Wed, 18 Jan 2017 21:35:59 +0100 Subject: [PATCH] Refs #23919 -- Removed obsolete __ne__() methods. __ne__() defaults to the opposite of __eq__() on Python 3 when it doesn't return NotImplemented. --- django/contrib/auth/models.py | 3 --- django/contrib/gis/gdal/geometries.py | 4 ---- django/contrib/gis/gdal/geomtype.py | 3 --- django/contrib/gis/geos/geometry.py | 4 ---- django/contrib/postgres/validators.py | 3 --- django/core/cache/__init__.py | 3 --- django/core/checks/messages.py | 3 --- django/core/validators.py | 3 --- django/db/__init__.py | 3 --- django/db/migrations/migration.py | 3 --- django/db/migrations/state.py | 6 ------ django/db/models/base.py | 3 --- django/db/models/fields/files.py | 3 --- django/db/models/indexes.py | 3 --- django/db/models/manager.py | 3 --- django/forms/utils.py | 3 --- django/template/base.py | 3 --- django/test/html.py | 3 --- django/utils/functional.py | 5 ----- 19 files changed, 64 deletions(-) diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 0fc2ab41da..9eaf7a6e34 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -391,9 +391,6 @@ class AnonymousUser(object): def __eq__(self, other): return isinstance(other, self.__class__) - def __ne__(self, other): - return not self.__eq__(other) - def __hash__(self): return 1 # instances always return the same hash value diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py index 50c1d9ff65..1dd85ac139 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -179,10 +179,6 @@ class OGRGeometry(GDALBase): else: return False - def __ne__(self, other): - "Tests for inequality." - return not (self == other) - def __str__(self): "WKT is used for the string representation." return self.wkt diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py index 79c3356f5e..37539c8544 100644 --- a/django/contrib/gis/gdal/geomtype.py +++ b/django/contrib/gis/gdal/geomtype.py @@ -68,9 +68,6 @@ class OGRGeomType(object): else: return False - def __ne__(self, other): - return not (self == other) - @property def name(self): "Returns a short-hand string form of the OGR Geometry type." diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py index f49ce2e0de..e015fdc3d5 100644 --- a/django/contrib/gis/geos/geometry.py +++ b/django/contrib/gis/geos/geometry.py @@ -177,10 +177,6 @@ class GEOSGeometry(GEOSBase, ListMixin): else: return False - def __ne__(self, other): - "The not equals operator." - return not (self == other) - # ### Geometry set-like operations ### # Thanks to Sean Gillies for inspiration: # http://lists.gispython.org/pipermail/community/2007-July/001034.html diff --git a/django/contrib/postgres/validators.py b/django/contrib/postgres/validators.py index 5676da78b0..756ae73440 100644 --- a/django/contrib/postgres/validators.py +++ b/django/contrib/postgres/validators.py @@ -66,9 +66,6 @@ class KeysValidator(object): self.strict == other.strict ) - def __ne__(self, other): - return not (self == other) - class RangeMaxValueValidator(MaxValueValidator): def compare(self, a, b): diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py index cd2bb43886..2b253b1077 100644 --- a/django/core/cache/__init__.py +++ b/django/core/cache/__init__.py @@ -110,9 +110,6 @@ class DefaultCacheProxy(object): def __eq__(self, other): return caches[DEFAULT_CACHE_ALIAS] == other - def __ne__(self, other): - return caches[DEFAULT_CACHE_ALIAS] != other - cache = DefaultCacheProxy() diff --git a/django/core/checks/messages.py b/django/core/checks/messages.py index da198d72b9..5bb292503f 100644 --- a/django/core/checks/messages.py +++ b/django/core/checks/messages.py @@ -25,9 +25,6 @@ class CheckMessage(object): for attr in ['level', 'msg', 'hint', 'obj', 'id']) ) - def __ne__(self, other): - return not (self == other) - def __str__(self): from django.db import models diff --git a/django/core/validators.py b/django/core/validators.py index 6e7220c826..1bb2478129 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -68,9 +68,6 @@ class RegexValidator(object): (self.inverse_match == other.inverse_match) ) - def __ne__(self, other): - return not (self == other) - @deconstructible class URLValidator(RegexValidator): diff --git a/django/db/__init__.py b/django/db/__init__.py index d25a9f0116..a00dc788dc 100644 --- a/django/db/__init__.py +++ b/django/db/__init__.py @@ -41,9 +41,6 @@ class DefaultConnectionProxy(object): def __eq__(self, other): return connections[DEFAULT_DB_ALIAS] == other - def __ne__(self, other): - return connections[DEFAULT_DB_ALIAS] != other - connection = DefaultConnectionProxy() diff --git a/django/db/migrations/migration.py b/django/db/migrations/migration.py index d1a24d4361..5b6bb647c9 100644 --- a/django/db/migrations/migration.py +++ b/django/db/migrations/migration.py @@ -62,9 +62,6 @@ class Migration(object): return False return (self.name == other.name) and (self.app_label == other.app_label) - def __ne__(self, other): - return not (self == other) - def __repr__(self): return "" % (self.app_label, self.name) diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py index db42220918..6699b77713 100644 --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -233,9 +233,6 @@ class ProjectState(object): return False return all(model == other.models[key] for key, model in self.models.items()) - def __ne__(self, other): - return not (self == other) - class AppConfigStub(AppConfig): """ @@ -626,6 +623,3 @@ class ModelState(object): (self.bases == other.bases) and (self.managers == other.managers) ) - - def __ne__(self, other): - return not (self == other) diff --git a/django/db/models/base.py b/django/db/models/base.py index b5f6c1e353..4ee7aa0349 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -520,9 +520,6 @@ class Model(metaclass=ModelBase): return self is other return my_pk == other._get_pk_val() - def __ne__(self, other): - return not self.__eq__(other) - def __hash__(self): if self._get_pk_val() is None: raise TypeError("Model instances without primary key value are unhashable") diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py index 90b6515409..38dda4c1df 100644 --- a/django/db/models/fields/files.py +++ b/django/db/models/fields/files.py @@ -28,9 +28,6 @@ class FieldFile(File): return self.name == other.name return self.name == other - def __ne__(self, other): - return not self.__eq__(other) - def __hash__(self): return hash(self.name) diff --git a/django/db/models/indexes.py b/django/db/models/indexes.py index c296f22163..27390ccc18 100644 --- a/django/db/models/indexes.py +++ b/django/db/models/indexes.py @@ -117,6 +117,3 @@ class Index(object): def __eq__(self, other): return (self.__class__ == other.__class__) and (self.deconstruct() == other.deconstruct()) - - def __ne__(self, other): - return not (self == other) diff --git a/django/db/models/manager.py b/django/db/models/manager.py index 96c82e54eb..bb3d61b083 100644 --- a/django/db/models/manager.py +++ b/django/db/models/manager.py @@ -160,9 +160,6 @@ class BaseManager(object): self._constructor_args == other._constructor_args ) - def __ne__(self, other): - return not (self == other) - def __hash__(self): return id(self) diff --git a/django/forms/utils.py b/django/forms/utils.py index 3a86f419df..59d70178f4 100644 --- a/django/forms/utils.py +++ b/django/forms/utils.py @@ -133,9 +133,6 @@ class ErrorList(UserList, list): def __eq__(self, other): return list(self) == other - def __ne__(self, other): - return list(self) != other - def __getitem__(self, i): error = self.data[i] if isinstance(error, ValidationError): diff --git a/django/template/base.py b/django/template/base.py index c7c2249aa0..7f18869dbb 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -140,9 +140,6 @@ class Origin(object): self.loader == other.loader ) - def __ne__(self, other): - return not self.__eq__(other) - @property def loader_name(self): if self.loader: diff --git a/django/test/html.py b/django/test/html.py index d84b9770e1..67a2ad65e1 100644 --- a/django/test/html.py +++ b/django/test/html.py @@ -81,9 +81,6 @@ class Element(object): def __hash__(self): return hash((self.name,) + tuple(a for a in self.attributes)) - def __ne__(self, element): - return not self.__eq__(element) - def _count(self, element, count=True): if not isinstance(element, str): if self == element: diff --git a/django/utils/functional.py b/django/utils/functional.py index 0efce6c635..2eeffa0447 100644 --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -126,11 +126,6 @@ def lazy(func, *resultclasses): # a __str__() method from the proxied class. return str(self.__cast()) - def __ne__(self, other): - if isinstance(other, Promise): - other = other.__cast() - return self.__cast() != other - def __eq__(self, other): if isinstance(other, Promise): other = other.__cast()